babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { ActionManager } from "babylonjs/Actions/actionManager";
  9539. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9540. import { Node } from "babylonjs/node";
  9541. /**
  9542. * Interface used to define Action
  9543. */
  9544. export interface IAction {
  9545. /**
  9546. * Trigger for the action
  9547. */
  9548. trigger: number;
  9549. /** Options of the trigger */
  9550. triggerOptions: any;
  9551. /**
  9552. * Gets the trigger parameters
  9553. * @returns the trigger parameters
  9554. */
  9555. getTriggerParameter(): any;
  9556. /**
  9557. * Internal only - executes current action event
  9558. * @hidden
  9559. */
  9560. _executeCurrent(evt?: ActionEvent): void;
  9561. /**
  9562. * Serialize placeholder for child classes
  9563. * @param parent of child
  9564. * @returns the serialized object
  9565. */
  9566. serialize(parent: any): any;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Internal only - manager for action
  9574. * @hidden
  9575. */
  9576. _actionManager: AbstractActionManager;
  9577. /**
  9578. * Adds action to chain of actions, may be a DoNothingAction
  9579. * @param action defines the next action to execute
  9580. * @returns The action passed in
  9581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9582. */
  9583. then(action: IAction): IAction;
  9584. }
  9585. /**
  9586. * The action to be carried out following a trigger
  9587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9588. */
  9589. export class Action implements IAction {
  9590. /** the trigger, with or without parameters, for the action */
  9591. triggerOptions: any;
  9592. /**
  9593. * Trigger for the action
  9594. */
  9595. trigger: number;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. private _nextActiveAction;
  9602. private _child;
  9603. private _condition?;
  9604. private _triggerParameter;
  9605. /**
  9606. * An event triggered prior to action being executed.
  9607. */
  9608. onBeforeExecuteObservable: Observable<Action>;
  9609. /**
  9610. * Creates a new Action
  9611. * @param triggerOptions the trigger, with or without parameters, for the action
  9612. * @param condition an optional determinant of action
  9613. */
  9614. constructor(
  9615. /** the trigger, with or without parameters, for the action */
  9616. triggerOptions: any, condition?: Condition);
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _prepare(): void;
  9622. /**
  9623. * Gets the trigger parameters
  9624. * @returns the trigger parameters
  9625. */
  9626. getTriggerParameter(): any;
  9627. /**
  9628. * Internal only - executes current action event
  9629. * @hidden
  9630. */
  9631. _executeCurrent(evt?: ActionEvent): void;
  9632. /**
  9633. * Execute placeholder for child classes
  9634. * @param evt optional action event
  9635. */
  9636. execute(evt?: ActionEvent): void;
  9637. /**
  9638. * Skips to next active action
  9639. */
  9640. skipToNextActiveAction(): void;
  9641. /**
  9642. * Adds action to chain of actions, may be a DoNothingAction
  9643. * @param action defines the next action to execute
  9644. * @returns The action passed in
  9645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9646. */
  9647. then(action: Action): Action;
  9648. /**
  9649. * Internal only
  9650. * @hidden
  9651. */
  9652. _getProperty(propertyPath: string): string;
  9653. /**
  9654. * Internal only
  9655. * @hidden
  9656. */
  9657. _getEffectiveTarget(target: any, propertyPath: string): any;
  9658. /**
  9659. * Serialize placeholder for child classes
  9660. * @param parent of child
  9661. * @returns the serialized object
  9662. */
  9663. serialize(parent: any): any;
  9664. /**
  9665. * Internal only called by serialize
  9666. * @hidden
  9667. */
  9668. protected _serialize(serializedAction: any, parent?: any): any;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. static _SerializeValueAsString: (value: any) => string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. static _GetTargetProperty: (target: Scene | Node) => {
  9679. name: string;
  9680. targetType: string;
  9681. value: string;
  9682. };
  9683. }
  9684. }
  9685. declare module "babylonjs/Actions/condition" {
  9686. import { ActionManager } from "babylonjs/Actions/actionManager";
  9687. /**
  9688. * A Condition applied to an Action
  9689. */
  9690. export class Condition {
  9691. /**
  9692. * Internal only - manager for action
  9693. * @hidden
  9694. */
  9695. _actionManager: ActionManager;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _evaluationId: number;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. _currentResult: boolean;
  9706. /**
  9707. * Creates a new Condition
  9708. * @param actionManager the manager of the action the condition is applied to
  9709. */
  9710. constructor(actionManager: ActionManager);
  9711. /**
  9712. * Check if the current condition is valid
  9713. * @returns a boolean
  9714. */
  9715. isValid(): boolean;
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _getProperty(propertyPath: string): string;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getEffectiveTarget(target: any, propertyPath: string): any;
  9726. /**
  9727. * Serialize placeholder for child classes
  9728. * @returns the serialized object
  9729. */
  9730. serialize(): any;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedCondition: any): any;
  9736. }
  9737. /**
  9738. * Defines specific conditional operators as extensions of Condition
  9739. */
  9740. export class ValueCondition extends Condition {
  9741. /** path to specify the property of the target the conditional operator uses */
  9742. propertyPath: string;
  9743. /** the value compared by the conditional operator against the current value of the property */
  9744. value: any;
  9745. /** the conditional operator, default ValueCondition.IsEqual */
  9746. operator: number;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsEqual;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsDifferent;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. private static _IsGreater;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. private static _IsLesser;
  9767. /**
  9768. * returns the number for IsEqual
  9769. */
  9770. static get IsEqual(): number;
  9771. /**
  9772. * Returns the number for IsDifferent
  9773. */
  9774. static get IsDifferent(): number;
  9775. /**
  9776. * Returns the number for IsGreater
  9777. */
  9778. static get IsGreater(): number;
  9779. /**
  9780. * Returns the number for IsLesser
  9781. */
  9782. static get IsLesser(): number;
  9783. /**
  9784. * Internal only The action manager for the condition
  9785. * @hidden
  9786. */
  9787. _actionManager: ActionManager;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _target;
  9793. /**
  9794. * Internal only
  9795. * @hidden
  9796. */
  9797. private _effectiveTarget;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. private _property;
  9803. /**
  9804. * Creates a new ValueCondition
  9805. * @param actionManager manager for the action the condition applies to
  9806. * @param target for the action
  9807. * @param propertyPath path to specify the property of the target the conditional operator uses
  9808. * @param value the value compared by the conditional operator against the current value of the property
  9809. * @param operator the conditional operator, default ValueCondition.IsEqual
  9810. */
  9811. constructor(actionManager: ActionManager, target: any,
  9812. /** path to specify the property of the target the conditional operator uses */
  9813. propertyPath: string,
  9814. /** the value compared by the conditional operator against the current value of the property */
  9815. value: any,
  9816. /** the conditional operator, default ValueCondition.IsEqual */
  9817. operator?: number);
  9818. /**
  9819. * Compares the given value with the property value for the specified conditional operator
  9820. * @returns the result of the comparison
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the ValueCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Gets the name of the conditional operator for the ValueCondition
  9830. * @param operator the conditional operator
  9831. * @returns the name
  9832. */
  9833. static GetOperatorName(operator: number): string;
  9834. }
  9835. /**
  9836. * Defines a predicate condition as an extension of Condition
  9837. */
  9838. export class PredicateCondition extends Condition {
  9839. /** defines the predicate function used to validate the condition */
  9840. predicate: () => boolean;
  9841. /**
  9842. * Internal only - manager for action
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Creates a new PredicateCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param predicate defines the predicate function used to validate the condition
  9850. */
  9851. constructor(actionManager: ActionManager,
  9852. /** defines the predicate function used to validate the condition */
  9853. predicate: () => boolean);
  9854. /**
  9855. * @returns the validity of the predicate condition
  9856. */
  9857. isValid(): boolean;
  9858. }
  9859. /**
  9860. * Defines a state condition as an extension of Condition
  9861. */
  9862. export class StateCondition extends Condition {
  9863. /** Value to compare with target state */
  9864. value: string;
  9865. /**
  9866. * Internal only - manager for action
  9867. * @hidden
  9868. */
  9869. _actionManager: ActionManager;
  9870. /**
  9871. * Internal only
  9872. * @hidden
  9873. */
  9874. private _target;
  9875. /**
  9876. * Creates a new StateCondition
  9877. * @param actionManager manager for the action the condition applies to
  9878. * @param target of the condition
  9879. * @param value to compare with target state
  9880. */
  9881. constructor(actionManager: ActionManager, target: any,
  9882. /** Value to compare with target state */
  9883. value: string);
  9884. /**
  9885. * Gets a boolean indicating if the current condition is met
  9886. * @returns the validity of the state
  9887. */
  9888. isValid(): boolean;
  9889. /**
  9890. * Serialize the StateCondition into a JSON compatible object
  9891. * @returns serialization object
  9892. */
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module "babylonjs/Actions/directActions" {
  9897. import { Action } from "babylonjs/Actions/action";
  9898. import { Condition } from "babylonjs/Actions/condition";
  9899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9900. /**
  9901. * This defines an action responsible to toggle a boolean once triggered.
  9902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9903. */
  9904. export class SwitchBooleanAction extends Action {
  9905. /**
  9906. * The path to the boolean property in the target object
  9907. */
  9908. propertyPath: string;
  9909. private _target;
  9910. private _effectiveTarget;
  9911. private _property;
  9912. /**
  9913. * Instantiate the action
  9914. * @param triggerOptions defines the trigger options
  9915. * @param target defines the object containing the boolean
  9916. * @param propertyPath defines the path to the boolean property in the target object
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action toggle the boolean value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set a the state field of the target
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class SetStateAction extends Action {
  9939. /**
  9940. * The value to store in the state field.
  9941. */
  9942. value: string;
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the object containing the state property
  9948. * @param value defines the value to store in the state field
  9949. * @param condition defines the trigger related conditions
  9950. */
  9951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9952. /**
  9953. * Execute the action and store the value on the target state property.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to set a property of the target
  9965. * to a desired value once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class SetValueAction extends Action {
  9969. /**
  9970. * The path of the property to set in the target.
  9971. */
  9972. propertyPath: string;
  9973. /**
  9974. * The value to set in the property
  9975. */
  9976. value: any;
  9977. private _target;
  9978. private _effectiveTarget;
  9979. private _property;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the object containing the property
  9984. * @param propertyPath defines the path of the property to set in the target
  9985. * @param value defines the value to set in the property
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and set the targetted property to the desired value.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to increment the target value
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class IncrementValueAction extends Action {
  10008. /**
  10009. * The path of the property to increment in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value we should increment the property by.
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to increment in the target
  10024. * @param value defines the value value we should increment the property by
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and increment the target of the value amount.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to start an animation once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class PlayAnimationAction extends Action {
  10046. /**
  10047. * Where the animation should start (animation frame)
  10048. */
  10049. from: number;
  10050. /**
  10051. * Where the animation should stop (animation frame)
  10052. */
  10053. to: number;
  10054. /**
  10055. * Define if the animation should loop or stop after the first play.
  10056. */
  10057. loop?: boolean;
  10058. private _target;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param target defines the target animation or animation name
  10063. * @param from defines from where the animation should start (animation frame)
  10064. * @param end defines where the animation should stop (animation frame)
  10065. * @param loop defines if the animation should loop or stop after the first play
  10066. * @param condition defines the trigger related conditions
  10067. */
  10068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10069. /** @hidden */
  10070. _prepare(): void;
  10071. /**
  10072. * Execute the action and play the animation.
  10073. */
  10074. execute(): void;
  10075. /**
  10076. * Serializes the actions and its related information.
  10077. * @param parent defines the object to serialize in
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. }
  10082. /**
  10083. * This defines an action responsible to stop an animation once triggered.
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10085. */
  10086. export class StopAnimationAction extends Action {
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target animation or animation name
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and stop the animation.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible that does nothing once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class DoNothingAction extends Action {
  10113. /**
  10114. * Instantiate the action
  10115. * @param triggerOptions defines the trigger options
  10116. * @param condition defines the trigger related conditions
  10117. */
  10118. constructor(triggerOptions?: any, condition?: Condition);
  10119. /**
  10120. * Execute the action and do nothing.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. /**
  10131. * This defines an action responsible to trigger several actions once triggered.
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class CombineAction extends Action {
  10135. /**
  10136. * The list of aggregated animations to run.
  10137. */
  10138. children: Action[];
  10139. /**
  10140. * Instantiate the action
  10141. * @param triggerOptions defines the trigger options
  10142. * @param children defines the list of aggregated animations to run
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and executes all the aggregated actions.
  10150. */
  10151. execute(evt: ActionEvent): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. /**
  10160. * This defines an action responsible to run code (external event) once triggered.
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10162. */
  10163. export class ExecuteCodeAction extends Action {
  10164. /**
  10165. * The callback function to run.
  10166. */
  10167. func: (evt: ActionEvent) => void;
  10168. /**
  10169. * Instantiate the action
  10170. * @param triggerOptions defines the trigger options
  10171. * @param func defines the callback function to run
  10172. * @param condition defines the trigger related conditions
  10173. */
  10174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10175. /**
  10176. * Execute the action and run the attached code.
  10177. */
  10178. execute(evt: ActionEvent): void;
  10179. }
  10180. /**
  10181. * This defines an action responsible to set the parent property of the target once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class SetParentAction extends Action {
  10185. private _parent;
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target containing the parent property
  10191. * @param parent defines from where the animation should start (animation frame)
  10192. * @param condition defines the trigger related conditions
  10193. */
  10194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10195. /** @hidden */
  10196. _prepare(): void;
  10197. /**
  10198. * Execute the action and set the parent property.
  10199. */
  10200. execute(): void;
  10201. /**
  10202. * Serializes the actions and its related information.
  10203. * @param parent defines the object to serialize in
  10204. * @returns the serialized object
  10205. */
  10206. serialize(parent: any): any;
  10207. }
  10208. }
  10209. declare module "babylonjs/Actions/actionManager" {
  10210. import { Nullable } from "babylonjs/types";
  10211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10212. import { Scene } from "babylonjs/scene";
  10213. import { IAction } from "babylonjs/Actions/action";
  10214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. /**
  10217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ActionManager extends AbstractActionManager {
  10222. /**
  10223. * Nothing
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly NothingTrigger: number;
  10227. /**
  10228. * On pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnPickTrigger: number;
  10232. /**
  10233. * On left pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnLeftPickTrigger: number;
  10237. /**
  10238. * On right pick
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnRightPickTrigger: number;
  10242. /**
  10243. * On center pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnCenterPickTrigger: number;
  10247. /**
  10248. * On pick down
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickDownTrigger: number;
  10252. /**
  10253. * On double pick
  10254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10255. */
  10256. static readonly OnDoublePickTrigger: number;
  10257. /**
  10258. * On pick up
  10259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10260. */
  10261. static readonly OnPickUpTrigger: number;
  10262. /**
  10263. * On pick out.
  10264. * This trigger will only be raised if you also declared a OnPickDown
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPickOutTrigger: number;
  10268. /**
  10269. * On long press
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnLongPressTrigger: number;
  10273. /**
  10274. * On pointer over
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnPointerOverTrigger: number;
  10278. /**
  10279. * On pointer out
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPointerOutTrigger: number;
  10283. /**
  10284. * On every frame
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnEveryFrameTrigger: number;
  10288. /**
  10289. * On intersection enter
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnIntersectionEnterTrigger: number;
  10293. /**
  10294. * On intersection exit
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnIntersectionExitTrigger: number;
  10298. /**
  10299. * On key down
  10300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10301. */
  10302. static readonly OnKeyDownTrigger: number;
  10303. /**
  10304. * On key up
  10305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10306. */
  10307. static readonly OnKeyUpTrigger: number;
  10308. private _scene;
  10309. /**
  10310. * Creates a new action manager
  10311. * @param scene defines the hosting scene
  10312. */
  10313. constructor(scene: Scene);
  10314. /**
  10315. * Releases all associated resources
  10316. */
  10317. dispose(): void;
  10318. /**
  10319. * Gets hosting scene
  10320. * @returns the hosting scene
  10321. */
  10322. getScene(): Scene;
  10323. /**
  10324. * Does this action manager handles actions of any of the given triggers
  10325. * @param triggers defines the triggers to be tested
  10326. * @return a boolean indicating whether one (or more) of the triggers is handled
  10327. */
  10328. hasSpecificTriggers(triggers: number[]): boolean;
  10329. /**
  10330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10331. * speed.
  10332. * @param triggerA defines the trigger to be tested
  10333. * @param triggerB defines the trigger to be tested
  10334. * @return a boolean indicating whether one (or more) of the triggers is handled
  10335. */
  10336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10337. /**
  10338. * Does this action manager handles actions of a given trigger
  10339. * @param trigger defines the trigger to be tested
  10340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10341. * @return whether the trigger is handled
  10342. */
  10343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10344. /**
  10345. * Does this action manager has pointer triggers
  10346. */
  10347. get hasPointerTriggers(): boolean;
  10348. /**
  10349. * Does this action manager has pick triggers
  10350. */
  10351. get hasPickTriggers(): boolean;
  10352. /**
  10353. * Registers an action to this action manager
  10354. * @param action defines the action to be registered
  10355. * @return the action amended (prepared) after registration
  10356. */
  10357. registerAction(action: IAction): Nullable<IAction>;
  10358. /**
  10359. * Unregisters an action to this action manager
  10360. * @param action defines the action to be unregistered
  10361. * @return a boolean indicating whether the action has been unregistered
  10362. */
  10363. unregisterAction(action: IAction): Boolean;
  10364. /**
  10365. * Process a specific trigger
  10366. * @param trigger defines the trigger to process
  10367. * @param evt defines the event details to be processed
  10368. */
  10369. processTrigger(trigger: number, evt?: IActionEvent): void;
  10370. /** @hidden */
  10371. _getEffectiveTarget(target: any, propertyPath: string): any;
  10372. /** @hidden */
  10373. _getProperty(propertyPath: string): string;
  10374. /**
  10375. * Serialize this manager to a JSON object
  10376. * @param name defines the property name to store this manager
  10377. * @returns a JSON representation of this manager
  10378. */
  10379. serialize(name: string): any;
  10380. /**
  10381. * Creates a new ActionManager from a JSON data
  10382. * @param parsedActions defines the JSON data to read from
  10383. * @param object defines the hosting mesh
  10384. * @param scene defines the hosting scene
  10385. */
  10386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10387. /**
  10388. * Get a trigger name by index
  10389. * @param trigger defines the trigger index
  10390. * @returns a trigger name
  10391. */
  10392. static GetTriggerName(trigger: number): string;
  10393. }
  10394. }
  10395. declare module "babylonjs/Sprites/sprite" {
  10396. import { Vector3 } from "babylonjs/Maths/math.vector";
  10397. import { Nullable } from "babylonjs/types";
  10398. import { ActionManager } from "babylonjs/Actions/actionManager";
  10399. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10400. import { Color4 } from "babylonjs/Maths/math.color";
  10401. import { Observable } from "babylonjs/Misc/observable";
  10402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10403. import { Animation } from "babylonjs/Animations/animation";
  10404. /**
  10405. * Class used to represent a sprite
  10406. * @see https://doc.babylonjs.com/babylon101/sprites
  10407. */
  10408. export class Sprite implements IAnimatable {
  10409. /** defines the name */
  10410. name: string;
  10411. /** Gets or sets the current world position */
  10412. position: Vector3;
  10413. /** Gets or sets the main color */
  10414. color: Color4;
  10415. /** Gets or sets the width */
  10416. width: number;
  10417. /** Gets or sets the height */
  10418. height: number;
  10419. /** Gets or sets rotation angle */
  10420. angle: number;
  10421. /** Gets or sets the cell index in the sprite sheet */
  10422. cellIndex: number;
  10423. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10424. cellRef: string;
  10425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10426. invertU: boolean;
  10427. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10428. invertV: boolean;
  10429. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10430. disposeWhenFinishedAnimating: boolean;
  10431. /** Gets the list of attached animations */
  10432. animations: Nullable<Array<Animation>>;
  10433. /** Gets or sets a boolean indicating if the sprite can be picked */
  10434. isPickable: boolean;
  10435. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10436. useAlphaForPicking: boolean;
  10437. /** @hidden */
  10438. _xOffset: number;
  10439. /** @hidden */
  10440. _yOffset: number;
  10441. /** @hidden */
  10442. _xSize: number;
  10443. /** @hidden */
  10444. _ySize: number;
  10445. /**
  10446. * Gets or sets the associated action manager
  10447. */
  10448. actionManager: Nullable<ActionManager>;
  10449. /**
  10450. * An event triggered when the control has been disposed
  10451. */
  10452. onDisposeObservable: Observable<Sprite>;
  10453. private _animationStarted;
  10454. private _loopAnimation;
  10455. private _fromIndex;
  10456. private _toIndex;
  10457. private _delay;
  10458. private _direction;
  10459. private _manager;
  10460. private _time;
  10461. private _onAnimationEnd;
  10462. /**
  10463. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10464. */
  10465. isVisible: boolean;
  10466. /**
  10467. * Gets or sets the sprite size
  10468. */
  10469. get size(): number;
  10470. set size(value: number);
  10471. /**
  10472. * Returns a boolean indicating if the animation is started
  10473. */
  10474. get animationStarted(): boolean;
  10475. /**
  10476. * Gets or sets the unique id of the sprite
  10477. */
  10478. uniqueId: number;
  10479. /**
  10480. * Gets the manager of this sprite
  10481. */
  10482. get manager(): ISpriteManager;
  10483. /**
  10484. * Creates a new Sprite
  10485. * @param name defines the name
  10486. * @param manager defines the manager
  10487. */
  10488. constructor(
  10489. /** defines the name */
  10490. name: string, manager: ISpriteManager);
  10491. /**
  10492. * Returns the string "Sprite"
  10493. * @returns "Sprite"
  10494. */
  10495. getClassName(): string;
  10496. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10497. get fromIndex(): number;
  10498. set fromIndex(value: number);
  10499. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10500. get toIndex(): number;
  10501. set toIndex(value: number);
  10502. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10503. get loopAnimation(): boolean;
  10504. set loopAnimation(value: boolean);
  10505. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10506. get delay(): number;
  10507. set delay(value: number);
  10508. /**
  10509. * Starts an animation
  10510. * @param from defines the initial key
  10511. * @param to defines the end key
  10512. * @param loop defines if the animation must loop
  10513. * @param delay defines the start delay (in ms)
  10514. * @param onAnimationEnd defines a callback to call when animation ends
  10515. */
  10516. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10517. /** Stops current animation (if any) */
  10518. stopAnimation(): void;
  10519. /** @hidden */
  10520. _animate(deltaTime: number): void;
  10521. /** Release associated resources */
  10522. dispose(): void;
  10523. /**
  10524. * Serializes the sprite to a JSON object
  10525. * @returns the JSON object
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Parses a JSON object to create a new sprite
  10530. * @param parsedSprite The JSON object to parse
  10531. * @param manager defines the hosting manager
  10532. * @returns the new sprite
  10533. */
  10534. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10535. }
  10536. }
  10537. declare module "babylonjs/Collisions/pickingInfo" {
  10538. import { Nullable } from "babylonjs/types";
  10539. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10541. import { Sprite } from "babylonjs/Sprites/sprite";
  10542. import { Ray } from "babylonjs/Culling/ray";
  10543. /**
  10544. * Information about the result of picking within a scene
  10545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10546. */
  10547. export class PickingInfo {
  10548. /** @hidden */
  10549. _pickingUnavailable: boolean;
  10550. /**
  10551. * If the pick collided with an object
  10552. */
  10553. hit: boolean;
  10554. /**
  10555. * Distance away where the pick collided
  10556. */
  10557. distance: number;
  10558. /**
  10559. * The location of pick collision
  10560. */
  10561. pickedPoint: Nullable<Vector3>;
  10562. /**
  10563. * The mesh corresponding the the pick collision
  10564. */
  10565. pickedMesh: Nullable<AbstractMesh>;
  10566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10567. bu: number;
  10568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10569. bv: number;
  10570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10571. faceId: number;
  10572. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10573. subMeshFaceId: number;
  10574. /** Id of the the submesh that was picked */
  10575. subMeshId: number;
  10576. /** If a sprite was picked, this will be the sprite the pick collided with */
  10577. pickedSprite: Nullable<Sprite>;
  10578. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10579. thinInstanceIndex: number;
  10580. /**
  10581. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10582. */
  10583. originMesh: Nullable<AbstractMesh>;
  10584. /**
  10585. * The ray that was used to perform the picking.
  10586. */
  10587. ray: Nullable<Ray>;
  10588. /**
  10589. * Gets the normal correspodning to the face the pick collided with
  10590. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10591. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10592. * @returns The normal correspodning to the face the pick collided with
  10593. */
  10594. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10595. /**
  10596. * Gets the texture coordinates of where the pick occured
  10597. * @returns the vector containing the coordnates of the texture
  10598. */
  10599. getTextureCoordinates(): Nullable<Vector2>;
  10600. }
  10601. }
  10602. declare module "babylonjs/Culling/ray" {
  10603. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10604. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10607. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10609. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10610. import { Plane } from "babylonjs/Maths/math.plane";
  10611. /**
  10612. * Class representing a ray with position and direction
  10613. */
  10614. export class Ray {
  10615. /** origin point */
  10616. origin: Vector3;
  10617. /** direction */
  10618. direction: Vector3;
  10619. /** length of the ray */
  10620. length: number;
  10621. private static readonly _TmpVector3;
  10622. private _tmpRay;
  10623. /**
  10624. * Creates a new ray
  10625. * @param origin origin point
  10626. * @param direction direction
  10627. * @param length length of the ray
  10628. */
  10629. constructor(
  10630. /** origin point */
  10631. origin: Vector3,
  10632. /** direction */
  10633. direction: Vector3,
  10634. /** length of the ray */
  10635. length?: number);
  10636. /**
  10637. * Checks if the ray intersects a box
  10638. * This does not account for the ray lenght by design to improve perfs.
  10639. * @param minimum bound of the box
  10640. * @param maximum bound of the box
  10641. * @param intersectionTreshold extra extend to be added to the box in all direction
  10642. * @returns if the box was hit
  10643. */
  10644. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10645. /**
  10646. * Checks if the ray intersects a box
  10647. * This does not account for the ray lenght by design to improve perfs.
  10648. * @param box the bounding box to check
  10649. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10650. * @returns if the box was hit
  10651. */
  10652. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10653. /**
  10654. * If the ray hits a sphere
  10655. * @param sphere the bounding sphere to check
  10656. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10657. * @returns true if it hits the sphere
  10658. */
  10659. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10660. /**
  10661. * If the ray hits a triange
  10662. * @param vertex0 triangle vertex
  10663. * @param vertex1 triangle vertex
  10664. * @param vertex2 triangle vertex
  10665. * @returns intersection information if hit
  10666. */
  10667. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10668. /**
  10669. * Checks if ray intersects a plane
  10670. * @param plane the plane to check
  10671. * @returns the distance away it was hit
  10672. */
  10673. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10674. /**
  10675. * Calculate the intercept of a ray on a given axis
  10676. * @param axis to check 'x' | 'y' | 'z'
  10677. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10678. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10679. */
  10680. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10681. /**
  10682. * Checks if ray intersects a mesh
  10683. * @param mesh the mesh to check
  10684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10685. * @returns picking info of the intersecton
  10686. */
  10687. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10688. /**
  10689. * Checks if ray intersects a mesh
  10690. * @param meshes the meshes to check
  10691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10692. * @param results array to store result in
  10693. * @returns Array of picking infos
  10694. */
  10695. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10696. private _comparePickingInfo;
  10697. private static smallnum;
  10698. private static rayl;
  10699. /**
  10700. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10701. * @param sega the first point of the segment to test the intersection against
  10702. * @param segb the second point of the segment to test the intersection against
  10703. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10704. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10705. */
  10706. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10707. /**
  10708. * Update the ray from viewport position
  10709. * @param x position
  10710. * @param y y position
  10711. * @param viewportWidth viewport width
  10712. * @param viewportHeight viewport height
  10713. * @param world world matrix
  10714. * @param view view matrix
  10715. * @param projection projection matrix
  10716. * @returns this ray updated
  10717. */
  10718. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10719. /**
  10720. * Creates a ray with origin and direction of 0,0,0
  10721. * @returns the new ray
  10722. */
  10723. static Zero(): Ray;
  10724. /**
  10725. * Creates a new ray from screen space and viewport
  10726. * @param x position
  10727. * @param y y position
  10728. * @param viewportWidth viewport width
  10729. * @param viewportHeight viewport height
  10730. * @param world world matrix
  10731. * @param view view matrix
  10732. * @param projection projection matrix
  10733. * @returns new ray
  10734. */
  10735. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10736. /**
  10737. * 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
  10738. * transformed to the given world matrix.
  10739. * @param origin The origin point
  10740. * @param end The end point
  10741. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10742. * @returns the new ray
  10743. */
  10744. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10745. /**
  10746. * Transforms a ray by a matrix
  10747. * @param ray ray to transform
  10748. * @param matrix matrix to apply
  10749. * @returns the resulting new ray
  10750. */
  10751. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10752. /**
  10753. * Transforms a ray by a matrix
  10754. * @param ray ray to transform
  10755. * @param matrix matrix to apply
  10756. * @param result ray to store result in
  10757. */
  10758. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10759. /**
  10760. * Unproject a ray from screen space to object space
  10761. * @param sourceX defines the screen space x coordinate to use
  10762. * @param sourceY defines the screen space y coordinate to use
  10763. * @param viewportWidth defines the current width of the viewport
  10764. * @param viewportHeight defines the current height of the viewport
  10765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10766. * @param view defines the view matrix to use
  10767. * @param projection defines the projection matrix to use
  10768. */
  10769. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10770. }
  10771. /**
  10772. * Type used to define predicate used to select faces when a mesh intersection is detected
  10773. */
  10774. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10775. module "babylonjs/scene" {
  10776. interface Scene {
  10777. /** @hidden */
  10778. _tempPickingRay: Nullable<Ray>;
  10779. /** @hidden */
  10780. _cachedRayForTransform: Ray;
  10781. /** @hidden */
  10782. _pickWithRayInverseMatrix: Matrix;
  10783. /** @hidden */
  10784. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10785. /** @hidden */
  10786. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10787. /** @hidden */
  10788. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10789. }
  10790. }
  10791. }
  10792. declare module "babylonjs/sceneComponent" {
  10793. import { Scene } from "babylonjs/scene";
  10794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10796. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10798. import { Nullable } from "babylonjs/types";
  10799. import { Camera } from "babylonjs/Cameras/camera";
  10800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10801. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10802. import { AbstractScene } from "babylonjs/abstractScene";
  10803. import { Mesh } from "babylonjs/Meshes/mesh";
  10804. /**
  10805. * Groups all the scene component constants in one place to ease maintenance.
  10806. * @hidden
  10807. */
  10808. export class SceneComponentConstants {
  10809. static readonly NAME_EFFECTLAYER: string;
  10810. static readonly NAME_LAYER: string;
  10811. static readonly NAME_LENSFLARESYSTEM: string;
  10812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10813. static readonly NAME_PARTICLESYSTEM: string;
  10814. static readonly NAME_GAMEPAD: string;
  10815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10817. static readonly NAME_PREPASSRENDERER: string;
  10818. static readonly NAME_DEPTHRENDERER: string;
  10819. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10820. static readonly NAME_SPRITE: string;
  10821. static readonly NAME_OUTLINERENDERER: string;
  10822. static readonly NAME_PROCEDURALTEXTURE: string;
  10823. static readonly NAME_SHADOWGENERATOR: string;
  10824. static readonly NAME_OCTREE: string;
  10825. static readonly NAME_PHYSICSENGINE: string;
  10826. static readonly NAME_AUDIO: string;
  10827. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10828. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10829. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10832. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10848. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10849. static readonly STEP_AFTERRENDER_AUDIO: number;
  10850. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10854. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10855. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10856. static readonly STEP_POINTERMOVE_SPRITE: number;
  10857. static readonly STEP_POINTERDOWN_SPRITE: number;
  10858. static readonly STEP_POINTERUP_SPRITE: number;
  10859. }
  10860. /**
  10861. * This represents a scene component.
  10862. *
  10863. * This is used to decouple the dependency the scene is having on the different workloads like
  10864. * layers, post processes...
  10865. */
  10866. export interface ISceneComponent {
  10867. /**
  10868. * The name of the component. Each component must have a unique name.
  10869. */
  10870. name: string;
  10871. /**
  10872. * The scene the component belongs to.
  10873. */
  10874. scene: Scene;
  10875. /**
  10876. * Register the component to one instance of a scene.
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. }
  10889. /**
  10890. * This represents a SERIALIZABLE scene component.
  10891. *
  10892. * This extends Scene Component to add Serialization methods on top.
  10893. */
  10894. export interface ISceneSerializableComponent extends ISceneComponent {
  10895. /**
  10896. * Adds all the elements from the container to the scene
  10897. * @param container the container holding the elements
  10898. */
  10899. addFromContainer(container: AbstractScene): void;
  10900. /**
  10901. * Removes all the elements in the container from the scene
  10902. * @param container contains the elements to remove
  10903. * @param dispose if the removed element should be disposed (default: false)
  10904. */
  10905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10906. /**
  10907. * Serializes the component data to the specified json object
  10908. * @param serializationObject The object to serialize to
  10909. */
  10910. serialize(serializationObject: any): void;
  10911. }
  10912. /**
  10913. * Strong typing of a Mesh related stage step action
  10914. */
  10915. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10916. /**
  10917. * Strong typing of a Evaluate Sub Mesh related stage step action
  10918. */
  10919. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10920. /**
  10921. * Strong typing of a Active Mesh related stage step action
  10922. */
  10923. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10924. /**
  10925. * Strong typing of a Camera related stage step action
  10926. */
  10927. export type CameraStageAction = (camera: Camera) => void;
  10928. /**
  10929. * Strong typing of a Camera Frame buffer related stage step action
  10930. */
  10931. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10932. /**
  10933. * Strong typing of a Render Target related stage step action
  10934. */
  10935. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10936. /**
  10937. * Strong typing of a RenderingGroup related stage step action
  10938. */
  10939. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10940. /**
  10941. * Strong typing of a Mesh Render related stage step action
  10942. */
  10943. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10944. /**
  10945. * Strong typing of a simple stage step action
  10946. */
  10947. export type SimpleStageAction = () => void;
  10948. /**
  10949. * Strong typing of a render target action.
  10950. */
  10951. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10952. /**
  10953. * Strong typing of a pointer move action.
  10954. */
  10955. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10956. /**
  10957. * Strong typing of a pointer up/down action.
  10958. */
  10959. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10960. /**
  10961. * Representation of a stage in the scene (Basically a list of ordered steps)
  10962. * @hidden
  10963. */
  10964. export class Stage<T extends Function> extends Array<{
  10965. index: number;
  10966. component: ISceneComponent;
  10967. action: T;
  10968. }> {
  10969. /**
  10970. * Hide ctor from the rest of the world.
  10971. * @param items The items to add.
  10972. */
  10973. private constructor();
  10974. /**
  10975. * Creates a new Stage.
  10976. * @returns A new instance of a Stage
  10977. */
  10978. static Create<T extends Function>(): Stage<T>;
  10979. /**
  10980. * Registers a step in an ordered way in the targeted stage.
  10981. * @param index Defines the position to register the step in
  10982. * @param component Defines the component attached to the step
  10983. * @param action Defines the action to launch during the step
  10984. */
  10985. registerStep(index: number, component: ISceneComponent, action: T): void;
  10986. /**
  10987. * Clears all the steps from the stage.
  10988. */
  10989. clear(): void;
  10990. }
  10991. }
  10992. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10993. import { Nullable } from "babylonjs/types";
  10994. import { Observable } from "babylonjs/Misc/observable";
  10995. import { Scene } from "babylonjs/scene";
  10996. import { Sprite } from "babylonjs/Sprites/sprite";
  10997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10998. import { Ray } from "babylonjs/Culling/ray";
  10999. import { Camera } from "babylonjs/Cameras/camera";
  11000. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11001. import { ISceneComponent } from "babylonjs/sceneComponent";
  11002. module "babylonjs/scene" {
  11003. interface Scene {
  11004. /** @hidden */
  11005. _pointerOverSprite: Nullable<Sprite>;
  11006. /** @hidden */
  11007. _pickedDownSprite: Nullable<Sprite>;
  11008. /** @hidden */
  11009. _tempSpritePickingRay: Nullable<Ray>;
  11010. /**
  11011. * All of the sprite managers added to this scene
  11012. * @see https://doc.babylonjs.com/babylon101/sprites
  11013. */
  11014. spriteManagers: Array<ISpriteManager>;
  11015. /**
  11016. * An event triggered when sprites rendering is about to start
  11017. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11018. */
  11019. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11020. /**
  11021. * An event triggered when sprites rendering is done
  11022. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11023. */
  11024. onAfterSpritesRenderingObservable: Observable<Scene>;
  11025. /** @hidden */
  11026. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11027. /** Launch a ray to try to pick a sprite in the scene
  11028. * @param x position on screen
  11029. * @param y position on screen
  11030. * @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
  11031. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11032. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11033. * @returns a PickingInfo
  11034. */
  11035. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11036. /** Use the given ray to pick a sprite in the scene
  11037. * @param ray The ray (in world space) to use to pick meshes
  11038. * @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
  11039. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11040. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11041. * @returns a PickingInfo
  11042. */
  11043. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11044. /** @hidden */
  11045. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11046. /** Launch a ray to try to pick sprites in the scene
  11047. * @param x position on screen
  11048. * @param y position on screen
  11049. * @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
  11050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11051. * @returns a PickingInfo array
  11052. */
  11053. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11054. /** Use the given ray to pick sprites in the scene
  11055. * @param ray The ray (in world space) to use to pick meshes
  11056. * @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
  11057. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11058. * @returns a PickingInfo array
  11059. */
  11060. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11061. /**
  11062. * Force the sprite under the pointer
  11063. * @param sprite defines the sprite to use
  11064. */
  11065. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11066. /**
  11067. * Gets the sprite under the pointer
  11068. * @returns a Sprite or null if no sprite is under the pointer
  11069. */
  11070. getPointerOverSprite(): Nullable<Sprite>;
  11071. }
  11072. }
  11073. /**
  11074. * Defines the sprite scene component responsible to manage sprites
  11075. * in a given scene.
  11076. */
  11077. export class SpriteSceneComponent implements ISceneComponent {
  11078. /**
  11079. * The component name helpfull to identify the component in the list of scene components.
  11080. */
  11081. readonly name: string;
  11082. /**
  11083. * The scene the component belongs to.
  11084. */
  11085. scene: Scene;
  11086. /** @hidden */
  11087. private _spritePredicate;
  11088. /**
  11089. * Creates a new instance of the component for the given scene
  11090. * @param scene Defines the scene to register the component in
  11091. */
  11092. constructor(scene: Scene);
  11093. /**
  11094. * Registers the component in a given scene
  11095. */
  11096. register(): void;
  11097. /**
  11098. * Rebuilds the elements related to this component in case of
  11099. * context lost for instance.
  11100. */
  11101. rebuild(): void;
  11102. /**
  11103. * Disposes the component and the associated ressources.
  11104. */
  11105. dispose(): void;
  11106. private _pickSpriteButKeepRay;
  11107. private _pointerMove;
  11108. private _pointerDown;
  11109. private _pointerUp;
  11110. }
  11111. }
  11112. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11113. /** @hidden */
  11114. export var fogFragmentDeclaration: {
  11115. name: string;
  11116. shader: string;
  11117. };
  11118. }
  11119. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11120. /** @hidden */
  11121. export var fogFragment: {
  11122. name: string;
  11123. shader: string;
  11124. };
  11125. }
  11126. declare module "babylonjs/Shaders/sprites.fragment" {
  11127. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11129. /** @hidden */
  11130. export var spritesPixelShader: {
  11131. name: string;
  11132. shader: string;
  11133. };
  11134. }
  11135. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11136. /** @hidden */
  11137. export var fogVertexDeclaration: {
  11138. name: string;
  11139. shader: string;
  11140. };
  11141. }
  11142. declare module "babylonjs/Shaders/sprites.vertex" {
  11143. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11144. /** @hidden */
  11145. export var spritesVertexShader: {
  11146. name: string;
  11147. shader: string;
  11148. };
  11149. }
  11150. declare module "babylonjs/Sprites/spriteManager" {
  11151. import { IDisposable, Scene } from "babylonjs/scene";
  11152. import { Nullable } from "babylonjs/types";
  11153. import { Observable } from "babylonjs/Misc/observable";
  11154. import { Sprite } from "babylonjs/Sprites/sprite";
  11155. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11156. import { Camera } from "babylonjs/Cameras/camera";
  11157. import { Texture } from "babylonjs/Materials/Textures/texture";
  11158. import "babylonjs/Shaders/sprites.fragment";
  11159. import "babylonjs/Shaders/sprites.vertex";
  11160. import { Ray } from "babylonjs/Culling/ray";
  11161. /**
  11162. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11163. */
  11164. export interface ISpriteManager extends IDisposable {
  11165. /**
  11166. * Gets manager's name
  11167. */
  11168. name: string;
  11169. /**
  11170. * Restricts the camera to viewing objects with the same layerMask.
  11171. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11172. */
  11173. layerMask: number;
  11174. /**
  11175. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11176. */
  11177. isPickable: boolean;
  11178. /**
  11179. * Gets the hosting scene
  11180. */
  11181. scene: Scene;
  11182. /**
  11183. * Specifies the rendering group id for this mesh (0 by default)
  11184. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11185. */
  11186. renderingGroupId: number;
  11187. /**
  11188. * Defines the list of sprites managed by the manager.
  11189. */
  11190. sprites: Array<Sprite>;
  11191. /**
  11192. * Gets or sets the spritesheet texture
  11193. */
  11194. texture: Texture;
  11195. /** Defines the default width of a cell in the spritesheet */
  11196. cellWidth: number;
  11197. /** Defines the default height of a cell in the spritesheet */
  11198. cellHeight: number;
  11199. /**
  11200. * Tests the intersection of a sprite with a specific ray.
  11201. * @param ray The ray we are sending to test the collision
  11202. * @param camera The camera space we are sending rays in
  11203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11205. * @returns picking info or null.
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Renders the list of sprites on screen.
  11218. */
  11219. render(): void;
  11220. }
  11221. /**
  11222. * Class used to manage multiple sprites on the same spritesheet
  11223. * @see https://doc.babylonjs.com/babylon101/sprites
  11224. */
  11225. export class SpriteManager implements ISpriteManager {
  11226. /** defines the manager's name */
  11227. name: string;
  11228. /** Define the Url to load snippets */
  11229. static SnippetUrl: string;
  11230. /** Snippet ID if the manager was created from the snippet server */
  11231. snippetId: string;
  11232. /** Gets the list of sprites */
  11233. sprites: Sprite[];
  11234. /** Gets or sets the rendering group id (0 by default) */
  11235. renderingGroupId: number;
  11236. /** Gets or sets camera layer mask */
  11237. layerMask: number;
  11238. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11239. fogEnabled: boolean;
  11240. /** Gets or sets a boolean indicating if the sprites are pickable */
  11241. isPickable: boolean;
  11242. /** Defines the default width of a cell in the spritesheet */
  11243. cellWidth: number;
  11244. /** Defines the default height of a cell in the spritesheet */
  11245. cellHeight: number;
  11246. /** Associative array from JSON sprite data file */
  11247. private _cellData;
  11248. /** Array of sprite names from JSON sprite data file */
  11249. private _spriteMap;
  11250. /** True when packed cell data from JSON file is ready*/
  11251. private _packedAndReady;
  11252. private _textureContent;
  11253. private _useInstancing;
  11254. /**
  11255. * An event triggered when the manager is disposed.
  11256. */
  11257. onDisposeObservable: Observable<SpriteManager>;
  11258. private _onDisposeObserver;
  11259. /**
  11260. * Callback called when the manager is disposed
  11261. */
  11262. set onDispose(callback: () => void);
  11263. private _capacity;
  11264. private _fromPacked;
  11265. private _spriteTexture;
  11266. private _epsilon;
  11267. private _scene;
  11268. private _vertexData;
  11269. private _buffer;
  11270. private _vertexBuffers;
  11271. private _spriteBuffer;
  11272. private _indexBuffer;
  11273. private _effectBase;
  11274. private _effectFog;
  11275. private _vertexBufferSize;
  11276. /**
  11277. * Gets or sets the unique id of the sprite
  11278. */
  11279. uniqueId: number;
  11280. /**
  11281. * Gets the array of sprites
  11282. */
  11283. get children(): Sprite[];
  11284. /**
  11285. * Gets the hosting scene
  11286. */
  11287. get scene(): Scene;
  11288. /**
  11289. * Gets the capacity of the manager
  11290. */
  11291. get capacity(): number;
  11292. /**
  11293. * Gets or sets the spritesheet texture
  11294. */
  11295. get texture(): Texture;
  11296. set texture(value: Texture);
  11297. private _blendMode;
  11298. /**
  11299. * Blend mode use to render the particle, it can be any of
  11300. * the static Constants.ALPHA_x properties provided in this class.
  11301. * Default value is Constants.ALPHA_COMBINE
  11302. */
  11303. get blendMode(): number;
  11304. set blendMode(blendMode: number);
  11305. /** Disables writing to the depth buffer when rendering the sprites.
  11306. * It can be handy to disable depth writing when using textures without alpha channel
  11307. * and setting some specific blend modes.
  11308. */
  11309. disableDepthWrite: boolean;
  11310. /**
  11311. * Creates a new sprite manager
  11312. * @param name defines the manager's name
  11313. * @param imgUrl defines the sprite sheet url
  11314. * @param capacity defines the maximum allowed number of sprites
  11315. * @param cellSize defines the size of a sprite cell
  11316. * @param scene defines the hosting scene
  11317. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11318. * @param samplingMode defines the smapling mode to use with spritesheet
  11319. * @param fromPacked set to false; do not alter
  11320. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11321. */
  11322. constructor(
  11323. /** defines the manager's name */
  11324. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11325. /**
  11326. * Returns the string "SpriteManager"
  11327. * @returns "SpriteManager"
  11328. */
  11329. getClassName(): string;
  11330. private _makePacked;
  11331. private _appendSpriteVertex;
  11332. private _checkTextureAlpha;
  11333. /**
  11334. * Intersects the sprites with a ray
  11335. * @param ray defines the ray to intersect with
  11336. * @param camera defines the current active camera
  11337. * @param predicate defines a predicate used to select candidate sprites
  11338. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11339. * @returns null if no hit or a PickingInfo
  11340. */
  11341. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11342. /**
  11343. * Intersects the sprites with a ray
  11344. * @param ray defines the ray to intersect with
  11345. * @param camera defines the current active camera
  11346. * @param predicate defines a predicate used to select candidate sprites
  11347. * @returns null if no hit or a PickingInfo array
  11348. */
  11349. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11350. /**
  11351. * Render all child sprites
  11352. */
  11353. render(): void;
  11354. /**
  11355. * Release associated resources
  11356. */
  11357. dispose(): void;
  11358. /**
  11359. * Serializes the sprite manager to a JSON object
  11360. * @param serializeTexture defines if the texture must be serialized as well
  11361. * @returns the JSON object
  11362. */
  11363. serialize(serializeTexture?: boolean): any;
  11364. /**
  11365. * Parses a JSON object to create a new sprite manager.
  11366. * @param parsedManager The JSON object to parse
  11367. * @param scene The scene to create the sprite managerin
  11368. * @param rootUrl The root url to use to load external dependencies like texture
  11369. * @returns the new sprite manager
  11370. */
  11371. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11372. /**
  11373. * Creates a sprite manager from a snippet saved in a remote file
  11374. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11375. * @param url defines the url to load from
  11376. * @param scene defines the hosting scene
  11377. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11378. * @returns a promise that will resolve to the new sprite manager
  11379. */
  11380. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11381. /**
  11382. * Creates a sprite manager from a snippet saved by the sprite editor
  11383. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11384. * @param scene defines the hosting scene
  11385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11386. * @returns a promise that will resolve to the new sprite manager
  11387. */
  11388. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11389. }
  11390. }
  11391. declare module "babylonjs/Misc/gradients" {
  11392. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11393. /** Interface used by value gradients (color, factor, ...) */
  11394. export interface IValueGradient {
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number;
  11399. }
  11400. /** Class used to store color4 gradient */
  11401. export class ColorGradient implements IValueGradient {
  11402. /**
  11403. * Gets or sets the gradient value (between 0 and 1)
  11404. */
  11405. gradient: number;
  11406. /**
  11407. * Gets or sets first associated color
  11408. */
  11409. color1: Color4;
  11410. /**
  11411. * Gets or sets second associated color
  11412. */
  11413. color2?: Color4 | undefined;
  11414. /**
  11415. * Creates a new color4 gradient
  11416. * @param gradient gets or sets the gradient value (between 0 and 1)
  11417. * @param color1 gets or sets first associated color
  11418. * @param color2 gets or sets first second color
  11419. */
  11420. constructor(
  11421. /**
  11422. * Gets or sets the gradient value (between 0 and 1)
  11423. */
  11424. gradient: number,
  11425. /**
  11426. * Gets or sets first associated color
  11427. */
  11428. color1: Color4,
  11429. /**
  11430. * Gets or sets second associated color
  11431. */
  11432. color2?: Color4 | undefined);
  11433. /**
  11434. * Will get a color picked randomly between color1 and color2.
  11435. * If color2 is undefined then color1 will be used
  11436. * @param result defines the target Color4 to store the result in
  11437. */
  11438. getColorToRef(result: Color4): void;
  11439. }
  11440. /** Class used to store color 3 gradient */
  11441. export class Color3Gradient implements IValueGradient {
  11442. /**
  11443. * Gets or sets the gradient value (between 0 and 1)
  11444. */
  11445. gradient: number;
  11446. /**
  11447. * Gets or sets the associated color
  11448. */
  11449. color: Color3;
  11450. /**
  11451. * Creates a new color3 gradient
  11452. * @param gradient gets or sets the gradient value (between 0 and 1)
  11453. * @param color gets or sets associated color
  11454. */
  11455. constructor(
  11456. /**
  11457. * Gets or sets the gradient value (between 0 and 1)
  11458. */
  11459. gradient: number,
  11460. /**
  11461. * Gets or sets the associated color
  11462. */
  11463. color: Color3);
  11464. }
  11465. /** Class used to store factor gradient */
  11466. export class FactorGradient implements IValueGradient {
  11467. /**
  11468. * Gets or sets the gradient value (between 0 and 1)
  11469. */
  11470. gradient: number;
  11471. /**
  11472. * Gets or sets first associated factor
  11473. */
  11474. factor1: number;
  11475. /**
  11476. * Gets or sets second associated factor
  11477. */
  11478. factor2?: number | undefined;
  11479. /**
  11480. * Creates a new factor gradient
  11481. * @param gradient gets or sets the gradient value (between 0 and 1)
  11482. * @param factor1 gets or sets first associated factor
  11483. * @param factor2 gets or sets second associated factor
  11484. */
  11485. constructor(
  11486. /**
  11487. * Gets or sets the gradient value (between 0 and 1)
  11488. */
  11489. gradient: number,
  11490. /**
  11491. * Gets or sets first associated factor
  11492. */
  11493. factor1: number,
  11494. /**
  11495. * Gets or sets second associated factor
  11496. */
  11497. factor2?: number | undefined);
  11498. /**
  11499. * Will get a number picked randomly between factor1 and factor2.
  11500. * If factor2 is undefined then factor1 will be used
  11501. * @returns the picked number
  11502. */
  11503. getFactor(): number;
  11504. }
  11505. /**
  11506. * Helper used to simplify some generic gradient tasks
  11507. */
  11508. export class GradientHelper {
  11509. /**
  11510. * Gets the current gradient from an array of IValueGradient
  11511. * @param ratio defines the current ratio to get
  11512. * @param gradients defines the array of IValueGradient
  11513. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11514. */
  11515. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11516. }
  11517. }
  11518. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11519. import { Nullable } from "babylonjs/types";
  11520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11521. import { Scene } from "babylonjs/scene";
  11522. module "babylonjs/Engines/thinEngine" {
  11523. interface ThinEngine {
  11524. /**
  11525. * Creates a raw texture
  11526. * @param data defines the data to store in the texture
  11527. * @param width defines the width of the texture
  11528. * @param height defines the height of the texture
  11529. * @param format defines the format of the data
  11530. * @param generateMipMaps defines if the engine should generate the mip levels
  11531. * @param invertY defines if data must be stored with Y axis inverted
  11532. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11533. * @param compression defines the compression used (null by default)
  11534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11535. * @returns the raw texture inside an InternalTexture
  11536. */
  11537. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11538. /**
  11539. * Update a raw texture
  11540. * @param texture defines the texture to update
  11541. * @param data defines the data to store in the texture
  11542. * @param format defines the format of the data
  11543. * @param invertY defines if data must be stored with Y axis inverted
  11544. */
  11545. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11546. /**
  11547. * Update a raw texture
  11548. * @param texture defines the texture to update
  11549. * @param data defines the data to store in the texture
  11550. * @param format defines the format of the data
  11551. * @param invertY defines if data must be stored with Y axis inverted
  11552. * @param compression defines the compression used (null by default)
  11553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11554. */
  11555. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11556. /**
  11557. * Creates a new raw cube texture
  11558. * @param data defines the array of data to use to create each face
  11559. * @param size defines the size of the textures
  11560. * @param format defines the format of the data
  11561. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11562. * @param generateMipMaps defines if the engine should generate the mip levels
  11563. * @param invertY defines if data must be stored with Y axis inverted
  11564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11565. * @param compression defines the compression used (null by default)
  11566. * @returns the cube texture as an InternalTexture
  11567. */
  11568. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11569. /**
  11570. * Update a raw cube texture
  11571. * @param texture defines the texture to udpdate
  11572. * @param data defines the data to store
  11573. * @param format defines the data format
  11574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11575. * @param invertY defines if data must be stored with Y axis inverted
  11576. */
  11577. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11578. /**
  11579. * Update a raw cube texture
  11580. * @param texture defines the texture to udpdate
  11581. * @param data defines the data to store
  11582. * @param format defines the data format
  11583. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11584. * @param invertY defines if data must be stored with Y axis inverted
  11585. * @param compression defines the compression used (null by default)
  11586. */
  11587. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11588. /**
  11589. * Update a raw cube texture
  11590. * @param texture defines the texture to udpdate
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11594. * @param invertY defines if data must be stored with Y axis inverted
  11595. * @param compression defines the compression used (null by default)
  11596. * @param level defines which level of the texture to update
  11597. */
  11598. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11599. /**
  11600. * Creates a new raw cube texture from a specified url
  11601. * @param url defines the url where the data is located
  11602. * @param scene defines the current scene
  11603. * @param size defines the size of the textures
  11604. * @param format defines the format of the data
  11605. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11606. * @param noMipmap defines if the engine should avoid generating the mip levels
  11607. * @param callback defines a callback used to extract texture data from loaded data
  11608. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11609. * @param onLoad defines a callback called when texture is loaded
  11610. * @param onError defines a callback called if there is an error
  11611. * @returns the cube texture as an InternalTexture
  11612. */
  11613. 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;
  11614. /**
  11615. * Creates a new raw cube texture from a specified url
  11616. * @param url defines the url where the data is located
  11617. * @param scene defines the current scene
  11618. * @param size defines the size of the textures
  11619. * @param format defines the format of the data
  11620. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11621. * @param noMipmap defines if the engine should avoid generating the mip levels
  11622. * @param callback defines a callback used to extract texture data from loaded data
  11623. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11624. * @param onLoad defines a callback called when texture is loaded
  11625. * @param onError defines a callback called if there is an error
  11626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11627. * @param invertY defines if data must be stored with Y axis inverted
  11628. * @returns the cube texture as an InternalTexture
  11629. */
  11630. 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;
  11631. /**
  11632. * Creates a new raw 3D texture
  11633. * @param data defines the data used to create the texture
  11634. * @param width defines the width of the texture
  11635. * @param height defines the height of the texture
  11636. * @param depth defines the depth of the texture
  11637. * @param format defines the format of the texture
  11638. * @param generateMipMaps defines if the engine must generate mip levels
  11639. * @param invertY defines if data must be stored with Y axis inverted
  11640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11641. * @param compression defines the compressed used (can be null)
  11642. * @param textureType defines the compressed used (can be null)
  11643. * @returns a new raw 3D texture (stored in an InternalTexture)
  11644. */
  11645. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11646. /**
  11647. * Update a raw 3D texture
  11648. * @param texture defines the texture to update
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param invertY defines if data must be stored with Y axis inverted
  11652. */
  11653. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11654. /**
  11655. * Update a raw 3D texture
  11656. * @param texture defines the texture to update
  11657. * @param data defines the data to store
  11658. * @param format defines the data format
  11659. * @param invertY defines if data must be stored with Y axis inverted
  11660. * @param compression defines the used compression (can be null)
  11661. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11662. */
  11663. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11664. /**
  11665. * Creates a new raw 2D array texture
  11666. * @param data defines the data used to create the texture
  11667. * @param width defines the width of the texture
  11668. * @param height defines the height of the texture
  11669. * @param depth defines the number of layers of the texture
  11670. * @param format defines the format of the texture
  11671. * @param generateMipMaps defines if the engine must generate mip levels
  11672. * @param invertY defines if data must be stored with Y axis inverted
  11673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11674. * @param compression defines the compressed used (can be null)
  11675. * @param textureType defines the compressed used (can be null)
  11676. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11677. */
  11678. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11679. /**
  11680. * Update a raw 2D array texture
  11681. * @param texture defines the texture to update
  11682. * @param data defines the data to store
  11683. * @param format defines the data format
  11684. * @param invertY defines if data must be stored with Y axis inverted
  11685. */
  11686. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11687. /**
  11688. * Update a raw 2D array texture
  11689. * @param texture defines the texture to update
  11690. * @param data defines the data to store
  11691. * @param format defines the data format
  11692. * @param invertY defines if data must be stored with Y axis inverted
  11693. * @param compression defines the used compression (can be null)
  11694. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11695. */
  11696. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11697. }
  11698. }
  11699. }
  11700. declare module "babylonjs/Materials/Textures/rawTexture" {
  11701. import { Texture } from "babylonjs/Materials/Textures/texture";
  11702. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11703. import { Nullable } from "babylonjs/types";
  11704. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11705. import { Scene } from "babylonjs/scene";
  11706. /**
  11707. * Raw texture can help creating a texture directly from an array of data.
  11708. * This can be super useful if you either get the data from an uncompressed source or
  11709. * if you wish to create your texture pixel by pixel.
  11710. */
  11711. export class RawTexture extends Texture {
  11712. /**
  11713. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11714. */
  11715. format: number;
  11716. /**
  11717. * Instantiates a new RawTexture.
  11718. * Raw texture can help creating a texture directly from an array of data.
  11719. * This can be super useful if you either get the data from an uncompressed source or
  11720. * if you wish to create your texture pixel by pixel.
  11721. * @param data define the array of data to use to create the texture
  11722. * @param width define the width of the texture
  11723. * @param height define the height of the texture
  11724. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11725. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11726. * @param generateMipMaps define whether mip maps should be generated or not
  11727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11729. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11730. */
  11731. constructor(data: ArrayBufferView, width: number, height: number,
  11732. /**
  11733. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11734. */
  11735. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11736. /**
  11737. * Updates the texture underlying data.
  11738. * @param data Define the new data of the texture
  11739. */
  11740. update(data: ArrayBufferView): void;
  11741. /**
  11742. * Creates a luminance texture from some data.
  11743. * @param data Define the texture data
  11744. * @param width Define the width of the texture
  11745. * @param height Define the height of the texture
  11746. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11747. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11748. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11749. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11750. * @returns the luminance texture
  11751. */
  11752. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11753. /**
  11754. * Creates a luminance alpha texture from some data.
  11755. * @param data Define the texture data
  11756. * @param width Define the width of the texture
  11757. * @param height Define the height of the texture
  11758. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11759. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11762. * @returns the luminance alpha texture
  11763. */
  11764. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11765. /**
  11766. * Creates an alpha texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the alpha texture
  11775. */
  11776. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a RGB texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11787. * @returns the RGB alpha texture
  11788. */
  11789. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11790. /**
  11791. * Creates a RGBA texture from some data.
  11792. * @param data Define the texture data
  11793. * @param width Define the width of the texture
  11794. * @param height Define the height of the texture
  11795. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11799. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11800. * @returns the RGBA texture
  11801. */
  11802. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11803. /**
  11804. * Creates a R texture from some data.
  11805. * @param data Define the texture data
  11806. * @param width Define the width of the texture
  11807. * @param height Define the height of the texture
  11808. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11813. * @returns the R texture
  11814. */
  11815. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11816. }
  11817. }
  11818. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11819. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11820. import { IndicesArray, DataArray } from "babylonjs/types";
  11821. module "babylonjs/Engines/thinEngine" {
  11822. interface ThinEngine {
  11823. /**
  11824. * Update a dynamic index buffer
  11825. * @param indexBuffer defines the target index buffer
  11826. * @param indices defines the data to update
  11827. * @param offset defines the offset in the target index buffer where update should start
  11828. */
  11829. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11830. /**
  11831. * Updates a dynamic vertex buffer.
  11832. * @param vertexBuffer the vertex buffer to update
  11833. * @param data the data used to update the vertex buffer
  11834. * @param byteOffset the byte offset of the data
  11835. * @param byteLength the byte length of the data
  11836. */
  11837. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11838. }
  11839. }
  11840. }
  11841. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11842. import { Scene } from "babylonjs/scene";
  11843. import { ISceneComponent } from "babylonjs/sceneComponent";
  11844. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11845. module "babylonjs/abstractScene" {
  11846. interface AbstractScene {
  11847. /**
  11848. * The list of procedural textures added to the scene
  11849. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11850. */
  11851. proceduralTextures: Array<ProceduralTexture>;
  11852. }
  11853. }
  11854. /**
  11855. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11856. * in a given scene.
  11857. */
  11858. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11859. /**
  11860. * The component name helpfull to identify the component in the list of scene components.
  11861. */
  11862. readonly name: string;
  11863. /**
  11864. * The scene the component belongs to.
  11865. */
  11866. scene: Scene;
  11867. /**
  11868. * Creates a new instance of the component for the given scene
  11869. * @param scene Defines the scene to register the component in
  11870. */
  11871. constructor(scene: Scene);
  11872. /**
  11873. * Registers the component in a given scene
  11874. */
  11875. register(): void;
  11876. /**
  11877. * Rebuilds the elements related to this component in case of
  11878. * context lost for instance.
  11879. */
  11880. rebuild(): void;
  11881. /**
  11882. * Disposes the component and the associated ressources.
  11883. */
  11884. dispose(): void;
  11885. private _beforeClear;
  11886. }
  11887. }
  11888. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11890. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11891. module "babylonjs/Engines/thinEngine" {
  11892. interface ThinEngine {
  11893. /**
  11894. * Creates a new render target cube texture
  11895. * @param size defines the size of the texture
  11896. * @param options defines the options used to create the texture
  11897. * @returns a new render target cube texture stored in an InternalTexture
  11898. */
  11899. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11900. }
  11901. }
  11902. }
  11903. declare module "babylonjs/Shaders/procedural.vertex" {
  11904. /** @hidden */
  11905. export var proceduralVertexShader: {
  11906. name: string;
  11907. shader: string;
  11908. };
  11909. }
  11910. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11911. import { Observable } from "babylonjs/Misc/observable";
  11912. import { Nullable } from "babylonjs/types";
  11913. import { Scene } from "babylonjs/scene";
  11914. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11915. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11916. import { Effect } from "babylonjs/Materials/effect";
  11917. import { Texture } from "babylonjs/Materials/Textures/texture";
  11918. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11919. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11920. import "babylonjs/Shaders/procedural.vertex";
  11921. /**
  11922. * 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.
  11923. * This is the base class of any Procedural texture and contains most of the shareable code.
  11924. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11925. */
  11926. export class ProceduralTexture extends Texture {
  11927. isCube: boolean;
  11928. /**
  11929. * Define if the texture is enabled or not (disabled texture will not render)
  11930. */
  11931. isEnabled: boolean;
  11932. /**
  11933. * Define if the texture must be cleared before rendering (default is true)
  11934. */
  11935. autoClear: boolean;
  11936. /**
  11937. * Callback called when the texture is generated
  11938. */
  11939. onGenerated: () => void;
  11940. /**
  11941. * Event raised when the texture is generated
  11942. */
  11943. onGeneratedObservable: Observable<ProceduralTexture>;
  11944. /** @hidden */
  11945. _generateMipMaps: boolean;
  11946. /** @hidden **/
  11947. _effect: Effect;
  11948. /** @hidden */
  11949. _textures: {
  11950. [key: string]: Texture;
  11951. };
  11952. /** @hidden */
  11953. protected _fallbackTexture: Nullable<Texture>;
  11954. private _size;
  11955. private _currentRefreshId;
  11956. private _frameId;
  11957. private _refreshRate;
  11958. private _vertexBuffers;
  11959. private _indexBuffer;
  11960. private _uniforms;
  11961. private _samplers;
  11962. private _fragment;
  11963. private _floats;
  11964. private _ints;
  11965. private _floatsArrays;
  11966. private _colors3;
  11967. private _colors4;
  11968. private _vectors2;
  11969. private _vectors3;
  11970. private _matrices;
  11971. private _fallbackTextureUsed;
  11972. private _fullEngine;
  11973. private _cachedDefines;
  11974. private _contentUpdateId;
  11975. private _contentData;
  11976. /**
  11977. * Instantiates a new procedural texture.
  11978. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11979. * This is the base class of any Procedural texture and contains most of the shareable code.
  11980. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11981. * @param name Define the name of the texture
  11982. * @param size Define the size of the texture to create
  11983. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11984. * @param scene Define the scene the texture belongs to
  11985. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11986. * @param generateMipMaps Define if the texture should creates mip maps or not
  11987. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11988. */
  11989. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11990. /**
  11991. * The effect that is created when initializing the post process.
  11992. * @returns The created effect corresponding the the postprocess.
  11993. */
  11994. getEffect(): Effect;
  11995. /**
  11996. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11997. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11998. */
  11999. getContent(): Nullable<ArrayBufferView>;
  12000. private _createIndexBuffer;
  12001. /** @hidden */
  12002. _rebuild(): void;
  12003. /**
  12004. * Resets the texture in order to recreate its associated resources.
  12005. * This can be called in case of context loss
  12006. */
  12007. reset(): void;
  12008. protected _getDefines(): string;
  12009. /**
  12010. * Is the texture ready to be used ? (rendered at least once)
  12011. * @returns true if ready, otherwise, false.
  12012. */
  12013. isReady(): boolean;
  12014. /**
  12015. * Resets the refresh counter of the texture and start bak from scratch.
  12016. * Could be useful to regenerate the texture if it is setup to render only once.
  12017. */
  12018. resetRefreshCounter(): void;
  12019. /**
  12020. * Set the fragment shader to use in order to render the texture.
  12021. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12022. */
  12023. setFragment(fragment: any): void;
  12024. /**
  12025. * Define the refresh rate of the texture or the rendering frequency.
  12026. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12027. */
  12028. get refreshRate(): number;
  12029. set refreshRate(value: number);
  12030. /** @hidden */
  12031. _shouldRender(): boolean;
  12032. /**
  12033. * Get the size the texture is rendering at.
  12034. * @returns the size (texture is always squared)
  12035. */
  12036. getRenderSize(): number;
  12037. /**
  12038. * Resize the texture to new value.
  12039. * @param size Define the new size the texture should have
  12040. * @param generateMipMaps Define whether the new texture should create mip maps
  12041. */
  12042. resize(size: number, generateMipMaps: boolean): void;
  12043. private _checkUniform;
  12044. /**
  12045. * Set a texture in the shader program used to render.
  12046. * @param name Define the name of the uniform samplers as defined in the shader
  12047. * @param texture Define the texture to bind to this sampler
  12048. * @return the texture itself allowing "fluent" like uniform updates
  12049. */
  12050. setTexture(name: string, texture: Texture): ProceduralTexture;
  12051. /**
  12052. * Set a float in the shader.
  12053. * @param name Define the name of the uniform as defined in the shader
  12054. * @param value Define the value to give to the uniform
  12055. * @return the texture itself allowing "fluent" like uniform updates
  12056. */
  12057. setFloat(name: string, value: number): ProceduralTexture;
  12058. /**
  12059. * Set a int in the shader.
  12060. * @param name Define the name of the uniform as defined in the shader
  12061. * @param value Define the value to give to the uniform
  12062. * @return the texture itself allowing "fluent" like uniform updates
  12063. */
  12064. setInt(name: string, value: number): ProceduralTexture;
  12065. /**
  12066. * Set an array of floats in the shader.
  12067. * @param name Define the name of the uniform as defined in the shader
  12068. * @param value Define the value to give to the uniform
  12069. * @return the texture itself allowing "fluent" like uniform updates
  12070. */
  12071. setFloats(name: string, value: number[]): ProceduralTexture;
  12072. /**
  12073. * Set a vec3 in the shader from a Color3.
  12074. * @param name Define the name of the uniform as defined in the shader
  12075. * @param value Define the value to give to the uniform
  12076. * @return the texture itself allowing "fluent" like uniform updates
  12077. */
  12078. setColor3(name: string, value: Color3): ProceduralTexture;
  12079. /**
  12080. * Set a vec4 in the shader from a Color4.
  12081. * @param name Define the name of the uniform as defined in the shader
  12082. * @param value Define the value to give to the uniform
  12083. * @return the texture itself allowing "fluent" like uniform updates
  12084. */
  12085. setColor4(name: string, value: Color4): ProceduralTexture;
  12086. /**
  12087. * Set a vec2 in the shader from a Vector2.
  12088. * @param name Define the name of the uniform as defined in the shader
  12089. * @param value Define the value to give to the uniform
  12090. * @return the texture itself allowing "fluent" like uniform updates
  12091. */
  12092. setVector2(name: string, value: Vector2): ProceduralTexture;
  12093. /**
  12094. * Set a vec3 in the shader from a Vector3.
  12095. * @param name Define the name of the uniform as defined in the shader
  12096. * @param value Define the value to give to the uniform
  12097. * @return the texture itself allowing "fluent" like uniform updates
  12098. */
  12099. setVector3(name: string, value: Vector3): ProceduralTexture;
  12100. /**
  12101. * Set a mat4 in the shader from a MAtrix.
  12102. * @param name Define the name of the uniform as defined in the shader
  12103. * @param value Define the value to give to the uniform
  12104. * @return the texture itself allowing "fluent" like uniform updates
  12105. */
  12106. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12107. /**
  12108. * Render the texture to its associated render target.
  12109. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12110. */
  12111. render(useCameraPostProcess?: boolean): void;
  12112. /**
  12113. * Clone the texture.
  12114. * @returns the cloned texture
  12115. */
  12116. clone(): ProceduralTexture;
  12117. /**
  12118. * Dispose the texture and release its asoociated resources.
  12119. */
  12120. dispose(): void;
  12121. }
  12122. }
  12123. declare module "babylonjs/Particles/baseParticleSystem" {
  12124. import { Nullable } from "babylonjs/types";
  12125. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12127. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12128. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12129. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12131. import { Color4 } from "babylonjs/Maths/math.color";
  12132. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12133. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12134. import { Animation } from "babylonjs/Animations/animation";
  12135. import { Scene } from "babylonjs/scene";
  12136. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12137. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12138. /**
  12139. * This represents the base class for particle system in Babylon.
  12140. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12141. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12142. * @example https://doc.babylonjs.com/babylon101/particles
  12143. */
  12144. export class BaseParticleSystem {
  12145. /**
  12146. * Source color is added to the destination color without alpha affecting the result
  12147. */
  12148. static BLENDMODE_ONEONE: number;
  12149. /**
  12150. * Blend current color and particle color using particle’s alpha
  12151. */
  12152. static BLENDMODE_STANDARD: number;
  12153. /**
  12154. * Add current color and particle color multiplied by particle’s alpha
  12155. */
  12156. static BLENDMODE_ADD: number;
  12157. /**
  12158. * Multiply current color with particle color
  12159. */
  12160. static BLENDMODE_MULTIPLY: number;
  12161. /**
  12162. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12163. */
  12164. static BLENDMODE_MULTIPLYADD: number;
  12165. /**
  12166. * List of animations used by the particle system.
  12167. */
  12168. animations: Animation[];
  12169. /**
  12170. * Gets or sets the unique id of the particle system
  12171. */
  12172. uniqueId: number;
  12173. /**
  12174. * The id of the Particle system.
  12175. */
  12176. id: string;
  12177. /**
  12178. * The friendly name of the Particle system.
  12179. */
  12180. name: string;
  12181. /**
  12182. * Snippet ID if the particle system was created from the snippet server
  12183. */
  12184. snippetId: string;
  12185. /**
  12186. * The rendering group used by the Particle system to chose when to render.
  12187. */
  12188. renderingGroupId: number;
  12189. /**
  12190. * The emitter represents the Mesh or position we are attaching the particle system to.
  12191. */
  12192. emitter: Nullable<AbstractMesh | Vector3>;
  12193. /**
  12194. * The maximum number of particles to emit per frame
  12195. */
  12196. emitRate: number;
  12197. /**
  12198. * If you want to launch only a few particles at once, that can be done, as well.
  12199. */
  12200. manualEmitCount: number;
  12201. /**
  12202. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12203. */
  12204. updateSpeed: number;
  12205. /**
  12206. * The amount of time the particle system is running (depends of the overall update speed).
  12207. */
  12208. targetStopDuration: number;
  12209. /**
  12210. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12211. */
  12212. disposeOnStop: boolean;
  12213. /**
  12214. * Minimum power of emitting particles.
  12215. */
  12216. minEmitPower: number;
  12217. /**
  12218. * Maximum power of emitting particles.
  12219. */
  12220. maxEmitPower: number;
  12221. /**
  12222. * Minimum life time of emitting particles.
  12223. */
  12224. minLifeTime: number;
  12225. /**
  12226. * Maximum life time of emitting particles.
  12227. */
  12228. maxLifeTime: number;
  12229. /**
  12230. * Minimum Size of emitting particles.
  12231. */
  12232. minSize: number;
  12233. /**
  12234. * Maximum Size of emitting particles.
  12235. */
  12236. maxSize: number;
  12237. /**
  12238. * Minimum scale of emitting particles on X axis.
  12239. */
  12240. minScaleX: number;
  12241. /**
  12242. * Maximum scale of emitting particles on X axis.
  12243. */
  12244. maxScaleX: number;
  12245. /**
  12246. * Minimum scale of emitting particles on Y axis.
  12247. */
  12248. minScaleY: number;
  12249. /**
  12250. * Maximum scale of emitting particles on Y axis.
  12251. */
  12252. maxScaleY: number;
  12253. /**
  12254. * Gets or sets the minimal initial rotation in radians.
  12255. */
  12256. minInitialRotation: number;
  12257. /**
  12258. * Gets or sets the maximal initial rotation in radians.
  12259. */
  12260. maxInitialRotation: number;
  12261. /**
  12262. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12263. */
  12264. minAngularSpeed: number;
  12265. /**
  12266. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12267. */
  12268. maxAngularSpeed: number;
  12269. /**
  12270. * The texture used to render each particle. (this can be a spritesheet)
  12271. */
  12272. particleTexture: Nullable<BaseTexture>;
  12273. /**
  12274. * The layer mask we are rendering the particles through.
  12275. */
  12276. layerMask: number;
  12277. /**
  12278. * This can help using your own shader to render the particle system.
  12279. * The according effect will be created
  12280. */
  12281. customShader: any;
  12282. /**
  12283. * By default particle system starts as soon as they are created. This prevents the
  12284. * automatic start to happen and let you decide when to start emitting particles.
  12285. */
  12286. preventAutoStart: boolean;
  12287. private _noiseTexture;
  12288. /**
  12289. * Gets or sets a texture used to add random noise to particle positions
  12290. */
  12291. get noiseTexture(): Nullable<ProceduralTexture>;
  12292. set noiseTexture(value: Nullable<ProceduralTexture>);
  12293. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12294. noiseStrength: Vector3;
  12295. /**
  12296. * Callback triggered when the particle animation is ending.
  12297. */
  12298. onAnimationEnd: Nullable<() => void>;
  12299. /**
  12300. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12301. */
  12302. blendMode: number;
  12303. /**
  12304. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12305. * to override the particles.
  12306. */
  12307. forceDepthWrite: boolean;
  12308. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12309. preWarmCycles: number;
  12310. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12311. preWarmStepOffset: number;
  12312. /**
  12313. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12314. */
  12315. spriteCellChangeSpeed: number;
  12316. /**
  12317. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12318. */
  12319. startSpriteCellID: number;
  12320. /**
  12321. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12322. */
  12323. endSpriteCellID: number;
  12324. /**
  12325. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12326. */
  12327. spriteCellWidth: number;
  12328. /**
  12329. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12330. */
  12331. spriteCellHeight: number;
  12332. /**
  12333. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12334. */
  12335. spriteRandomStartCell: boolean;
  12336. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12337. translationPivot: Vector2;
  12338. /** @hidden */
  12339. protected _isAnimationSheetEnabled: boolean;
  12340. /**
  12341. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12342. */
  12343. beginAnimationOnStart: boolean;
  12344. /**
  12345. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12346. */
  12347. beginAnimationFrom: number;
  12348. /**
  12349. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12350. */
  12351. beginAnimationTo: number;
  12352. /**
  12353. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12354. */
  12355. beginAnimationLoop: boolean;
  12356. /**
  12357. * Gets or sets a world offset applied to all particles
  12358. */
  12359. worldOffset: Vector3;
  12360. /**
  12361. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12362. */
  12363. get isAnimationSheetEnabled(): boolean;
  12364. set isAnimationSheetEnabled(value: boolean);
  12365. /**
  12366. * Get hosting scene
  12367. * @returns the scene
  12368. */
  12369. getScene(): Nullable<Scene>;
  12370. /**
  12371. * You can use gravity if you want to give an orientation to your particles.
  12372. */
  12373. gravity: Vector3;
  12374. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12375. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12377. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12378. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12380. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12381. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12382. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12383. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12384. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12386. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12387. /**
  12388. * Defines the delay in milliseconds before starting the system (0 by default)
  12389. */
  12390. startDelay: number;
  12391. /**
  12392. * Gets the current list of drag gradients.
  12393. * You must use addDragGradient and removeDragGradient to udpate this list
  12394. * @returns the list of drag gradients
  12395. */
  12396. getDragGradients(): Nullable<Array<FactorGradient>>;
  12397. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12398. limitVelocityDamping: number;
  12399. /**
  12400. * Gets the current list of limit velocity gradients.
  12401. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12402. * @returns the list of limit velocity gradients
  12403. */
  12404. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of color gradients.
  12407. * You must use addColorGradient and removeColorGradient to udpate this list
  12408. * @returns the list of color gradients
  12409. */
  12410. getColorGradients(): Nullable<Array<ColorGradient>>;
  12411. /**
  12412. * Gets the current list of size gradients.
  12413. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12414. * @returns the list of size gradients
  12415. */
  12416. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Gets the current list of color remap gradients.
  12419. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12420. * @returns the list of color remap gradients
  12421. */
  12422. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12423. /**
  12424. * Gets the current list of alpha remap gradients.
  12425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12426. * @returns the list of alpha remap gradients
  12427. */
  12428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12429. /**
  12430. * Gets the current list of life time gradients.
  12431. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12432. * @returns the list of life time gradients
  12433. */
  12434. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12435. /**
  12436. * Gets the current list of angular speed gradients.
  12437. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12438. * @returns the list of angular speed gradients
  12439. */
  12440. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12441. /**
  12442. * Gets the current list of velocity gradients.
  12443. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12444. * @returns the list of velocity gradients
  12445. */
  12446. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12447. /**
  12448. * Gets the current list of start size gradients.
  12449. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12450. * @returns the list of start size gradients
  12451. */
  12452. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12453. /**
  12454. * Gets the current list of emit rate gradients.
  12455. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12456. * @returns the list of emit rate gradients
  12457. */
  12458. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12459. /**
  12460. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12462. */
  12463. get direction1(): Vector3;
  12464. set direction1(value: Vector3);
  12465. /**
  12466. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12467. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12468. */
  12469. get direction2(): Vector3;
  12470. set direction2(value: Vector3);
  12471. /**
  12472. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12473. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12474. */
  12475. get minEmitBox(): Vector3;
  12476. set minEmitBox(value: Vector3);
  12477. /**
  12478. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12480. */
  12481. get maxEmitBox(): Vector3;
  12482. set maxEmitBox(value: Vector3);
  12483. /**
  12484. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12485. */
  12486. color1: Color4;
  12487. /**
  12488. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12489. */
  12490. color2: Color4;
  12491. /**
  12492. * Color the particle will have at the end of its lifetime
  12493. */
  12494. colorDead: Color4;
  12495. /**
  12496. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12497. */
  12498. textureMask: Color4;
  12499. /**
  12500. * The particle emitter type defines the emitter used by the particle system.
  12501. * It can be for example box, sphere, or cone...
  12502. */
  12503. particleEmitterType: IParticleEmitterType;
  12504. /** @hidden */
  12505. _isSubEmitter: boolean;
  12506. /**
  12507. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12508. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12509. */
  12510. billboardMode: number;
  12511. protected _isBillboardBased: boolean;
  12512. /**
  12513. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12514. */
  12515. get isBillboardBased(): boolean;
  12516. set isBillboardBased(value: boolean);
  12517. /**
  12518. * The scene the particle system belongs to.
  12519. */
  12520. protected _scene: Nullable<Scene>;
  12521. /**
  12522. * The engine the particle system belongs to.
  12523. */
  12524. protected _engine: ThinEngine;
  12525. /**
  12526. * Local cache of defines for image processing.
  12527. */
  12528. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12529. /**
  12530. * Default configuration related to image processing available in the standard Material.
  12531. */
  12532. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12533. /**
  12534. * Gets the image processing configuration used either in this material.
  12535. */
  12536. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12537. /**
  12538. * Sets the Default image processing configuration used either in the this material.
  12539. *
  12540. * If sets to null, the scene one is in use.
  12541. */
  12542. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12543. /**
  12544. * Attaches a new image processing configuration to the Standard Material.
  12545. * @param configuration
  12546. */
  12547. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12548. /** @hidden */
  12549. protected _reset(): void;
  12550. /** @hidden */
  12551. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12552. /**
  12553. * Instantiates a particle system.
  12554. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12555. * @param name The name of the particle system
  12556. */
  12557. constructor(name: string);
  12558. /**
  12559. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12562. * @returns the emitter
  12563. */
  12564. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12565. /**
  12566. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12567. * @param radius The radius of the hemisphere to emit from
  12568. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12569. * @returns the emitter
  12570. */
  12571. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12572. /**
  12573. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12574. * @param radius The radius of the sphere to emit from
  12575. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12576. * @returns the emitter
  12577. */
  12578. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12579. /**
  12580. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12581. * @param radius The radius of the sphere to emit from
  12582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12584. * @returns the emitter
  12585. */
  12586. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12587. /**
  12588. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12589. * @param radius The radius of the emission cylinder
  12590. * @param height The height of the emission cylinder
  12591. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12592. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12593. * @returns the emitter
  12594. */
  12595. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12596. /**
  12597. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12598. * @param radius The radius of the cylinder to emit from
  12599. * @param height The height of the emission cylinder
  12600. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12603. * @returns the emitter
  12604. */
  12605. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12606. /**
  12607. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12608. * @param radius The radius of the cone to emit from
  12609. * @param angle The base angle of the cone
  12610. * @returns the emitter
  12611. */
  12612. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12613. /**
  12614. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12617. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12618. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12619. * @returns the emitter
  12620. */
  12621. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12622. }
  12623. }
  12624. declare module "babylonjs/Particles/subEmitter" {
  12625. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12626. import { Scene } from "babylonjs/scene";
  12627. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12628. /**
  12629. * Type of sub emitter
  12630. */
  12631. export enum SubEmitterType {
  12632. /**
  12633. * Attached to the particle over it's lifetime
  12634. */
  12635. ATTACHED = 0,
  12636. /**
  12637. * Created when the particle dies
  12638. */
  12639. END = 1
  12640. }
  12641. /**
  12642. * Sub emitter class used to emit particles from an existing particle
  12643. */
  12644. export class SubEmitter {
  12645. /**
  12646. * the particle system to be used by the sub emitter
  12647. */
  12648. particleSystem: ParticleSystem;
  12649. /**
  12650. * Type of the submitter (Default: END)
  12651. */
  12652. type: SubEmitterType;
  12653. /**
  12654. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12655. * Note: This only is supported when using an emitter of type Mesh
  12656. */
  12657. inheritDirection: boolean;
  12658. /**
  12659. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12660. */
  12661. inheritedVelocityAmount: number;
  12662. /**
  12663. * Creates a sub emitter
  12664. * @param particleSystem the particle system to be used by the sub emitter
  12665. */
  12666. constructor(
  12667. /**
  12668. * the particle system to be used by the sub emitter
  12669. */
  12670. particleSystem: ParticleSystem);
  12671. /**
  12672. * Clones the sub emitter
  12673. * @returns the cloned sub emitter
  12674. */
  12675. clone(): SubEmitter;
  12676. /**
  12677. * Serialize current object to a JSON object
  12678. * @returns the serialized object
  12679. */
  12680. serialize(): any;
  12681. /** @hidden */
  12682. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12683. /**
  12684. * Creates a new SubEmitter from a serialized JSON version
  12685. * @param serializationObject defines the JSON object to read from
  12686. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12687. * @param rootUrl defines the rootUrl for data loading
  12688. * @returns a new SubEmitter
  12689. */
  12690. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12691. /** Release associated resources */
  12692. dispose(): void;
  12693. }
  12694. }
  12695. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12696. /** @hidden */
  12697. export var imageProcessingDeclaration: {
  12698. name: string;
  12699. shader: string;
  12700. };
  12701. }
  12702. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12703. /** @hidden */
  12704. export var imageProcessingFunctions: {
  12705. name: string;
  12706. shader: string;
  12707. };
  12708. }
  12709. declare module "babylonjs/Shaders/particles.fragment" {
  12710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12711. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12712. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12713. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12714. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12715. /** @hidden */
  12716. export var particlesPixelShader: {
  12717. name: string;
  12718. shader: string;
  12719. };
  12720. }
  12721. declare module "babylonjs/Shaders/particles.vertex" {
  12722. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12724. /** @hidden */
  12725. export var particlesVertexShader: {
  12726. name: string;
  12727. shader: string;
  12728. };
  12729. }
  12730. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12731. import { Nullable } from "babylonjs/types";
  12732. import { Plane } from "babylonjs/Maths/math";
  12733. /**
  12734. * Interface used to define entities containing multiple clip planes
  12735. */
  12736. export interface IClipPlanesHolder {
  12737. /**
  12738. * Gets or sets the active clipplane 1
  12739. */
  12740. clipPlane: Nullable<Plane>;
  12741. /**
  12742. * Gets or sets the active clipplane 2
  12743. */
  12744. clipPlane2: Nullable<Plane>;
  12745. /**
  12746. * Gets or sets the active clipplane 3
  12747. */
  12748. clipPlane3: Nullable<Plane>;
  12749. /**
  12750. * Gets or sets the active clipplane 4
  12751. */
  12752. clipPlane4: Nullable<Plane>;
  12753. /**
  12754. * Gets or sets the active clipplane 5
  12755. */
  12756. clipPlane5: Nullable<Plane>;
  12757. /**
  12758. * Gets or sets the active clipplane 6
  12759. */
  12760. clipPlane6: Nullable<Plane>;
  12761. }
  12762. }
  12763. declare module "babylonjs/Materials/thinMaterialHelper" {
  12764. import { Effect } from "babylonjs/Materials/effect";
  12765. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12766. /**
  12767. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12768. *
  12769. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12770. *
  12771. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12772. */
  12773. export class ThinMaterialHelper {
  12774. /**
  12775. * Binds the clip plane information from the holder to the effect.
  12776. * @param effect The effect we are binding the data to
  12777. * @param holder The entity containing the clip plane information
  12778. */
  12779. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12780. }
  12781. }
  12782. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12783. module "babylonjs/Engines/thinEngine" {
  12784. interface ThinEngine {
  12785. /**
  12786. * Sets alpha constants used by some alpha blending modes
  12787. * @param r defines the red component
  12788. * @param g defines the green component
  12789. * @param b defines the blue component
  12790. * @param a defines the alpha component
  12791. */
  12792. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12793. /**
  12794. * Sets the current alpha mode
  12795. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12796. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12797. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12798. */
  12799. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12800. /**
  12801. * Gets the current alpha mode
  12802. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12803. * @returns the current alpha mode
  12804. */
  12805. getAlphaMode(): number;
  12806. /**
  12807. * Sets the current alpha equation
  12808. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12809. */
  12810. setAlphaEquation(equation: number): void;
  12811. /**
  12812. * Gets the current alpha equation.
  12813. * @returns the current alpha equation
  12814. */
  12815. getAlphaEquation(): number;
  12816. }
  12817. }
  12818. }
  12819. declare module "babylonjs/Particles/particleSystem" {
  12820. import { Nullable } from "babylonjs/types";
  12821. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12822. import { Observable } from "babylonjs/Misc/observable";
  12823. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12824. import { Effect } from "babylonjs/Materials/effect";
  12825. import { IDisposable } from "babylonjs/scene";
  12826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12827. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12828. import { Particle } from "babylonjs/Particles/particle";
  12829. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12831. import "babylonjs/Shaders/particles.fragment";
  12832. import "babylonjs/Shaders/particles.vertex";
  12833. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12835. import "babylonjs/Engines/Extensions/engine.alpha";
  12836. import { Scene } from "babylonjs/scene";
  12837. /**
  12838. * This represents a particle system in Babylon.
  12839. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12840. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12841. * @example https://doc.babylonjs.com/babylon101/particles
  12842. */
  12843. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12844. /**
  12845. * Billboard mode will only apply to Y axis
  12846. */
  12847. static readonly BILLBOARDMODE_Y: number;
  12848. /**
  12849. * Billboard mode will apply to all axes
  12850. */
  12851. static readonly BILLBOARDMODE_ALL: number;
  12852. /**
  12853. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12854. */
  12855. static readonly BILLBOARDMODE_STRETCHED: number;
  12856. /**
  12857. * This function can be defined to provide custom update for active particles.
  12858. * This function will be called instead of regular update (age, position, color, etc.).
  12859. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12860. */
  12861. updateFunction: (particles: Particle[]) => void;
  12862. private _emitterWorldMatrix;
  12863. /**
  12864. * This function can be defined to specify initial direction for every new particle.
  12865. * It by default use the emitterType defined function
  12866. */
  12867. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12868. /**
  12869. * This function can be defined to specify initial position for every new particle.
  12870. * It by default use the emitterType defined function
  12871. */
  12872. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12873. /**
  12874. * @hidden
  12875. */
  12876. _inheritedVelocityOffset: Vector3;
  12877. /**
  12878. * An event triggered when the system is disposed
  12879. */
  12880. onDisposeObservable: Observable<IParticleSystem>;
  12881. private _onDisposeObserver;
  12882. /**
  12883. * Sets a callback that will be triggered when the system is disposed
  12884. */
  12885. set onDispose(callback: () => void);
  12886. private _particles;
  12887. private _epsilon;
  12888. private _capacity;
  12889. private _stockParticles;
  12890. private _newPartsExcess;
  12891. private _vertexData;
  12892. private _vertexBuffer;
  12893. private _vertexBuffers;
  12894. private _spriteBuffer;
  12895. private _indexBuffer;
  12896. private _effect;
  12897. private _customEffect;
  12898. private _cachedDefines;
  12899. private _scaledColorStep;
  12900. private _colorDiff;
  12901. private _scaledDirection;
  12902. private _scaledGravity;
  12903. private _currentRenderId;
  12904. private _alive;
  12905. private _useInstancing;
  12906. private _started;
  12907. private _stopped;
  12908. private _actualFrame;
  12909. private _scaledUpdateSpeed;
  12910. private _vertexBufferSize;
  12911. /** @hidden */
  12912. _currentEmitRateGradient: Nullable<FactorGradient>;
  12913. /** @hidden */
  12914. _currentEmitRate1: number;
  12915. /** @hidden */
  12916. _currentEmitRate2: number;
  12917. /** @hidden */
  12918. _currentStartSizeGradient: Nullable<FactorGradient>;
  12919. /** @hidden */
  12920. _currentStartSize1: number;
  12921. /** @hidden */
  12922. _currentStartSize2: number;
  12923. private readonly _rawTextureWidth;
  12924. private _rampGradientsTexture;
  12925. private _useRampGradients;
  12926. /** Gets or sets a matrix to use to compute projection */
  12927. defaultProjectionMatrix: Matrix;
  12928. /** Gets or sets a matrix to use to compute view */
  12929. defaultViewMatrix: Matrix;
  12930. /** Gets or sets a boolean indicating that ramp gradients must be used
  12931. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12932. */
  12933. get useRampGradients(): boolean;
  12934. set useRampGradients(value: boolean);
  12935. /**
  12936. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12937. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12938. */
  12939. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12940. private _subEmitters;
  12941. /**
  12942. * @hidden
  12943. * If the particle systems emitter should be disposed when the particle system is disposed
  12944. */
  12945. _disposeEmitterOnDispose: boolean;
  12946. /**
  12947. * The current active Sub-systems, this property is used by the root particle system only.
  12948. */
  12949. activeSubSystems: Array<ParticleSystem>;
  12950. /**
  12951. * Specifies if the particles are updated in emitter local space or world space
  12952. */
  12953. isLocal: boolean;
  12954. private _rootParticleSystem;
  12955. /**
  12956. * Gets the current list of active particles
  12957. */
  12958. get particles(): Particle[];
  12959. /**
  12960. * Gets the number of particles active at the same time.
  12961. * @returns The number of active particles.
  12962. */
  12963. getActiveCount(): number;
  12964. /**
  12965. * Returns the string "ParticleSystem"
  12966. * @returns a string containing the class name
  12967. */
  12968. getClassName(): string;
  12969. /**
  12970. * Gets a boolean indicating that the system is stopping
  12971. * @returns true if the system is currently stopping
  12972. */
  12973. isStopping(): boolean;
  12974. /**
  12975. * Gets the custom effect used to render the particles
  12976. * @param blendMode Blend mode for which the effect should be retrieved
  12977. * @returns The effect
  12978. */
  12979. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12980. /**
  12981. * Sets the custom effect used to render the particles
  12982. * @param effect The effect to set
  12983. * @param blendMode Blend mode for which the effect should be set
  12984. */
  12985. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12986. /** @hidden */
  12987. private _onBeforeDrawParticlesObservable;
  12988. /**
  12989. * Observable that will be called just before the particles are drawn
  12990. */
  12991. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12992. /**
  12993. * Gets the name of the particle vertex shader
  12994. */
  12995. get vertexShaderName(): string;
  12996. /**
  12997. * Instantiates a particle system.
  12998. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12999. * @param name The name of the particle system
  13000. * @param capacity The max number of particles alive at the same time
  13001. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13002. * @param customEffect a custom effect used to change the way particles are rendered by default
  13003. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13004. * @param epsilon Offset used to render the particles
  13005. */
  13006. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13007. private _addFactorGradient;
  13008. private _removeFactorGradient;
  13009. /**
  13010. * Adds a new life time gradient
  13011. * @param gradient defines the gradient to use (between 0 and 1)
  13012. * @param factor defines the life time factor to affect to the specified gradient
  13013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13014. * @returns the current particle system
  13015. */
  13016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13017. /**
  13018. * Remove a specific life time gradient
  13019. * @param gradient defines the gradient to remove
  13020. * @returns the current particle system
  13021. */
  13022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13023. /**
  13024. * Adds a new size gradient
  13025. * @param gradient defines the gradient to use (between 0 and 1)
  13026. * @param factor defines the size factor to affect to the specified gradient
  13027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13028. * @returns the current particle system
  13029. */
  13030. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13031. /**
  13032. * Remove a specific size gradient
  13033. * @param gradient defines the gradient to remove
  13034. * @returns the current particle system
  13035. */
  13036. removeSizeGradient(gradient: number): IParticleSystem;
  13037. /**
  13038. * Adds a new color remap gradient
  13039. * @param gradient defines the gradient to use (between 0 and 1)
  13040. * @param min defines the color remap minimal range
  13041. * @param max defines the color remap maximal range
  13042. * @returns the current particle system
  13043. */
  13044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13045. /**
  13046. * Remove a specific color remap gradient
  13047. * @param gradient defines the gradient to remove
  13048. * @returns the current particle system
  13049. */
  13050. removeColorRemapGradient(gradient: number): IParticleSystem;
  13051. /**
  13052. * Adds a new alpha remap gradient
  13053. * @param gradient defines the gradient to use (between 0 and 1)
  13054. * @param min defines the alpha remap minimal range
  13055. * @param max defines the alpha remap maximal range
  13056. * @returns the current particle system
  13057. */
  13058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13059. /**
  13060. * Remove a specific alpha remap gradient
  13061. * @param gradient defines the gradient to remove
  13062. * @returns the current particle system
  13063. */
  13064. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13065. /**
  13066. * Adds a new angular speed gradient
  13067. * @param gradient defines the gradient to use (between 0 and 1)
  13068. * @param factor defines the angular speed to affect to the specified gradient
  13069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13070. * @returns the current particle system
  13071. */
  13072. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13073. /**
  13074. * Remove a specific angular speed gradient
  13075. * @param gradient defines the gradient to remove
  13076. * @returns the current particle system
  13077. */
  13078. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13079. /**
  13080. * Adds a new velocity gradient
  13081. * @param gradient defines the gradient to use (between 0 and 1)
  13082. * @param factor defines the velocity to affect to the specified gradient
  13083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13084. * @returns the current particle system
  13085. */
  13086. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13087. /**
  13088. * Remove a specific velocity gradient
  13089. * @param gradient defines the gradient to remove
  13090. * @returns the current particle system
  13091. */
  13092. removeVelocityGradient(gradient: number): IParticleSystem;
  13093. /**
  13094. * Adds a new limit velocity gradient
  13095. * @param gradient defines the gradient to use (between 0 and 1)
  13096. * @param factor defines the limit velocity value to affect to the specified gradient
  13097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13098. * @returns the current particle system
  13099. */
  13100. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13101. /**
  13102. * Remove a specific limit velocity gradient
  13103. * @param gradient defines the gradient to remove
  13104. * @returns the current particle system
  13105. */
  13106. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13107. /**
  13108. * Adds a new drag gradient
  13109. * @param gradient defines the gradient to use (between 0 and 1)
  13110. * @param factor defines the drag value to affect to the specified gradient
  13111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13112. * @returns the current particle system
  13113. */
  13114. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13115. /**
  13116. * Remove a specific drag gradient
  13117. * @param gradient defines the gradient to remove
  13118. * @returns the current particle system
  13119. */
  13120. removeDragGradient(gradient: number): IParticleSystem;
  13121. /**
  13122. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13123. * @param gradient defines the gradient to use (between 0 and 1)
  13124. * @param factor defines the emit rate value to affect to the specified gradient
  13125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13126. * @returns the current particle system
  13127. */
  13128. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13129. /**
  13130. * Remove a specific emit rate gradient
  13131. * @param gradient defines the gradient to remove
  13132. * @returns the current particle system
  13133. */
  13134. removeEmitRateGradient(gradient: number): IParticleSystem;
  13135. /**
  13136. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13137. * @param gradient defines the gradient to use (between 0 and 1)
  13138. * @param factor defines the start size value to affect to the specified gradient
  13139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13140. * @returns the current particle system
  13141. */
  13142. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13143. /**
  13144. * Remove a specific start size gradient
  13145. * @param gradient defines the gradient to remove
  13146. * @returns the current particle system
  13147. */
  13148. removeStartSizeGradient(gradient: number): IParticleSystem;
  13149. private _createRampGradientTexture;
  13150. /**
  13151. * Gets the current list of ramp gradients.
  13152. * You must use addRampGradient and removeRampGradient to udpate this list
  13153. * @returns the list of ramp gradients
  13154. */
  13155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13156. /** Force the system to rebuild all gradients that need to be resync */
  13157. forceRefreshGradients(): void;
  13158. private _syncRampGradientTexture;
  13159. /**
  13160. * Adds a new ramp gradient used to remap particle colors
  13161. * @param gradient defines the gradient to use (between 0 and 1)
  13162. * @param color defines the color to affect to the specified gradient
  13163. * @returns the current particle system
  13164. */
  13165. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13166. /**
  13167. * Remove a specific ramp gradient
  13168. * @param gradient defines the gradient to remove
  13169. * @returns the current particle system
  13170. */
  13171. removeRampGradient(gradient: number): ParticleSystem;
  13172. /**
  13173. * Adds a new color gradient
  13174. * @param gradient defines the gradient to use (between 0 and 1)
  13175. * @param color1 defines the color to affect to the specified gradient
  13176. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13177. * @returns this particle system
  13178. */
  13179. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13180. /**
  13181. * Remove a specific color gradient
  13182. * @param gradient defines the gradient to remove
  13183. * @returns this particle system
  13184. */
  13185. removeColorGradient(gradient: number): IParticleSystem;
  13186. private _fetchR;
  13187. protected _reset(): void;
  13188. private _resetEffect;
  13189. private _createVertexBuffers;
  13190. private _createIndexBuffer;
  13191. /**
  13192. * Gets the maximum number of particles active at the same time.
  13193. * @returns The max number of active particles.
  13194. */
  13195. getCapacity(): number;
  13196. /**
  13197. * Gets whether there are still active particles in the system.
  13198. * @returns True if it is alive, otherwise false.
  13199. */
  13200. isAlive(): boolean;
  13201. /**
  13202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13203. * @returns True if it has been started, otherwise false.
  13204. */
  13205. isStarted(): boolean;
  13206. private _prepareSubEmitterInternalArray;
  13207. /**
  13208. * Starts the particle system and begins to emit
  13209. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13210. */
  13211. start(delay?: number): void;
  13212. /**
  13213. * Stops the particle system.
  13214. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13215. */
  13216. stop(stopSubEmitters?: boolean): void;
  13217. /**
  13218. * Remove all active particles
  13219. */
  13220. reset(): void;
  13221. /**
  13222. * @hidden (for internal use only)
  13223. */
  13224. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13225. /**
  13226. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13227. * Its lifetime will start back at 0.
  13228. */
  13229. recycleParticle: (particle: Particle) => void;
  13230. private _stopSubEmitters;
  13231. private _createParticle;
  13232. private _removeFromRoot;
  13233. private _emitFromParticle;
  13234. private _update;
  13235. /** @hidden */
  13236. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13237. /** @hidden */
  13238. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13239. /**
  13240. * Fill the defines array according to the current settings of the particle system
  13241. * @param defines Array to be updated
  13242. * @param blendMode blend mode to take into account when updating the array
  13243. */
  13244. fillDefines(defines: Array<string>, blendMode: number): void;
  13245. /**
  13246. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13247. * @param uniforms Uniforms array to fill
  13248. * @param attributes Attributes array to fill
  13249. * @param samplers Samplers array to fill
  13250. */
  13251. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13252. /** @hidden */
  13253. private _getEffect;
  13254. /**
  13255. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13256. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13257. */
  13258. animate(preWarmOnly?: boolean): void;
  13259. private _appendParticleVertices;
  13260. /**
  13261. * Rebuilds the particle system.
  13262. */
  13263. rebuild(): void;
  13264. /**
  13265. * Is this system ready to be used/rendered
  13266. * @return true if the system is ready
  13267. */
  13268. isReady(): boolean;
  13269. private _render;
  13270. /**
  13271. * Renders the particle system in its current state.
  13272. * @returns the current number of particles
  13273. */
  13274. render(): number;
  13275. /**
  13276. * Disposes the particle system and free the associated resources
  13277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13278. */
  13279. dispose(disposeTexture?: boolean): void;
  13280. /**
  13281. * Clones the particle system.
  13282. * @param name The name of the cloned object
  13283. * @param newEmitter The new emitter to use
  13284. * @returns the cloned particle system
  13285. */
  13286. clone(name: string, newEmitter: any): ParticleSystem;
  13287. /**
  13288. * Serializes the particle system to a JSON object
  13289. * @param serializeTexture defines if the texture must be serialized as well
  13290. * @returns the JSON object
  13291. */
  13292. serialize(serializeTexture?: boolean): any;
  13293. /** @hidden */
  13294. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13295. /** @hidden */
  13296. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13297. /**
  13298. * Parses a JSON object to create a particle system.
  13299. * @param parsedParticleSystem The JSON object to parse
  13300. * @param sceneOrEngine The scene or the engine to create the particle system in
  13301. * @param rootUrl The root url to use to load external dependencies like texture
  13302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13303. * @returns the Parsed particle system
  13304. */
  13305. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13306. }
  13307. }
  13308. declare module "babylonjs/Particles/particle" {
  13309. import { Nullable } from "babylonjs/types";
  13310. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13311. import { Color4 } from "babylonjs/Maths/math.color";
  13312. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13313. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13314. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13315. /**
  13316. * A particle represents one of the element emitted by a particle system.
  13317. * This is mainly define by its coordinates, direction, velocity and age.
  13318. */
  13319. export class Particle {
  13320. /**
  13321. * The particle system the particle belongs to.
  13322. */
  13323. particleSystem: ParticleSystem;
  13324. private static _Count;
  13325. /**
  13326. * Unique ID of the particle
  13327. */
  13328. id: number;
  13329. /**
  13330. * The world position of the particle in the scene.
  13331. */
  13332. position: Vector3;
  13333. /**
  13334. * The world direction of the particle in the scene.
  13335. */
  13336. direction: Vector3;
  13337. /**
  13338. * The color of the particle.
  13339. */
  13340. color: Color4;
  13341. /**
  13342. * The color change of the particle per step.
  13343. */
  13344. colorStep: Color4;
  13345. /**
  13346. * Defines how long will the life of the particle be.
  13347. */
  13348. lifeTime: number;
  13349. /**
  13350. * The current age of the particle.
  13351. */
  13352. age: number;
  13353. /**
  13354. * The current size of the particle.
  13355. */
  13356. size: number;
  13357. /**
  13358. * The current scale of the particle.
  13359. */
  13360. scale: Vector2;
  13361. /**
  13362. * The current angle of the particle.
  13363. */
  13364. angle: number;
  13365. /**
  13366. * Defines how fast is the angle changing.
  13367. */
  13368. angularSpeed: number;
  13369. /**
  13370. * Defines the cell index used by the particle to be rendered from a sprite.
  13371. */
  13372. cellIndex: number;
  13373. /**
  13374. * The information required to support color remapping
  13375. */
  13376. remapData: Vector4;
  13377. /** @hidden */
  13378. _randomCellOffset?: number;
  13379. /** @hidden */
  13380. _initialDirection: Nullable<Vector3>;
  13381. /** @hidden */
  13382. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13383. /** @hidden */
  13384. _initialStartSpriteCellID: number;
  13385. /** @hidden */
  13386. _initialEndSpriteCellID: number;
  13387. /** @hidden */
  13388. _currentColorGradient: Nullable<ColorGradient>;
  13389. /** @hidden */
  13390. _currentColor1: Color4;
  13391. /** @hidden */
  13392. _currentColor2: Color4;
  13393. /** @hidden */
  13394. _currentSizeGradient: Nullable<FactorGradient>;
  13395. /** @hidden */
  13396. _currentSize1: number;
  13397. /** @hidden */
  13398. _currentSize2: number;
  13399. /** @hidden */
  13400. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13401. /** @hidden */
  13402. _currentAngularSpeed1: number;
  13403. /** @hidden */
  13404. _currentAngularSpeed2: number;
  13405. /** @hidden */
  13406. _currentVelocityGradient: Nullable<FactorGradient>;
  13407. /** @hidden */
  13408. _currentVelocity1: number;
  13409. /** @hidden */
  13410. _currentVelocity2: number;
  13411. /** @hidden */
  13412. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13413. /** @hidden */
  13414. _currentLimitVelocity1: number;
  13415. /** @hidden */
  13416. _currentLimitVelocity2: number;
  13417. /** @hidden */
  13418. _currentDragGradient: Nullable<FactorGradient>;
  13419. /** @hidden */
  13420. _currentDrag1: number;
  13421. /** @hidden */
  13422. _currentDrag2: number;
  13423. /** @hidden */
  13424. _randomNoiseCoordinates1: Vector3;
  13425. /** @hidden */
  13426. _randomNoiseCoordinates2: Vector3;
  13427. /** @hidden */
  13428. _localPosition?: Vector3;
  13429. /**
  13430. * Creates a new instance Particle
  13431. * @param particleSystem the particle system the particle belongs to
  13432. */
  13433. constructor(
  13434. /**
  13435. * The particle system the particle belongs to.
  13436. */
  13437. particleSystem: ParticleSystem);
  13438. private updateCellInfoFromSystem;
  13439. /**
  13440. * Defines how the sprite cell index is updated for the particle
  13441. */
  13442. updateCellIndex(): void;
  13443. /** @hidden */
  13444. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13445. /** @hidden */
  13446. _inheritParticleInfoToSubEmitters(): void;
  13447. /** @hidden */
  13448. _reset(): void;
  13449. /**
  13450. * Copy the properties of particle to another one.
  13451. * @param other the particle to copy the information to.
  13452. */
  13453. copyTo(other: Particle): void;
  13454. }
  13455. }
  13456. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Effect } from "babylonjs/Materials/effect";
  13459. import { Particle } from "babylonjs/Particles/particle";
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Scene } from "babylonjs/scene";
  13462. /**
  13463. * Particle emitter represents a volume emitting particles.
  13464. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13465. */
  13466. export interface IParticleEmitterType {
  13467. /**
  13468. * Called by the particle System when the direction is computed for the created particle.
  13469. * @param worldMatrix is the world matrix of the particle system
  13470. * @param directionToUpdate is the direction vector to update with the result
  13471. * @param particle is the particle we are computed the direction for
  13472. * @param isLocal defines if the direction should be set in local space
  13473. */
  13474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13475. /**
  13476. * Called by the particle System when the position is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param positionToUpdate is the position vector to update with the result
  13479. * @param particle is the particle we are computed the position for
  13480. * @param isLocal defines if the position should be set in local space
  13481. */
  13482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Clones the current emitter and returns a copy of it
  13485. * @returns the new emitter
  13486. */
  13487. clone(): IParticleEmitterType;
  13488. /**
  13489. * Called by the GPUParticleSystem to setup the update shader
  13490. * @param effect defines the update shader
  13491. */
  13492. applyToShader(effect: Effect): void;
  13493. /**
  13494. * Returns a string to use to update the GPU particles update shader
  13495. * @returns the effect defines string
  13496. */
  13497. getEffectDefines(): string;
  13498. /**
  13499. * Returns a string representing the class name
  13500. * @returns a string containing the class name
  13501. */
  13502. getClassName(): string;
  13503. /**
  13504. * Serializes the particle system to a JSON object.
  13505. * @returns the JSON object
  13506. */
  13507. serialize(): any;
  13508. /**
  13509. * Parse properties from a JSON object
  13510. * @param serializationObject defines the JSON object
  13511. * @param scene defines the hosting scene
  13512. */
  13513. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13514. }
  13515. }
  13516. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13517. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13518. import { Effect } from "babylonjs/Materials/effect";
  13519. import { Particle } from "babylonjs/Particles/particle";
  13520. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13521. /**
  13522. * Particle emitter emitting particles from the inside of a box.
  13523. * It emits the particles randomly between 2 given directions.
  13524. */
  13525. export class BoxParticleEmitter implements IParticleEmitterType {
  13526. /**
  13527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13528. */
  13529. direction1: Vector3;
  13530. /**
  13531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13532. */
  13533. direction2: Vector3;
  13534. /**
  13535. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13536. */
  13537. minEmitBox: Vector3;
  13538. /**
  13539. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13540. */
  13541. maxEmitBox: Vector3;
  13542. /**
  13543. * Creates a new instance BoxParticleEmitter
  13544. */
  13545. constructor();
  13546. /**
  13547. * Called by the particle System when the direction is computed for the created particle.
  13548. * @param worldMatrix is the world matrix of the particle system
  13549. * @param directionToUpdate is the direction vector to update with the result
  13550. * @param particle is the particle we are computed the direction for
  13551. * @param isLocal defines if the direction should be set in local space
  13552. */
  13553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13554. /**
  13555. * Called by the particle System when the position is computed for the created particle.
  13556. * @param worldMatrix is the world matrix of the particle system
  13557. * @param positionToUpdate is the position vector to update with the result
  13558. * @param particle is the particle we are computed the position for
  13559. * @param isLocal defines if the position should be set in local space
  13560. */
  13561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13562. /**
  13563. * Clones the current emitter and returns a copy of it
  13564. * @returns the new emitter
  13565. */
  13566. clone(): BoxParticleEmitter;
  13567. /**
  13568. * Called by the GPUParticleSystem to setup the update shader
  13569. * @param effect defines the update shader
  13570. */
  13571. applyToShader(effect: Effect): void;
  13572. /**
  13573. * Returns a string to use to update the GPU particles update shader
  13574. * @returns a string containng the defines string
  13575. */
  13576. getEffectDefines(): string;
  13577. /**
  13578. * Returns the string "BoxParticleEmitter"
  13579. * @returns a string containing the class name
  13580. */
  13581. getClassName(): string;
  13582. /**
  13583. * Serializes the particle system to a JSON object.
  13584. * @returns the JSON object
  13585. */
  13586. serialize(): any;
  13587. /**
  13588. * Parse properties from a JSON object
  13589. * @param serializationObject defines the JSON object
  13590. */
  13591. parse(serializationObject: any): void;
  13592. }
  13593. }
  13594. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13595. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Effect } from "babylonjs/Materials/effect";
  13597. import { Particle } from "babylonjs/Particles/particle";
  13598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13599. /**
  13600. * Particle emitter emitting particles from the inside of a cone.
  13601. * It emits the particles alongside the cone volume from the base to the particle.
  13602. * The emission direction might be randomized.
  13603. */
  13604. export class ConeParticleEmitter implements IParticleEmitterType {
  13605. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13606. directionRandomizer: number;
  13607. private _radius;
  13608. private _angle;
  13609. private _height;
  13610. /**
  13611. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13612. */
  13613. radiusRange: number;
  13614. /**
  13615. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13616. */
  13617. heightRange: number;
  13618. /**
  13619. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13620. */
  13621. emitFromSpawnPointOnly: boolean;
  13622. /**
  13623. * Gets or sets the radius of the emission cone
  13624. */
  13625. get radius(): number;
  13626. set radius(value: number);
  13627. /**
  13628. * Gets or sets the angle of the emission cone
  13629. */
  13630. get angle(): number;
  13631. set angle(value: number);
  13632. private _buildHeight;
  13633. /**
  13634. * Creates a new instance ConeParticleEmitter
  13635. * @param radius the radius of the emission cone (1 by default)
  13636. * @param angle the cone base angle (PI by default)
  13637. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13638. */
  13639. constructor(radius?: number, angle?: number,
  13640. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13641. directionRandomizer?: number);
  13642. /**
  13643. * Called by the particle System when the direction is computed for the created particle.
  13644. * @param worldMatrix is the world matrix of the particle system
  13645. * @param directionToUpdate is the direction vector to update with the result
  13646. * @param particle is the particle we are computed the direction for
  13647. * @param isLocal defines if the direction should be set in local space
  13648. */
  13649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13650. /**
  13651. * Called by the particle System when the position is computed for the created particle.
  13652. * @param worldMatrix is the world matrix of the particle system
  13653. * @param positionToUpdate is the position vector to update with the result
  13654. * @param particle is the particle we are computed the position for
  13655. * @param isLocal defines if the position should be set in local space
  13656. */
  13657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13658. /**
  13659. * Clones the current emitter and returns a copy of it
  13660. * @returns the new emitter
  13661. */
  13662. clone(): ConeParticleEmitter;
  13663. /**
  13664. * Called by the GPUParticleSystem to setup the update shader
  13665. * @param effect defines the update shader
  13666. */
  13667. applyToShader(effect: Effect): void;
  13668. /**
  13669. * Returns a string to use to update the GPU particles update shader
  13670. * @returns a string containng the defines string
  13671. */
  13672. getEffectDefines(): string;
  13673. /**
  13674. * Returns the string "ConeParticleEmitter"
  13675. * @returns a string containing the class name
  13676. */
  13677. getClassName(): string;
  13678. /**
  13679. * Serializes the particle system to a JSON object.
  13680. * @returns the JSON object
  13681. */
  13682. serialize(): any;
  13683. /**
  13684. * Parse properties from a JSON object
  13685. * @param serializationObject defines the JSON object
  13686. */
  13687. parse(serializationObject: any): void;
  13688. }
  13689. }
  13690. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13691. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13692. import { Effect } from "babylonjs/Materials/effect";
  13693. import { Particle } from "babylonjs/Particles/particle";
  13694. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13695. /**
  13696. * Particle emitter emitting particles from the inside of a cylinder.
  13697. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13698. */
  13699. export class CylinderParticleEmitter implements IParticleEmitterType {
  13700. /**
  13701. * The radius of the emission cylinder.
  13702. */
  13703. radius: number;
  13704. /**
  13705. * The height of the emission cylinder.
  13706. */
  13707. height: number;
  13708. /**
  13709. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13710. */
  13711. radiusRange: number;
  13712. /**
  13713. * How much to randomize the particle direction [0-1].
  13714. */
  13715. directionRandomizer: number;
  13716. /**
  13717. * Creates a new instance CylinderParticleEmitter
  13718. * @param radius the radius of the emission cylinder (1 by default)
  13719. * @param height the height of the emission cylinder (1 by default)
  13720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13721. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13722. */
  13723. constructor(
  13724. /**
  13725. * The radius of the emission cylinder.
  13726. */
  13727. radius?: number,
  13728. /**
  13729. * The height of the emission cylinder.
  13730. */
  13731. height?: number,
  13732. /**
  13733. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13734. */
  13735. radiusRange?: number,
  13736. /**
  13737. * How much to randomize the particle direction [0-1].
  13738. */
  13739. directionRandomizer?: number);
  13740. /**
  13741. * Called by the particle System when the direction is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param directionToUpdate is the direction vector to update with the result
  13744. * @param particle is the particle we are computed the direction for
  13745. * @param isLocal defines if the direction should be set in local space
  13746. */
  13747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Called by the particle System when the position is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param positionToUpdate is the position vector to update with the result
  13752. * @param particle is the particle we are computed the position for
  13753. * @param isLocal defines if the position should be set in local space
  13754. */
  13755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Clones the current emitter and returns a copy of it
  13758. * @returns the new emitter
  13759. */
  13760. clone(): CylinderParticleEmitter;
  13761. /**
  13762. * Called by the GPUParticleSystem to setup the update shader
  13763. * @param effect defines the update shader
  13764. */
  13765. applyToShader(effect: Effect): void;
  13766. /**
  13767. * Returns a string to use to update the GPU particles update shader
  13768. * @returns a string containng the defines string
  13769. */
  13770. getEffectDefines(): string;
  13771. /**
  13772. * Returns the string "CylinderParticleEmitter"
  13773. * @returns a string containing the class name
  13774. */
  13775. getClassName(): string;
  13776. /**
  13777. * Serializes the particle system to a JSON object.
  13778. * @returns the JSON object
  13779. */
  13780. serialize(): any;
  13781. /**
  13782. * Parse properties from a JSON object
  13783. * @param serializationObject defines the JSON object
  13784. */
  13785. parse(serializationObject: any): void;
  13786. }
  13787. /**
  13788. * Particle emitter emitting particles from the inside of a cylinder.
  13789. * It emits the particles randomly between two vectors.
  13790. */
  13791. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13792. /**
  13793. * The min limit of the emission direction.
  13794. */
  13795. direction1: Vector3;
  13796. /**
  13797. * The max limit of the emission direction.
  13798. */
  13799. direction2: Vector3;
  13800. /**
  13801. * Creates a new instance CylinderDirectedParticleEmitter
  13802. * @param radius the radius of the emission cylinder (1 by default)
  13803. * @param height the height of the emission cylinder (1 by default)
  13804. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13805. * @param direction1 the min limit of the emission direction (up vector by default)
  13806. * @param direction2 the max limit of the emission direction (up vector by default)
  13807. */
  13808. constructor(radius?: number, height?: number, radiusRange?: number,
  13809. /**
  13810. * The min limit of the emission direction.
  13811. */
  13812. direction1?: Vector3,
  13813. /**
  13814. * The max limit of the emission direction.
  13815. */
  13816. direction2?: Vector3);
  13817. /**
  13818. * Called by the particle System when the direction is computed for the created particle.
  13819. * @param worldMatrix is the world matrix of the particle system
  13820. * @param directionToUpdate is the direction vector to update with the result
  13821. * @param particle is the particle we are computed the direction for
  13822. */
  13823. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): CylinderDirectedParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "CylinderDirectedParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. */
  13853. parse(serializationObject: any): void;
  13854. }
  13855. }
  13856. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13857. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13858. import { Effect } from "babylonjs/Materials/effect";
  13859. import { Particle } from "babylonjs/Particles/particle";
  13860. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13861. /**
  13862. * Particle emitter emitting particles from the inside of a hemisphere.
  13863. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13864. */
  13865. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13866. /**
  13867. * The radius of the emission hemisphere.
  13868. */
  13869. radius: number;
  13870. /**
  13871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13872. */
  13873. radiusRange: number;
  13874. /**
  13875. * How much to randomize the particle direction [0-1].
  13876. */
  13877. directionRandomizer: number;
  13878. /**
  13879. * Creates a new instance HemisphericParticleEmitter
  13880. * @param radius the radius of the emission hemisphere (1 by default)
  13881. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13883. */
  13884. constructor(
  13885. /**
  13886. * The radius of the emission hemisphere.
  13887. */
  13888. radius?: number,
  13889. /**
  13890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13891. */
  13892. radiusRange?: number,
  13893. /**
  13894. * How much to randomize the particle direction [0-1].
  13895. */
  13896. directionRandomizer?: number);
  13897. /**
  13898. * Called by the particle System when the direction is computed for the created particle.
  13899. * @param worldMatrix is the world matrix of the particle system
  13900. * @param directionToUpdate is the direction vector to update with the result
  13901. * @param particle is the particle we are computed the direction for
  13902. * @param isLocal defines if the direction should be set in local space
  13903. */
  13904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13905. /**
  13906. * Called by the particle System when the position is computed for the created particle.
  13907. * @param worldMatrix is the world matrix of the particle system
  13908. * @param positionToUpdate is the position vector to update with the result
  13909. * @param particle is the particle we are computed the position for
  13910. * @param isLocal defines if the position should be set in local space
  13911. */
  13912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13913. /**
  13914. * Clones the current emitter and returns a copy of it
  13915. * @returns the new emitter
  13916. */
  13917. clone(): HemisphericParticleEmitter;
  13918. /**
  13919. * Called by the GPUParticleSystem to setup the update shader
  13920. * @param effect defines the update shader
  13921. */
  13922. applyToShader(effect: Effect): void;
  13923. /**
  13924. * Returns a string to use to update the GPU particles update shader
  13925. * @returns a string containng the defines string
  13926. */
  13927. getEffectDefines(): string;
  13928. /**
  13929. * Returns the string "HemisphericParticleEmitter"
  13930. * @returns a string containing the class name
  13931. */
  13932. getClassName(): string;
  13933. /**
  13934. * Serializes the particle system to a JSON object.
  13935. * @returns the JSON object
  13936. */
  13937. serialize(): any;
  13938. /**
  13939. * Parse properties from a JSON object
  13940. * @param serializationObject defines the JSON object
  13941. */
  13942. parse(serializationObject: any): void;
  13943. }
  13944. }
  13945. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13947. import { Effect } from "babylonjs/Materials/effect";
  13948. import { Particle } from "babylonjs/Particles/particle";
  13949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13950. /**
  13951. * Particle emitter emitting particles from a point.
  13952. * It emits the particles randomly between 2 given directions.
  13953. */
  13954. export class PointParticleEmitter implements IParticleEmitterType {
  13955. /**
  13956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13957. */
  13958. direction1: Vector3;
  13959. /**
  13960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13961. */
  13962. direction2: Vector3;
  13963. /**
  13964. * Creates a new instance PointParticleEmitter
  13965. */
  13966. constructor();
  13967. /**
  13968. * Called by the particle System when the direction is computed for the created particle.
  13969. * @param worldMatrix is the world matrix of the particle system
  13970. * @param directionToUpdate is the direction vector to update with the result
  13971. * @param particle is the particle we are computed the direction for
  13972. * @param isLocal defines if the direction should be set in local space
  13973. */
  13974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13975. /**
  13976. * Called by the particle System when the position is computed for the created particle.
  13977. * @param worldMatrix is the world matrix of the particle system
  13978. * @param positionToUpdate is the position vector to update with the result
  13979. * @param particle is the particle we are computed the position for
  13980. * @param isLocal defines if the position should be set in local space
  13981. */
  13982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13983. /**
  13984. * Clones the current emitter and returns a copy of it
  13985. * @returns the new emitter
  13986. */
  13987. clone(): PointParticleEmitter;
  13988. /**
  13989. * Called by the GPUParticleSystem to setup the update shader
  13990. * @param effect defines the update shader
  13991. */
  13992. applyToShader(effect: Effect): void;
  13993. /**
  13994. * Returns a string to use to update the GPU particles update shader
  13995. * @returns a string containng the defines string
  13996. */
  13997. getEffectDefines(): string;
  13998. /**
  13999. * Returns the string "PointParticleEmitter"
  14000. * @returns a string containing the class name
  14001. */
  14002. getClassName(): string;
  14003. /**
  14004. * Serializes the particle system to a JSON object.
  14005. * @returns the JSON object
  14006. */
  14007. serialize(): any;
  14008. /**
  14009. * Parse properties from a JSON object
  14010. * @param serializationObject defines the JSON object
  14011. */
  14012. parse(serializationObject: any): void;
  14013. }
  14014. }
  14015. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14017. import { Effect } from "babylonjs/Materials/effect";
  14018. import { Particle } from "babylonjs/Particles/particle";
  14019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14020. /**
  14021. * Particle emitter emitting particles from the inside of a sphere.
  14022. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14023. */
  14024. export class SphereParticleEmitter implements IParticleEmitterType {
  14025. /**
  14026. * The radius of the emission sphere.
  14027. */
  14028. radius: number;
  14029. /**
  14030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14031. */
  14032. radiusRange: number;
  14033. /**
  14034. * How much to randomize the particle direction [0-1].
  14035. */
  14036. directionRandomizer: number;
  14037. /**
  14038. * Creates a new instance SphereParticleEmitter
  14039. * @param radius the radius of the emission sphere (1 by default)
  14040. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14041. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14042. */
  14043. constructor(
  14044. /**
  14045. * The radius of the emission sphere.
  14046. */
  14047. radius?: number,
  14048. /**
  14049. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14050. */
  14051. radiusRange?: number,
  14052. /**
  14053. * How much to randomize the particle direction [0-1].
  14054. */
  14055. directionRandomizer?: number);
  14056. /**
  14057. * Called by the particle System when the direction is computed for the created particle.
  14058. * @param worldMatrix is the world matrix of the particle system
  14059. * @param directionToUpdate is the direction vector to update with the result
  14060. * @param particle is the particle we are computed the direction for
  14061. * @param isLocal defines if the direction should be set in local space
  14062. */
  14063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14064. /**
  14065. * Called by the particle System when the position is computed for the created particle.
  14066. * @param worldMatrix is the world matrix of the particle system
  14067. * @param positionToUpdate is the position vector to update with the result
  14068. * @param particle is the particle we are computed the position for
  14069. * @param isLocal defines if the position should be set in local space
  14070. */
  14071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14072. /**
  14073. * Clones the current emitter and returns a copy of it
  14074. * @returns the new emitter
  14075. */
  14076. clone(): SphereParticleEmitter;
  14077. /**
  14078. * Called by the GPUParticleSystem to setup the update shader
  14079. * @param effect defines the update shader
  14080. */
  14081. applyToShader(effect: Effect): void;
  14082. /**
  14083. * Returns a string to use to update the GPU particles update shader
  14084. * @returns a string containng the defines string
  14085. */
  14086. getEffectDefines(): string;
  14087. /**
  14088. * Returns the string "SphereParticleEmitter"
  14089. * @returns a string containing the class name
  14090. */
  14091. getClassName(): string;
  14092. /**
  14093. * Serializes the particle system to a JSON object.
  14094. * @returns the JSON object
  14095. */
  14096. serialize(): any;
  14097. /**
  14098. * Parse properties from a JSON object
  14099. * @param serializationObject defines the JSON object
  14100. */
  14101. parse(serializationObject: any): void;
  14102. }
  14103. /**
  14104. * Particle emitter emitting particles from the inside of a sphere.
  14105. * It emits the particles randomly between two vectors.
  14106. */
  14107. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14108. /**
  14109. * The min limit of the emission direction.
  14110. */
  14111. direction1: Vector3;
  14112. /**
  14113. * The max limit of the emission direction.
  14114. */
  14115. direction2: Vector3;
  14116. /**
  14117. * Creates a new instance SphereDirectedParticleEmitter
  14118. * @param radius the radius of the emission sphere (1 by default)
  14119. * @param direction1 the min limit of the emission direction (up vector by default)
  14120. * @param direction2 the max limit of the emission direction (up vector by default)
  14121. */
  14122. constructor(radius?: number,
  14123. /**
  14124. * The min limit of the emission direction.
  14125. */
  14126. direction1?: Vector3,
  14127. /**
  14128. * The max limit of the emission direction.
  14129. */
  14130. direction2?: Vector3);
  14131. /**
  14132. * Called by the particle System when the direction is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param directionToUpdate is the direction vector to update with the result
  14135. * @param particle is the particle we are computed the direction for
  14136. */
  14137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14138. /**
  14139. * Clones the current emitter and returns a copy of it
  14140. * @returns the new emitter
  14141. */
  14142. clone(): SphereDirectedParticleEmitter;
  14143. /**
  14144. * Called by the GPUParticleSystem to setup the update shader
  14145. * @param effect defines the update shader
  14146. */
  14147. applyToShader(effect: Effect): void;
  14148. /**
  14149. * Returns a string to use to update the GPU particles update shader
  14150. * @returns a string containng the defines string
  14151. */
  14152. getEffectDefines(): string;
  14153. /**
  14154. * Returns the string "SphereDirectedParticleEmitter"
  14155. * @returns a string containing the class name
  14156. */
  14157. getClassName(): string;
  14158. /**
  14159. * Serializes the particle system to a JSON object.
  14160. * @returns the JSON object
  14161. */
  14162. serialize(): any;
  14163. /**
  14164. * Parse properties from a JSON object
  14165. * @param serializationObject defines the JSON object
  14166. */
  14167. parse(serializationObject: any): void;
  14168. }
  14169. }
  14170. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14171. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14172. import { Effect } from "babylonjs/Materials/effect";
  14173. import { Particle } from "babylonjs/Particles/particle";
  14174. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14175. import { Nullable } from "babylonjs/types";
  14176. /**
  14177. * Particle emitter emitting particles from a custom list of positions.
  14178. */
  14179. export class CustomParticleEmitter implements IParticleEmitterType {
  14180. /**
  14181. * Gets or sets the position generator that will create the inital position of each particle.
  14182. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14183. */
  14184. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14185. /**
  14186. * Gets or sets the destination generator that will create the final destination of each particle.
  14187. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14188. */
  14189. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14190. /**
  14191. * Creates a new instance CustomParticleEmitter
  14192. */
  14193. constructor();
  14194. /**
  14195. * Called by the particle System when the direction is computed for the created particle.
  14196. * @param worldMatrix is the world matrix of the particle system
  14197. * @param directionToUpdate is the direction vector to update with the result
  14198. * @param particle is the particle we are computed the direction for
  14199. * @param isLocal defines if the direction should be set in local space
  14200. */
  14201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14202. /**
  14203. * Called by the particle System when the position is computed for the created particle.
  14204. * @param worldMatrix is the world matrix of the particle system
  14205. * @param positionToUpdate is the position vector to update with the result
  14206. * @param particle is the particle we are computed the position for
  14207. * @param isLocal defines if the position should be set in local space
  14208. */
  14209. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14210. /**
  14211. * Clones the current emitter and returns a copy of it
  14212. * @returns the new emitter
  14213. */
  14214. clone(): CustomParticleEmitter;
  14215. /**
  14216. * Called by the GPUParticleSystem to setup the update shader
  14217. * @param effect defines the update shader
  14218. */
  14219. applyToShader(effect: Effect): void;
  14220. /**
  14221. * Returns a string to use to update the GPU particles update shader
  14222. * @returns a string containng the defines string
  14223. */
  14224. getEffectDefines(): string;
  14225. /**
  14226. * Returns the string "PointParticleEmitter"
  14227. * @returns a string containing the class name
  14228. */
  14229. getClassName(): string;
  14230. /**
  14231. * Serializes the particle system to a JSON object.
  14232. * @returns the JSON object
  14233. */
  14234. serialize(): any;
  14235. /**
  14236. * Parse properties from a JSON object
  14237. * @param serializationObject defines the JSON object
  14238. */
  14239. parse(serializationObject: any): void;
  14240. }
  14241. }
  14242. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14243. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14244. import { Effect } from "babylonjs/Materials/effect";
  14245. import { Particle } from "babylonjs/Particles/particle";
  14246. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14247. import { Nullable } from "babylonjs/types";
  14248. import { Scene } from "babylonjs/scene";
  14249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14250. /**
  14251. * Particle emitter emitting particles from the inside of a box.
  14252. * It emits the particles randomly between 2 given directions.
  14253. */
  14254. export class MeshParticleEmitter implements IParticleEmitterType {
  14255. private _indices;
  14256. private _positions;
  14257. private _normals;
  14258. private _storedNormal;
  14259. private _mesh;
  14260. /**
  14261. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14262. */
  14263. direction1: Vector3;
  14264. /**
  14265. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14266. */
  14267. direction2: Vector3;
  14268. /**
  14269. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14270. */
  14271. useMeshNormalsForDirection: boolean;
  14272. /** Defines the mesh to use as source */
  14273. get mesh(): Nullable<AbstractMesh>;
  14274. set mesh(value: Nullable<AbstractMesh>);
  14275. /**
  14276. * Creates a new instance MeshParticleEmitter
  14277. * @param mesh defines the mesh to use as source
  14278. */
  14279. constructor(mesh?: Nullable<AbstractMesh>);
  14280. /**
  14281. * Called by the particle System when the direction is computed for the created particle.
  14282. * @param worldMatrix is the world matrix of the particle system
  14283. * @param directionToUpdate is the direction vector to update with the result
  14284. * @param particle is the particle we are computed the direction for
  14285. * @param isLocal defines if the direction should be set in local space
  14286. */
  14287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14288. /**
  14289. * Called by the particle System when the position is computed for the created particle.
  14290. * @param worldMatrix is the world matrix of the particle system
  14291. * @param positionToUpdate is the position vector to update with the result
  14292. * @param particle is the particle we are computed the position for
  14293. * @param isLocal defines if the position should be set in local space
  14294. */
  14295. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14296. /**
  14297. * Clones the current emitter and returns a copy of it
  14298. * @returns the new emitter
  14299. */
  14300. clone(): MeshParticleEmitter;
  14301. /**
  14302. * Called by the GPUParticleSystem to setup the update shader
  14303. * @param effect defines the update shader
  14304. */
  14305. applyToShader(effect: Effect): void;
  14306. /**
  14307. * Returns a string to use to update the GPU particles update shader
  14308. * @returns a string containng the defines string
  14309. */
  14310. getEffectDefines(): string;
  14311. /**
  14312. * Returns the string "BoxParticleEmitter"
  14313. * @returns a string containing the class name
  14314. */
  14315. getClassName(): string;
  14316. /**
  14317. * Serializes the particle system to a JSON object.
  14318. * @returns the JSON object
  14319. */
  14320. serialize(): any;
  14321. /**
  14322. * Parse properties from a JSON object
  14323. * @param serializationObject defines the JSON object
  14324. * @param scene defines the hosting scene
  14325. */
  14326. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14327. }
  14328. }
  14329. declare module "babylonjs/Particles/EmitterTypes/index" {
  14330. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14331. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14332. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14333. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14334. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14335. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14336. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14337. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14338. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14339. }
  14340. declare module "babylonjs/Particles/IParticleSystem" {
  14341. import { Nullable } from "babylonjs/types";
  14342. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14343. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14345. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14346. import { Scene } from "babylonjs/scene";
  14347. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14348. import { Effect } from "babylonjs/Materials/effect";
  14349. import { Observable } from "babylonjs/Misc/observable";
  14350. import { Animation } from "babylonjs/Animations/animation";
  14351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14352. /**
  14353. * Interface representing a particle system in Babylon.js.
  14354. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14355. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14356. */
  14357. export interface IParticleSystem {
  14358. /**
  14359. * List of animations used by the particle system.
  14360. */
  14361. animations: Animation[];
  14362. /**
  14363. * The id of the Particle system.
  14364. */
  14365. id: string;
  14366. /**
  14367. * The name of the Particle system.
  14368. */
  14369. name: string;
  14370. /**
  14371. * The emitter represents the Mesh or position we are attaching the particle system to.
  14372. */
  14373. emitter: Nullable<AbstractMesh | Vector3>;
  14374. /**
  14375. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14376. */
  14377. isBillboardBased: boolean;
  14378. /**
  14379. * The rendering group used by the Particle system to chose when to render.
  14380. */
  14381. renderingGroupId: number;
  14382. /**
  14383. * The layer mask we are rendering the particles through.
  14384. */
  14385. layerMask: number;
  14386. /**
  14387. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14388. */
  14389. updateSpeed: number;
  14390. /**
  14391. * The amount of time the particle system is running (depends of the overall update speed).
  14392. */
  14393. targetStopDuration: number;
  14394. /**
  14395. * The texture used to render each particle. (this can be a spritesheet)
  14396. */
  14397. particleTexture: Nullable<BaseTexture>;
  14398. /**
  14399. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14400. */
  14401. blendMode: number;
  14402. /**
  14403. * Minimum life time of emitting particles.
  14404. */
  14405. minLifeTime: number;
  14406. /**
  14407. * Maximum life time of emitting particles.
  14408. */
  14409. maxLifeTime: number;
  14410. /**
  14411. * Minimum Size of emitting particles.
  14412. */
  14413. minSize: number;
  14414. /**
  14415. * Maximum Size of emitting particles.
  14416. */
  14417. maxSize: number;
  14418. /**
  14419. * Minimum scale of emitting particles on X axis.
  14420. */
  14421. minScaleX: number;
  14422. /**
  14423. * Maximum scale of emitting particles on X axis.
  14424. */
  14425. maxScaleX: number;
  14426. /**
  14427. * Minimum scale of emitting particles on Y axis.
  14428. */
  14429. minScaleY: number;
  14430. /**
  14431. * Maximum scale of emitting particles on Y axis.
  14432. */
  14433. maxScaleY: number;
  14434. /**
  14435. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14436. */
  14437. color1: Color4;
  14438. /**
  14439. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14440. */
  14441. color2: Color4;
  14442. /**
  14443. * Color the particle will have at the end of its lifetime.
  14444. */
  14445. colorDead: Color4;
  14446. /**
  14447. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14448. */
  14449. emitRate: number;
  14450. /**
  14451. * You can use gravity if you want to give an orientation to your particles.
  14452. */
  14453. gravity: Vector3;
  14454. /**
  14455. * Minimum power of emitting particles.
  14456. */
  14457. minEmitPower: number;
  14458. /**
  14459. * Maximum power of emitting particles.
  14460. */
  14461. maxEmitPower: number;
  14462. /**
  14463. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14464. */
  14465. minAngularSpeed: number;
  14466. /**
  14467. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14468. */
  14469. maxAngularSpeed: number;
  14470. /**
  14471. * Gets or sets the minimal initial rotation in radians.
  14472. */
  14473. minInitialRotation: number;
  14474. /**
  14475. * Gets or sets the maximal initial rotation in radians.
  14476. */
  14477. maxInitialRotation: number;
  14478. /**
  14479. * The particle emitter type defines the emitter used by the particle system.
  14480. * It can be for example box, sphere, or cone...
  14481. */
  14482. particleEmitterType: Nullable<IParticleEmitterType>;
  14483. /**
  14484. * Defines the delay in milliseconds before starting the system (0 by default)
  14485. */
  14486. startDelay: number;
  14487. /**
  14488. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14489. */
  14490. preWarmCycles: number;
  14491. /**
  14492. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14493. */
  14494. preWarmStepOffset: number;
  14495. /**
  14496. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14497. */
  14498. spriteCellChangeSpeed: number;
  14499. /**
  14500. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14501. */
  14502. startSpriteCellID: number;
  14503. /**
  14504. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14505. */
  14506. endSpriteCellID: number;
  14507. /**
  14508. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14509. */
  14510. spriteCellWidth: number;
  14511. /**
  14512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14513. */
  14514. spriteCellHeight: number;
  14515. /**
  14516. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14517. */
  14518. spriteRandomStartCell: boolean;
  14519. /**
  14520. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14521. */
  14522. isAnimationSheetEnabled: boolean;
  14523. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14524. translationPivot: Vector2;
  14525. /**
  14526. * Gets or sets a texture used to add random noise to particle positions
  14527. */
  14528. noiseTexture: Nullable<BaseTexture>;
  14529. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14530. noiseStrength: Vector3;
  14531. /**
  14532. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14533. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14534. */
  14535. billboardMode: number;
  14536. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14537. limitVelocityDamping: number;
  14538. /**
  14539. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14540. */
  14541. beginAnimationOnStart: boolean;
  14542. /**
  14543. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14544. */
  14545. beginAnimationFrom: number;
  14546. /**
  14547. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14548. */
  14549. beginAnimationTo: number;
  14550. /**
  14551. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14552. */
  14553. beginAnimationLoop: boolean;
  14554. /**
  14555. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14556. */
  14557. disposeOnStop: boolean;
  14558. /**
  14559. * Specifies if the particles are updated in emitter local space or world space
  14560. */
  14561. isLocal: boolean;
  14562. /** Snippet ID if the particle system was created from the snippet server */
  14563. snippetId: string;
  14564. /** Gets or sets a matrix to use to compute projection */
  14565. defaultProjectionMatrix: Matrix;
  14566. /**
  14567. * Gets the maximum number of particles active at the same time.
  14568. * @returns The max number of active particles.
  14569. */
  14570. getCapacity(): number;
  14571. /**
  14572. * Gets the number of particles active at the same time.
  14573. * @returns The number of active particles.
  14574. */
  14575. getActiveCount(): number;
  14576. /**
  14577. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14578. * @returns True if it has been started, otherwise false.
  14579. */
  14580. isStarted(): boolean;
  14581. /**
  14582. * Animates the particle system for this frame.
  14583. */
  14584. animate(): void;
  14585. /**
  14586. * Renders the particle system in its current state.
  14587. * @returns the current number of particles
  14588. */
  14589. render(): number;
  14590. /**
  14591. * Dispose the particle system and frees its associated resources.
  14592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14593. */
  14594. dispose(disposeTexture?: boolean): void;
  14595. /**
  14596. * An event triggered when the system is disposed
  14597. */
  14598. onDisposeObservable: Observable<IParticleSystem>;
  14599. /**
  14600. * Clones the particle system.
  14601. * @param name The name of the cloned object
  14602. * @param newEmitter The new emitter to use
  14603. * @returns the cloned particle system
  14604. */
  14605. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14606. /**
  14607. * Serializes the particle system to a JSON object
  14608. * @param serializeTexture defines if the texture must be serialized as well
  14609. * @returns the JSON object
  14610. */
  14611. serialize(serializeTexture: boolean): any;
  14612. /**
  14613. * Rebuild the particle system
  14614. */
  14615. rebuild(): void;
  14616. /** Force the system to rebuild all gradients that need to be resync */
  14617. forceRefreshGradients(): void;
  14618. /**
  14619. * Starts the particle system and begins to emit
  14620. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14621. */
  14622. start(delay?: number): void;
  14623. /**
  14624. * Stops the particle system.
  14625. */
  14626. stop(): void;
  14627. /**
  14628. * Remove all active particles
  14629. */
  14630. reset(): void;
  14631. /**
  14632. * Gets a boolean indicating that the system is stopping
  14633. * @returns true if the system is currently stopping
  14634. */
  14635. isStopping(): boolean;
  14636. /**
  14637. * Is this system ready to be used/rendered
  14638. * @return true if the system is ready
  14639. */
  14640. isReady(): boolean;
  14641. /**
  14642. * Returns the string "ParticleSystem"
  14643. * @returns a string containing the class name
  14644. */
  14645. getClassName(): string;
  14646. /**
  14647. * Gets the custom effect used to render the particles
  14648. * @param blendMode Blend mode for which the effect should be retrieved
  14649. * @returns The effect
  14650. */
  14651. getCustomEffect(blendMode: number): Nullable<Effect>;
  14652. /**
  14653. * Sets the custom effect used to render the particles
  14654. * @param effect The effect to set
  14655. * @param blendMode Blend mode for which the effect should be set
  14656. */
  14657. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14658. /**
  14659. * Fill the defines array according to the current settings of the particle system
  14660. * @param defines Array to be updated
  14661. * @param blendMode blend mode to take into account when updating the array
  14662. */
  14663. fillDefines(defines: Array<string>, blendMode: number): void;
  14664. /**
  14665. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14666. * @param uniforms Uniforms array to fill
  14667. * @param attributes Attributes array to fill
  14668. * @param samplers Samplers array to fill
  14669. */
  14670. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14671. /**
  14672. * Observable that will be called just before the particles are drawn
  14673. */
  14674. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14675. /**
  14676. * Gets the name of the particle vertex shader
  14677. */
  14678. vertexShaderName: string;
  14679. /**
  14680. * Adds a new color gradient
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color1 defines the color to affect to the specified gradient
  14683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14684. * @returns the current particle system
  14685. */
  14686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14687. /**
  14688. * Remove a specific color gradient
  14689. * @param gradient defines the gradient to remove
  14690. * @returns the current particle system
  14691. */
  14692. removeColorGradient(gradient: number): IParticleSystem;
  14693. /**
  14694. * Adds a new size gradient
  14695. * @param gradient defines the gradient to use (between 0 and 1)
  14696. * @param factor defines the size factor to affect to the specified gradient
  14697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14698. * @returns the current particle system
  14699. */
  14700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14701. /**
  14702. * Remove a specific size gradient
  14703. * @param gradient defines the gradient to remove
  14704. * @returns the current particle system
  14705. */
  14706. removeSizeGradient(gradient: number): IParticleSystem;
  14707. /**
  14708. * Gets the current list of color gradients.
  14709. * You must use addColorGradient and removeColorGradient to udpate this list
  14710. * @returns the list of color gradients
  14711. */
  14712. getColorGradients(): Nullable<Array<ColorGradient>>;
  14713. /**
  14714. * Gets the current list of size gradients.
  14715. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14716. * @returns the list of size gradients
  14717. */
  14718. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14719. /**
  14720. * Gets the current list of angular speed gradients.
  14721. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14722. * @returns the list of angular speed gradients
  14723. */
  14724. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14725. /**
  14726. * Adds a new angular speed gradient
  14727. * @param gradient defines the gradient to use (between 0 and 1)
  14728. * @param factor defines the angular speed to affect to the specified gradient
  14729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14730. * @returns the current particle system
  14731. */
  14732. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14733. /**
  14734. * Remove a specific angular speed gradient
  14735. * @param gradient defines the gradient to remove
  14736. * @returns the current particle system
  14737. */
  14738. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14739. /**
  14740. * Gets the current list of velocity gradients.
  14741. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14742. * @returns the list of velocity gradients
  14743. */
  14744. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14745. /**
  14746. * Adds a new velocity gradient
  14747. * @param gradient defines the gradient to use (between 0 and 1)
  14748. * @param factor defines the velocity to affect to the specified gradient
  14749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14750. * @returns the current particle system
  14751. */
  14752. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14753. /**
  14754. * Remove a specific velocity gradient
  14755. * @param gradient defines the gradient to remove
  14756. * @returns the current particle system
  14757. */
  14758. removeVelocityGradient(gradient: number): IParticleSystem;
  14759. /**
  14760. * Gets the current list of limit velocity gradients.
  14761. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14762. * @returns the list of limit velocity gradients
  14763. */
  14764. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14765. /**
  14766. * Adds a new limit velocity gradient
  14767. * @param gradient defines the gradient to use (between 0 and 1)
  14768. * @param factor defines the limit velocity to affect to the specified gradient
  14769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14770. * @returns the current particle system
  14771. */
  14772. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14773. /**
  14774. * Remove a specific limit velocity gradient
  14775. * @param gradient defines the gradient to remove
  14776. * @returns the current particle system
  14777. */
  14778. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14779. /**
  14780. * Adds a new drag gradient
  14781. * @param gradient defines the gradient to use (between 0 and 1)
  14782. * @param factor defines the drag to affect to the specified gradient
  14783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14784. * @returns the current particle system
  14785. */
  14786. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14787. /**
  14788. * Remove a specific drag gradient
  14789. * @param gradient defines the gradient to remove
  14790. * @returns the current particle system
  14791. */
  14792. removeDragGradient(gradient: number): IParticleSystem;
  14793. /**
  14794. * Gets the current list of drag gradients.
  14795. * You must use addDragGradient and removeDragGradient to udpate this list
  14796. * @returns the list of drag gradients
  14797. */
  14798. getDragGradients(): Nullable<Array<FactorGradient>>;
  14799. /**
  14800. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14801. * @param gradient defines the gradient to use (between 0 and 1)
  14802. * @param factor defines the emit rate to affect to the specified gradient
  14803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14804. * @returns the current particle system
  14805. */
  14806. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14807. /**
  14808. * Remove a specific emit rate gradient
  14809. * @param gradient defines the gradient to remove
  14810. * @returns the current particle system
  14811. */
  14812. removeEmitRateGradient(gradient: number): IParticleSystem;
  14813. /**
  14814. * Gets the current list of emit rate gradients.
  14815. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14816. * @returns the list of emit rate gradients
  14817. */
  14818. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14821. * @param gradient defines the gradient to use (between 0 and 1)
  14822. * @param factor defines the start size to affect to the specified gradient
  14823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14824. * @returns the current particle system
  14825. */
  14826. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14827. /**
  14828. * Remove a specific start size gradient
  14829. * @param gradient defines the gradient to remove
  14830. * @returns the current particle system
  14831. */
  14832. removeStartSizeGradient(gradient: number): IParticleSystem;
  14833. /**
  14834. * Gets the current list of start size gradients.
  14835. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14836. * @returns the list of start size gradients
  14837. */
  14838. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14839. /**
  14840. * Adds a new life time gradient
  14841. * @param gradient defines the gradient to use (between 0 and 1)
  14842. * @param factor defines the life time factor to affect to the specified gradient
  14843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14844. * @returns the current particle system
  14845. */
  14846. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14847. /**
  14848. * Remove a specific life time gradient
  14849. * @param gradient defines the gradient to remove
  14850. * @returns the current particle system
  14851. */
  14852. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14853. /**
  14854. * Gets the current list of life time gradients.
  14855. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14856. * @returns the list of life time gradients
  14857. */
  14858. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14859. /**
  14860. * Gets the current list of color gradients.
  14861. * You must use addColorGradient and removeColorGradient to udpate this list
  14862. * @returns the list of color gradients
  14863. */
  14864. getColorGradients(): Nullable<Array<ColorGradient>>;
  14865. /**
  14866. * Adds a new ramp gradient used to remap particle colors
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param color defines the color to affect to the specified gradient
  14869. * @returns the current particle system
  14870. */
  14871. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14872. /**
  14873. * Gets the current list of ramp gradients.
  14874. * You must use addRampGradient and removeRampGradient to udpate this list
  14875. * @returns the list of ramp gradients
  14876. */
  14877. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14878. /** Gets or sets a boolean indicating that ramp gradients must be used
  14879. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14880. */
  14881. useRampGradients: boolean;
  14882. /**
  14883. * Adds a new color remap gradient
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param min defines the color remap minimal range
  14886. * @param max defines the color remap maximal range
  14887. * @returns the current particle system
  14888. */
  14889. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14890. /**
  14891. * Gets the current list of color remap gradients.
  14892. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14893. * @returns the list of color remap gradients
  14894. */
  14895. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14896. /**
  14897. * Adds a new alpha remap gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param min defines the alpha remap minimal range
  14900. * @param max defines the alpha remap maximal range
  14901. * @returns the current particle system
  14902. */
  14903. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14904. /**
  14905. * Gets the current list of alpha remap gradients.
  14906. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14907. * @returns the list of alpha remap gradients
  14908. */
  14909. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14910. /**
  14911. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14912. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14913. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14914. * @returns the emitter
  14915. */
  14916. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14917. /**
  14918. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14919. * @param radius The radius of the hemisphere to emit from
  14920. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14921. * @returns the emitter
  14922. */
  14923. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14924. /**
  14925. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14926. * @param radius The radius of the sphere to emit from
  14927. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14928. * @returns the emitter
  14929. */
  14930. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14931. /**
  14932. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14933. * @param radius The radius of the sphere to emit from
  14934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14936. * @returns the emitter
  14937. */
  14938. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14939. /**
  14940. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14941. * @param radius The radius of the emission cylinder
  14942. * @param height The height of the emission cylinder
  14943. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14944. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14945. * @returns the emitter
  14946. */
  14947. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14948. /**
  14949. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14950. * @param radius The radius of the cylinder to emit from
  14951. * @param height The height of the emission cylinder
  14952. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14953. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14954. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14955. * @returns the emitter
  14956. */
  14957. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14958. /**
  14959. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14960. * @param radius The radius of the cone to emit from
  14961. * @param angle The base angle of the cone
  14962. * @returns the emitter
  14963. */
  14964. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14965. /**
  14966. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14967. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14968. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14969. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14970. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14971. * @returns the emitter
  14972. */
  14973. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14974. /**
  14975. * Get hosting scene
  14976. * @returns the scene
  14977. */
  14978. getScene(): Nullable<Scene>;
  14979. }
  14980. }
  14981. declare module "babylonjs/Meshes/transformNode" {
  14982. import { DeepImmutable } from "babylonjs/types";
  14983. import { Observable } from "babylonjs/Misc/observable";
  14984. import { Nullable } from "babylonjs/types";
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { Scene } from "babylonjs/scene";
  14987. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14988. import { Node } from "babylonjs/node";
  14989. import { Bone } from "babylonjs/Bones/bone";
  14990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14991. import { Space } from "babylonjs/Maths/math.axis";
  14992. /**
  14993. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14994. * @see https://doc.babylonjs.com/how_to/transformnode
  14995. */
  14996. export class TransformNode extends Node {
  14997. /**
  14998. * Object will not rotate to face the camera
  14999. */
  15000. static BILLBOARDMODE_NONE: number;
  15001. /**
  15002. * Object will rotate to face the camera but only on the x axis
  15003. */
  15004. static BILLBOARDMODE_X: number;
  15005. /**
  15006. * Object will rotate to face the camera but only on the y axis
  15007. */
  15008. static BILLBOARDMODE_Y: number;
  15009. /**
  15010. * Object will rotate to face the camera but only on the z axis
  15011. */
  15012. static BILLBOARDMODE_Z: number;
  15013. /**
  15014. * Object will rotate to face the camera
  15015. */
  15016. static BILLBOARDMODE_ALL: number;
  15017. /**
  15018. * Object will rotate to face the camera's position instead of orientation
  15019. */
  15020. static BILLBOARDMODE_USE_POSITION: number;
  15021. private static _TmpRotation;
  15022. private static _TmpScaling;
  15023. private static _TmpTranslation;
  15024. private _forward;
  15025. private _forwardInverted;
  15026. private _up;
  15027. private _right;
  15028. private _rightInverted;
  15029. private _position;
  15030. private _rotation;
  15031. private _rotationQuaternion;
  15032. protected _scaling: Vector3;
  15033. protected _isDirty: boolean;
  15034. private _transformToBoneReferal;
  15035. private _isAbsoluteSynced;
  15036. private _billboardMode;
  15037. /**
  15038. * Gets or sets the billboard mode. Default is 0.
  15039. *
  15040. * | Value | Type | Description |
  15041. * | --- | --- | --- |
  15042. * | 0 | BILLBOARDMODE_NONE | |
  15043. * | 1 | BILLBOARDMODE_X | |
  15044. * | 2 | BILLBOARDMODE_Y | |
  15045. * | 4 | BILLBOARDMODE_Z | |
  15046. * | 7 | BILLBOARDMODE_ALL | |
  15047. *
  15048. */
  15049. get billboardMode(): number;
  15050. set billboardMode(value: number);
  15051. private _preserveParentRotationForBillboard;
  15052. /**
  15053. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15054. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15055. */
  15056. get preserveParentRotationForBillboard(): boolean;
  15057. set preserveParentRotationForBillboard(value: boolean);
  15058. /**
  15059. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  15060. */
  15061. scalingDeterminant: number;
  15062. private _infiniteDistance;
  15063. /**
  15064. * Gets or sets the distance of the object to max, often used by skybox
  15065. */
  15066. get infiniteDistance(): boolean;
  15067. set infiniteDistance(value: boolean);
  15068. /**
  15069. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15070. * By default the system will update normals to compensate
  15071. */
  15072. ignoreNonUniformScaling: boolean;
  15073. /**
  15074. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  15075. */
  15076. reIntegrateRotationIntoRotationQuaternion: boolean;
  15077. /** @hidden */
  15078. _poseMatrix: Nullable<Matrix>;
  15079. /** @hidden */
  15080. _localMatrix: Matrix;
  15081. private _usePivotMatrix;
  15082. private _absolutePosition;
  15083. private _absoluteScaling;
  15084. private _absoluteRotationQuaternion;
  15085. private _pivotMatrix;
  15086. private _pivotMatrixInverse;
  15087. protected _postMultiplyPivotMatrix: boolean;
  15088. protected _isWorldMatrixFrozen: boolean;
  15089. /** @hidden */
  15090. _indexInSceneTransformNodesArray: number;
  15091. /**
  15092. * An event triggered after the world matrix is updated
  15093. */
  15094. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15095. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15096. /**
  15097. * Gets a string identifying the name of the class
  15098. * @returns "TransformNode" string
  15099. */
  15100. getClassName(): string;
  15101. /**
  15102. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15103. */
  15104. get position(): Vector3;
  15105. set position(newPosition: Vector3);
  15106. /**
  15107. * 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)).
  15108. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15109. */
  15110. get rotation(): Vector3;
  15111. set rotation(newRotation: Vector3);
  15112. /**
  15113. * 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)).
  15114. */
  15115. get scaling(): Vector3;
  15116. set scaling(newScaling: Vector3);
  15117. /**
  15118. * 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).
  15119. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15120. */
  15121. get rotationQuaternion(): Nullable<Quaternion>;
  15122. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15123. /**
  15124. * The forward direction of that transform in world space.
  15125. */
  15126. get forward(): Vector3;
  15127. /**
  15128. * The up direction of that transform in world space.
  15129. */
  15130. get up(): Vector3;
  15131. /**
  15132. * The right direction of that transform in world space.
  15133. */
  15134. get right(): Vector3;
  15135. /**
  15136. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15137. * @param matrix the matrix to copy the pose from
  15138. * @returns this TransformNode.
  15139. */
  15140. updatePoseMatrix(matrix: Matrix): TransformNode;
  15141. /**
  15142. * Returns the mesh Pose matrix.
  15143. * @returns the pose matrix
  15144. */
  15145. getPoseMatrix(): Matrix;
  15146. /** @hidden */
  15147. _isSynchronized(): boolean;
  15148. /** @hidden */
  15149. _initCache(): void;
  15150. /**
  15151. * Flag the transform node as dirty (Forcing it to update everything)
  15152. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15153. * @returns this transform node
  15154. */
  15155. markAsDirty(property: string): TransformNode;
  15156. /**
  15157. * Returns the current mesh absolute position.
  15158. * Returns a Vector3.
  15159. */
  15160. get absolutePosition(): Vector3;
  15161. /**
  15162. * Returns the current mesh absolute scaling.
  15163. * Returns a Vector3.
  15164. */
  15165. get absoluteScaling(): Vector3;
  15166. /**
  15167. * Returns the current mesh absolute rotation.
  15168. * Returns a Quaternion.
  15169. */
  15170. get absoluteRotationQuaternion(): Quaternion;
  15171. /**
  15172. * Sets a new matrix to apply before all other transformation
  15173. * @param matrix defines the transform matrix
  15174. * @returns the current TransformNode
  15175. */
  15176. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15177. /**
  15178. * Sets a new pivot matrix to the current node
  15179. * @param matrix defines the new pivot matrix to use
  15180. * @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
  15181. * @returns the current TransformNode
  15182. */
  15183. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15184. /**
  15185. * Returns the mesh pivot matrix.
  15186. * Default : Identity.
  15187. * @returns the matrix
  15188. */
  15189. getPivotMatrix(): Matrix;
  15190. /**
  15191. * Instantiate (when possible) or clone that node with its hierarchy
  15192. * @param newParent defines the new parent to use for the instance (or clone)
  15193. * @param options defines options to configure how copy is done
  15194. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15195. * @returns an instance (or a clone) of the current node with its hiearchy
  15196. */
  15197. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15198. doNotInstantiate: boolean;
  15199. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15200. /**
  15201. * Prevents the World matrix to be computed any longer
  15202. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15203. * @returns the TransformNode.
  15204. */
  15205. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15206. /**
  15207. * Allows back the World matrix computation.
  15208. * @returns the TransformNode.
  15209. */
  15210. unfreezeWorldMatrix(): this;
  15211. /**
  15212. * True if the World matrix has been frozen.
  15213. */
  15214. get isWorldMatrixFrozen(): boolean;
  15215. /**
  15216. * Retuns the mesh absolute position in the World.
  15217. * @returns a Vector3.
  15218. */
  15219. getAbsolutePosition(): Vector3;
  15220. /**
  15221. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15222. * @param absolutePosition the absolute position to set
  15223. * @returns the TransformNode.
  15224. */
  15225. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15226. /**
  15227. * Sets the mesh position in its local space.
  15228. * @param vector3 the position to set in localspace
  15229. * @returns the TransformNode.
  15230. */
  15231. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15232. /**
  15233. * Returns the mesh position in the local space from the current World matrix values.
  15234. * @returns a new Vector3.
  15235. */
  15236. getPositionExpressedInLocalSpace(): Vector3;
  15237. /**
  15238. * Translates the mesh along the passed Vector3 in its local space.
  15239. * @param vector3 the distance to translate in localspace
  15240. * @returns the TransformNode.
  15241. */
  15242. locallyTranslate(vector3: Vector3): TransformNode;
  15243. private static _lookAtVectorCache;
  15244. /**
  15245. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15246. * @param targetPoint the position (must be in same space as current mesh) to look at
  15247. * @param yawCor optional yaw (y-axis) correction in radians
  15248. * @param pitchCor optional pitch (x-axis) correction in radians
  15249. * @param rollCor optional roll (z-axis) correction in radians
  15250. * @param space the choosen space of the target
  15251. * @returns the TransformNode.
  15252. */
  15253. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15254. /**
  15255. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15256. * This Vector3 is expressed in the World space.
  15257. * @param localAxis axis to rotate
  15258. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15259. */
  15260. getDirection(localAxis: Vector3): Vector3;
  15261. /**
  15262. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15263. * localAxis is expressed in the mesh local space.
  15264. * result is computed in the Wordl space from the mesh World matrix.
  15265. * @param localAxis axis to rotate
  15266. * @param result the resulting transformnode
  15267. * @returns this TransformNode.
  15268. */
  15269. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15270. /**
  15271. * Sets this transform node rotation to the given local axis.
  15272. * @param localAxis the axis in local space
  15273. * @param yawCor optional yaw (y-axis) correction in radians
  15274. * @param pitchCor optional pitch (x-axis) correction in radians
  15275. * @param rollCor optional roll (z-axis) correction in radians
  15276. * @returns this TransformNode
  15277. */
  15278. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15279. /**
  15280. * Sets a new pivot point to the current node
  15281. * @param point defines the new pivot point to use
  15282. * @param space defines if the point is in world or local space (local by default)
  15283. * @returns the current TransformNode
  15284. */
  15285. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15286. /**
  15287. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15288. * @returns the pivot point
  15289. */
  15290. getPivotPoint(): Vector3;
  15291. /**
  15292. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15293. * @param result the vector3 to store the result
  15294. * @returns this TransformNode.
  15295. */
  15296. getPivotPointToRef(result: Vector3): TransformNode;
  15297. /**
  15298. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15299. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15300. */
  15301. getAbsolutePivotPoint(): Vector3;
  15302. /**
  15303. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15304. * @param result vector3 to store the result
  15305. * @returns this TransformNode.
  15306. */
  15307. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15308. /**
  15309. * Defines the passed node as the parent of the current node.
  15310. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15311. * @see https://doc.babylonjs.com/how_to/parenting
  15312. * @param node the node ot set as the parent
  15313. * @returns this TransformNode.
  15314. */
  15315. setParent(node: Nullable<Node>): TransformNode;
  15316. private _nonUniformScaling;
  15317. /**
  15318. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15319. */
  15320. get nonUniformScaling(): boolean;
  15321. /** @hidden */
  15322. _updateNonUniformScalingState(value: boolean): boolean;
  15323. /**
  15324. * Attach the current TransformNode to another TransformNode associated with a bone
  15325. * @param bone Bone affecting the TransformNode
  15326. * @param affectedTransformNode TransformNode associated with the bone
  15327. * @returns this object
  15328. */
  15329. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15330. /**
  15331. * Detach the transform node if its associated with a bone
  15332. * @returns this object
  15333. */
  15334. detachFromBone(): TransformNode;
  15335. private static _rotationAxisCache;
  15336. /**
  15337. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15338. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15339. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15340. * The passed axis is also normalized.
  15341. * @param axis the axis to rotate around
  15342. * @param amount the amount to rotate in radians
  15343. * @param space Space to rotate in (Default: local)
  15344. * @returns the TransformNode.
  15345. */
  15346. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15347. /**
  15348. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15349. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15350. * The passed axis is also normalized. .
  15351. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15352. * @param point the point to rotate around
  15353. * @param axis the axis to rotate around
  15354. * @param amount the amount to rotate in radians
  15355. * @returns the TransformNode
  15356. */
  15357. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15358. /**
  15359. * Translates the mesh along the axis vector for the passed distance in the given space.
  15360. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15361. * @param axis the axis to translate in
  15362. * @param distance the distance to translate
  15363. * @param space Space to rotate in (Default: local)
  15364. * @returns the TransformNode.
  15365. */
  15366. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15367. /**
  15368. * Adds a rotation step to the mesh current rotation.
  15369. * x, y, z are Euler angles expressed in radians.
  15370. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15371. * This means this rotation is made in the mesh local space only.
  15372. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15373. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15374. * ```javascript
  15375. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15376. * ```
  15377. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15378. * 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.
  15379. * @param x Rotation to add
  15380. * @param y Rotation to add
  15381. * @param z Rotation to add
  15382. * @returns the TransformNode.
  15383. */
  15384. addRotation(x: number, y: number, z: number): TransformNode;
  15385. /**
  15386. * @hidden
  15387. */
  15388. protected _getEffectiveParent(): Nullable<Node>;
  15389. /**
  15390. * Computes the world matrix of the node
  15391. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15392. * @returns the world matrix
  15393. */
  15394. computeWorldMatrix(force?: boolean): Matrix;
  15395. /**
  15396. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15397. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15398. */
  15399. resetLocalMatrix(independentOfChildren?: boolean): void;
  15400. protected _afterComputeWorldMatrix(): void;
  15401. /**
  15402. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15403. * @param func callback function to add
  15404. *
  15405. * @returns the TransformNode.
  15406. */
  15407. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15408. /**
  15409. * Removes a registered callback function.
  15410. * @param func callback function to remove
  15411. * @returns the TransformNode.
  15412. */
  15413. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15414. /**
  15415. * Gets the position of the current mesh in camera space
  15416. * @param camera defines the camera to use
  15417. * @returns a position
  15418. */
  15419. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15420. /**
  15421. * Returns the distance from the mesh to the active camera
  15422. * @param camera defines the camera to use
  15423. * @returns the distance
  15424. */
  15425. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15426. /**
  15427. * Clone the current transform node
  15428. * @param name Name of the new clone
  15429. * @param newParent New parent for the clone
  15430. * @param doNotCloneChildren Do not clone children hierarchy
  15431. * @returns the new transform node
  15432. */
  15433. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15434. /**
  15435. * Serializes the objects information.
  15436. * @param currentSerializationObject defines the object to serialize in
  15437. * @returns the serialized object
  15438. */
  15439. serialize(currentSerializationObject?: any): any;
  15440. /**
  15441. * Returns a new TransformNode object parsed from the source provided.
  15442. * @param parsedTransformNode is the source.
  15443. * @param scene the scne the object belongs to
  15444. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15445. * @returns a new TransformNode object parsed from the source provided.
  15446. */
  15447. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15448. /**
  15449. * Get all child-transformNodes of this node
  15450. * @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
  15451. * @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
  15452. * @returns an array of TransformNode
  15453. */
  15454. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15455. /**
  15456. * Releases resources associated with this transform node.
  15457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15459. */
  15460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15461. /**
  15462. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15463. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15464. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15465. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15466. * @returns the current mesh
  15467. */
  15468. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15469. private _syncAbsoluteScalingAndRotation;
  15470. }
  15471. }
  15472. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15473. /**
  15474. * Class used to override all child animations of a given target
  15475. */
  15476. export class AnimationPropertiesOverride {
  15477. /**
  15478. * Gets or sets a value indicating if animation blending must be used
  15479. */
  15480. enableBlending: boolean;
  15481. /**
  15482. * Gets or sets the blending speed to use when enableBlending is true
  15483. */
  15484. blendingSpeed: number;
  15485. /**
  15486. * Gets or sets the default loop mode to use
  15487. */
  15488. loopMode: number;
  15489. }
  15490. }
  15491. declare module "babylonjs/Bones/bone" {
  15492. import { Skeleton } from "babylonjs/Bones/skeleton";
  15493. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15494. import { Nullable } from "babylonjs/types";
  15495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15497. import { Node } from "babylonjs/node";
  15498. import { Space } from "babylonjs/Maths/math.axis";
  15499. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15500. /**
  15501. * Class used to store bone information
  15502. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15503. */
  15504. export class Bone extends Node {
  15505. /**
  15506. * defines the bone name
  15507. */
  15508. name: string;
  15509. private static _tmpVecs;
  15510. private static _tmpQuat;
  15511. private static _tmpMats;
  15512. /**
  15513. * Gets the list of child bones
  15514. */
  15515. children: Bone[];
  15516. /** Gets the animations associated with this bone */
  15517. animations: import("babylonjs/Animations/animation").Animation[];
  15518. /**
  15519. * Gets or sets bone length
  15520. */
  15521. length: number;
  15522. /**
  15523. * @hidden Internal only
  15524. * Set this value to map this bone to a different index in the transform matrices
  15525. * Set this value to -1 to exclude the bone from the transform matrices
  15526. */
  15527. _index: Nullable<number>;
  15528. private _skeleton;
  15529. private _localMatrix;
  15530. private _restPose;
  15531. private _bindPose;
  15532. private _baseMatrix;
  15533. private _absoluteTransform;
  15534. private _invertedAbsoluteTransform;
  15535. private _parent;
  15536. private _scalingDeterminant;
  15537. private _worldTransform;
  15538. private _localScaling;
  15539. private _localRotation;
  15540. private _localPosition;
  15541. private _needToDecompose;
  15542. private _needToCompose;
  15543. /** @hidden */
  15544. _linkedTransformNode: Nullable<TransformNode>;
  15545. /** @hidden */
  15546. _waitingTransformNodeId: Nullable<string>;
  15547. /** @hidden */
  15548. get _matrix(): Matrix;
  15549. /** @hidden */
  15550. set _matrix(value: Matrix);
  15551. /**
  15552. * Create a new bone
  15553. * @param name defines the bone name
  15554. * @param skeleton defines the parent skeleton
  15555. * @param parentBone defines the parent (can be null if the bone is the root)
  15556. * @param localMatrix defines the local matrix
  15557. * @param restPose defines the rest pose matrix
  15558. * @param baseMatrix defines the base matrix
  15559. * @param index defines index of the bone in the hiearchy
  15560. */
  15561. constructor(
  15562. /**
  15563. * defines the bone name
  15564. */
  15565. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15566. /**
  15567. * Gets the current object class name.
  15568. * @return the class name
  15569. */
  15570. getClassName(): string;
  15571. /**
  15572. * Gets the parent skeleton
  15573. * @returns a skeleton
  15574. */
  15575. getSkeleton(): Skeleton;
  15576. /**
  15577. * Gets parent bone
  15578. * @returns a bone or null if the bone is the root of the bone hierarchy
  15579. */
  15580. getParent(): Nullable<Bone>;
  15581. /**
  15582. * Returns an array containing the root bones
  15583. * @returns an array containing the root bones
  15584. */
  15585. getChildren(): Array<Bone>;
  15586. /**
  15587. * Gets the node index in matrix array generated for rendering
  15588. * @returns the node index
  15589. */
  15590. getIndex(): number;
  15591. /**
  15592. * Sets the parent bone
  15593. * @param parent defines the parent (can be null if the bone is the root)
  15594. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15595. */
  15596. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15597. /**
  15598. * Gets the local matrix
  15599. * @returns a matrix
  15600. */
  15601. getLocalMatrix(): Matrix;
  15602. /**
  15603. * Gets the base matrix (initial matrix which remains unchanged)
  15604. * @returns a matrix
  15605. */
  15606. getBaseMatrix(): Matrix;
  15607. /**
  15608. * Gets the rest pose matrix
  15609. * @returns a matrix
  15610. */
  15611. getRestPose(): Matrix;
  15612. /**
  15613. * Sets the rest pose matrix
  15614. * @param matrix the local-space rest pose to set for this bone
  15615. */
  15616. setRestPose(matrix: Matrix): void;
  15617. /**
  15618. * Gets the bind pose matrix
  15619. * @returns the bind pose matrix
  15620. */
  15621. getBindPose(): Matrix;
  15622. /**
  15623. * Sets the bind pose matrix
  15624. * @param matrix the local-space bind pose to set for this bone
  15625. */
  15626. setBindPose(matrix: Matrix): void;
  15627. /**
  15628. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15629. */
  15630. getWorldMatrix(): Matrix;
  15631. /**
  15632. * Sets the local matrix to rest pose matrix
  15633. */
  15634. returnToRest(): void;
  15635. /**
  15636. * Gets the inverse of the absolute transform matrix.
  15637. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15638. * @returns a matrix
  15639. */
  15640. getInvertedAbsoluteTransform(): Matrix;
  15641. /**
  15642. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15643. * @returns a matrix
  15644. */
  15645. getAbsoluteTransform(): Matrix;
  15646. /**
  15647. * Links with the given transform node.
  15648. * The local matrix of this bone is copied from the transform node every frame.
  15649. * @param transformNode defines the transform node to link to
  15650. */
  15651. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15652. /**
  15653. * Gets the node used to drive the bone's transformation
  15654. * @returns a transform node or null
  15655. */
  15656. getTransformNode(): Nullable<TransformNode>;
  15657. /** Gets or sets current position (in local space) */
  15658. get position(): Vector3;
  15659. set position(newPosition: Vector3);
  15660. /** Gets or sets current rotation (in local space) */
  15661. get rotation(): Vector3;
  15662. set rotation(newRotation: Vector3);
  15663. /** Gets or sets current rotation quaternion (in local space) */
  15664. get rotationQuaternion(): Quaternion;
  15665. set rotationQuaternion(newRotation: Quaternion);
  15666. /** Gets or sets current scaling (in local space) */
  15667. get scaling(): Vector3;
  15668. set scaling(newScaling: Vector3);
  15669. /**
  15670. * Gets the animation properties override
  15671. */
  15672. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15673. private _decompose;
  15674. private _compose;
  15675. /**
  15676. * Update the base and local matrices
  15677. * @param matrix defines the new base or local matrix
  15678. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15679. * @param updateLocalMatrix defines if the local matrix should be updated
  15680. */
  15681. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15682. /** @hidden */
  15683. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15684. /**
  15685. * Flag the bone as dirty (Forcing it to update everything)
  15686. */
  15687. markAsDirty(): void;
  15688. /** @hidden */
  15689. _markAsDirtyAndCompose(): void;
  15690. private _markAsDirtyAndDecompose;
  15691. /**
  15692. * Translate the bone in local or world space
  15693. * @param vec The amount to translate the bone
  15694. * @param space The space that the translation is in
  15695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15696. */
  15697. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15698. /**
  15699. * Set the postion of the bone in local or world space
  15700. * @param position The position to set the bone
  15701. * @param space The space that the position is in
  15702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15703. */
  15704. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15705. /**
  15706. * Set the absolute position of the bone (world space)
  15707. * @param position The position to set the bone
  15708. * @param mesh The mesh that this bone is attached to
  15709. */
  15710. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15711. /**
  15712. * Scale the bone on the x, y and z axes (in local space)
  15713. * @param x The amount to scale the bone on the x axis
  15714. * @param y The amount to scale the bone on the y axis
  15715. * @param z The amount to scale the bone on the z axis
  15716. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15717. */
  15718. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15719. /**
  15720. * Set the bone scaling in local space
  15721. * @param scale defines the scaling vector
  15722. */
  15723. setScale(scale: Vector3): void;
  15724. /**
  15725. * Gets the current scaling in local space
  15726. * @returns the current scaling vector
  15727. */
  15728. getScale(): Vector3;
  15729. /**
  15730. * Gets the current scaling in local space and stores it in a target vector
  15731. * @param result defines the target vector
  15732. */
  15733. getScaleToRef(result: Vector3): void;
  15734. /**
  15735. * Set the yaw, pitch, and roll of the bone in local or world space
  15736. * @param yaw The rotation of the bone on the y axis
  15737. * @param pitch The rotation of the bone on the x axis
  15738. * @param roll The rotation of the bone on the z axis
  15739. * @param space The space that the axes of rotation are in
  15740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15741. */
  15742. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15743. /**
  15744. * Add a rotation to the bone on an axis in local or world space
  15745. * @param axis The axis to rotate the bone on
  15746. * @param amount The amount to rotate the bone
  15747. * @param space The space that the axis is in
  15748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15749. */
  15750. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15751. /**
  15752. * Set the rotation of the bone to a particular axis angle in local or world space
  15753. * @param axis The axis to rotate the bone on
  15754. * @param angle The angle that the bone should be rotated to
  15755. * @param space The space that the axis is in
  15756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15757. */
  15758. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15759. /**
  15760. * Set the euler rotation of the bone in local of world space
  15761. * @param rotation The euler rotation that the bone should be set to
  15762. * @param space The space that the rotation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the quaternion rotation of the bone in local of world space
  15768. * @param quat The quaternion rotation that the bone should be set to
  15769. * @param space The space that the rotation is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the rotation matrix of the bone in local of world space
  15775. * @param rotMat The rotation matrix that the bone should be set to
  15776. * @param space The space that the rotation is in
  15777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15778. */
  15779. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15780. private _rotateWithMatrix;
  15781. private _getNegativeRotationToRef;
  15782. /**
  15783. * Get the position of the bone in local or world space
  15784. * @param space The space that the returned position is in
  15785. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15786. * @returns The position of the bone
  15787. */
  15788. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15789. /**
  15790. * Copy the position of the bone to a vector3 in local or world space
  15791. * @param space The space that the returned position is in
  15792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15793. * @param result The vector3 to copy the position to
  15794. */
  15795. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15796. /**
  15797. * Get the absolute position of the bone (world space)
  15798. * @param mesh The mesh that this bone is attached to
  15799. * @returns The absolute position of the bone
  15800. */
  15801. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15802. /**
  15803. * Copy the absolute position of the bone (world space) to the result param
  15804. * @param mesh The mesh that this bone is attached to
  15805. * @param result The vector3 to copy the absolute position to
  15806. */
  15807. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15808. /**
  15809. * Compute the absolute transforms of this bone and its children
  15810. */
  15811. computeAbsoluteTransforms(): void;
  15812. /**
  15813. * Get the world direction from an axis that is in the local space of the bone
  15814. * @param localAxis The local direction that is used to compute the world direction
  15815. * @param mesh The mesh that this bone is attached to
  15816. * @returns The world direction
  15817. */
  15818. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15819. /**
  15820. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15821. * @param localAxis The local direction that is used to compute the world direction
  15822. * @param mesh The mesh that this bone is attached to
  15823. * @param result The vector3 that the world direction will be copied to
  15824. */
  15825. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15826. /**
  15827. * Get the euler rotation of the bone in local or world space
  15828. * @param space The space that the rotation should be in
  15829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15830. * @returns The euler rotation
  15831. */
  15832. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15833. /**
  15834. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15835. * @param space The space that the rotation should be in
  15836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15837. * @param result The vector3 that the rotation should be copied to
  15838. */
  15839. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15840. /**
  15841. * Get the quaternion rotation of the bone in either local or world space
  15842. * @param space The space that the rotation should be in
  15843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15844. * @returns The quaternion rotation
  15845. */
  15846. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15847. /**
  15848. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15849. * @param space The space that the rotation should be in
  15850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15851. * @param result The quaternion that the rotation should be copied to
  15852. */
  15853. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15854. /**
  15855. * Get the rotation matrix of the bone in local or world space
  15856. * @param space The space that the rotation should be in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. * @returns The rotation matrix
  15859. */
  15860. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15861. /**
  15862. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15863. * @param space The space that the rotation should be in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. * @param result The quaternion that the rotation should be copied to
  15866. */
  15867. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15868. /**
  15869. * Get the world position of a point that is in the local space of the bone
  15870. * @param position The local position
  15871. * @param mesh The mesh that this bone is attached to
  15872. * @returns The world position
  15873. */
  15874. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15875. /**
  15876. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15877. * @param position The local position
  15878. * @param mesh The mesh that this bone is attached to
  15879. * @param result The vector3 that the world position should be copied to
  15880. */
  15881. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15882. /**
  15883. * Get the local position of a point that is in world space
  15884. * @param position The world position
  15885. * @param mesh The mesh that this bone is attached to
  15886. * @returns The local position
  15887. */
  15888. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15889. /**
  15890. * Get the local position of a point that is in world space and copy it to the result param
  15891. * @param position The world position
  15892. * @param mesh The mesh that this bone is attached to
  15893. * @param result The vector3 that the local position should be copied to
  15894. */
  15895. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15896. }
  15897. }
  15898. declare module "babylonjs/Animations/runtimeAnimation" {
  15899. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15900. import { Animatable } from "babylonjs/Animations/animatable";
  15901. import { Scene } from "babylonjs/scene";
  15902. /**
  15903. * Defines a runtime animation
  15904. */
  15905. export class RuntimeAnimation {
  15906. private _events;
  15907. /**
  15908. * The current frame of the runtime animation
  15909. */
  15910. private _currentFrame;
  15911. /**
  15912. * The animation used by the runtime animation
  15913. */
  15914. private _animation;
  15915. /**
  15916. * The target of the runtime animation
  15917. */
  15918. private _target;
  15919. /**
  15920. * The initiating animatable
  15921. */
  15922. private _host;
  15923. /**
  15924. * The original value of the runtime animation
  15925. */
  15926. private _originalValue;
  15927. /**
  15928. * The original blend value of the runtime animation
  15929. */
  15930. private _originalBlendValue;
  15931. /**
  15932. * The offsets cache of the runtime animation
  15933. */
  15934. private _offsetsCache;
  15935. /**
  15936. * The high limits cache of the runtime animation
  15937. */
  15938. private _highLimitsCache;
  15939. /**
  15940. * Specifies if the runtime animation has been stopped
  15941. */
  15942. private _stopped;
  15943. /**
  15944. * The blending factor of the runtime animation
  15945. */
  15946. private _blendingFactor;
  15947. /**
  15948. * The BabylonJS scene
  15949. */
  15950. private _scene;
  15951. /**
  15952. * The current value of the runtime animation
  15953. */
  15954. private _currentValue;
  15955. /** @hidden */
  15956. _animationState: _IAnimationState;
  15957. /**
  15958. * The active target of the runtime animation
  15959. */
  15960. private _activeTargets;
  15961. private _currentActiveTarget;
  15962. private _directTarget;
  15963. /**
  15964. * The target path of the runtime animation
  15965. */
  15966. private _targetPath;
  15967. /**
  15968. * The weight of the runtime animation
  15969. */
  15970. private _weight;
  15971. /**
  15972. * The ratio offset of the runtime animation
  15973. */
  15974. private _ratioOffset;
  15975. /**
  15976. * The previous delay of the runtime animation
  15977. */
  15978. private _previousDelay;
  15979. /**
  15980. * The previous ratio of the runtime animation
  15981. */
  15982. private _previousRatio;
  15983. private _enableBlending;
  15984. private _keys;
  15985. private _minFrame;
  15986. private _maxFrame;
  15987. private _minValue;
  15988. private _maxValue;
  15989. private _targetIsArray;
  15990. /**
  15991. * Gets the current frame of the runtime animation
  15992. */
  15993. get currentFrame(): number;
  15994. /**
  15995. * Gets the weight of the runtime animation
  15996. */
  15997. get weight(): number;
  15998. /**
  15999. * Gets the current value of the runtime animation
  16000. */
  16001. get currentValue(): any;
  16002. /**
  16003. * Gets the target path of the runtime animation
  16004. */
  16005. get targetPath(): string;
  16006. /**
  16007. * Gets the actual target of the runtime animation
  16008. */
  16009. get target(): any;
  16010. /**
  16011. * Gets the additive state of the runtime animation
  16012. */
  16013. get isAdditive(): boolean;
  16014. /** @hidden */
  16015. _onLoop: () => void;
  16016. /**
  16017. * Create a new RuntimeAnimation object
  16018. * @param target defines the target of the animation
  16019. * @param animation defines the source animation object
  16020. * @param scene defines the hosting scene
  16021. * @param host defines the initiating Animatable
  16022. */
  16023. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16024. private _preparePath;
  16025. /**
  16026. * Gets the animation from the runtime animation
  16027. */
  16028. get animation(): Animation;
  16029. /**
  16030. * Resets the runtime animation to the beginning
  16031. * @param restoreOriginal defines whether to restore the target property to the original value
  16032. */
  16033. reset(restoreOriginal?: boolean): void;
  16034. /**
  16035. * Specifies if the runtime animation is stopped
  16036. * @returns Boolean specifying if the runtime animation is stopped
  16037. */
  16038. isStopped(): boolean;
  16039. /**
  16040. * Disposes of the runtime animation
  16041. */
  16042. dispose(): void;
  16043. /**
  16044. * Apply the interpolated value to the target
  16045. * @param currentValue defines the value computed by the animation
  16046. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16047. */
  16048. setValue(currentValue: any, weight: number): void;
  16049. private _getOriginalValues;
  16050. private _setValue;
  16051. /**
  16052. * Gets the loop pmode of the runtime animation
  16053. * @returns Loop Mode
  16054. */
  16055. private _getCorrectLoopMode;
  16056. /**
  16057. * Move the current animation to a given frame
  16058. * @param frame defines the frame to move to
  16059. */
  16060. goToFrame(frame: number): void;
  16061. /**
  16062. * @hidden Internal use only
  16063. */
  16064. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16065. /**
  16066. * Execute the current animation
  16067. * @param delay defines the delay to add to the current frame
  16068. * @param from defines the lower bound of the animation range
  16069. * @param to defines the upper bound of the animation range
  16070. * @param loop defines if the current animation must loop
  16071. * @param speedRatio defines the current speed ratio
  16072. * @param weight defines the weight of the animation (default is -1 so no weight)
  16073. * @param onLoop optional callback called when animation loops
  16074. * @returns a boolean indicating if the animation is running
  16075. */
  16076. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16077. }
  16078. }
  16079. declare module "babylonjs/Animations/animatable" {
  16080. import { Animation } from "babylonjs/Animations/animation";
  16081. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16082. import { Nullable } from "babylonjs/types";
  16083. import { Observable } from "babylonjs/Misc/observable";
  16084. import { Scene } from "babylonjs/scene";
  16085. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16086. import { Node } from "babylonjs/node";
  16087. /**
  16088. * Class used to store an actual running animation
  16089. */
  16090. export class Animatable {
  16091. /** defines the target object */
  16092. target: any;
  16093. /** defines the starting frame number (default is 0) */
  16094. fromFrame: number;
  16095. /** defines the ending frame number (default is 100) */
  16096. toFrame: number;
  16097. /** defines if the animation must loop (default is false) */
  16098. loopAnimation: boolean;
  16099. /** defines a callback to call when animation ends if it is not looping */
  16100. onAnimationEnd?: (() => void) | null | undefined;
  16101. /** defines a callback to call when animation loops */
  16102. onAnimationLoop?: (() => void) | null | undefined;
  16103. /** defines whether the animation should be evaluated additively */
  16104. isAdditive: boolean;
  16105. private _localDelayOffset;
  16106. private _pausedDelay;
  16107. private _runtimeAnimations;
  16108. private _paused;
  16109. private _scene;
  16110. private _speedRatio;
  16111. private _weight;
  16112. private _syncRoot;
  16113. /**
  16114. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16115. * This will only apply for non looping animation (default is true)
  16116. */
  16117. disposeOnEnd: boolean;
  16118. /**
  16119. * Gets a boolean indicating if the animation has started
  16120. */
  16121. animationStarted: boolean;
  16122. /**
  16123. * Observer raised when the animation ends
  16124. */
  16125. onAnimationEndObservable: Observable<Animatable>;
  16126. /**
  16127. * Observer raised when the animation loops
  16128. */
  16129. onAnimationLoopObservable: Observable<Animatable>;
  16130. /**
  16131. * Gets the root Animatable used to synchronize and normalize animations
  16132. */
  16133. get syncRoot(): Nullable<Animatable>;
  16134. /**
  16135. * Gets the current frame of the first RuntimeAnimation
  16136. * Used to synchronize Animatables
  16137. */
  16138. get masterFrame(): number;
  16139. /**
  16140. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16141. */
  16142. get weight(): number;
  16143. set weight(value: number);
  16144. /**
  16145. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16146. */
  16147. get speedRatio(): number;
  16148. set speedRatio(value: number);
  16149. /**
  16150. * Creates a new Animatable
  16151. * @param scene defines the hosting scene
  16152. * @param target defines the target object
  16153. * @param fromFrame defines the starting frame number (default is 0)
  16154. * @param toFrame defines the ending frame number (default is 100)
  16155. * @param loopAnimation defines if the animation must loop (default is false)
  16156. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16157. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16158. * @param animations defines a group of animation to add to the new Animatable
  16159. * @param onAnimationLoop defines a callback to call when animation loops
  16160. * @param isAdditive defines whether the animation should be evaluated additively
  16161. */
  16162. constructor(scene: Scene,
  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, speedRatio?: number,
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  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. /**
  16178. * Synchronize and normalize current Animatable with a source Animatable
  16179. * This is useful when using animation weights and when animations are not of the same length
  16180. * @param root defines the root Animatable to synchronize with
  16181. * @returns the current Animatable
  16182. */
  16183. syncWith(root: Animatable): Animatable;
  16184. /**
  16185. * Gets the list of runtime animations
  16186. * @returns an array of RuntimeAnimation
  16187. */
  16188. getAnimations(): RuntimeAnimation[];
  16189. /**
  16190. * Adds more animations to the current animatable
  16191. * @param target defines the target of the animations
  16192. * @param animations defines the new animations to add
  16193. */
  16194. appendAnimations(target: any, animations: Animation[]): void;
  16195. /**
  16196. * Gets the source animation for a specific property
  16197. * @param property defines the propertyu to look for
  16198. * @returns null or the source animation for the given property
  16199. */
  16200. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16201. /**
  16202. * Gets the runtime animation for a specific property
  16203. * @param property defines the propertyu to look for
  16204. * @returns null or the runtime animation for the given property
  16205. */
  16206. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16207. /**
  16208. * Resets the animatable to its original state
  16209. */
  16210. reset(): void;
  16211. /**
  16212. * Allows the animatable to blend with current running animations
  16213. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16214. * @param blendingSpeed defines the blending speed to use
  16215. */
  16216. enableBlending(blendingSpeed: number): void;
  16217. /**
  16218. * Disable animation blending
  16219. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16220. */
  16221. disableBlending(): void;
  16222. /**
  16223. * Jump directly to a given frame
  16224. * @param frame defines the frame to jump to
  16225. */
  16226. goToFrame(frame: number): void;
  16227. /**
  16228. * Pause the animation
  16229. */
  16230. pause(): void;
  16231. /**
  16232. * Restart the animation
  16233. */
  16234. restart(): void;
  16235. private _raiseOnAnimationEnd;
  16236. /**
  16237. * Stop and delete the current animation
  16238. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16239. * @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)
  16240. */
  16241. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16242. /**
  16243. * Wait asynchronously for the animation to end
  16244. * @returns a promise which will be fullfilled when the animation ends
  16245. */
  16246. waitAsync(): Promise<Animatable>;
  16247. /** @hidden */
  16248. _animate(delay: number): boolean;
  16249. }
  16250. module "babylonjs/scene" {
  16251. interface Scene {
  16252. /** @hidden */
  16253. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16254. /** @hidden */
  16255. _processLateAnimationBindingsForMatrices(holder: {
  16256. totalWeight: number;
  16257. totalAdditiveWeight: number;
  16258. animations: RuntimeAnimation[];
  16259. additiveAnimations: RuntimeAnimation[];
  16260. originalValue: Matrix;
  16261. }): any;
  16262. /** @hidden */
  16263. _processLateAnimationBindingsForQuaternions(holder: {
  16264. totalWeight: number;
  16265. totalAdditiveWeight: number;
  16266. animations: RuntimeAnimation[];
  16267. additiveAnimations: RuntimeAnimation[];
  16268. originalValue: Quaternion;
  16269. }, refQuaternion: Quaternion): Quaternion;
  16270. /** @hidden */
  16271. _processLateAnimationBindings(): void;
  16272. /**
  16273. * Will start the animation sequence of a given target
  16274. * @param target defines the target
  16275. * @param from defines from which frame should animation start
  16276. * @param to defines until which frame should animation run.
  16277. * @param weight defines the weight to apply to the animation (1.0 by default)
  16278. * @param loop defines if the animation loops
  16279. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16280. * @param onAnimationEnd defines the function to be executed when the animation ends
  16281. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16282. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16283. * @param onAnimationLoop defines the callback to call when an animation loops
  16284. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16285. * @returns the animatable object created for this animation
  16286. */
  16287. 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;
  16288. /**
  16289. * Will start the animation sequence of a given target
  16290. * @param target defines the target
  16291. * @param from defines from which frame should animation start
  16292. * @param to defines until which frame should animation run.
  16293. * @param loop defines if the animation loops
  16294. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16295. * @param onAnimationEnd defines the function to be executed when the animation ends
  16296. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16297. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16298. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16299. * @param onAnimationLoop defines the callback to call when an animation loops
  16300. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16301. * @returns the animatable object created for this animation
  16302. */
  16303. 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;
  16304. /**
  16305. * Will start the animation sequence of a given target and its hierarchy
  16306. * @param target defines the target
  16307. * @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.
  16308. * @param from defines from which frame should animation start
  16309. * @param to defines until which frame should animation run.
  16310. * @param loop defines if the animation loops
  16311. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16312. * @param onAnimationEnd defines the function to be executed when the animation ends
  16313. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16314. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16315. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16316. * @param onAnimationLoop defines the callback to call when an animation loops
  16317. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16318. * @returns the list of created animatables
  16319. */
  16320. 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[];
  16321. /**
  16322. * Begin a new animation on a given node
  16323. * @param target defines the target where the animation will take place
  16324. * @param animations defines the list of animations to start
  16325. * @param from defines the initial value
  16326. * @param to defines the final value
  16327. * @param loop defines if you want animation to loop (off by default)
  16328. * @param speedRatio defines the speed ratio to apply to all animations
  16329. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16330. * @param onAnimationLoop defines the callback to call when an animation loops
  16331. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16332. * @returns the list of created animatables
  16333. */
  16334. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16335. /**
  16336. * Begin a new animation on a given node and its hierarchy
  16337. * @param target defines the root node where the animation will take place
  16338. * @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.
  16339. * @param animations defines the list of animations to start
  16340. * @param from defines the initial value
  16341. * @param to defines the final value
  16342. * @param loop defines if you want animation to loop (off by default)
  16343. * @param speedRatio defines the speed ratio to apply to all animations
  16344. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16345. * @param onAnimationLoop defines the callback to call when an animation loops
  16346. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16347. * @returns the list of animatables created for all nodes
  16348. */
  16349. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16350. /**
  16351. * Gets the animatable associated with a specific target
  16352. * @param target defines the target of the animatable
  16353. * @returns the required animatable if found
  16354. */
  16355. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16356. /**
  16357. * Gets all animatables associated with a given target
  16358. * @param target defines the target to look animatables for
  16359. * @returns an array of Animatables
  16360. */
  16361. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16362. /**
  16363. * Stops and removes all animations that have been applied to the scene
  16364. */
  16365. stopAllAnimations(): void;
  16366. /**
  16367. * Gets the current delta time used by animation engine
  16368. */
  16369. deltaTime: number;
  16370. }
  16371. }
  16372. module "babylonjs/Bones/bone" {
  16373. interface Bone {
  16374. /**
  16375. * Copy an animation range from another bone
  16376. * @param source defines the source bone
  16377. * @param rangeName defines the range name to copy
  16378. * @param frameOffset defines the frame offset
  16379. * @param rescaleAsRequired defines if rescaling must be applied if required
  16380. * @param skelDimensionsRatio defines the scaling ratio
  16381. * @returns true if operation was successful
  16382. */
  16383. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16384. }
  16385. }
  16386. }
  16387. declare module "babylonjs/Bones/skeleton" {
  16388. import { Bone } from "babylonjs/Bones/bone";
  16389. import { Observable } from "babylonjs/Misc/observable";
  16390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16391. import { Scene } from "babylonjs/scene";
  16392. import { Nullable } from "babylonjs/types";
  16393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16394. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16395. import { Animatable } from "babylonjs/Animations/animatable";
  16396. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16397. import { Animation } from "babylonjs/Animations/animation";
  16398. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16399. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16400. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16401. /**
  16402. * Class used to handle skinning animations
  16403. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16404. */
  16405. export class Skeleton implements IAnimatable {
  16406. /** defines the skeleton name */
  16407. name: string;
  16408. /** defines the skeleton Id */
  16409. id: string;
  16410. /**
  16411. * Defines the list of child bones
  16412. */
  16413. bones: Bone[];
  16414. /**
  16415. * Defines an estimate of the dimension of the skeleton at rest
  16416. */
  16417. dimensionsAtRest: Vector3;
  16418. /**
  16419. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16420. */
  16421. needInitialSkinMatrix: boolean;
  16422. /**
  16423. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16424. */
  16425. overrideMesh: Nullable<AbstractMesh>;
  16426. /**
  16427. * Gets the list of animations attached to this skeleton
  16428. */
  16429. animations: Array<Animation>;
  16430. private _scene;
  16431. private _isDirty;
  16432. private _transformMatrices;
  16433. private _transformMatrixTexture;
  16434. private _meshesWithPoseMatrix;
  16435. private _animatables;
  16436. private _identity;
  16437. private _synchronizedWithMesh;
  16438. private _ranges;
  16439. private _lastAbsoluteTransformsUpdateId;
  16440. private _canUseTextureForBones;
  16441. private _uniqueId;
  16442. /** @hidden */
  16443. _numBonesWithLinkedTransformNode: number;
  16444. /** @hidden */
  16445. _hasWaitingData: Nullable<boolean>;
  16446. /**
  16447. * Specifies if the skeleton should be serialized
  16448. */
  16449. doNotSerialize: boolean;
  16450. private _useTextureToStoreBoneMatrices;
  16451. /**
  16452. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16453. * Please note that this option is not available if the hardware does not support it
  16454. */
  16455. get useTextureToStoreBoneMatrices(): boolean;
  16456. set useTextureToStoreBoneMatrices(value: boolean);
  16457. private _animationPropertiesOverride;
  16458. /**
  16459. * Gets or sets the animation properties override
  16460. */
  16461. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16462. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16463. /**
  16464. * List of inspectable custom properties (used by the Inspector)
  16465. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16466. */
  16467. inspectableCustomProperties: IInspectable[];
  16468. /**
  16469. * An observable triggered before computing the skeleton's matrices
  16470. */
  16471. onBeforeComputeObservable: Observable<Skeleton>;
  16472. /**
  16473. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16474. */
  16475. get isUsingTextureForMatrices(): boolean;
  16476. /**
  16477. * Gets the unique ID of this skeleton
  16478. */
  16479. get uniqueId(): number;
  16480. /**
  16481. * Creates a new skeleton
  16482. * @param name defines the skeleton name
  16483. * @param id defines the skeleton Id
  16484. * @param scene defines the hosting scene
  16485. */
  16486. constructor(
  16487. /** defines the skeleton name */
  16488. name: string,
  16489. /** defines the skeleton Id */
  16490. id: string, scene: Scene);
  16491. /**
  16492. * Gets the current object class name.
  16493. * @return the class name
  16494. */
  16495. getClassName(): string;
  16496. /**
  16497. * Returns an array containing the root bones
  16498. * @returns an array containing the root bones
  16499. */
  16500. getChildren(): Array<Bone>;
  16501. /**
  16502. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16503. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16504. * @returns a Float32Array containing matrices data
  16505. */
  16506. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16507. /**
  16508. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16509. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16510. * @returns a raw texture containing the data
  16511. */
  16512. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16513. /**
  16514. * Gets the current hosting scene
  16515. * @returns a scene object
  16516. */
  16517. getScene(): Scene;
  16518. /**
  16519. * Gets a string representing the current skeleton data
  16520. * @param fullDetails defines a boolean indicating if we want a verbose version
  16521. * @returns a string representing the current skeleton data
  16522. */
  16523. toString(fullDetails?: boolean): string;
  16524. /**
  16525. * Get bone's index searching by name
  16526. * @param name defines bone's name to search for
  16527. * @return the indice of the bone. Returns -1 if not found
  16528. */
  16529. getBoneIndexByName(name: string): number;
  16530. /**
  16531. * Creater a new animation range
  16532. * @param name defines the name of the range
  16533. * @param from defines the start key
  16534. * @param to defines the end key
  16535. */
  16536. createAnimationRange(name: string, from: number, to: number): void;
  16537. /**
  16538. * Delete a specific animation range
  16539. * @param name defines the name of the range
  16540. * @param deleteFrames defines if frames must be removed as well
  16541. */
  16542. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16543. /**
  16544. * Gets a specific animation range
  16545. * @param name defines the name of the range to look for
  16546. * @returns the requested animation range or null if not found
  16547. */
  16548. getAnimationRange(name: string): Nullable<AnimationRange>;
  16549. /**
  16550. * Gets the list of all animation ranges defined on this skeleton
  16551. * @returns an array
  16552. */
  16553. getAnimationRanges(): Nullable<AnimationRange>[];
  16554. /**
  16555. * Copy animation range from a source skeleton.
  16556. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16557. * @param source defines the source skeleton
  16558. * @param name defines the name of the range to copy
  16559. * @param rescaleAsRequired defines if rescaling must be applied if required
  16560. * @returns true if operation was successful
  16561. */
  16562. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16563. /**
  16564. * Forces the skeleton to go to rest pose
  16565. */
  16566. returnToRest(): void;
  16567. private _getHighestAnimationFrame;
  16568. /**
  16569. * Begin a specific animation range
  16570. * @param name defines the name of the range to start
  16571. * @param loop defines if looping must be turned on (false by default)
  16572. * @param speedRatio defines the speed ratio to apply (1 by default)
  16573. * @param onAnimationEnd defines a callback which will be called when animation will end
  16574. * @returns a new animatable
  16575. */
  16576. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16577. /**
  16578. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16579. * @param skeleton defines the Skeleton containing the animation range to convert
  16580. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16581. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16582. * @returns the original skeleton
  16583. */
  16584. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16585. /** @hidden */
  16586. _markAsDirty(): void;
  16587. /** @hidden */
  16588. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16589. /** @hidden */
  16590. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16591. private _computeTransformMatrices;
  16592. /**
  16593. * Build all resources required to render a skeleton
  16594. */
  16595. prepare(): void;
  16596. /**
  16597. * Gets the list of animatables currently running for this skeleton
  16598. * @returns an array of animatables
  16599. */
  16600. getAnimatables(): IAnimatable[];
  16601. /**
  16602. * Clone the current skeleton
  16603. * @param name defines the name of the new skeleton
  16604. * @param id defines the id of the new skeleton
  16605. * @returns the new skeleton
  16606. */
  16607. clone(name: string, id?: string): Skeleton;
  16608. /**
  16609. * Enable animation blending for this skeleton
  16610. * @param blendingSpeed defines the blending speed to apply
  16611. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16612. */
  16613. enableBlending(blendingSpeed?: number): void;
  16614. /**
  16615. * Releases all resources associated with the current skeleton
  16616. */
  16617. dispose(): void;
  16618. /**
  16619. * Serialize the skeleton in a JSON object
  16620. * @returns a JSON object
  16621. */
  16622. serialize(): any;
  16623. /**
  16624. * Creates a new skeleton from serialized data
  16625. * @param parsedSkeleton defines the serialized data
  16626. * @param scene defines the hosting scene
  16627. * @returns a new skeleton
  16628. */
  16629. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16630. /**
  16631. * Compute all node absolute transforms
  16632. * @param forceUpdate defines if computation must be done even if cache is up to date
  16633. */
  16634. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16635. /**
  16636. * Gets the root pose matrix
  16637. * @returns a matrix
  16638. */
  16639. getPoseMatrix(): Nullable<Matrix>;
  16640. /**
  16641. * Sorts bones per internal index
  16642. */
  16643. sortBones(): void;
  16644. private _sortBones;
  16645. }
  16646. }
  16647. declare module "babylonjs/Meshes/instancedMesh" {
  16648. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16649. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16650. import { Camera } from "babylonjs/Cameras/camera";
  16651. import { Node } from "babylonjs/node";
  16652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16653. import { Mesh } from "babylonjs/Meshes/mesh";
  16654. import { Material } from "babylonjs/Materials/material";
  16655. import { Skeleton } from "babylonjs/Bones/skeleton";
  16656. import { Light } from "babylonjs/Lights/light";
  16657. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16658. /**
  16659. * Creates an instance based on a source mesh.
  16660. */
  16661. export class InstancedMesh extends AbstractMesh {
  16662. private _sourceMesh;
  16663. private _currentLOD;
  16664. /** @hidden */
  16665. _indexInSourceMeshInstanceArray: number;
  16666. constructor(name: string, source: Mesh);
  16667. /**
  16668. * Returns the string "InstancedMesh".
  16669. */
  16670. getClassName(): string;
  16671. /** Gets the list of lights affecting that mesh */
  16672. get lightSources(): Light[];
  16673. _resyncLightSources(): void;
  16674. _resyncLightSource(light: Light): void;
  16675. _removeLightSource(light: Light, dispose: boolean): void;
  16676. /**
  16677. * If the source mesh receives shadows
  16678. */
  16679. get receiveShadows(): boolean;
  16680. /**
  16681. * The material of the source mesh
  16682. */
  16683. get material(): Nullable<Material>;
  16684. /**
  16685. * Visibility of the source mesh
  16686. */
  16687. get visibility(): number;
  16688. /**
  16689. * Skeleton of the source mesh
  16690. */
  16691. get skeleton(): Nullable<Skeleton>;
  16692. /**
  16693. * Rendering ground id of the source mesh
  16694. */
  16695. get renderingGroupId(): number;
  16696. set renderingGroupId(value: number);
  16697. /**
  16698. * Returns the total number of vertices (integer).
  16699. */
  16700. getTotalVertices(): number;
  16701. /**
  16702. * Returns a positive integer : the total number of indices in this mesh geometry.
  16703. * @returns the numner of indices or zero if the mesh has no geometry.
  16704. */
  16705. getTotalIndices(): number;
  16706. /**
  16707. * The source mesh of the instance
  16708. */
  16709. get sourceMesh(): Mesh;
  16710. /**
  16711. * Creates a new InstancedMesh object from the mesh model.
  16712. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16713. * @param name defines the name of the new instance
  16714. * @returns a new InstancedMesh
  16715. */
  16716. createInstance(name: string): InstancedMesh;
  16717. /**
  16718. * Is this node ready to be used/rendered
  16719. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16720. * @return {boolean} is it ready
  16721. */
  16722. isReady(completeCheck?: boolean): boolean;
  16723. /**
  16724. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16725. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16726. * @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.
  16727. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16728. */
  16729. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16730. /**
  16731. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16732. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16733. * The `data` are either a numeric array either a Float32Array.
  16734. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16735. * 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).
  16736. * Note that a new underlying VertexBuffer object is created each call.
  16737. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16738. *
  16739. * Possible `kind` values :
  16740. * - VertexBuffer.PositionKind
  16741. * - VertexBuffer.UVKind
  16742. * - VertexBuffer.UV2Kind
  16743. * - VertexBuffer.UV3Kind
  16744. * - VertexBuffer.UV4Kind
  16745. * - VertexBuffer.UV5Kind
  16746. * - VertexBuffer.UV6Kind
  16747. * - VertexBuffer.ColorKind
  16748. * - VertexBuffer.MatricesIndicesKind
  16749. * - VertexBuffer.MatricesIndicesExtraKind
  16750. * - VertexBuffer.MatricesWeightsKind
  16751. * - VertexBuffer.MatricesWeightsExtraKind
  16752. *
  16753. * Returns the Mesh.
  16754. */
  16755. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16756. /**
  16757. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16758. * If the mesh has no geometry, it is simply returned as it is.
  16759. * The `data` are either a numeric array either a Float32Array.
  16760. * No new underlying VertexBuffer object is created.
  16761. * 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.
  16762. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16763. *
  16764. * Possible `kind` values :
  16765. * - VertexBuffer.PositionKind
  16766. * - VertexBuffer.UVKind
  16767. * - VertexBuffer.UV2Kind
  16768. * - VertexBuffer.UV3Kind
  16769. * - VertexBuffer.UV4Kind
  16770. * - VertexBuffer.UV5Kind
  16771. * - VertexBuffer.UV6Kind
  16772. * - VertexBuffer.ColorKind
  16773. * - VertexBuffer.MatricesIndicesKind
  16774. * - VertexBuffer.MatricesIndicesExtraKind
  16775. * - VertexBuffer.MatricesWeightsKind
  16776. * - VertexBuffer.MatricesWeightsExtraKind
  16777. *
  16778. * Returns the Mesh.
  16779. */
  16780. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16781. /**
  16782. * Sets the mesh indices.
  16783. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16784. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16785. * This method creates a new index buffer each call.
  16786. * Returns the Mesh.
  16787. */
  16788. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16789. /**
  16790. * Boolean : True if the mesh owns the requested kind of data.
  16791. */
  16792. isVerticesDataPresent(kind: string): boolean;
  16793. /**
  16794. * Returns an array of indices (IndicesArray).
  16795. */
  16796. getIndices(): Nullable<IndicesArray>;
  16797. get _positions(): Nullable<Vector3[]>;
  16798. /**
  16799. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16800. * This means the mesh underlying bounding box and sphere are recomputed.
  16801. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16802. * @returns the current mesh
  16803. */
  16804. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16805. /** @hidden */
  16806. _preActivate(): InstancedMesh;
  16807. /** @hidden */
  16808. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16809. /** @hidden */
  16810. _postActivate(): void;
  16811. getWorldMatrix(): Matrix;
  16812. get isAnInstance(): boolean;
  16813. /**
  16814. * Returns the current associated LOD AbstractMesh.
  16815. */
  16816. getLOD(camera: Camera): AbstractMesh;
  16817. /** @hidden */
  16818. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16819. /** @hidden */
  16820. _syncSubMeshes(): InstancedMesh;
  16821. /** @hidden */
  16822. _generatePointsArray(): boolean;
  16823. /** @hidden */
  16824. _updateBoundingInfo(): AbstractMesh;
  16825. /**
  16826. * Creates a new InstancedMesh from the current mesh.
  16827. * - name (string) : the cloned mesh name
  16828. * - newParent (optional Node) : the optional Node to parent the clone to.
  16829. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16830. *
  16831. * Returns the clone.
  16832. */
  16833. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16834. /**
  16835. * Disposes the InstancedMesh.
  16836. * Returns nothing.
  16837. */
  16838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16839. }
  16840. module "babylonjs/Meshes/mesh" {
  16841. interface Mesh {
  16842. /**
  16843. * Register a custom buffer that will be instanced
  16844. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16845. * @param kind defines the buffer kind
  16846. * @param stride defines the stride in floats
  16847. */
  16848. registerInstancedBuffer(kind: string, stride: number): void;
  16849. /**
  16850. * true to use the edge renderer for all instances of this mesh
  16851. */
  16852. edgesShareWithInstances: boolean;
  16853. /** @hidden */
  16854. _userInstancedBuffersStorage: {
  16855. data: {
  16856. [key: string]: Float32Array;
  16857. };
  16858. sizes: {
  16859. [key: string]: number;
  16860. };
  16861. vertexBuffers: {
  16862. [key: string]: Nullable<VertexBuffer>;
  16863. };
  16864. strides: {
  16865. [key: string]: number;
  16866. };
  16867. };
  16868. }
  16869. }
  16870. module "babylonjs/Meshes/abstractMesh" {
  16871. interface AbstractMesh {
  16872. /**
  16873. * Object used to store instanced buffers defined by user
  16874. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16875. */
  16876. instancedBuffers: {
  16877. [key: string]: any;
  16878. };
  16879. }
  16880. }
  16881. }
  16882. declare module "babylonjs/Materials/shaderMaterial" {
  16883. import { Nullable } from "babylonjs/types";
  16884. import { Scene } from "babylonjs/scene";
  16885. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16887. import { Mesh } from "babylonjs/Meshes/mesh";
  16888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16890. import { Effect } from "babylonjs/Materials/effect";
  16891. import { Material } from "babylonjs/Materials/material";
  16892. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16893. /**
  16894. * Defines the options associated with the creation of a shader material.
  16895. */
  16896. export interface IShaderMaterialOptions {
  16897. /**
  16898. * Does the material work in alpha blend mode
  16899. */
  16900. needAlphaBlending: boolean;
  16901. /**
  16902. * Does the material work in alpha test mode
  16903. */
  16904. needAlphaTesting: boolean;
  16905. /**
  16906. * The list of attribute names used in the shader
  16907. */
  16908. attributes: string[];
  16909. /**
  16910. * The list of unifrom names used in the shader
  16911. */
  16912. uniforms: string[];
  16913. /**
  16914. * The list of UBO names used in the shader
  16915. */
  16916. uniformBuffers: string[];
  16917. /**
  16918. * The list of sampler names used in the shader
  16919. */
  16920. samplers: string[];
  16921. /**
  16922. * The list of defines used in the shader
  16923. */
  16924. defines: string[];
  16925. }
  16926. /**
  16927. * 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.
  16928. *
  16929. * This returned material effects how the mesh will look based on the code in the shaders.
  16930. *
  16931. * @see https://doc.babylonjs.com/how_to/shader_material
  16932. */
  16933. export class ShaderMaterial extends Material {
  16934. private _shaderPath;
  16935. private _options;
  16936. private _textures;
  16937. private _textureArrays;
  16938. private _floats;
  16939. private _ints;
  16940. private _floatsArrays;
  16941. private _colors3;
  16942. private _colors3Arrays;
  16943. private _colors4;
  16944. private _colors4Arrays;
  16945. private _vectors2;
  16946. private _vectors3;
  16947. private _vectors4;
  16948. private _matrices;
  16949. private _matrixArrays;
  16950. private _matrices3x3;
  16951. private _matrices2x2;
  16952. private _vectors2Arrays;
  16953. private _vectors3Arrays;
  16954. private _vectors4Arrays;
  16955. private _cachedWorldViewMatrix;
  16956. private _cachedWorldViewProjectionMatrix;
  16957. private _renderId;
  16958. private _multiview;
  16959. private _cachedDefines;
  16960. /** Define the Url to load snippets */
  16961. static SnippetUrl: string;
  16962. /** Snippet ID if the material was created from the snippet server */
  16963. snippetId: string;
  16964. /**
  16965. * Instantiate a new shader material.
  16966. * 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.
  16967. * This returned material effects how the mesh will look based on the code in the shaders.
  16968. * @see https://doc.babylonjs.com/how_to/shader_material
  16969. * @param name Define the name of the material in the scene
  16970. * @param scene Define the scene the material belongs to
  16971. * @param shaderPath Defines the route to the shader code in one of three ways:
  16972. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16973. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16974. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16975. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16976. * @param options Define the options used to create the shader
  16977. */
  16978. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16979. /**
  16980. * Gets the shader path used to define the shader code
  16981. * It can be modified to trigger a new compilation
  16982. */
  16983. get shaderPath(): any;
  16984. /**
  16985. * Sets the shader path used to define the shader code
  16986. * It can be modified to trigger a new compilation
  16987. */
  16988. set shaderPath(shaderPath: any);
  16989. /**
  16990. * Gets the options used to compile the shader.
  16991. * They can be modified to trigger a new compilation
  16992. */
  16993. get options(): IShaderMaterialOptions;
  16994. /**
  16995. * Gets the current class name of the material e.g. "ShaderMaterial"
  16996. * Mainly use in serialization.
  16997. * @returns the class name
  16998. */
  16999. getClassName(): string;
  17000. /**
  17001. * Specifies if the material will require alpha blending
  17002. * @returns a boolean specifying if alpha blending is needed
  17003. */
  17004. needAlphaBlending(): boolean;
  17005. /**
  17006. * Specifies if this material should be rendered in alpha test mode
  17007. * @returns a boolean specifying if an alpha test is needed.
  17008. */
  17009. needAlphaTesting(): boolean;
  17010. private _checkUniform;
  17011. /**
  17012. * Set a texture in the shader.
  17013. * @param name Define the name of the uniform samplers as defined in the shader
  17014. * @param texture Define the texture to bind to this sampler
  17015. * @return the material itself allowing "fluent" like uniform updates
  17016. */
  17017. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17018. /**
  17019. * Set a texture array in the shader.
  17020. * @param name Define the name of the uniform sampler array as defined in the shader
  17021. * @param textures Define the list of textures to bind to this sampler
  17022. * @return the material itself allowing "fluent" like uniform updates
  17023. */
  17024. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17025. /**
  17026. * Set a float in the shader.
  17027. * @param name Define the name of the uniform as defined in the shader
  17028. * @param value Define the value to give to the uniform
  17029. * @return the material itself allowing "fluent" like uniform updates
  17030. */
  17031. setFloat(name: string, value: number): ShaderMaterial;
  17032. /**
  17033. * Set a int in the shader.
  17034. * @param name Define the name of the uniform as defined in the shader
  17035. * @param value Define the value to give to the uniform
  17036. * @return the material itself allowing "fluent" like uniform updates
  17037. */
  17038. setInt(name: string, value: number): ShaderMaterial;
  17039. /**
  17040. * Set an array of floats in the shader.
  17041. * @param name Define the name of the uniform as defined in the shader
  17042. * @param value Define the value to give to the uniform
  17043. * @return the material itself allowing "fluent" like uniform updates
  17044. */
  17045. setFloats(name: string, value: number[]): ShaderMaterial;
  17046. /**
  17047. * Set a vec3 in the shader from a Color3.
  17048. * @param name Define the name of the uniform as defined in the shader
  17049. * @param value Define the value to give to the uniform
  17050. * @return the material itself allowing "fluent" like uniform updates
  17051. */
  17052. setColor3(name: string, value: Color3): ShaderMaterial;
  17053. /**
  17054. * Set a vec3 array in the shader from a Color3 array.
  17055. * @param name Define the name of the uniform as defined in the shader
  17056. * @param value Define the value to give to the uniform
  17057. * @return the material itself allowing "fluent" like uniform updates
  17058. */
  17059. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17060. /**
  17061. * Set a vec4 in the shader from a Color4.
  17062. * @param name Define the name of the uniform as defined in the shader
  17063. * @param value Define the value to give to the uniform
  17064. * @return the material itself allowing "fluent" like uniform updates
  17065. */
  17066. setColor4(name: string, value: Color4): ShaderMaterial;
  17067. /**
  17068. * Set a vec4 array in the shader from a Color4 array.
  17069. * @param name Define the name of the uniform as defined in the shader
  17070. * @param value Define the value to give to the uniform
  17071. * @return the material itself allowing "fluent" like uniform updates
  17072. */
  17073. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17074. /**
  17075. * Set a vec2 in the shader from a Vector2.
  17076. * @param name Define the name of the uniform as defined in the shader
  17077. * @param value Define the value to give to the uniform
  17078. * @return the material itself allowing "fluent" like uniform updates
  17079. */
  17080. setVector2(name: string, value: Vector2): ShaderMaterial;
  17081. /**
  17082. * Set a vec3 in the shader from a Vector3.
  17083. * @param name Define the name of the uniform as defined in the shader
  17084. * @param value Define the value to give to the uniform
  17085. * @return the material itself allowing "fluent" like uniform updates
  17086. */
  17087. setVector3(name: string, value: Vector3): ShaderMaterial;
  17088. /**
  17089. * Set a vec4 in the shader from a Vector4.
  17090. * @param name Define the name of the uniform as defined in the shader
  17091. * @param value Define the value to give to the uniform
  17092. * @return the material itself allowing "fluent" like uniform updates
  17093. */
  17094. setVector4(name: string, value: Vector4): ShaderMaterial;
  17095. /**
  17096. * Set a mat4 in the shader from a Matrix.
  17097. * @param name Define the name of the uniform as defined in the shader
  17098. * @param value Define the value to give to the uniform
  17099. * @return the material itself allowing "fluent" like uniform updates
  17100. */
  17101. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17102. /**
  17103. * Set a float32Array in the shader from a matrix array.
  17104. * @param name Define the name of the uniform as defined in the shader
  17105. * @param value Define the value to give to the uniform
  17106. * @return the material itself allowing "fluent" like uniform updates
  17107. */
  17108. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17109. /**
  17110. * Set a mat3 in the shader from a Float32Array.
  17111. * @param name Define the name of the uniform as defined in the shader
  17112. * @param value Define the value to give to the uniform
  17113. * @return the material itself allowing "fluent" like uniform updates
  17114. */
  17115. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17116. /**
  17117. * Set a mat2 in the shader from a Float32Array.
  17118. * @param name Define the name of the uniform as defined in the shader
  17119. * @param value Define the value to give to the uniform
  17120. * @return the material itself allowing "fluent" like uniform updates
  17121. */
  17122. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17123. /**
  17124. * Set a vec2 array in the shader from a number array.
  17125. * @param name Define the name of the uniform as defined in the shader
  17126. * @param value Define the value to give to the uniform
  17127. * @return the material itself allowing "fluent" like uniform updates
  17128. */
  17129. setArray2(name: string, value: number[]): ShaderMaterial;
  17130. /**
  17131. * Set a vec3 array in the shader from a number array.
  17132. * @param name Define the name of the uniform as defined in the shader
  17133. * @param value Define the value to give to the uniform
  17134. * @return the material itself allowing "fluent" like uniform updates
  17135. */
  17136. setArray3(name: string, value: number[]): ShaderMaterial;
  17137. /**
  17138. * Set a vec4 array in the shader from a number array.
  17139. * @param name Define the name of the uniform as defined in the shader
  17140. * @param value Define the value to give to the uniform
  17141. * @return the material itself allowing "fluent" like uniform updates
  17142. */
  17143. setArray4(name: string, value: number[]): ShaderMaterial;
  17144. private _checkCache;
  17145. /**
  17146. * Specifies that the submesh is ready to be used
  17147. * @param mesh defines the mesh to check
  17148. * @param subMesh defines which submesh to check
  17149. * @param useInstances specifies that instances should be used
  17150. * @returns a boolean indicating that the submesh is ready or not
  17151. */
  17152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17153. /**
  17154. * Checks if the material is ready to render the requested mesh
  17155. * @param mesh Define the mesh to render
  17156. * @param useInstances Define whether or not the material is used with instances
  17157. * @returns true if ready, otherwise false
  17158. */
  17159. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17160. /**
  17161. * Binds the world matrix to the material
  17162. * @param world defines the world transformation matrix
  17163. * @param effectOverride - If provided, use this effect instead of internal effect
  17164. */
  17165. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17166. /**
  17167. * Binds the submesh to this material by preparing the effect and shader to draw
  17168. * @param world defines the world transformation matrix
  17169. * @param mesh defines the mesh containing the submesh
  17170. * @param subMesh defines the submesh to bind the material to
  17171. */
  17172. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17173. /**
  17174. * Binds the material to the mesh
  17175. * @param world defines the world transformation matrix
  17176. * @param mesh defines the mesh to bind the material to
  17177. * @param effectOverride - If provided, use this effect instead of internal effect
  17178. */
  17179. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17180. protected _afterBind(mesh?: Mesh): void;
  17181. /**
  17182. * Gets the active textures from the material
  17183. * @returns an array of textures
  17184. */
  17185. getActiveTextures(): BaseTexture[];
  17186. /**
  17187. * Specifies if the material uses a texture
  17188. * @param texture defines the texture to check against the material
  17189. * @returns a boolean specifying if the material uses the texture
  17190. */
  17191. hasTexture(texture: BaseTexture): boolean;
  17192. /**
  17193. * Makes a duplicate of the material, and gives it a new name
  17194. * @param name defines the new name for the duplicated material
  17195. * @returns the cloned material
  17196. */
  17197. clone(name: string): ShaderMaterial;
  17198. /**
  17199. * Disposes the material
  17200. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17201. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17202. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17203. */
  17204. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17205. /**
  17206. * Serializes this material in a JSON representation
  17207. * @returns the serialized material object
  17208. */
  17209. serialize(): any;
  17210. /**
  17211. * Creates a shader material from parsed shader material data
  17212. * @param source defines the JSON represnetation of the material
  17213. * @param scene defines the hosting scene
  17214. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17215. * @returns a new material
  17216. */
  17217. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17218. /**
  17219. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17220. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17221. * @param url defines the url to load from
  17222. * @param scene defines the hosting scene
  17223. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17224. * @returns a promise that will resolve to the new ShaderMaterial
  17225. */
  17226. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17227. /**
  17228. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17229. * @param snippetId defines the snippet to load
  17230. * @param scene defines the hosting scene
  17231. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17232. * @returns a promise that will resolve to the new ShaderMaterial
  17233. */
  17234. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17235. }
  17236. }
  17237. declare module "babylonjs/Shaders/color.fragment" {
  17238. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17239. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17240. /** @hidden */
  17241. export var colorPixelShader: {
  17242. name: string;
  17243. shader: string;
  17244. };
  17245. }
  17246. declare module "babylonjs/Shaders/color.vertex" {
  17247. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17248. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17249. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17250. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17251. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17252. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17253. /** @hidden */
  17254. export var colorVertexShader: {
  17255. name: string;
  17256. shader: string;
  17257. };
  17258. }
  17259. declare module "babylonjs/Meshes/linesMesh" {
  17260. import { Nullable } from "babylonjs/types";
  17261. import { Scene } from "babylonjs/scene";
  17262. import { Color3 } from "babylonjs/Maths/math.color";
  17263. import { Node } from "babylonjs/node";
  17264. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17265. import { Mesh } from "babylonjs/Meshes/mesh";
  17266. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17267. import { Effect } from "babylonjs/Materials/effect";
  17268. import { Material } from "babylonjs/Materials/material";
  17269. import "babylonjs/Shaders/color.fragment";
  17270. import "babylonjs/Shaders/color.vertex";
  17271. /**
  17272. * Line mesh
  17273. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17274. */
  17275. export class LinesMesh extends Mesh {
  17276. /**
  17277. * If vertex color should be applied to the mesh
  17278. */
  17279. readonly useVertexColor?: boolean | undefined;
  17280. /**
  17281. * If vertex alpha should be applied to the mesh
  17282. */
  17283. readonly useVertexAlpha?: boolean | undefined;
  17284. /**
  17285. * Color of the line (Default: White)
  17286. */
  17287. color: Color3;
  17288. /**
  17289. * Alpha of the line (Default: 1)
  17290. */
  17291. alpha: number;
  17292. /**
  17293. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17294. * This margin is expressed in world space coordinates, so its value may vary.
  17295. * Default value is 0.1
  17296. */
  17297. intersectionThreshold: number;
  17298. private _colorShader;
  17299. private color4;
  17300. /**
  17301. * Creates a new LinesMesh
  17302. * @param name defines the name
  17303. * @param scene defines the hosting scene
  17304. * @param parent defines the parent mesh if any
  17305. * @param source defines the optional source LinesMesh used to clone data from
  17306. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17307. * When false, achieved by calling a clone(), also passing False.
  17308. * This will make creation of children, recursive.
  17309. * @param useVertexColor defines if this LinesMesh supports vertex color
  17310. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17311. */
  17312. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17313. /**
  17314. * If vertex color should be applied to the mesh
  17315. */
  17316. useVertexColor?: boolean | undefined,
  17317. /**
  17318. * If vertex alpha should be applied to the mesh
  17319. */
  17320. useVertexAlpha?: boolean | undefined);
  17321. private _addClipPlaneDefine;
  17322. private _removeClipPlaneDefine;
  17323. isReady(): boolean;
  17324. /**
  17325. * Returns the string "LineMesh"
  17326. */
  17327. getClassName(): string;
  17328. /**
  17329. * @hidden
  17330. */
  17331. get material(): Material;
  17332. /**
  17333. * @hidden
  17334. */
  17335. set material(value: Material);
  17336. /**
  17337. * @hidden
  17338. */
  17339. get checkCollisions(): boolean;
  17340. /** @hidden */
  17341. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17342. /** @hidden */
  17343. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17344. /**
  17345. * Disposes of the line mesh
  17346. * @param doNotRecurse If children should be disposed
  17347. */
  17348. dispose(doNotRecurse?: boolean): void;
  17349. /**
  17350. * Returns a new LineMesh object cloned from the current one.
  17351. */
  17352. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17353. /**
  17354. * Creates a new InstancedLinesMesh object from the mesh model.
  17355. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17356. * @param name defines the name of the new instance
  17357. * @returns a new InstancedLinesMesh
  17358. */
  17359. createInstance(name: string): InstancedLinesMesh;
  17360. }
  17361. /**
  17362. * Creates an instance based on a source LinesMesh
  17363. */
  17364. export class InstancedLinesMesh extends InstancedMesh {
  17365. /**
  17366. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17367. * This margin is expressed in world space coordinates, so its value may vary.
  17368. * Initilized with the intersectionThreshold value of the source LinesMesh
  17369. */
  17370. intersectionThreshold: number;
  17371. constructor(name: string, source: LinesMesh);
  17372. /**
  17373. * Returns the string "InstancedLinesMesh".
  17374. */
  17375. getClassName(): string;
  17376. }
  17377. }
  17378. declare module "babylonjs/Shaders/line.fragment" {
  17379. /** @hidden */
  17380. export var linePixelShader: {
  17381. name: string;
  17382. shader: string;
  17383. };
  17384. }
  17385. declare module "babylonjs/Shaders/line.vertex" {
  17386. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17387. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17388. /** @hidden */
  17389. export var lineVertexShader: {
  17390. name: string;
  17391. shader: string;
  17392. };
  17393. }
  17394. declare module "babylonjs/Rendering/edgesRenderer" {
  17395. import { Nullable } from "babylonjs/types";
  17396. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17398. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17399. import { IDisposable } from "babylonjs/scene";
  17400. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17401. import "babylonjs/Shaders/line.fragment";
  17402. import "babylonjs/Shaders/line.vertex";
  17403. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17404. import { SmartArray } from "babylonjs/Misc/smartArray";
  17405. module "babylonjs/scene" {
  17406. interface Scene {
  17407. /** @hidden */
  17408. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17409. }
  17410. }
  17411. module "babylonjs/Meshes/abstractMesh" {
  17412. interface AbstractMesh {
  17413. /**
  17414. * Gets the edgesRenderer associated with the mesh
  17415. */
  17416. edgesRenderer: Nullable<EdgesRenderer>;
  17417. }
  17418. }
  17419. module "babylonjs/Meshes/linesMesh" {
  17420. interface LinesMesh {
  17421. /**
  17422. * Enables the edge rendering mode on the mesh.
  17423. * This mode makes the mesh edges visible
  17424. * @param epsilon defines the maximal distance between two angles to detect a face
  17425. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17426. * @returns the currentAbstractMesh
  17427. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17428. */
  17429. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17430. }
  17431. }
  17432. module "babylonjs/Meshes/linesMesh" {
  17433. interface InstancedLinesMesh {
  17434. /**
  17435. * Enables the edge rendering mode on the mesh.
  17436. * This mode makes the mesh edges visible
  17437. * @param epsilon defines the maximal distance between two angles to detect a face
  17438. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17439. * @returns the current InstancedLinesMesh
  17440. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17441. */
  17442. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17443. }
  17444. }
  17445. /**
  17446. * Defines the minimum contract an Edges renderer should follow.
  17447. */
  17448. export interface IEdgesRenderer extends IDisposable {
  17449. /**
  17450. * Gets or sets a boolean indicating if the edgesRenderer is active
  17451. */
  17452. isEnabled: boolean;
  17453. /**
  17454. * Renders the edges of the attached mesh,
  17455. */
  17456. render(): void;
  17457. /**
  17458. * Checks wether or not the edges renderer is ready to render.
  17459. * @return true if ready, otherwise false.
  17460. */
  17461. isReady(): boolean;
  17462. /**
  17463. * List of instances to render in case the source mesh has instances
  17464. */
  17465. customInstances: SmartArray<Matrix>;
  17466. }
  17467. /**
  17468. * Defines the additional options of the edges renderer
  17469. */
  17470. export interface IEdgesRendererOptions {
  17471. /**
  17472. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17473. * If not defined, the default value is true
  17474. */
  17475. useAlternateEdgeFinder?: boolean;
  17476. /**
  17477. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17478. * If not defined, the default value is true.
  17479. * 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)
  17480. * This option is used only if useAlternateEdgeFinder = true
  17481. */
  17482. useFastVertexMerger?: boolean;
  17483. /**
  17484. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17485. * The default value is 1e-6
  17486. * This option is used only if useAlternateEdgeFinder = true
  17487. */
  17488. epsilonVertexMerge?: number;
  17489. /**
  17490. * 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
  17491. * 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.
  17492. * This option is used only if useAlternateEdgeFinder = true
  17493. */
  17494. applyTessellation?: boolean;
  17495. /**
  17496. * 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
  17497. * The default value is 1e-6
  17498. * This option is used only if useAlternateEdgeFinder = true
  17499. */
  17500. epsilonVertexAligned?: number;
  17501. }
  17502. /**
  17503. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17504. */
  17505. export class EdgesRenderer implements IEdgesRenderer {
  17506. /**
  17507. * Define the size of the edges with an orthographic camera
  17508. */
  17509. edgesWidthScalerForOrthographic: number;
  17510. /**
  17511. * Define the size of the edges with a perspective camera
  17512. */
  17513. edgesWidthScalerForPerspective: number;
  17514. protected _source: AbstractMesh;
  17515. protected _linesPositions: number[];
  17516. protected _linesNormals: number[];
  17517. protected _linesIndices: number[];
  17518. protected _epsilon: number;
  17519. protected _indicesCount: number;
  17520. protected _lineShader: ShaderMaterial;
  17521. protected _ib: DataBuffer;
  17522. protected _buffers: {
  17523. [key: string]: Nullable<VertexBuffer>;
  17524. };
  17525. protected _buffersForInstances: {
  17526. [key: string]: Nullable<VertexBuffer>;
  17527. };
  17528. protected _checkVerticesInsteadOfIndices: boolean;
  17529. protected _options: Nullable<IEdgesRendererOptions>;
  17530. private _meshRebuildObserver;
  17531. private _meshDisposeObserver;
  17532. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17533. isEnabled: boolean;
  17534. /**
  17535. * List of instances to render in case the source mesh has instances
  17536. */
  17537. customInstances: SmartArray<Matrix>;
  17538. private static GetShader;
  17539. /**
  17540. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17541. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17542. * @param source Mesh used to create edges
  17543. * @param epsilon sum of angles in adjacency to check for edge
  17544. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17545. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17546. * @param options The options to apply when generating the edges
  17547. */
  17548. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17549. protected _prepareRessources(): void;
  17550. /** @hidden */
  17551. _rebuild(): void;
  17552. /**
  17553. * Releases the required resources for the edges renderer
  17554. */
  17555. dispose(): void;
  17556. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17557. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17558. /**
  17559. * Checks if the pair of p0 and p1 is en edge
  17560. * @param faceIndex
  17561. * @param edge
  17562. * @param faceNormals
  17563. * @param p0
  17564. * @param p1
  17565. * @private
  17566. */
  17567. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17568. /**
  17569. * push line into the position, normal and index buffer
  17570. * @protected
  17571. */
  17572. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17573. /**
  17574. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17575. */
  17576. private _tessellateTriangle;
  17577. private _generateEdgesLinesAlternate;
  17578. /**
  17579. * Generates lines edges from adjacencjes
  17580. * @private
  17581. */
  17582. _generateEdgesLines(): void;
  17583. /**
  17584. * Checks wether or not the edges renderer is ready to render.
  17585. * @return true if ready, otherwise false.
  17586. */
  17587. isReady(): boolean;
  17588. /**
  17589. * Renders the edges of the attached mesh,
  17590. */
  17591. render(): void;
  17592. }
  17593. /**
  17594. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17595. */
  17596. export class LineEdgesRenderer extends EdgesRenderer {
  17597. /**
  17598. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17599. * @param source LineMesh used to generate edges
  17600. * @param epsilon not important (specified angle for edge detection)
  17601. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17602. */
  17603. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17604. /**
  17605. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17606. */
  17607. _generateEdgesLines(): void;
  17608. }
  17609. }
  17610. declare module "babylonjs/Rendering/renderingGroup" {
  17611. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17612. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17614. import { Nullable } from "babylonjs/types";
  17615. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17616. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17617. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17618. import { Material } from "babylonjs/Materials/material";
  17619. import { Scene } from "babylonjs/scene";
  17620. /**
  17621. * This represents the object necessary to create a rendering group.
  17622. * This is exclusively used and created by the rendering manager.
  17623. * To modify the behavior, you use the available helpers in your scene or meshes.
  17624. * @hidden
  17625. */
  17626. export class RenderingGroup {
  17627. index: number;
  17628. private static _zeroVector;
  17629. private _scene;
  17630. private _opaqueSubMeshes;
  17631. private _transparentSubMeshes;
  17632. private _alphaTestSubMeshes;
  17633. private _depthOnlySubMeshes;
  17634. private _particleSystems;
  17635. private _spriteManagers;
  17636. private _opaqueSortCompareFn;
  17637. private _alphaTestSortCompareFn;
  17638. private _transparentSortCompareFn;
  17639. private _renderOpaque;
  17640. private _renderAlphaTest;
  17641. private _renderTransparent;
  17642. /** @hidden */
  17643. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17644. onBeforeTransparentRendering: () => void;
  17645. /**
  17646. * Set the opaque sort comparison function.
  17647. * If null the sub meshes will be render in the order they were created
  17648. */
  17649. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17650. /**
  17651. * Set the alpha test sort comparison function.
  17652. * If null the sub meshes will be render in the order they were created
  17653. */
  17654. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17655. /**
  17656. * Set the transparent sort comparison function.
  17657. * If null the sub meshes will be render in the order they were created
  17658. */
  17659. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17660. /**
  17661. * Creates a new rendering group.
  17662. * @param index The rendering group index
  17663. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17664. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17665. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17666. */
  17667. 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>);
  17668. /**
  17669. * Render all the sub meshes contained in the group.
  17670. * @param customRenderFunction Used to override the default render behaviour of the group.
  17671. * @returns true if rendered some submeshes.
  17672. */
  17673. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17674. /**
  17675. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17676. * @param subMeshes The submeshes to render
  17677. */
  17678. private renderOpaqueSorted;
  17679. /**
  17680. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17681. * @param subMeshes The submeshes to render
  17682. */
  17683. private renderAlphaTestSorted;
  17684. /**
  17685. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17686. * @param subMeshes The submeshes to render
  17687. */
  17688. private renderTransparentSorted;
  17689. /**
  17690. * Renders the submeshes in a specified order.
  17691. * @param subMeshes The submeshes to sort before render
  17692. * @param sortCompareFn The comparison function use to sort
  17693. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17694. * @param transparent Specifies to activate blending if true
  17695. */
  17696. private static renderSorted;
  17697. /**
  17698. * Renders the submeshes in the order they were dispatched (no sort applied).
  17699. * @param subMeshes The submeshes to render
  17700. */
  17701. private static renderUnsorted;
  17702. /**
  17703. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17704. * are rendered back to front if in the same alpha index.
  17705. *
  17706. * @param a The first submesh
  17707. * @param b The second submesh
  17708. * @returns The result of the comparison
  17709. */
  17710. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17711. /**
  17712. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17713. * are rendered back to front.
  17714. *
  17715. * @param a The first submesh
  17716. * @param b The second submesh
  17717. * @returns The result of the comparison
  17718. */
  17719. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17720. /**
  17721. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17722. * are rendered front to back (prevent overdraw).
  17723. *
  17724. * @param a The first submesh
  17725. * @param b The second submesh
  17726. * @returns The result of the comparison
  17727. */
  17728. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17729. /**
  17730. * Resets the different lists of submeshes to prepare a new frame.
  17731. */
  17732. prepare(): void;
  17733. dispose(): void;
  17734. /**
  17735. * Inserts the submesh in its correct queue depending on its material.
  17736. * @param subMesh The submesh to dispatch
  17737. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17738. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17739. */
  17740. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17741. dispatchSprites(spriteManager: ISpriteManager): void;
  17742. dispatchParticles(particleSystem: IParticleSystem): void;
  17743. private _renderParticles;
  17744. private _renderSprites;
  17745. }
  17746. }
  17747. declare module "babylonjs/Rendering/renderingManager" {
  17748. import { Nullable } from "babylonjs/types";
  17749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17751. import { SmartArray } from "babylonjs/Misc/smartArray";
  17752. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17753. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17754. import { Material } from "babylonjs/Materials/material";
  17755. import { Scene } from "babylonjs/scene";
  17756. import { Camera } from "babylonjs/Cameras/camera";
  17757. /**
  17758. * Interface describing the different options available in the rendering manager
  17759. * regarding Auto Clear between groups.
  17760. */
  17761. export interface IRenderingManagerAutoClearSetup {
  17762. /**
  17763. * Defines whether or not autoclear is enable.
  17764. */
  17765. autoClear: boolean;
  17766. /**
  17767. * Defines whether or not to autoclear the depth buffer.
  17768. */
  17769. depth: boolean;
  17770. /**
  17771. * Defines whether or not to autoclear the stencil buffer.
  17772. */
  17773. stencil: boolean;
  17774. }
  17775. /**
  17776. * This class is used by the onRenderingGroupObservable
  17777. */
  17778. export class RenderingGroupInfo {
  17779. /**
  17780. * The Scene that being rendered
  17781. */
  17782. scene: Scene;
  17783. /**
  17784. * The camera currently used for the rendering pass
  17785. */
  17786. camera: Nullable<Camera>;
  17787. /**
  17788. * The ID of the renderingGroup being processed
  17789. */
  17790. renderingGroupId: number;
  17791. }
  17792. /**
  17793. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17794. * It is enable to manage the different groups as well as the different necessary sort functions.
  17795. * This should not be used directly aside of the few static configurations
  17796. */
  17797. export class RenderingManager {
  17798. /**
  17799. * The max id used for rendering groups (not included)
  17800. */
  17801. static MAX_RENDERINGGROUPS: number;
  17802. /**
  17803. * The min id used for rendering groups (included)
  17804. */
  17805. static MIN_RENDERINGGROUPS: number;
  17806. /**
  17807. * Used to globally prevent autoclearing scenes.
  17808. */
  17809. static AUTOCLEAR: boolean;
  17810. /**
  17811. * @hidden
  17812. */
  17813. _useSceneAutoClearSetup: boolean;
  17814. private _scene;
  17815. private _renderingGroups;
  17816. private _depthStencilBufferAlreadyCleaned;
  17817. private _autoClearDepthStencil;
  17818. private _customOpaqueSortCompareFn;
  17819. private _customAlphaTestSortCompareFn;
  17820. private _customTransparentSortCompareFn;
  17821. private _renderingGroupInfo;
  17822. /**
  17823. * Instantiates a new rendering group for a particular scene
  17824. * @param scene Defines the scene the groups belongs to
  17825. */
  17826. constructor(scene: Scene);
  17827. private _clearDepthStencilBuffer;
  17828. /**
  17829. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17830. * @hidden
  17831. */
  17832. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17833. /**
  17834. * Resets the different information of the group to prepare a new frame
  17835. * @hidden
  17836. */
  17837. reset(): void;
  17838. /**
  17839. * Dispose and release the group and its associated resources.
  17840. * @hidden
  17841. */
  17842. dispose(): void;
  17843. /**
  17844. * Clear the info related to rendering groups preventing retention points during dispose.
  17845. */
  17846. freeRenderingGroups(): void;
  17847. private _prepareRenderingGroup;
  17848. /**
  17849. * Add a sprite manager to the rendering manager in order to render it this frame.
  17850. * @param spriteManager Define the sprite manager to render
  17851. */
  17852. dispatchSprites(spriteManager: ISpriteManager): void;
  17853. /**
  17854. * Add a particle system to the rendering manager in order to render it this frame.
  17855. * @param particleSystem Define the particle system to render
  17856. */
  17857. dispatchParticles(particleSystem: IParticleSystem): void;
  17858. /**
  17859. * Add a submesh to the manager in order to render it this frame
  17860. * @param subMesh The submesh to dispatch
  17861. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17862. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17863. */
  17864. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17865. /**
  17866. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17867. * This allowed control for front to back rendering or reversly depending of the special needs.
  17868. *
  17869. * @param renderingGroupId The rendering group id corresponding to its index
  17870. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17871. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17872. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17873. */
  17874. 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;
  17875. /**
  17876. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17877. *
  17878. * @param renderingGroupId The rendering group id corresponding to its index
  17879. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17880. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17881. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17882. */
  17883. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17884. /**
  17885. * Gets the current auto clear configuration for one rendering group of the rendering
  17886. * manager.
  17887. * @param index the rendering group index to get the information for
  17888. * @returns The auto clear setup for the requested rendering group
  17889. */
  17890. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17891. }
  17892. }
  17893. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17894. import { SmartArray } from "babylonjs/Misc/smartArray";
  17895. import { Nullable } from "babylonjs/types";
  17896. import { Scene } from "babylonjs/scene";
  17897. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17898. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17900. import { Mesh } from "babylonjs/Meshes/mesh";
  17901. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17902. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17903. import { Effect } from "babylonjs/Materials/effect";
  17904. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17905. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17906. import "babylonjs/Shaders/shadowMap.fragment";
  17907. import "babylonjs/Shaders/shadowMap.vertex";
  17908. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17909. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17910. import { Observable } from "babylonjs/Misc/observable";
  17911. /**
  17912. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17913. */
  17914. export interface ICustomShaderOptions {
  17915. /**
  17916. * Gets or sets the custom shader name to use
  17917. */
  17918. shaderName: string;
  17919. /**
  17920. * The list of attribute names used in the shader
  17921. */
  17922. attributes?: string[];
  17923. /**
  17924. * The list of unifrom names used in the shader
  17925. */
  17926. uniforms?: string[];
  17927. /**
  17928. * The list of sampler names used in the shader
  17929. */
  17930. samplers?: string[];
  17931. /**
  17932. * The list of defines used in the shader
  17933. */
  17934. defines?: string[];
  17935. }
  17936. /**
  17937. * Interface to implement to create a shadow generator compatible with BJS.
  17938. */
  17939. export interface IShadowGenerator {
  17940. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17941. id: string;
  17942. /**
  17943. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17944. * @returns The render target texture if present otherwise, null
  17945. */
  17946. getShadowMap(): Nullable<RenderTargetTexture>;
  17947. /**
  17948. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17949. * @param subMesh The submesh we want to render in the shadow map
  17950. * @param useInstances Defines wether will draw in the map using instances
  17951. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17952. * @returns true if ready otherwise, false
  17953. */
  17954. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17955. /**
  17956. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17957. * @param defines Defines of the material we want to update
  17958. * @param lightIndex Index of the light in the enabled light list of the material
  17959. */
  17960. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17961. /**
  17962. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17963. * defined in the generator but impacting the effect).
  17964. * It implies the unifroms available on the materials are the standard BJS ones.
  17965. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17966. * @param effect The effect we are binfing the information for
  17967. */
  17968. bindShadowLight(lightIndex: string, effect: Effect): void;
  17969. /**
  17970. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17971. * (eq to shadow prjection matrix * light transform matrix)
  17972. * @returns The transform matrix used to create the shadow map
  17973. */
  17974. getTransformMatrix(): Matrix;
  17975. /**
  17976. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17977. * Cube and 2D textures for instance.
  17978. */
  17979. recreateShadowMap(): void;
  17980. /**
  17981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17982. * @param onCompiled Callback triggered at the and of the effects compilation
  17983. * @param options Sets of optional options forcing the compilation with different modes
  17984. */
  17985. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17986. useInstances: boolean;
  17987. }>): void;
  17988. /**
  17989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17990. * @param options Sets of optional options forcing the compilation with different modes
  17991. * @returns A promise that resolves when the compilation completes
  17992. */
  17993. forceCompilationAsync(options?: Partial<{
  17994. useInstances: boolean;
  17995. }>): Promise<void>;
  17996. /**
  17997. * Serializes the shadow generator setup to a json object.
  17998. * @returns The serialized JSON object
  17999. */
  18000. serialize(): any;
  18001. /**
  18002. * Disposes the Shadow map and related Textures and effects.
  18003. */
  18004. dispose(): void;
  18005. }
  18006. /**
  18007. * Default implementation IShadowGenerator.
  18008. * This is the main object responsible of generating shadows in the framework.
  18009. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18010. */
  18011. export class ShadowGenerator implements IShadowGenerator {
  18012. /**
  18013. * Name of the shadow generator class
  18014. */
  18015. static CLASSNAME: string;
  18016. /**
  18017. * Shadow generator mode None: no filtering applied.
  18018. */
  18019. static readonly FILTER_NONE: number;
  18020. /**
  18021. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18022. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18023. */
  18024. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18025. /**
  18026. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18027. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18028. */
  18029. static readonly FILTER_POISSONSAMPLING: number;
  18030. /**
  18031. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18032. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18033. */
  18034. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18035. /**
  18036. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18037. * edge artifacts on steep falloff.
  18038. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18039. */
  18040. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18041. /**
  18042. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18043. * edge artifacts on steep falloff.
  18044. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18045. */
  18046. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18047. /**
  18048. * Shadow generator mode PCF: Percentage Closer Filtering
  18049. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18050. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18051. */
  18052. static readonly FILTER_PCF: number;
  18053. /**
  18054. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18055. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18056. * Contact Hardening
  18057. */
  18058. static readonly FILTER_PCSS: number;
  18059. /**
  18060. * Reserved for PCF and PCSS
  18061. * Highest Quality.
  18062. *
  18063. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18064. *
  18065. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18066. */
  18067. static readonly QUALITY_HIGH: number;
  18068. /**
  18069. * Reserved for PCF and PCSS
  18070. * Good tradeoff for quality/perf cross devices
  18071. *
  18072. * Execute PCF on a 3*3 kernel.
  18073. *
  18074. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18075. */
  18076. static readonly QUALITY_MEDIUM: number;
  18077. /**
  18078. * Reserved for PCF and PCSS
  18079. * The lowest quality but the fastest.
  18080. *
  18081. * Execute PCF on a 1*1 kernel.
  18082. *
  18083. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18084. */
  18085. static readonly QUALITY_LOW: number;
  18086. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18087. id: string;
  18088. /** Gets or sets the custom shader name to use */
  18089. customShaderOptions: ICustomShaderOptions;
  18090. /**
  18091. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18092. */
  18093. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18094. /**
  18095. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18096. */
  18097. onAfterShadowMapRenderObservable: Observable<Effect>;
  18098. /**
  18099. * Observable triggered before a mesh is rendered in the shadow map.
  18100. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18101. */
  18102. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18103. /**
  18104. * Observable triggered after a mesh is rendered in the shadow map.
  18105. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18106. */
  18107. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18108. protected _bias: number;
  18109. /**
  18110. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18111. */
  18112. get bias(): number;
  18113. /**
  18114. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18115. */
  18116. set bias(bias: number);
  18117. protected _normalBias: number;
  18118. /**
  18119. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18120. */
  18121. get normalBias(): number;
  18122. /**
  18123. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18124. */
  18125. set normalBias(normalBias: number);
  18126. protected _blurBoxOffset: number;
  18127. /**
  18128. * Gets the blur box offset: offset applied during the blur pass.
  18129. * Only useful if useKernelBlur = false
  18130. */
  18131. get blurBoxOffset(): number;
  18132. /**
  18133. * Sets the blur box offset: offset applied during the blur pass.
  18134. * Only useful if useKernelBlur = false
  18135. */
  18136. set blurBoxOffset(value: number);
  18137. protected _blurScale: number;
  18138. /**
  18139. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18140. * 2 means half of the size.
  18141. */
  18142. get blurScale(): number;
  18143. /**
  18144. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18145. * 2 means half of the size.
  18146. */
  18147. set blurScale(value: number);
  18148. protected _blurKernel: number;
  18149. /**
  18150. * Gets the blur kernel: kernel size of the blur pass.
  18151. * Only useful if useKernelBlur = true
  18152. */
  18153. get blurKernel(): number;
  18154. /**
  18155. * Sets the blur kernel: kernel size of the blur pass.
  18156. * Only useful if useKernelBlur = true
  18157. */
  18158. set blurKernel(value: number);
  18159. protected _useKernelBlur: boolean;
  18160. /**
  18161. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18162. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18163. */
  18164. get useKernelBlur(): boolean;
  18165. /**
  18166. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18167. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18168. */
  18169. set useKernelBlur(value: boolean);
  18170. protected _depthScale: number;
  18171. /**
  18172. * Gets the depth scale used in ESM mode.
  18173. */
  18174. get depthScale(): number;
  18175. /**
  18176. * Sets the depth scale used in ESM mode.
  18177. * This can override the scale stored on the light.
  18178. */
  18179. set depthScale(value: number);
  18180. protected _validateFilter(filter: number): number;
  18181. protected _filter: number;
  18182. /**
  18183. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18184. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18185. */
  18186. get filter(): number;
  18187. /**
  18188. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18189. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18190. */
  18191. set filter(value: number);
  18192. /**
  18193. * Gets if the current filter is set to Poisson Sampling.
  18194. */
  18195. get usePoissonSampling(): boolean;
  18196. /**
  18197. * Sets the current filter to Poisson Sampling.
  18198. */
  18199. set usePoissonSampling(value: boolean);
  18200. /**
  18201. * Gets if the current filter is set to ESM.
  18202. */
  18203. get useExponentialShadowMap(): boolean;
  18204. /**
  18205. * Sets the current filter is to ESM.
  18206. */
  18207. set useExponentialShadowMap(value: boolean);
  18208. /**
  18209. * Gets if the current filter is set to filtered ESM.
  18210. */
  18211. get useBlurExponentialShadowMap(): boolean;
  18212. /**
  18213. * Gets if the current filter is set to filtered ESM.
  18214. */
  18215. set useBlurExponentialShadowMap(value: boolean);
  18216. /**
  18217. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18218. * exponential to prevent steep falloff artifacts).
  18219. */
  18220. get useCloseExponentialShadowMap(): boolean;
  18221. /**
  18222. * Sets the current filter to "close ESM" (using the inverse of the
  18223. * exponential to prevent steep falloff artifacts).
  18224. */
  18225. set useCloseExponentialShadowMap(value: boolean);
  18226. /**
  18227. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18228. * exponential to prevent steep falloff artifacts).
  18229. */
  18230. get useBlurCloseExponentialShadowMap(): boolean;
  18231. /**
  18232. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18233. * exponential to prevent steep falloff artifacts).
  18234. */
  18235. set useBlurCloseExponentialShadowMap(value: boolean);
  18236. /**
  18237. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18238. */
  18239. get usePercentageCloserFiltering(): boolean;
  18240. /**
  18241. * Sets the current filter to "PCF" (percentage closer filtering).
  18242. */
  18243. set usePercentageCloserFiltering(value: boolean);
  18244. protected _filteringQuality: number;
  18245. /**
  18246. * Gets the PCF or PCSS Quality.
  18247. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18248. */
  18249. get filteringQuality(): number;
  18250. /**
  18251. * Sets the PCF or PCSS Quality.
  18252. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18253. */
  18254. set filteringQuality(filteringQuality: number);
  18255. /**
  18256. * Gets if the current filter is set to "PCSS" (contact hardening).
  18257. */
  18258. get useContactHardeningShadow(): boolean;
  18259. /**
  18260. * Sets the current filter to "PCSS" (contact hardening).
  18261. */
  18262. set useContactHardeningShadow(value: boolean);
  18263. protected _contactHardeningLightSizeUVRatio: number;
  18264. /**
  18265. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18266. * Using a ratio helps keeping shape stability independently of the map size.
  18267. *
  18268. * It does not account for the light projection as it was having too much
  18269. * instability during the light setup or during light position changes.
  18270. *
  18271. * Only valid if useContactHardeningShadow is true.
  18272. */
  18273. get contactHardeningLightSizeUVRatio(): number;
  18274. /**
  18275. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18276. * Using a ratio helps keeping shape stability independently of the map size.
  18277. *
  18278. * It does not account for the light projection as it was having too much
  18279. * instability during the light setup or during light position changes.
  18280. *
  18281. * Only valid if useContactHardeningShadow is true.
  18282. */
  18283. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18284. protected _darkness: number;
  18285. /** Gets or sets the actual darkness of a shadow */
  18286. get darkness(): number;
  18287. set darkness(value: number);
  18288. /**
  18289. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18290. * 0 means strongest and 1 would means no shadow.
  18291. * @returns the darkness.
  18292. */
  18293. getDarkness(): number;
  18294. /**
  18295. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18296. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18297. * @returns the shadow generator allowing fluent coding.
  18298. */
  18299. setDarkness(darkness: number): ShadowGenerator;
  18300. protected _transparencyShadow: boolean;
  18301. /** Gets or sets the ability to have transparent shadow */
  18302. get transparencyShadow(): boolean;
  18303. set transparencyShadow(value: boolean);
  18304. /**
  18305. * Sets the ability to have transparent shadow (boolean).
  18306. * @param transparent True if transparent else False
  18307. * @returns the shadow generator allowing fluent coding
  18308. */
  18309. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18310. /**
  18311. * Enables or disables shadows with varying strength based on the transparency
  18312. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18313. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18314. * mesh.visibility * alphaTexture.a
  18315. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18316. */
  18317. enableSoftTransparentShadow: boolean;
  18318. protected _shadowMap: Nullable<RenderTargetTexture>;
  18319. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18320. /**
  18321. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18322. * @returns The render target texture if present otherwise, null
  18323. */
  18324. getShadowMap(): Nullable<RenderTargetTexture>;
  18325. /**
  18326. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18327. * @returns The render target texture if the shadow map is present otherwise, null
  18328. */
  18329. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18330. /**
  18331. * Gets the class name of that object
  18332. * @returns "ShadowGenerator"
  18333. */
  18334. getClassName(): string;
  18335. /**
  18336. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18337. * @param mesh Mesh to add
  18338. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18339. * @returns the Shadow Generator itself
  18340. */
  18341. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18342. /**
  18343. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18344. * @param mesh Mesh to remove
  18345. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18346. * @returns the Shadow Generator itself
  18347. */
  18348. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18349. /**
  18350. * Controls the extent to which the shadows fade out at the edge of the frustum
  18351. */
  18352. frustumEdgeFalloff: number;
  18353. protected _light: IShadowLight;
  18354. /**
  18355. * Returns the associated light object.
  18356. * @returns the light generating the shadow
  18357. */
  18358. getLight(): IShadowLight;
  18359. /**
  18360. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18361. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18362. * It might on the other hand introduce peter panning.
  18363. */
  18364. forceBackFacesOnly: boolean;
  18365. protected _scene: Scene;
  18366. protected _lightDirection: Vector3;
  18367. protected _effect: Effect;
  18368. protected _viewMatrix: Matrix;
  18369. protected _projectionMatrix: Matrix;
  18370. protected _transformMatrix: Matrix;
  18371. protected _cachedPosition: Vector3;
  18372. protected _cachedDirection: Vector3;
  18373. protected _cachedDefines: string;
  18374. protected _currentRenderID: number;
  18375. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18376. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18377. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18378. protected _blurPostProcesses: PostProcess[];
  18379. protected _mapSize: number;
  18380. protected _currentFaceIndex: number;
  18381. protected _currentFaceIndexCache: number;
  18382. protected _textureType: number;
  18383. protected _defaultTextureMatrix: Matrix;
  18384. protected _storedUniqueId: Nullable<number>;
  18385. /** @hidden */
  18386. static _SceneComponentInitialization: (scene: Scene) => void;
  18387. /**
  18388. * Creates a ShadowGenerator object.
  18389. * A ShadowGenerator is the required tool to use the shadows.
  18390. * Each light casting shadows needs to use its own ShadowGenerator.
  18391. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18392. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18393. * @param light The light object generating the shadows.
  18394. * @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.
  18395. */
  18396. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18397. protected _initializeGenerator(): void;
  18398. protected _createTargetRenderTexture(): void;
  18399. protected _initializeShadowMap(): void;
  18400. protected _initializeBlurRTTAndPostProcesses(): void;
  18401. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18402. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18403. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18404. protected _applyFilterValues(): void;
  18405. /**
  18406. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18407. * @param onCompiled Callback triggered at the and of the effects compilation
  18408. * @param options Sets of optional options forcing the compilation with different modes
  18409. */
  18410. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18411. useInstances: boolean;
  18412. }>): void;
  18413. /**
  18414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18415. * @param options Sets of optional options forcing the compilation with different modes
  18416. * @returns A promise that resolves when the compilation completes
  18417. */
  18418. forceCompilationAsync(options?: Partial<{
  18419. useInstances: boolean;
  18420. }>): Promise<void>;
  18421. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18422. private _prepareShadowDefines;
  18423. /**
  18424. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18425. * @param subMesh The submesh we want to render in the shadow map
  18426. * @param useInstances Defines wether will draw in the map using instances
  18427. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18428. * @returns true if ready otherwise, false
  18429. */
  18430. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18431. /**
  18432. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18433. * @param defines Defines of the material we want to update
  18434. * @param lightIndex Index of the light in the enabled light list of the material
  18435. */
  18436. prepareDefines(defines: any, lightIndex: number): void;
  18437. /**
  18438. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18439. * defined in the generator but impacting the effect).
  18440. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18441. * @param effect The effect we are binfing the information for
  18442. */
  18443. bindShadowLight(lightIndex: string, effect: Effect): void;
  18444. /**
  18445. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18446. * (eq to shadow prjection matrix * light transform matrix)
  18447. * @returns The transform matrix used to create the shadow map
  18448. */
  18449. getTransformMatrix(): Matrix;
  18450. /**
  18451. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18452. * Cube and 2D textures for instance.
  18453. */
  18454. recreateShadowMap(): void;
  18455. protected _disposeBlurPostProcesses(): void;
  18456. protected _disposeRTTandPostProcesses(): void;
  18457. /**
  18458. * Disposes the ShadowGenerator.
  18459. * Returns nothing.
  18460. */
  18461. dispose(): void;
  18462. /**
  18463. * Serializes the shadow generator setup to a json object.
  18464. * @returns The serialized JSON object
  18465. */
  18466. serialize(): any;
  18467. /**
  18468. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18469. * @param parsedShadowGenerator The JSON object to parse
  18470. * @param scene The scene to create the shadow map for
  18471. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18472. * @returns The parsed shadow generator
  18473. */
  18474. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18475. }
  18476. }
  18477. declare module "babylonjs/Lights/light" {
  18478. import { Nullable } from "babylonjs/types";
  18479. import { Scene } from "babylonjs/scene";
  18480. import { Vector3 } from "babylonjs/Maths/math.vector";
  18481. import { Color3 } from "babylonjs/Maths/math.color";
  18482. import { Node } from "babylonjs/node";
  18483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18484. import { Effect } from "babylonjs/Materials/effect";
  18485. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18486. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18487. /**
  18488. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18489. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18490. * 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.
  18491. */
  18492. export abstract class Light extends Node {
  18493. /**
  18494. * Falloff Default: light is falling off following the material specification:
  18495. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18496. */
  18497. static readonly FALLOFF_DEFAULT: number;
  18498. /**
  18499. * Falloff Physical: light is falling off following the inverse squared distance law.
  18500. */
  18501. static readonly FALLOFF_PHYSICAL: number;
  18502. /**
  18503. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18504. * to enhance interoperability with other engines.
  18505. */
  18506. static readonly FALLOFF_GLTF: number;
  18507. /**
  18508. * Falloff Standard: light is falling off like in the standard material
  18509. * to enhance interoperability with other materials.
  18510. */
  18511. static readonly FALLOFF_STANDARD: number;
  18512. /**
  18513. * If every light affecting the material is in this lightmapMode,
  18514. * material.lightmapTexture adds or multiplies
  18515. * (depends on material.useLightmapAsShadowmap)
  18516. * after every other light calculations.
  18517. */
  18518. static readonly LIGHTMAP_DEFAULT: number;
  18519. /**
  18520. * material.lightmapTexture as only diffuse lighting from this light
  18521. * adds only specular lighting from this light
  18522. * adds dynamic shadows
  18523. */
  18524. static readonly LIGHTMAP_SPECULAR: number;
  18525. /**
  18526. * material.lightmapTexture as only lighting
  18527. * no light calculation from this light
  18528. * only adds dynamic shadows from this light
  18529. */
  18530. static readonly LIGHTMAP_SHADOWSONLY: number;
  18531. /**
  18532. * Each light type uses the default quantity according to its type:
  18533. * point/spot lights use luminous intensity
  18534. * directional lights use illuminance
  18535. */
  18536. static readonly INTENSITYMODE_AUTOMATIC: number;
  18537. /**
  18538. * lumen (lm)
  18539. */
  18540. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18541. /**
  18542. * candela (lm/sr)
  18543. */
  18544. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18545. /**
  18546. * lux (lm/m^2)
  18547. */
  18548. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18549. /**
  18550. * nit (cd/m^2)
  18551. */
  18552. static readonly INTENSITYMODE_LUMINANCE: number;
  18553. /**
  18554. * Light type const id of the point light.
  18555. */
  18556. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18557. /**
  18558. * Light type const id of the directional light.
  18559. */
  18560. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18561. /**
  18562. * Light type const id of the spot light.
  18563. */
  18564. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18565. /**
  18566. * Light type const id of the hemispheric light.
  18567. */
  18568. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18569. /**
  18570. * Diffuse gives the basic color to an object.
  18571. */
  18572. diffuse: Color3;
  18573. /**
  18574. * Specular produces a highlight color on an object.
  18575. * Note: This is note affecting PBR materials.
  18576. */
  18577. specular: Color3;
  18578. /**
  18579. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18580. * falling off base on range or angle.
  18581. * This can be set to any values in Light.FALLOFF_x.
  18582. *
  18583. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18584. * other types of materials.
  18585. */
  18586. falloffType: number;
  18587. /**
  18588. * Strength of the light.
  18589. * Note: By default it is define in the framework own unit.
  18590. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18591. */
  18592. intensity: number;
  18593. private _range;
  18594. protected _inverseSquaredRange: number;
  18595. /**
  18596. * Defines how far from the source the light is impacting in scene units.
  18597. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18598. */
  18599. get range(): number;
  18600. /**
  18601. * Defines how far from the source the light is impacting in scene units.
  18602. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18603. */
  18604. set range(value: number);
  18605. /**
  18606. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18607. * of light.
  18608. */
  18609. private _photometricScale;
  18610. private _intensityMode;
  18611. /**
  18612. * Gets the photometric scale used to interpret the intensity.
  18613. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18614. */
  18615. get intensityMode(): number;
  18616. /**
  18617. * Sets the photometric scale used to interpret the intensity.
  18618. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18619. */
  18620. set intensityMode(value: number);
  18621. private _radius;
  18622. /**
  18623. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18624. */
  18625. get radius(): number;
  18626. /**
  18627. * sets the light radius used by PBR Materials to simulate soft area lights.
  18628. */
  18629. set radius(value: number);
  18630. private _renderPriority;
  18631. /**
  18632. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18633. * exceeding the number allowed of the materials.
  18634. */
  18635. renderPriority: number;
  18636. private _shadowEnabled;
  18637. /**
  18638. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18639. * the current shadow generator.
  18640. */
  18641. get shadowEnabled(): boolean;
  18642. /**
  18643. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18644. * the current shadow generator.
  18645. */
  18646. set shadowEnabled(value: boolean);
  18647. private _includedOnlyMeshes;
  18648. /**
  18649. * Gets the only meshes impacted by this light.
  18650. */
  18651. get includedOnlyMeshes(): AbstractMesh[];
  18652. /**
  18653. * Sets the only meshes impacted by this light.
  18654. */
  18655. set includedOnlyMeshes(value: AbstractMesh[]);
  18656. private _excludedMeshes;
  18657. /**
  18658. * Gets the meshes not impacted by this light.
  18659. */
  18660. get excludedMeshes(): AbstractMesh[];
  18661. /**
  18662. * Sets the meshes not impacted by this light.
  18663. */
  18664. set excludedMeshes(value: AbstractMesh[]);
  18665. private _excludeWithLayerMask;
  18666. /**
  18667. * Gets the layer id use to find what meshes are not impacted by the light.
  18668. * Inactive if 0
  18669. */
  18670. get excludeWithLayerMask(): number;
  18671. /**
  18672. * Sets the layer id use to find what meshes are not impacted by the light.
  18673. * Inactive if 0
  18674. */
  18675. set excludeWithLayerMask(value: number);
  18676. private _includeOnlyWithLayerMask;
  18677. /**
  18678. * Gets the layer id use to find what meshes are impacted by the light.
  18679. * Inactive if 0
  18680. */
  18681. get includeOnlyWithLayerMask(): number;
  18682. /**
  18683. * Sets the layer id use to find what meshes are impacted by the light.
  18684. * Inactive if 0
  18685. */
  18686. set includeOnlyWithLayerMask(value: number);
  18687. private _lightmapMode;
  18688. /**
  18689. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18690. */
  18691. get lightmapMode(): number;
  18692. /**
  18693. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18694. */
  18695. set lightmapMode(value: number);
  18696. /**
  18697. * Shadow generator associted to the light.
  18698. * @hidden Internal use only.
  18699. */
  18700. _shadowGenerator: Nullable<IShadowGenerator>;
  18701. /**
  18702. * @hidden Internal use only.
  18703. */
  18704. _excludedMeshesIds: string[];
  18705. /**
  18706. * @hidden Internal use only.
  18707. */
  18708. _includedOnlyMeshesIds: string[];
  18709. /**
  18710. * The current light unifom buffer.
  18711. * @hidden Internal use only.
  18712. */
  18713. _uniformBuffer: UniformBuffer;
  18714. /** @hidden */
  18715. _renderId: number;
  18716. /**
  18717. * Creates a Light object in the scene.
  18718. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18719. * @param name The firendly name of the light
  18720. * @param scene The scene the light belongs too
  18721. */
  18722. constructor(name: string, scene: Scene);
  18723. protected abstract _buildUniformLayout(): void;
  18724. /**
  18725. * Sets the passed Effect "effect" with the Light information.
  18726. * @param effect The effect to update
  18727. * @param lightIndex The index of the light in the effect to update
  18728. * @returns The light
  18729. */
  18730. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18731. /**
  18732. * Sets the passed Effect "effect" with the Light textures.
  18733. * @param effect The effect to update
  18734. * @param lightIndex The index of the light in the effect to update
  18735. * @returns The light
  18736. */
  18737. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18738. /**
  18739. * Binds the lights information from the scene to the effect for the given mesh.
  18740. * @param lightIndex Light index
  18741. * @param scene The scene where the light belongs to
  18742. * @param effect The effect we are binding the data to
  18743. * @param useSpecular Defines if specular is supported
  18744. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18745. */
  18746. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18747. /**
  18748. * Sets the passed Effect "effect" with the Light information.
  18749. * @param effect The effect to update
  18750. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18751. * @returns The light
  18752. */
  18753. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18754. /**
  18755. * Returns the string "Light".
  18756. * @returns the class name
  18757. */
  18758. getClassName(): string;
  18759. /** @hidden */
  18760. readonly _isLight: boolean;
  18761. /**
  18762. * Converts the light information to a readable string for debug purpose.
  18763. * @param fullDetails Supports for multiple levels of logging within scene loading
  18764. * @returns the human readable light info
  18765. */
  18766. toString(fullDetails?: boolean): string;
  18767. /** @hidden */
  18768. protected _syncParentEnabledState(): void;
  18769. /**
  18770. * Set the enabled state of this node.
  18771. * @param value - the new enabled state
  18772. */
  18773. setEnabled(value: boolean): void;
  18774. /**
  18775. * Returns the Light associated shadow generator if any.
  18776. * @return the associated shadow generator.
  18777. */
  18778. getShadowGenerator(): Nullable<IShadowGenerator>;
  18779. /**
  18780. * Returns a Vector3, the absolute light position in the World.
  18781. * @returns the world space position of the light
  18782. */
  18783. getAbsolutePosition(): Vector3;
  18784. /**
  18785. * Specifies if the light will affect the passed mesh.
  18786. * @param mesh The mesh to test against the light
  18787. * @return true the mesh is affected otherwise, false.
  18788. */
  18789. canAffectMesh(mesh: AbstractMesh): boolean;
  18790. /**
  18791. * Sort function to order lights for rendering.
  18792. * @param a First Light object to compare to second.
  18793. * @param b Second Light object to compare first.
  18794. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18795. */
  18796. static CompareLightsPriority(a: Light, b: Light): number;
  18797. /**
  18798. * Releases resources associated with this node.
  18799. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18800. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18801. */
  18802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18803. /**
  18804. * Returns the light type ID (integer).
  18805. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18806. */
  18807. getTypeID(): number;
  18808. /**
  18809. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18810. * @returns the scaled intensity in intensity mode unit
  18811. */
  18812. getScaledIntensity(): number;
  18813. /**
  18814. * Returns a new Light object, named "name", from the current one.
  18815. * @param name The name of the cloned light
  18816. * @param newParent The parent of this light, if it has one
  18817. * @returns the new created light
  18818. */
  18819. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18820. /**
  18821. * Serializes the current light into a Serialization object.
  18822. * @returns the serialized object.
  18823. */
  18824. serialize(): any;
  18825. /**
  18826. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18827. * This new light is named "name" and added to the passed scene.
  18828. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18829. * @param name The friendly name of the light
  18830. * @param scene The scene the new light will belong to
  18831. * @returns the constructor function
  18832. */
  18833. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18834. /**
  18835. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18836. * @param parsedLight The JSON representation of the light
  18837. * @param scene The scene to create the parsed light in
  18838. * @returns the created light after parsing
  18839. */
  18840. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18841. private _hookArrayForExcluded;
  18842. private _hookArrayForIncludedOnly;
  18843. private _resyncMeshes;
  18844. /**
  18845. * Forces the meshes to update their light related information in their rendering used effects
  18846. * @hidden Internal Use Only
  18847. */
  18848. _markMeshesAsLightDirty(): void;
  18849. /**
  18850. * Recomputes the cached photometric scale if needed.
  18851. */
  18852. private _computePhotometricScale;
  18853. /**
  18854. * Returns the Photometric Scale according to the light type and intensity mode.
  18855. */
  18856. private _getPhotometricScale;
  18857. /**
  18858. * Reorder the light in the scene according to their defined priority.
  18859. * @hidden Internal Use Only
  18860. */
  18861. _reorderLightsInScene(): void;
  18862. /**
  18863. * Prepares the list of defines specific to the light type.
  18864. * @param defines the list of defines
  18865. * @param lightIndex defines the index of the light for the effect
  18866. */
  18867. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18868. }
  18869. }
  18870. declare module "babylonjs/Cameras/targetCamera" {
  18871. import { Nullable } from "babylonjs/types";
  18872. import { Camera } from "babylonjs/Cameras/camera";
  18873. import { Scene } from "babylonjs/scene";
  18874. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18875. /**
  18876. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18877. * This is the base of the follow, arc rotate cameras and Free camera
  18878. * @see https://doc.babylonjs.com/features/cameras
  18879. */
  18880. export class TargetCamera extends Camera {
  18881. private static _RigCamTransformMatrix;
  18882. private static _TargetTransformMatrix;
  18883. private static _TargetFocalPoint;
  18884. private _tmpUpVector;
  18885. private _tmpTargetVector;
  18886. /**
  18887. * Define the current direction the camera is moving to
  18888. */
  18889. cameraDirection: Vector3;
  18890. /**
  18891. * Define the current rotation the camera is rotating to
  18892. */
  18893. cameraRotation: Vector2;
  18894. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18895. ignoreParentScaling: boolean;
  18896. /**
  18897. * When set, the up vector of the camera will be updated by the rotation of the camera
  18898. */
  18899. updateUpVectorFromRotation: boolean;
  18900. private _tmpQuaternion;
  18901. /**
  18902. * Define the current rotation of the camera
  18903. */
  18904. rotation: Vector3;
  18905. /**
  18906. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18907. */
  18908. rotationQuaternion: Quaternion;
  18909. /**
  18910. * Define the current speed of the camera
  18911. */
  18912. speed: number;
  18913. /**
  18914. * Add constraint to the camera to prevent it to move freely in all directions and
  18915. * around all axis.
  18916. */
  18917. noRotationConstraint: boolean;
  18918. /**
  18919. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18920. * panning
  18921. */
  18922. invertRotation: boolean;
  18923. /**
  18924. * Speed multiplier for inverse camera panning
  18925. */
  18926. inverseRotationSpeed: number;
  18927. /**
  18928. * Define the current target of the camera as an object or a position.
  18929. */
  18930. lockedTarget: any;
  18931. /** @hidden */
  18932. _currentTarget: Vector3;
  18933. /** @hidden */
  18934. _initialFocalDistance: number;
  18935. /** @hidden */
  18936. _viewMatrix: Matrix;
  18937. /** @hidden */
  18938. _camMatrix: Matrix;
  18939. /** @hidden */
  18940. _cameraTransformMatrix: Matrix;
  18941. /** @hidden */
  18942. _cameraRotationMatrix: Matrix;
  18943. /** @hidden */
  18944. _referencePoint: Vector3;
  18945. /** @hidden */
  18946. _transformedReferencePoint: Vector3;
  18947. /** @hidden */
  18948. _reset: () => void;
  18949. private _defaultUp;
  18950. /**
  18951. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18952. * This is the base of the follow, arc rotate cameras and Free camera
  18953. * @see https://doc.babylonjs.com/features/cameras
  18954. * @param name Defines the name of the camera in the scene
  18955. * @param position Defines the start position of the camera in the scene
  18956. * @param scene Defines the scene the camera belongs to
  18957. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18958. */
  18959. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18960. /**
  18961. * Gets the position in front of the camera at a given distance.
  18962. * @param distance The distance from the camera we want the position to be
  18963. * @returns the position
  18964. */
  18965. getFrontPosition(distance: number): Vector3;
  18966. /** @hidden */
  18967. _getLockedTargetPosition(): Nullable<Vector3>;
  18968. private _storedPosition;
  18969. private _storedRotation;
  18970. private _storedRotationQuaternion;
  18971. /**
  18972. * Store current camera state of the camera (fov, position, rotation, etc..)
  18973. * @returns the camera
  18974. */
  18975. storeState(): Camera;
  18976. /**
  18977. * Restored camera state. You must call storeState() first
  18978. * @returns whether it was successful or not
  18979. * @hidden
  18980. */
  18981. _restoreStateValues(): boolean;
  18982. /** @hidden */
  18983. _initCache(): void;
  18984. /** @hidden */
  18985. _updateCache(ignoreParentClass?: boolean): void;
  18986. /** @hidden */
  18987. _isSynchronizedViewMatrix(): boolean;
  18988. /** @hidden */
  18989. _computeLocalCameraSpeed(): number;
  18990. /**
  18991. * Defines the target the camera should look at.
  18992. * @param target Defines the new target as a Vector or a mesh
  18993. */
  18994. setTarget(target: Vector3): void;
  18995. /**
  18996. * Defines the target point of the camera.
  18997. * The camera looks towards it form the radius distance.
  18998. */
  18999. get target(): Vector3;
  19000. set target(value: Vector3);
  19001. /**
  19002. * Return the current target position of the camera. This value is expressed in local space.
  19003. * @returns the target position
  19004. */
  19005. getTarget(): Vector3;
  19006. /** @hidden */
  19007. _decideIfNeedsToMove(): boolean;
  19008. /** @hidden */
  19009. _updatePosition(): void;
  19010. /** @hidden */
  19011. _checkInputs(): void;
  19012. protected _updateCameraRotationMatrix(): void;
  19013. /**
  19014. * 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)
  19015. * @returns the current camera
  19016. */
  19017. private _rotateUpVectorWithCameraRotationMatrix;
  19018. private _cachedRotationZ;
  19019. private _cachedQuaternionRotationZ;
  19020. /** @hidden */
  19021. _getViewMatrix(): Matrix;
  19022. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19023. /**
  19024. * @hidden
  19025. */
  19026. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19027. /**
  19028. * @hidden
  19029. */
  19030. _updateRigCameras(): void;
  19031. private _getRigCamPositionAndTarget;
  19032. /**
  19033. * Gets the current object class name.
  19034. * @return the class name
  19035. */
  19036. getClassName(): string;
  19037. }
  19038. }
  19039. declare module "babylonjs/Events/keyboardEvents" {
  19040. /**
  19041. * Gather the list of keyboard event types as constants.
  19042. */
  19043. export class KeyboardEventTypes {
  19044. /**
  19045. * The keydown event is fired when a key becomes active (pressed).
  19046. */
  19047. static readonly KEYDOWN: number;
  19048. /**
  19049. * The keyup event is fired when a key has been released.
  19050. */
  19051. static readonly KEYUP: number;
  19052. }
  19053. /**
  19054. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19055. */
  19056. export class KeyboardInfo {
  19057. /**
  19058. * Defines the type of event (KeyboardEventTypes)
  19059. */
  19060. type: number;
  19061. /**
  19062. * Defines the related dom event
  19063. */
  19064. event: KeyboardEvent;
  19065. /**
  19066. * Instantiates a new keyboard info.
  19067. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19068. * @param type Defines the type of event (KeyboardEventTypes)
  19069. * @param event Defines the related dom event
  19070. */
  19071. constructor(
  19072. /**
  19073. * Defines the type of event (KeyboardEventTypes)
  19074. */
  19075. type: number,
  19076. /**
  19077. * Defines the related dom event
  19078. */
  19079. event: KeyboardEvent);
  19080. }
  19081. /**
  19082. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19083. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19084. */
  19085. export class KeyboardInfoPre extends KeyboardInfo {
  19086. /**
  19087. * Defines the type of event (KeyboardEventTypes)
  19088. */
  19089. type: number;
  19090. /**
  19091. * Defines the related dom event
  19092. */
  19093. event: KeyboardEvent;
  19094. /**
  19095. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19096. */
  19097. skipOnPointerObservable: boolean;
  19098. /**
  19099. * Instantiates a new keyboard pre info.
  19100. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19101. * @param type Defines the type of event (KeyboardEventTypes)
  19102. * @param event Defines the related dom event
  19103. */
  19104. constructor(
  19105. /**
  19106. * Defines the type of event (KeyboardEventTypes)
  19107. */
  19108. type: number,
  19109. /**
  19110. * Defines the related dom event
  19111. */
  19112. event: KeyboardEvent);
  19113. }
  19114. }
  19115. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19116. import { Nullable } from "babylonjs/types";
  19117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19119. /**
  19120. * Manage the keyboard inputs to control the movement of a free camera.
  19121. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19122. */
  19123. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19124. /**
  19125. * Defines the camera the input is attached to.
  19126. */
  19127. camera: FreeCamera;
  19128. /**
  19129. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19130. */
  19131. keysUp: number[];
  19132. /**
  19133. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19134. */
  19135. keysUpward: number[];
  19136. /**
  19137. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19138. */
  19139. keysDown: number[];
  19140. /**
  19141. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19142. */
  19143. keysDownward: number[];
  19144. /**
  19145. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19146. */
  19147. keysLeft: number[];
  19148. /**
  19149. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19150. */
  19151. keysRight: number[];
  19152. private _keys;
  19153. private _onCanvasBlurObserver;
  19154. private _onKeyboardObserver;
  19155. private _engine;
  19156. private _scene;
  19157. /**
  19158. * Attach the input controls to a specific dom element to get the input from.
  19159. * @param element Defines the element the controls should be listened from
  19160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19161. */
  19162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19163. /**
  19164. * Detach the current controls from the specified dom element.
  19165. * @param element Defines the element to stop listening the inputs from
  19166. */
  19167. detachControl(element: Nullable<HTMLElement>): void;
  19168. /**
  19169. * Update the current camera state depending on the inputs that have been used this frame.
  19170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19171. */
  19172. checkInputs(): void;
  19173. /**
  19174. * Gets the class name of the current intput.
  19175. * @returns the class name
  19176. */
  19177. getClassName(): string;
  19178. /** @hidden */
  19179. _onLostFocus(): void;
  19180. /**
  19181. * Get the friendly name associated with the input class.
  19182. * @returns the input friendly name
  19183. */
  19184. getSimpleName(): string;
  19185. }
  19186. }
  19187. declare module "babylonjs/Events/pointerEvents" {
  19188. import { Nullable } from "babylonjs/types";
  19189. import { Vector2 } from "babylonjs/Maths/math.vector";
  19190. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19191. import { Ray } from "babylonjs/Culling/ray";
  19192. /**
  19193. * Gather the list of pointer event types as constants.
  19194. */
  19195. export class PointerEventTypes {
  19196. /**
  19197. * 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.
  19198. */
  19199. static readonly POINTERDOWN: number;
  19200. /**
  19201. * The pointerup event is fired when a pointer is no longer active.
  19202. */
  19203. static readonly POINTERUP: number;
  19204. /**
  19205. * The pointermove event is fired when a pointer changes coordinates.
  19206. */
  19207. static readonly POINTERMOVE: number;
  19208. /**
  19209. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19210. */
  19211. static readonly POINTERWHEEL: number;
  19212. /**
  19213. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19214. */
  19215. static readonly POINTERPICK: number;
  19216. /**
  19217. * The pointertap event is fired when a the object has been touched and released without drag.
  19218. */
  19219. static readonly POINTERTAP: number;
  19220. /**
  19221. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19222. */
  19223. static readonly POINTERDOUBLETAP: number;
  19224. }
  19225. /**
  19226. * Base class of pointer info types.
  19227. */
  19228. export class PointerInfoBase {
  19229. /**
  19230. * Defines the type of event (PointerEventTypes)
  19231. */
  19232. type: number;
  19233. /**
  19234. * Defines the related dom event
  19235. */
  19236. event: PointerEvent | MouseWheelEvent;
  19237. /**
  19238. * Instantiates the base class of pointers info.
  19239. * @param type Defines the type of event (PointerEventTypes)
  19240. * @param event Defines the related dom event
  19241. */
  19242. constructor(
  19243. /**
  19244. * Defines the type of event (PointerEventTypes)
  19245. */
  19246. type: number,
  19247. /**
  19248. * Defines the related dom event
  19249. */
  19250. event: PointerEvent | MouseWheelEvent);
  19251. }
  19252. /**
  19253. * This class is used to store pointer related info for the onPrePointerObservable event.
  19254. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19255. */
  19256. export class PointerInfoPre extends PointerInfoBase {
  19257. /**
  19258. * Ray from a pointer if availible (eg. 6dof controller)
  19259. */
  19260. ray: Nullable<Ray>;
  19261. /**
  19262. * Defines the local position of the pointer on the canvas.
  19263. */
  19264. localPosition: Vector2;
  19265. /**
  19266. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19267. */
  19268. skipOnPointerObservable: boolean;
  19269. /**
  19270. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19271. * @param type Defines the type of event (PointerEventTypes)
  19272. * @param event Defines the related dom event
  19273. * @param localX Defines the local x coordinates of the pointer when the event occured
  19274. * @param localY Defines the local y coordinates of the pointer when the event occured
  19275. */
  19276. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19277. }
  19278. /**
  19279. * This type contains all the data related to a pointer event in Babylon.js.
  19280. * 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.
  19281. */
  19282. export class PointerInfo extends PointerInfoBase {
  19283. /**
  19284. * Defines the picking info associated to the info (if any)\
  19285. */
  19286. pickInfo: Nullable<PickingInfo>;
  19287. /**
  19288. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19289. * @param type Defines the type of event (PointerEventTypes)
  19290. * @param event Defines the related dom event
  19291. * @param pickInfo Defines the picking info associated to the info (if any)\
  19292. */
  19293. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19294. /**
  19295. * Defines the picking info associated to the info (if any)\
  19296. */
  19297. pickInfo: Nullable<PickingInfo>);
  19298. }
  19299. /**
  19300. * Data relating to a touch event on the screen.
  19301. */
  19302. export interface PointerTouch {
  19303. /**
  19304. * X coordinate of touch.
  19305. */
  19306. x: number;
  19307. /**
  19308. * Y coordinate of touch.
  19309. */
  19310. y: number;
  19311. /**
  19312. * Id of touch. Unique for each finger.
  19313. */
  19314. pointerId: number;
  19315. /**
  19316. * Event type passed from DOM.
  19317. */
  19318. type: any;
  19319. }
  19320. }
  19321. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19322. import { Observable } from "babylonjs/Misc/observable";
  19323. import { Nullable } from "babylonjs/types";
  19324. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19325. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19326. /**
  19327. * Manage the mouse inputs to control the movement of a free camera.
  19328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19329. */
  19330. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19331. /**
  19332. * Define if touch is enabled in the mouse input
  19333. */
  19334. touchEnabled: boolean;
  19335. /**
  19336. * Defines the camera the input is attached to.
  19337. */
  19338. camera: FreeCamera;
  19339. /**
  19340. * Defines the buttons associated with the input to handle camera move.
  19341. */
  19342. buttons: number[];
  19343. /**
  19344. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19345. */
  19346. angularSensibility: number;
  19347. private _pointerInput;
  19348. private _onMouseMove;
  19349. private _observer;
  19350. private previousPosition;
  19351. /**
  19352. * Observable for when a pointer move event occurs containing the move offset
  19353. */
  19354. onPointerMovedObservable: Observable<{
  19355. offsetX: number;
  19356. offsetY: number;
  19357. }>;
  19358. /**
  19359. * @hidden
  19360. * If the camera should be rotated automatically based on pointer movement
  19361. */
  19362. _allowCameraRotation: boolean;
  19363. /**
  19364. * Manage the mouse inputs to control the movement of a free camera.
  19365. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19366. * @param touchEnabled Defines if touch is enabled or not
  19367. */
  19368. constructor(
  19369. /**
  19370. * Define if touch is enabled in the mouse input
  19371. */
  19372. touchEnabled?: boolean);
  19373. /**
  19374. * Attach the input controls to a specific dom element to get the input from.
  19375. * @param element Defines the element the controls should be listened from
  19376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19377. */
  19378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19379. /**
  19380. * Called on JS contextmenu event.
  19381. * Override this method to provide functionality.
  19382. */
  19383. protected onContextMenu(evt: PointerEvent): void;
  19384. /**
  19385. * Detach the current controls from the specified dom element.
  19386. * @param element Defines the element to stop listening the inputs from
  19387. */
  19388. detachControl(element: Nullable<HTMLElement>): void;
  19389. /**
  19390. * Gets the class name of the current intput.
  19391. * @returns the class name
  19392. */
  19393. getClassName(): string;
  19394. /**
  19395. * Get the friendly name associated with the input class.
  19396. * @returns the input friendly name
  19397. */
  19398. getSimpleName(): string;
  19399. }
  19400. }
  19401. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19402. import { Nullable } from "babylonjs/types";
  19403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19405. /**
  19406. * Manage the touch inputs to control the movement of a free camera.
  19407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19408. */
  19409. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19410. /**
  19411. * Define if mouse events can be treated as touch events
  19412. */
  19413. allowMouse: boolean;
  19414. /**
  19415. * Defines the camera the input is attached to.
  19416. */
  19417. camera: FreeCamera;
  19418. /**
  19419. * Defines the touch sensibility for rotation.
  19420. * The higher the faster.
  19421. */
  19422. touchAngularSensibility: number;
  19423. /**
  19424. * Defines the touch sensibility for move.
  19425. * The higher the faster.
  19426. */
  19427. touchMoveSensibility: number;
  19428. private _offsetX;
  19429. private _offsetY;
  19430. private _pointerPressed;
  19431. private _pointerInput;
  19432. private _observer;
  19433. private _onLostFocus;
  19434. /**
  19435. * Manage the touch inputs to control the movement of a free camera.
  19436. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19437. * @param allowMouse Defines if mouse events can be treated as touch events
  19438. */
  19439. constructor(
  19440. /**
  19441. * Define if mouse events can be treated as touch events
  19442. */
  19443. allowMouse?: boolean);
  19444. /**
  19445. * Attach the input controls to a specific dom element to get the input from.
  19446. * @param element Defines the element the controls should be listened from
  19447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19448. */
  19449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19450. /**
  19451. * Detach the current controls from the specified dom element.
  19452. * @param element Defines the element to stop listening the inputs from
  19453. */
  19454. detachControl(element: Nullable<HTMLElement>): void;
  19455. /**
  19456. * Update the current camera state depending on the inputs that have been used this frame.
  19457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19458. */
  19459. checkInputs(): void;
  19460. /**
  19461. * Gets the class name of the current intput.
  19462. * @returns the class name
  19463. */
  19464. getClassName(): string;
  19465. /**
  19466. * Get the friendly name associated with the input class.
  19467. * @returns the input friendly name
  19468. */
  19469. getSimpleName(): string;
  19470. }
  19471. }
  19472. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19473. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19474. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19475. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19476. import { Nullable } from "babylonjs/types";
  19477. /**
  19478. * Default Inputs manager for the FreeCamera.
  19479. * It groups all the default supported inputs for ease of use.
  19480. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19481. */
  19482. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19483. /**
  19484. * @hidden
  19485. */
  19486. _mouseInput: Nullable<FreeCameraMouseInput>;
  19487. /**
  19488. * Instantiates a new FreeCameraInputsManager.
  19489. * @param camera Defines the camera the inputs belong to
  19490. */
  19491. constructor(camera: FreeCamera);
  19492. /**
  19493. * Add keyboard input support to the input manager.
  19494. * @returns the current input manager
  19495. */
  19496. addKeyboard(): FreeCameraInputsManager;
  19497. /**
  19498. * Add mouse input support to the input manager.
  19499. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19500. * @returns the current input manager
  19501. */
  19502. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19503. /**
  19504. * Removes the mouse input support from the manager
  19505. * @returns the current input manager
  19506. */
  19507. removeMouse(): FreeCameraInputsManager;
  19508. /**
  19509. * Add touch input support to the input manager.
  19510. * @returns the current input manager
  19511. */
  19512. addTouch(): FreeCameraInputsManager;
  19513. /**
  19514. * Remove all attached input methods from a camera
  19515. */
  19516. clear(): void;
  19517. }
  19518. }
  19519. declare module "babylonjs/Cameras/freeCamera" {
  19520. import { Vector3 } from "babylonjs/Maths/math.vector";
  19521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19522. import { Scene } from "babylonjs/scene";
  19523. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19524. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19525. /**
  19526. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19527. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19528. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19529. */
  19530. export class FreeCamera extends TargetCamera {
  19531. /**
  19532. * Define the collision ellipsoid of the camera.
  19533. * This is helpful to simulate a camera body like the player body around the camera
  19534. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19535. */
  19536. ellipsoid: Vector3;
  19537. /**
  19538. * Define an offset for the position of the ellipsoid around the camera.
  19539. * This can be helpful to determine the center of the body near the gravity center of the body
  19540. * instead of its head.
  19541. */
  19542. ellipsoidOffset: Vector3;
  19543. /**
  19544. * Enable or disable collisions of the camera with the rest of the scene objects.
  19545. */
  19546. checkCollisions: boolean;
  19547. /**
  19548. * Enable or disable gravity on the camera.
  19549. */
  19550. applyGravity: boolean;
  19551. /**
  19552. * Define the input manager associated to the camera.
  19553. */
  19554. inputs: FreeCameraInputsManager;
  19555. /**
  19556. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19557. * Higher values reduce sensitivity.
  19558. */
  19559. get angularSensibility(): number;
  19560. /**
  19561. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19562. * Higher values reduce sensitivity.
  19563. */
  19564. set angularSensibility(value: number);
  19565. /**
  19566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19567. */
  19568. get keysUp(): number[];
  19569. set keysUp(value: number[]);
  19570. /**
  19571. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19572. */
  19573. get keysUpward(): number[];
  19574. set keysUpward(value: number[]);
  19575. /**
  19576. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19577. */
  19578. get keysDown(): number[];
  19579. set keysDown(value: number[]);
  19580. /**
  19581. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19582. */
  19583. get keysDownward(): number[];
  19584. set keysDownward(value: number[]);
  19585. /**
  19586. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19587. */
  19588. get keysLeft(): number[];
  19589. set keysLeft(value: number[]);
  19590. /**
  19591. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19592. */
  19593. get keysRight(): number[];
  19594. set keysRight(value: number[]);
  19595. /**
  19596. * Event raised when the camera collide with a mesh in the scene.
  19597. */
  19598. onCollide: (collidedMesh: AbstractMesh) => void;
  19599. private _collider;
  19600. private _needMoveForGravity;
  19601. private _oldPosition;
  19602. private _diffPosition;
  19603. private _newPosition;
  19604. /** @hidden */
  19605. _localDirection: Vector3;
  19606. /** @hidden */
  19607. _transformedDirection: Vector3;
  19608. /**
  19609. * Instantiates a Free Camera.
  19610. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19611. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19612. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19613. * @param name Define the name of the camera in the scene
  19614. * @param position Define the start position of the camera in the scene
  19615. * @param scene Define the scene the camera belongs to
  19616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19617. */
  19618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19619. /**
  19620. * Attached controls to the current camera.
  19621. * @param element Defines the element the controls should be listened from
  19622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19623. */
  19624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19625. /**
  19626. * Detach the current controls from the camera.
  19627. * The camera will stop reacting to inputs.
  19628. * @param element Defines the element to stop listening the inputs from
  19629. */
  19630. detachControl(element: HTMLElement): void;
  19631. private _collisionMask;
  19632. /**
  19633. * Define a collision mask to limit the list of object the camera can collide with
  19634. */
  19635. get collisionMask(): number;
  19636. set collisionMask(mask: number);
  19637. /** @hidden */
  19638. _collideWithWorld(displacement: Vector3): void;
  19639. private _onCollisionPositionChange;
  19640. /** @hidden */
  19641. _checkInputs(): void;
  19642. /** @hidden */
  19643. _decideIfNeedsToMove(): boolean;
  19644. /** @hidden */
  19645. _updatePosition(): void;
  19646. /**
  19647. * Destroy the camera and release the current resources hold by it.
  19648. */
  19649. dispose(): void;
  19650. /**
  19651. * Gets the current object class name.
  19652. * @return the class name
  19653. */
  19654. getClassName(): string;
  19655. }
  19656. }
  19657. declare module "babylonjs/Gamepads/gamepad" {
  19658. import { Observable } from "babylonjs/Misc/observable";
  19659. /**
  19660. * Represents a gamepad control stick position
  19661. */
  19662. export class StickValues {
  19663. /**
  19664. * The x component of the control stick
  19665. */
  19666. x: number;
  19667. /**
  19668. * The y component of the control stick
  19669. */
  19670. y: number;
  19671. /**
  19672. * Initializes the gamepad x and y control stick values
  19673. * @param x The x component of the gamepad control stick value
  19674. * @param y The y component of the gamepad control stick value
  19675. */
  19676. constructor(
  19677. /**
  19678. * The x component of the control stick
  19679. */
  19680. x: number,
  19681. /**
  19682. * The y component of the control stick
  19683. */
  19684. y: number);
  19685. }
  19686. /**
  19687. * An interface which manages callbacks for gamepad button changes
  19688. */
  19689. export interface GamepadButtonChanges {
  19690. /**
  19691. * Called when a gamepad has been changed
  19692. */
  19693. changed: boolean;
  19694. /**
  19695. * Called when a gamepad press event has been triggered
  19696. */
  19697. pressChanged: boolean;
  19698. /**
  19699. * Called when a touch event has been triggered
  19700. */
  19701. touchChanged: boolean;
  19702. /**
  19703. * Called when a value has changed
  19704. */
  19705. valueChanged: boolean;
  19706. }
  19707. /**
  19708. * Represents a gamepad
  19709. */
  19710. export class Gamepad {
  19711. /**
  19712. * The id of the gamepad
  19713. */
  19714. id: string;
  19715. /**
  19716. * The index of the gamepad
  19717. */
  19718. index: number;
  19719. /**
  19720. * The browser gamepad
  19721. */
  19722. browserGamepad: any;
  19723. /**
  19724. * Specifies what type of gamepad this represents
  19725. */
  19726. type: number;
  19727. private _leftStick;
  19728. private _rightStick;
  19729. /** @hidden */
  19730. _isConnected: boolean;
  19731. private _leftStickAxisX;
  19732. private _leftStickAxisY;
  19733. private _rightStickAxisX;
  19734. private _rightStickAxisY;
  19735. /**
  19736. * Triggered when the left control stick has been changed
  19737. */
  19738. private _onleftstickchanged;
  19739. /**
  19740. * Triggered when the right control stick has been changed
  19741. */
  19742. private _onrightstickchanged;
  19743. /**
  19744. * Represents a gamepad controller
  19745. */
  19746. static GAMEPAD: number;
  19747. /**
  19748. * Represents a generic controller
  19749. */
  19750. static GENERIC: number;
  19751. /**
  19752. * Represents an XBox controller
  19753. */
  19754. static XBOX: number;
  19755. /**
  19756. * Represents a pose-enabled controller
  19757. */
  19758. static POSE_ENABLED: number;
  19759. /**
  19760. * Represents an Dual Shock controller
  19761. */
  19762. static DUALSHOCK: number;
  19763. /**
  19764. * Specifies whether the left control stick should be Y-inverted
  19765. */
  19766. protected _invertLeftStickY: boolean;
  19767. /**
  19768. * Specifies if the gamepad has been connected
  19769. */
  19770. get isConnected(): boolean;
  19771. /**
  19772. * Initializes the gamepad
  19773. * @param id The id of the gamepad
  19774. * @param index The index of the gamepad
  19775. * @param browserGamepad The browser gamepad
  19776. * @param leftStickX The x component of the left joystick
  19777. * @param leftStickY The y component of the left joystick
  19778. * @param rightStickX The x component of the right joystick
  19779. * @param rightStickY The y component of the right joystick
  19780. */
  19781. constructor(
  19782. /**
  19783. * The id of the gamepad
  19784. */
  19785. id: string,
  19786. /**
  19787. * The index of the gamepad
  19788. */
  19789. index: number,
  19790. /**
  19791. * The browser gamepad
  19792. */
  19793. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19794. /**
  19795. * Callback triggered when the left joystick has changed
  19796. * @param callback
  19797. */
  19798. onleftstickchanged(callback: (values: StickValues) => void): void;
  19799. /**
  19800. * Callback triggered when the right joystick has changed
  19801. * @param callback
  19802. */
  19803. onrightstickchanged(callback: (values: StickValues) => void): void;
  19804. /**
  19805. * Gets the left joystick
  19806. */
  19807. get leftStick(): StickValues;
  19808. /**
  19809. * Sets the left joystick values
  19810. */
  19811. set leftStick(newValues: StickValues);
  19812. /**
  19813. * Gets the right joystick
  19814. */
  19815. get rightStick(): StickValues;
  19816. /**
  19817. * Sets the right joystick value
  19818. */
  19819. set rightStick(newValues: StickValues);
  19820. /**
  19821. * Updates the gamepad joystick positions
  19822. */
  19823. update(): void;
  19824. /**
  19825. * Disposes the gamepad
  19826. */
  19827. dispose(): void;
  19828. }
  19829. /**
  19830. * Represents a generic gamepad
  19831. */
  19832. export class GenericPad extends Gamepad {
  19833. private _buttons;
  19834. private _onbuttondown;
  19835. private _onbuttonup;
  19836. /**
  19837. * Observable triggered when a button has been pressed
  19838. */
  19839. onButtonDownObservable: Observable<number>;
  19840. /**
  19841. * Observable triggered when a button has been released
  19842. */
  19843. onButtonUpObservable: Observable<number>;
  19844. /**
  19845. * Callback triggered when a button has been pressed
  19846. * @param callback Called when a button has been pressed
  19847. */
  19848. onbuttondown(callback: (buttonPressed: number) => void): void;
  19849. /**
  19850. * Callback triggered when a button has been released
  19851. * @param callback Called when a button has been released
  19852. */
  19853. onbuttonup(callback: (buttonReleased: number) => void): void;
  19854. /**
  19855. * Initializes the generic gamepad
  19856. * @param id The id of the generic gamepad
  19857. * @param index The index of the generic gamepad
  19858. * @param browserGamepad The browser gamepad
  19859. */
  19860. constructor(id: string, index: number, browserGamepad: any);
  19861. private _setButtonValue;
  19862. /**
  19863. * Updates the generic gamepad
  19864. */
  19865. update(): void;
  19866. /**
  19867. * Disposes the generic gamepad
  19868. */
  19869. dispose(): void;
  19870. }
  19871. }
  19872. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19873. import { Observable } from "babylonjs/Misc/observable";
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19878. import { Ray } from "babylonjs/Culling/ray";
  19879. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19880. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19881. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19882. /**
  19883. * Defines the types of pose enabled controllers that are supported
  19884. */
  19885. export enum PoseEnabledControllerType {
  19886. /**
  19887. * HTC Vive
  19888. */
  19889. VIVE = 0,
  19890. /**
  19891. * Oculus Rift
  19892. */
  19893. OCULUS = 1,
  19894. /**
  19895. * Windows mixed reality
  19896. */
  19897. WINDOWS = 2,
  19898. /**
  19899. * Samsung gear VR
  19900. */
  19901. GEAR_VR = 3,
  19902. /**
  19903. * Google Daydream
  19904. */
  19905. DAYDREAM = 4,
  19906. /**
  19907. * Generic
  19908. */
  19909. GENERIC = 5
  19910. }
  19911. /**
  19912. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19913. */
  19914. export interface MutableGamepadButton {
  19915. /**
  19916. * Value of the button/trigger
  19917. */
  19918. value: number;
  19919. /**
  19920. * If the button/trigger is currently touched
  19921. */
  19922. touched: boolean;
  19923. /**
  19924. * If the button/trigger is currently pressed
  19925. */
  19926. pressed: boolean;
  19927. }
  19928. /**
  19929. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19930. * @hidden
  19931. */
  19932. export interface ExtendedGamepadButton extends GamepadButton {
  19933. /**
  19934. * If the button/trigger is currently pressed
  19935. */
  19936. readonly pressed: boolean;
  19937. /**
  19938. * If the button/trigger is currently touched
  19939. */
  19940. readonly touched: boolean;
  19941. /**
  19942. * Value of the button/trigger
  19943. */
  19944. readonly value: number;
  19945. }
  19946. /** @hidden */
  19947. export interface _GamePadFactory {
  19948. /**
  19949. * Returns whether or not the current gamepad can be created for this type of controller.
  19950. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19951. * @returns true if it can be created, otherwise false
  19952. */
  19953. canCreate(gamepadInfo: any): boolean;
  19954. /**
  19955. * Creates a new instance of the Gamepad.
  19956. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19957. * @returns the new gamepad instance
  19958. */
  19959. create(gamepadInfo: any): Gamepad;
  19960. }
  19961. /**
  19962. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19963. */
  19964. export class PoseEnabledControllerHelper {
  19965. /** @hidden */
  19966. static _ControllerFactories: _GamePadFactory[];
  19967. /** @hidden */
  19968. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19969. /**
  19970. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19971. * @param vrGamepad the gamepad to initialized
  19972. * @returns a vr controller of the type the gamepad identified as
  19973. */
  19974. static InitiateController(vrGamepad: any): Gamepad;
  19975. }
  19976. /**
  19977. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19978. */
  19979. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19980. /**
  19981. * If the controller is used in a webXR session
  19982. */
  19983. isXR: boolean;
  19984. private _deviceRoomPosition;
  19985. private _deviceRoomRotationQuaternion;
  19986. /**
  19987. * The device position in babylon space
  19988. */
  19989. devicePosition: Vector3;
  19990. /**
  19991. * The device rotation in babylon space
  19992. */
  19993. deviceRotationQuaternion: Quaternion;
  19994. /**
  19995. * The scale factor of the device in babylon space
  19996. */
  19997. deviceScaleFactor: number;
  19998. /**
  19999. * (Likely devicePosition should be used instead) The device position in its room space
  20000. */
  20001. position: Vector3;
  20002. /**
  20003. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20004. */
  20005. rotationQuaternion: Quaternion;
  20006. /**
  20007. * The type of controller (Eg. Windows mixed reality)
  20008. */
  20009. controllerType: PoseEnabledControllerType;
  20010. protected _calculatedPosition: Vector3;
  20011. private _calculatedRotation;
  20012. /**
  20013. * The raw pose from the device
  20014. */
  20015. rawPose: DevicePose;
  20016. private _trackPosition;
  20017. private _maxRotationDistFromHeadset;
  20018. private _draggedRoomRotation;
  20019. /**
  20020. * @hidden
  20021. */
  20022. _disableTrackPosition(fixedPosition: Vector3): void;
  20023. /**
  20024. * Internal, the mesh attached to the controller
  20025. * @hidden
  20026. */
  20027. _mesh: Nullable<AbstractMesh>;
  20028. private _poseControlledCamera;
  20029. private _leftHandSystemQuaternion;
  20030. /**
  20031. * Internal, matrix used to convert room space to babylon space
  20032. * @hidden
  20033. */
  20034. _deviceToWorld: Matrix;
  20035. /**
  20036. * Node to be used when casting a ray from the controller
  20037. * @hidden
  20038. */
  20039. _pointingPoseNode: Nullable<TransformNode>;
  20040. /**
  20041. * Name of the child mesh that can be used to cast a ray from the controller
  20042. */
  20043. static readonly POINTING_POSE: string;
  20044. /**
  20045. * Creates a new PoseEnabledController from a gamepad
  20046. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20047. */
  20048. constructor(browserGamepad: any);
  20049. private _workingMatrix;
  20050. /**
  20051. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20052. */
  20053. update(): void;
  20054. /**
  20055. * Updates only the pose device and mesh without doing any button event checking
  20056. */
  20057. protected _updatePoseAndMesh(): void;
  20058. /**
  20059. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20060. * @param poseData raw pose fromthe device
  20061. */
  20062. updateFromDevice(poseData: DevicePose): void;
  20063. /**
  20064. * @hidden
  20065. */
  20066. _meshAttachedObservable: Observable<AbstractMesh>;
  20067. /**
  20068. * Attaches a mesh to the controller
  20069. * @param mesh the mesh to be attached
  20070. */
  20071. attachToMesh(mesh: AbstractMesh): void;
  20072. /**
  20073. * Attaches the controllers mesh to a camera
  20074. * @param camera the camera the mesh should be attached to
  20075. */
  20076. attachToPoseControlledCamera(camera: TargetCamera): void;
  20077. /**
  20078. * Disposes of the controller
  20079. */
  20080. dispose(): void;
  20081. /**
  20082. * The mesh that is attached to the controller
  20083. */
  20084. get mesh(): Nullable<AbstractMesh>;
  20085. /**
  20086. * Gets the ray of the controller in the direction the controller is pointing
  20087. * @param length the length the resulting ray should be
  20088. * @returns a ray in the direction the controller is pointing
  20089. */
  20090. getForwardRay(length?: number): Ray;
  20091. }
  20092. }
  20093. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20094. import { Observable } from "babylonjs/Misc/observable";
  20095. import { Scene } from "babylonjs/scene";
  20096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20097. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20098. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20099. import { Nullable } from "babylonjs/types";
  20100. /**
  20101. * Defines the WebVRController object that represents controllers tracked in 3D space
  20102. */
  20103. export abstract class WebVRController extends PoseEnabledController {
  20104. /**
  20105. * Internal, the default controller model for the controller
  20106. */
  20107. protected _defaultModel: Nullable<AbstractMesh>;
  20108. /**
  20109. * Fired when the trigger state has changed
  20110. */
  20111. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20112. /**
  20113. * Fired when the main button state has changed
  20114. */
  20115. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20116. /**
  20117. * Fired when the secondary button state has changed
  20118. */
  20119. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20120. /**
  20121. * Fired when the pad state has changed
  20122. */
  20123. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20124. /**
  20125. * Fired when controllers stick values have changed
  20126. */
  20127. onPadValuesChangedObservable: Observable<StickValues>;
  20128. /**
  20129. * Array of button availible on the controller
  20130. */
  20131. protected _buttons: Array<MutableGamepadButton>;
  20132. private _onButtonStateChange;
  20133. /**
  20134. * Fired when a controller button's state has changed
  20135. * @param callback the callback containing the button that was modified
  20136. */
  20137. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20138. /**
  20139. * X and Y axis corresponding to the controllers joystick
  20140. */
  20141. pad: StickValues;
  20142. /**
  20143. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20144. */
  20145. hand: string;
  20146. /**
  20147. * The default controller model for the controller
  20148. */
  20149. get defaultModel(): Nullable<AbstractMesh>;
  20150. /**
  20151. * Creates a new WebVRController from a gamepad
  20152. * @param vrGamepad the gamepad that the WebVRController should be created from
  20153. */
  20154. constructor(vrGamepad: any);
  20155. /**
  20156. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20157. */
  20158. update(): void;
  20159. /**
  20160. * Function to be called when a button is modified
  20161. */
  20162. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20163. /**
  20164. * Loads a mesh and attaches it to the controller
  20165. * @param scene the scene the mesh should be added to
  20166. * @param meshLoaded callback for when the mesh has been loaded
  20167. */
  20168. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20169. private _setButtonValue;
  20170. private _changes;
  20171. private _checkChanges;
  20172. /**
  20173. * Disposes of th webVRCOntroller
  20174. */
  20175. dispose(): void;
  20176. }
  20177. }
  20178. declare module "babylonjs/Lights/hemisphericLight" {
  20179. import { Nullable } from "babylonjs/types";
  20180. import { Scene } from "babylonjs/scene";
  20181. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20182. import { Color3 } from "babylonjs/Maths/math.color";
  20183. import { Effect } from "babylonjs/Materials/effect";
  20184. import { Light } from "babylonjs/Lights/light";
  20185. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20186. /**
  20187. * The HemisphericLight simulates the ambient environment light,
  20188. * so the passed direction is the light reflection direction, not the incoming direction.
  20189. */
  20190. export class HemisphericLight extends Light {
  20191. /**
  20192. * The groundColor is the light in the opposite direction to the one specified during creation.
  20193. * 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.
  20194. */
  20195. groundColor: Color3;
  20196. /**
  20197. * The light reflection direction, not the incoming direction.
  20198. */
  20199. direction: Vector3;
  20200. /**
  20201. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20202. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20203. * The HemisphericLight can't cast shadows.
  20204. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20205. * @param name The friendly name of the light
  20206. * @param direction The direction of the light reflection
  20207. * @param scene The scene the light belongs to
  20208. */
  20209. constructor(name: string, direction: Vector3, scene: Scene);
  20210. protected _buildUniformLayout(): void;
  20211. /**
  20212. * Returns the string "HemisphericLight".
  20213. * @return The class name
  20214. */
  20215. getClassName(): string;
  20216. /**
  20217. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20218. * Returns the updated direction.
  20219. * @param target The target the direction should point to
  20220. * @return The computed direction
  20221. */
  20222. setDirectionToTarget(target: Vector3): Vector3;
  20223. /**
  20224. * Returns the shadow generator associated to the light.
  20225. * @returns Always null for hemispheric lights because it does not support shadows.
  20226. */
  20227. getShadowGenerator(): Nullable<IShadowGenerator>;
  20228. /**
  20229. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20230. * @param effect The effect to update
  20231. * @param lightIndex The index of the light in the effect to update
  20232. * @returns The hemispheric light
  20233. */
  20234. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20235. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20236. /**
  20237. * Computes the world matrix of the node
  20238. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20239. * @param useWasUpdatedFlag defines a reserved property
  20240. * @returns the world matrix
  20241. */
  20242. computeWorldMatrix(): Matrix;
  20243. /**
  20244. * Returns the integer 3.
  20245. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20246. */
  20247. getTypeID(): number;
  20248. /**
  20249. * Prepares the list of defines specific to the light type.
  20250. * @param defines the list of defines
  20251. * @param lightIndex defines the index of the light for the effect
  20252. */
  20253. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20254. }
  20255. }
  20256. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20257. /** @hidden */
  20258. export var vrMultiviewToSingleviewPixelShader: {
  20259. name: string;
  20260. shader: string;
  20261. };
  20262. }
  20263. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20265. import { Scene } from "babylonjs/scene";
  20266. /**
  20267. * Renders to multiple views with a single draw call
  20268. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20269. */
  20270. export class MultiviewRenderTarget extends RenderTargetTexture {
  20271. /**
  20272. * Creates a multiview render target
  20273. * @param scene scene used with the render target
  20274. * @param size the size of the render target (used for each view)
  20275. */
  20276. constructor(scene: Scene, size?: number | {
  20277. width: number;
  20278. height: number;
  20279. } | {
  20280. ratio: number;
  20281. });
  20282. /**
  20283. * @hidden
  20284. * @param faceIndex the face index, if its a cube texture
  20285. */
  20286. _bindFrameBuffer(faceIndex?: number): void;
  20287. /**
  20288. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20289. * @returns the view count
  20290. */
  20291. getViewCount(): number;
  20292. }
  20293. }
  20294. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20295. import { Camera } from "babylonjs/Cameras/camera";
  20296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20297. import { Nullable } from "babylonjs/types";
  20298. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20299. import { Matrix } from "babylonjs/Maths/math.vector";
  20300. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20301. module "babylonjs/Engines/engine" {
  20302. interface Engine {
  20303. /**
  20304. * Creates a new multiview render target
  20305. * @param width defines the width of the texture
  20306. * @param height defines the height of the texture
  20307. * @returns the created multiview texture
  20308. */
  20309. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20310. /**
  20311. * Binds a multiview framebuffer to be drawn to
  20312. * @param multiviewTexture texture to bind
  20313. */
  20314. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20315. }
  20316. }
  20317. module "babylonjs/Cameras/camera" {
  20318. interface Camera {
  20319. /**
  20320. * @hidden
  20321. * 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)
  20322. */
  20323. _useMultiviewToSingleView: boolean;
  20324. /**
  20325. * @hidden
  20326. * 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)
  20327. */
  20328. _multiviewTexture: Nullable<RenderTargetTexture>;
  20329. /**
  20330. * @hidden
  20331. * ensures the multiview texture of the camera exists and has the specified width/height
  20332. * @param width height to set on the multiview texture
  20333. * @param height width to set on the multiview texture
  20334. */
  20335. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20336. }
  20337. }
  20338. module "babylonjs/scene" {
  20339. interface Scene {
  20340. /** @hidden */
  20341. _transformMatrixR: Matrix;
  20342. /** @hidden */
  20343. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20344. /** @hidden */
  20345. _createMultiviewUbo(): void;
  20346. /** @hidden */
  20347. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20348. /** @hidden */
  20349. _renderMultiviewToSingleView(camera: Camera): void;
  20350. }
  20351. }
  20352. }
  20353. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20354. import { Camera } from "babylonjs/Cameras/camera";
  20355. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20356. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20357. import "babylonjs/Engines/Extensions/engine.multiview";
  20358. /**
  20359. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20360. * This will not be used for webXR as it supports displaying texture arrays directly
  20361. */
  20362. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20363. /**
  20364. * Gets a string identifying the name of the class
  20365. * @returns "VRMultiviewToSingleviewPostProcess" string
  20366. */
  20367. getClassName(): string;
  20368. /**
  20369. * Initializes a VRMultiviewToSingleview
  20370. * @param name name of the post process
  20371. * @param camera camera to be applied to
  20372. * @param scaleFactor scaling factor to the size of the output texture
  20373. */
  20374. constructor(name: string, camera: Camera, scaleFactor: number);
  20375. }
  20376. }
  20377. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20378. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20379. import { Nullable } from "babylonjs/types";
  20380. import { Size } from "babylonjs/Maths/math.size";
  20381. import { Observable } from "babylonjs/Misc/observable";
  20382. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20383. /**
  20384. * Interface used to define additional presentation attributes
  20385. */
  20386. export interface IVRPresentationAttributes {
  20387. /**
  20388. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20389. */
  20390. highRefreshRate: boolean;
  20391. /**
  20392. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20393. */
  20394. foveationLevel: number;
  20395. }
  20396. module "babylonjs/Engines/engine" {
  20397. interface Engine {
  20398. /** @hidden */
  20399. _vrDisplay: any;
  20400. /** @hidden */
  20401. _vrSupported: boolean;
  20402. /** @hidden */
  20403. _oldSize: Size;
  20404. /** @hidden */
  20405. _oldHardwareScaleFactor: number;
  20406. /** @hidden */
  20407. _vrExclusivePointerMode: boolean;
  20408. /** @hidden */
  20409. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20410. /** @hidden */
  20411. _onVRDisplayPointerRestricted: () => void;
  20412. /** @hidden */
  20413. _onVRDisplayPointerUnrestricted: () => void;
  20414. /** @hidden */
  20415. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20416. /** @hidden */
  20417. _onVrDisplayDisconnect: Nullable<() => void>;
  20418. /** @hidden */
  20419. _onVrDisplayPresentChange: Nullable<() => void>;
  20420. /**
  20421. * Observable signaled when VR display mode changes
  20422. */
  20423. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20424. /**
  20425. * Observable signaled when VR request present is complete
  20426. */
  20427. onVRRequestPresentComplete: Observable<boolean>;
  20428. /**
  20429. * Observable signaled when VR request present starts
  20430. */
  20431. onVRRequestPresentStart: Observable<Engine>;
  20432. /**
  20433. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20434. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20435. */
  20436. isInVRExclusivePointerMode: boolean;
  20437. /**
  20438. * Gets a boolean indicating if a webVR device was detected
  20439. * @returns true if a webVR device was detected
  20440. */
  20441. isVRDevicePresent(): boolean;
  20442. /**
  20443. * Gets the current webVR device
  20444. * @returns the current webVR device (or null)
  20445. */
  20446. getVRDevice(): any;
  20447. /**
  20448. * Initializes a webVR display and starts listening to display change events
  20449. * The onVRDisplayChangedObservable will be notified upon these changes
  20450. * @returns A promise containing a VRDisplay and if vr is supported
  20451. */
  20452. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20453. /** @hidden */
  20454. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20455. /**
  20456. * Gets or sets the presentation attributes used to configure VR rendering
  20457. */
  20458. vrPresentationAttributes?: IVRPresentationAttributes;
  20459. /**
  20460. * Call this function to switch to webVR mode
  20461. * Will do nothing if webVR is not supported or if there is no webVR device
  20462. * @param options the webvr options provided to the camera. mainly used for multiview
  20463. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20464. */
  20465. enableVR(options: WebVROptions): void;
  20466. /** @hidden */
  20467. _onVRFullScreenTriggered(): void;
  20468. }
  20469. }
  20470. }
  20471. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20472. import { Nullable } from "babylonjs/types";
  20473. import { Observable } from "babylonjs/Misc/observable";
  20474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20475. import { Scene } from "babylonjs/scene";
  20476. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20477. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20478. import { Node } from "babylonjs/node";
  20479. import { Ray } from "babylonjs/Culling/ray";
  20480. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20481. import "babylonjs/Engines/Extensions/engine.webVR";
  20482. /**
  20483. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20484. * IMPORTANT!! The data is right-hand data.
  20485. * @export
  20486. * @interface DevicePose
  20487. */
  20488. export interface DevicePose {
  20489. /**
  20490. * The position of the device, values in array are [x,y,z].
  20491. */
  20492. readonly position: Nullable<Float32Array>;
  20493. /**
  20494. * The linearVelocity of the device, values in array are [x,y,z].
  20495. */
  20496. readonly linearVelocity: Nullable<Float32Array>;
  20497. /**
  20498. * The linearAcceleration of the device, values in array are [x,y,z].
  20499. */
  20500. readonly linearAcceleration: Nullable<Float32Array>;
  20501. /**
  20502. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20503. */
  20504. readonly orientation: Nullable<Float32Array>;
  20505. /**
  20506. * The angularVelocity of the device, values in array are [x,y,z].
  20507. */
  20508. readonly angularVelocity: Nullable<Float32Array>;
  20509. /**
  20510. * The angularAcceleration of the device, values in array are [x,y,z].
  20511. */
  20512. readonly angularAcceleration: Nullable<Float32Array>;
  20513. }
  20514. /**
  20515. * Interface representing a pose controlled object in Babylon.
  20516. * A pose controlled object has both regular pose values as well as pose values
  20517. * from an external device such as a VR head mounted display
  20518. */
  20519. export interface PoseControlled {
  20520. /**
  20521. * The position of the object in babylon space.
  20522. */
  20523. position: Vector3;
  20524. /**
  20525. * The rotation quaternion of the object in babylon space.
  20526. */
  20527. rotationQuaternion: Quaternion;
  20528. /**
  20529. * The position of the device in babylon space.
  20530. */
  20531. devicePosition?: Vector3;
  20532. /**
  20533. * The rotation quaternion of the device in babylon space.
  20534. */
  20535. deviceRotationQuaternion: Quaternion;
  20536. /**
  20537. * The raw pose coming from the device.
  20538. */
  20539. rawPose: Nullable<DevicePose>;
  20540. /**
  20541. * The scale of the device to be used when translating from device space to babylon space.
  20542. */
  20543. deviceScaleFactor: number;
  20544. /**
  20545. * Updates the poseControlled values based on the input device pose.
  20546. * @param poseData the pose data to update the object with
  20547. */
  20548. updateFromDevice(poseData: DevicePose): void;
  20549. }
  20550. /**
  20551. * Set of options to customize the webVRCamera
  20552. */
  20553. export interface WebVROptions {
  20554. /**
  20555. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20556. */
  20557. trackPosition?: boolean;
  20558. /**
  20559. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20560. */
  20561. positionScale?: number;
  20562. /**
  20563. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20564. */
  20565. displayName?: string;
  20566. /**
  20567. * Should the native controller meshes be initialized. (default: true)
  20568. */
  20569. controllerMeshes?: boolean;
  20570. /**
  20571. * Creating a default HemiLight only on controllers. (default: true)
  20572. */
  20573. defaultLightingOnControllers?: boolean;
  20574. /**
  20575. * If you don't want to use the default VR button of the helper. (default: false)
  20576. */
  20577. useCustomVRButton?: boolean;
  20578. /**
  20579. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20580. */
  20581. customVRButton?: HTMLButtonElement;
  20582. /**
  20583. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20584. */
  20585. rayLength?: number;
  20586. /**
  20587. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20588. */
  20589. defaultHeight?: number;
  20590. /**
  20591. * If multiview should be used if availible (default: false)
  20592. */
  20593. useMultiview?: boolean;
  20594. }
  20595. /**
  20596. * This represents a WebVR camera.
  20597. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20598. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20599. */
  20600. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20601. private webVROptions;
  20602. /**
  20603. * @hidden
  20604. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20605. */
  20606. _vrDevice: any;
  20607. /**
  20608. * The rawPose of the vrDevice.
  20609. */
  20610. rawPose: Nullable<DevicePose>;
  20611. private _onVREnabled;
  20612. private _specsVersion;
  20613. private _attached;
  20614. private _frameData;
  20615. protected _descendants: Array<Node>;
  20616. private _deviceRoomPosition;
  20617. /** @hidden */
  20618. _deviceRoomRotationQuaternion: Quaternion;
  20619. private _standingMatrix;
  20620. /**
  20621. * Represents device position in babylon space.
  20622. */
  20623. devicePosition: Vector3;
  20624. /**
  20625. * Represents device rotation in babylon space.
  20626. */
  20627. deviceRotationQuaternion: Quaternion;
  20628. /**
  20629. * The scale of the device to be used when translating from device space to babylon space.
  20630. */
  20631. deviceScaleFactor: number;
  20632. private _deviceToWorld;
  20633. private _worldToDevice;
  20634. /**
  20635. * References to the webVR controllers for the vrDevice.
  20636. */
  20637. controllers: Array<WebVRController>;
  20638. /**
  20639. * Emits an event when a controller is attached.
  20640. */
  20641. onControllersAttachedObservable: Observable<WebVRController[]>;
  20642. /**
  20643. * Emits an event when a controller's mesh has been loaded;
  20644. */
  20645. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20646. /**
  20647. * Emits an event when the HMD's pose has been updated.
  20648. */
  20649. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20650. private _poseSet;
  20651. /**
  20652. * If the rig cameras be used as parent instead of this camera.
  20653. */
  20654. rigParenting: boolean;
  20655. private _lightOnControllers;
  20656. private _defaultHeight?;
  20657. /**
  20658. * Instantiates a WebVRFreeCamera.
  20659. * @param name The name of the WebVRFreeCamera
  20660. * @param position The starting anchor position for the camera
  20661. * @param scene The scene the camera belongs to
  20662. * @param webVROptions a set of customizable options for the webVRCamera
  20663. */
  20664. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20665. /**
  20666. * Gets the device distance from the ground in meters.
  20667. * @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.
  20668. */
  20669. deviceDistanceToRoomGround(): number;
  20670. /**
  20671. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20672. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20673. */
  20674. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20675. /**
  20676. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20677. * @returns A promise with a boolean set to if the standing matrix is supported.
  20678. */
  20679. useStandingMatrixAsync(): Promise<boolean>;
  20680. /**
  20681. * Disposes the camera
  20682. */
  20683. dispose(): void;
  20684. /**
  20685. * Gets a vrController by name.
  20686. * @param name The name of the controller to retreive
  20687. * @returns the controller matching the name specified or null if not found
  20688. */
  20689. getControllerByName(name: string): Nullable<WebVRController>;
  20690. private _leftController;
  20691. /**
  20692. * The controller corresponding to the users left hand.
  20693. */
  20694. get leftController(): Nullable<WebVRController>;
  20695. private _rightController;
  20696. /**
  20697. * The controller corresponding to the users right hand.
  20698. */
  20699. get rightController(): Nullable<WebVRController>;
  20700. /**
  20701. * Casts a ray forward from the vrCamera's gaze.
  20702. * @param length Length of the ray (default: 100)
  20703. * @returns the ray corresponding to the gaze
  20704. */
  20705. getForwardRay(length?: number): Ray;
  20706. /**
  20707. * @hidden
  20708. * Updates the camera based on device's frame data
  20709. */
  20710. _checkInputs(): void;
  20711. /**
  20712. * Updates the poseControlled values based on the input device pose.
  20713. * @param poseData Pose coming from the device
  20714. */
  20715. updateFromDevice(poseData: DevicePose): void;
  20716. private _htmlElementAttached;
  20717. private _detachIfAttached;
  20718. /**
  20719. * WebVR's attach control will start broadcasting frames to the device.
  20720. * Note that in certain browsers (chrome for example) this function must be called
  20721. * within a user-interaction callback. Example:
  20722. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20723. *
  20724. * @param element html element to attach the vrDevice to
  20725. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20726. */
  20727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20728. /**
  20729. * Detaches the camera from the html element and disables VR
  20730. *
  20731. * @param element html element to detach from
  20732. */
  20733. detachControl(element: HTMLElement): void;
  20734. /**
  20735. * @returns the name of this class
  20736. */
  20737. getClassName(): string;
  20738. /**
  20739. * Calls resetPose on the vrDisplay
  20740. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20741. */
  20742. resetToCurrentRotation(): void;
  20743. /**
  20744. * @hidden
  20745. * Updates the rig cameras (left and right eye)
  20746. */
  20747. _updateRigCameras(): void;
  20748. private _workingVector;
  20749. private _oneVector;
  20750. private _workingMatrix;
  20751. private updateCacheCalled;
  20752. private _correctPositionIfNotTrackPosition;
  20753. /**
  20754. * @hidden
  20755. * Updates the cached values of the camera
  20756. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20757. */
  20758. _updateCache(ignoreParentClass?: boolean): void;
  20759. /**
  20760. * @hidden
  20761. * Get current device position in babylon world
  20762. */
  20763. _computeDevicePosition(): void;
  20764. /**
  20765. * Updates the current device position and rotation in the babylon world
  20766. */
  20767. update(): void;
  20768. /**
  20769. * @hidden
  20770. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20771. * @returns an identity matrix
  20772. */
  20773. _getViewMatrix(): Matrix;
  20774. private _tmpMatrix;
  20775. /**
  20776. * This function is called by the two RIG cameras.
  20777. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20778. * @hidden
  20779. */
  20780. _getWebVRViewMatrix(): Matrix;
  20781. /** @hidden */
  20782. _getWebVRProjectionMatrix(): Matrix;
  20783. private _onGamepadConnectedObserver;
  20784. private _onGamepadDisconnectedObserver;
  20785. private _updateCacheWhenTrackingDisabledObserver;
  20786. /**
  20787. * Initializes the controllers and their meshes
  20788. */
  20789. initControllers(): void;
  20790. }
  20791. }
  20792. declare module "babylonjs/Materials/materialHelper" {
  20793. import { Nullable } from "babylonjs/types";
  20794. import { Scene } from "babylonjs/scene";
  20795. import { Engine } from "babylonjs/Engines/engine";
  20796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20797. import { Light } from "babylonjs/Lights/light";
  20798. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20799. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20800. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20801. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20802. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20803. /**
  20804. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20805. *
  20806. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20807. *
  20808. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20809. */
  20810. export class MaterialHelper {
  20811. /**
  20812. * Bind the current view position to an effect.
  20813. * @param effect The effect to be bound
  20814. * @param scene The scene the eyes position is used from
  20815. * @param variableName name of the shader variable that will hold the eye position
  20816. */
  20817. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20818. /**
  20819. * Helps preparing the defines values about the UVs in used in the effect.
  20820. * UVs are shared as much as we can accross channels in the shaders.
  20821. * @param texture The texture we are preparing the UVs for
  20822. * @param defines The defines to update
  20823. * @param key The channel key "diffuse", "specular"... used in the shader
  20824. */
  20825. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20826. /**
  20827. * Binds a texture matrix value to its corrsponding uniform
  20828. * @param texture The texture to bind the matrix for
  20829. * @param uniformBuffer The uniform buffer receivin the data
  20830. * @param key The channel key "diffuse", "specular"... used in the shader
  20831. */
  20832. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20833. /**
  20834. * Gets the current status of the fog (should it be enabled?)
  20835. * @param mesh defines the mesh to evaluate for fog support
  20836. * @param scene defines the hosting scene
  20837. * @returns true if fog must be enabled
  20838. */
  20839. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20840. /**
  20841. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20842. * @param mesh defines the current mesh
  20843. * @param scene defines the current scene
  20844. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20845. * @param pointsCloud defines if point cloud rendering has to be turned on
  20846. * @param fogEnabled defines if fog has to be turned on
  20847. * @param alphaTest defines if alpha testing has to be turned on
  20848. * @param defines defines the current list of defines
  20849. */
  20850. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20851. /**
  20852. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20853. * @param scene defines the current scene
  20854. * @param engine defines the current engine
  20855. * @param defines specifies the list of active defines
  20856. * @param useInstances defines if instances have to be turned on
  20857. * @param useClipPlane defines if clip plane have to be turned on
  20858. * @param useInstances defines if instances have to be turned on
  20859. * @param useThinInstances defines if thin instances have to be turned on
  20860. */
  20861. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20862. /**
  20863. * Prepares the defines for bones
  20864. * @param mesh The mesh containing the geometry data we will draw
  20865. * @param defines The defines to update
  20866. */
  20867. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20868. /**
  20869. * Prepares the defines for morph targets
  20870. * @param mesh The mesh containing the geometry data we will draw
  20871. * @param defines The defines to update
  20872. */
  20873. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20874. /**
  20875. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20876. * @param mesh The mesh containing the geometry data we will draw
  20877. * @param defines The defines to update
  20878. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20879. * @param useBones Precise whether bones should be used or not (override mesh info)
  20880. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20881. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20882. * @returns false if defines are considered not dirty and have not been checked
  20883. */
  20884. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20885. /**
  20886. * Prepares the defines related to multiview
  20887. * @param scene The scene we are intending to draw
  20888. * @param defines The defines to update
  20889. */
  20890. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20891. /**
  20892. * Prepares the defines related to the prepass
  20893. * @param scene The scene we are intending to draw
  20894. * @param defines The defines to update
  20895. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20896. */
  20897. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20898. /**
  20899. * Prepares the defines related to the light information passed in parameter
  20900. * @param scene The scene we are intending to draw
  20901. * @param mesh The mesh the effect is compiling for
  20902. * @param light The light the effect is compiling for
  20903. * @param lightIndex The index of the light
  20904. * @param defines The defines to update
  20905. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20906. * @param state Defines the current state regarding what is needed (normals, etc...)
  20907. */
  20908. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20909. needNormals: boolean;
  20910. needRebuild: boolean;
  20911. shadowEnabled: boolean;
  20912. specularEnabled: boolean;
  20913. lightmapMode: boolean;
  20914. }): void;
  20915. /**
  20916. * Prepares the defines related to the light information passed in parameter
  20917. * @param scene The scene we are intending to draw
  20918. * @param mesh The mesh the effect is compiling for
  20919. * @param defines The defines to update
  20920. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20921. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20922. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20923. * @returns true if normals will be required for the rest of the effect
  20924. */
  20925. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20926. /**
  20927. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20928. * @param lightIndex defines the light index
  20929. * @param uniformsList The uniform list
  20930. * @param samplersList The sampler list
  20931. * @param projectedLightTexture defines if projected texture must be used
  20932. * @param uniformBuffersList defines an optional list of uniform buffers
  20933. */
  20934. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20935. /**
  20936. * Prepares the uniforms and samplers list to be used in the effect
  20937. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20938. * @param samplersList The sampler list
  20939. * @param defines The defines helping in the list generation
  20940. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20941. */
  20942. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20943. /**
  20944. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20945. * @param defines The defines to update while falling back
  20946. * @param fallbacks The authorized effect fallbacks
  20947. * @param maxSimultaneousLights The maximum number of lights allowed
  20948. * @param rank the current rank of the Effect
  20949. * @returns The newly affected rank
  20950. */
  20951. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20952. private static _TmpMorphInfluencers;
  20953. /**
  20954. * Prepares the list of attributes required for morph targets according to the effect defines.
  20955. * @param attribs The current list of supported attribs
  20956. * @param mesh The mesh to prepare the morph targets attributes for
  20957. * @param influencers The number of influencers
  20958. */
  20959. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20960. /**
  20961. * Prepares the list of attributes required for morph targets according to the effect defines.
  20962. * @param attribs The current list of supported attribs
  20963. * @param mesh The mesh to prepare the morph targets attributes for
  20964. * @param defines The current Defines of the effect
  20965. */
  20966. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20967. /**
  20968. * Prepares the list of attributes required for bones according to the effect defines.
  20969. * @param attribs The current list of supported attribs
  20970. * @param mesh The mesh to prepare the bones attributes for
  20971. * @param defines The current Defines of the effect
  20972. * @param fallbacks The current efffect fallback strategy
  20973. */
  20974. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20975. /**
  20976. * Check and prepare the list of attributes required for instances according to the effect defines.
  20977. * @param attribs The current list of supported attribs
  20978. * @param defines The current MaterialDefines of the effect
  20979. */
  20980. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20981. /**
  20982. * Add the list of attributes required for instances to the attribs array.
  20983. * @param attribs The current list of supported attribs
  20984. */
  20985. static PushAttributesForInstances(attribs: string[]): void;
  20986. /**
  20987. * Binds the light information to the effect.
  20988. * @param light The light containing the generator
  20989. * @param effect The effect we are binding the data to
  20990. * @param lightIndex The light index in the effect used to render
  20991. */
  20992. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20993. /**
  20994. * Binds the lights information from the scene to the effect for the given mesh.
  20995. * @param light Light to bind
  20996. * @param lightIndex Light index
  20997. * @param scene The scene where the light belongs to
  20998. * @param effect The effect we are binding the data to
  20999. * @param useSpecular Defines if specular is supported
  21000. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21001. */
  21002. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21003. /**
  21004. * Binds the lights information from the scene to the effect for the given mesh.
  21005. * @param scene The scene the lights belongs to
  21006. * @param mesh The mesh we are binding the information to render
  21007. * @param effect The effect we are binding the data to
  21008. * @param defines The generated defines for the effect
  21009. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21010. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21011. */
  21012. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21013. private static _tempFogColor;
  21014. /**
  21015. * Binds the fog information from the scene to the effect for the given mesh.
  21016. * @param scene The scene the lights belongs to
  21017. * @param mesh The mesh we are binding the information to render
  21018. * @param effect The effect we are binding the data to
  21019. * @param linearSpace Defines if the fog effect is applied in linear space
  21020. */
  21021. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21022. /**
  21023. * Binds the bones information from the mesh to the effect.
  21024. * @param mesh The mesh we are binding the information to render
  21025. * @param effect The effect we are binding the data to
  21026. */
  21027. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21028. /**
  21029. * Binds the morph targets information from the mesh to the effect.
  21030. * @param abstractMesh The mesh we are binding the information to render
  21031. * @param effect The effect we are binding the data to
  21032. */
  21033. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21034. /**
  21035. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21036. * @param defines The generated defines used in the effect
  21037. * @param effect The effect we are binding the data to
  21038. * @param scene The scene we are willing to render with logarithmic scale for
  21039. */
  21040. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21041. /**
  21042. * Binds the clip plane information from the scene to the effect.
  21043. * @param scene The scene the clip plane information are extracted from
  21044. * @param effect The effect we are binding the data to
  21045. */
  21046. static BindClipPlane(effect: Effect, scene: Scene): void;
  21047. }
  21048. }
  21049. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21051. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21052. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21053. import { Nullable } from "babylonjs/types";
  21054. import { Effect } from "babylonjs/Materials/effect";
  21055. import { Matrix } from "babylonjs/Maths/math.vector";
  21056. import { Scene } from "babylonjs/scene";
  21057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21059. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21060. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21061. import { Observable } from "babylonjs/Misc/observable";
  21062. /**
  21063. * Block used to expose an input value
  21064. */
  21065. export class InputBlock extends NodeMaterialBlock {
  21066. private _mode;
  21067. private _associatedVariableName;
  21068. private _storedValue;
  21069. private _valueCallback;
  21070. private _type;
  21071. private _animationType;
  21072. /** Gets or set a value used to limit the range of float values */
  21073. min: number;
  21074. /** Gets or set a value used to limit the range of float values */
  21075. max: number;
  21076. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21077. isBoolean: boolean;
  21078. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21079. matrixMode: number;
  21080. /** @hidden */
  21081. _systemValue: Nullable<NodeMaterialSystemValues>;
  21082. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21083. visibleInInspector: boolean;
  21084. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21085. isConstant: boolean;
  21086. /** Gets or sets the group to use to display this block in the Inspector */
  21087. groupInInspector: string;
  21088. /** Gets an observable raised when the value is changed */
  21089. onValueChangedObservable: Observable<InputBlock>;
  21090. /**
  21091. * Gets or sets the connection point type (default is float)
  21092. */
  21093. get type(): NodeMaterialBlockConnectionPointTypes;
  21094. /**
  21095. * Creates a new InputBlock
  21096. * @param name defines the block name
  21097. * @param target defines the target of that block (Vertex by default)
  21098. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21099. */
  21100. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21101. /**
  21102. * Validates if a name is a reserve word.
  21103. * @param newName the new name to be given to the node.
  21104. * @returns false if the name is a reserve word, else true.
  21105. */
  21106. validateBlockName(newName: string): boolean;
  21107. /**
  21108. * Gets the output component
  21109. */
  21110. get output(): NodeMaterialConnectionPoint;
  21111. /**
  21112. * Set the source of this connection point to a vertex attribute
  21113. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21114. * @returns the current connection point
  21115. */
  21116. setAsAttribute(attributeName?: string): InputBlock;
  21117. /**
  21118. * Set the source of this connection point to a system value
  21119. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21120. * @returns the current connection point
  21121. */
  21122. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21123. /**
  21124. * Gets or sets the value of that point.
  21125. * Please note that this value will be ignored if valueCallback is defined
  21126. */
  21127. get value(): any;
  21128. set value(value: any);
  21129. /**
  21130. * Gets or sets a callback used to get the value of that point.
  21131. * Please note that setting this value will force the connection point to ignore the value property
  21132. */
  21133. get valueCallback(): () => any;
  21134. set valueCallback(value: () => any);
  21135. /**
  21136. * Gets or sets the associated variable name in the shader
  21137. */
  21138. get associatedVariableName(): string;
  21139. set associatedVariableName(value: string);
  21140. /** Gets or sets the type of animation applied to the input */
  21141. get animationType(): AnimatedInputBlockTypes;
  21142. set animationType(value: AnimatedInputBlockTypes);
  21143. /**
  21144. * Gets a boolean indicating that this connection point not defined yet
  21145. */
  21146. get isUndefined(): boolean;
  21147. /**
  21148. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21149. * In this case the connection point name must be the name of the uniform to use.
  21150. * Can only be set on inputs
  21151. */
  21152. get isUniform(): boolean;
  21153. set isUniform(value: boolean);
  21154. /**
  21155. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21156. * In this case the connection point name must be the name of the attribute to use
  21157. * Can only be set on inputs
  21158. */
  21159. get isAttribute(): boolean;
  21160. set isAttribute(value: boolean);
  21161. /**
  21162. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21163. * Can only be set on exit points
  21164. */
  21165. get isVarying(): boolean;
  21166. set isVarying(value: boolean);
  21167. /**
  21168. * Gets a boolean indicating that the current connection point is a system value
  21169. */
  21170. get isSystemValue(): boolean;
  21171. /**
  21172. * Gets or sets the current well known value or null if not defined as a system value
  21173. */
  21174. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21175. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21176. /**
  21177. * Gets the current class name
  21178. * @returns the class name
  21179. */
  21180. getClassName(): string;
  21181. /**
  21182. * Animate the input if animationType !== None
  21183. * @param scene defines the rendering scene
  21184. */
  21185. animate(scene: Scene): void;
  21186. private _emitDefine;
  21187. initialize(state: NodeMaterialBuildState): void;
  21188. /**
  21189. * Set the input block to its default value (based on its type)
  21190. */
  21191. setDefaultValue(): void;
  21192. private _emitConstant;
  21193. /** @hidden */
  21194. get _noContextSwitch(): boolean;
  21195. private _emit;
  21196. /** @hidden */
  21197. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21198. /** @hidden */
  21199. _transmit(effect: Effect, scene: Scene): void;
  21200. protected _buildBlock(state: NodeMaterialBuildState): void;
  21201. protected _dumpPropertiesCode(): string;
  21202. dispose(): void;
  21203. serialize(): any;
  21204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21205. }
  21206. }
  21207. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21208. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21209. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21210. import { Nullable } from "babylonjs/types";
  21211. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21212. import { Observable } from "babylonjs/Misc/observable";
  21213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21214. /**
  21215. * Enum used to define the compatibility state between two connection points
  21216. */
  21217. export enum NodeMaterialConnectionPointCompatibilityStates {
  21218. /** Points are compatibles */
  21219. Compatible = 0,
  21220. /** Points are incompatible because of their types */
  21221. TypeIncompatible = 1,
  21222. /** Points are incompatible because of their targets (vertex vs fragment) */
  21223. TargetIncompatible = 2
  21224. }
  21225. /**
  21226. * Defines the direction of a connection point
  21227. */
  21228. export enum NodeMaterialConnectionPointDirection {
  21229. /** Input */
  21230. Input = 0,
  21231. /** Output */
  21232. Output = 1
  21233. }
  21234. /**
  21235. * Defines a connection point for a block
  21236. */
  21237. export class NodeMaterialConnectionPoint {
  21238. /** @hidden */
  21239. _ownerBlock: NodeMaterialBlock;
  21240. /** @hidden */
  21241. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21242. private _endpoints;
  21243. private _associatedVariableName;
  21244. private _direction;
  21245. /** @hidden */
  21246. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21247. /** @hidden */
  21248. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21249. private _type;
  21250. /** @hidden */
  21251. _enforceAssociatedVariableName: boolean;
  21252. /** Gets the direction of the point */
  21253. get direction(): NodeMaterialConnectionPointDirection;
  21254. /** Indicates that this connection point needs dual validation before being connected to another point */
  21255. needDualDirectionValidation: boolean;
  21256. /**
  21257. * Gets or sets the additional types supported by this connection point
  21258. */
  21259. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21260. /**
  21261. * Gets or sets the additional types excluded by this connection point
  21262. */
  21263. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21264. /**
  21265. * Observable triggered when this point is connected
  21266. */
  21267. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21268. /**
  21269. * Gets or sets the associated variable name in the shader
  21270. */
  21271. get associatedVariableName(): string;
  21272. set associatedVariableName(value: string);
  21273. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21274. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21275. /**
  21276. * Gets or sets the connection point type (default is float)
  21277. */
  21278. get type(): NodeMaterialBlockConnectionPointTypes;
  21279. set type(value: NodeMaterialBlockConnectionPointTypes);
  21280. /**
  21281. * Gets or sets the connection point name
  21282. */
  21283. name: string;
  21284. /**
  21285. * Gets or sets the connection point name
  21286. */
  21287. displayName: string;
  21288. /**
  21289. * Gets or sets a boolean indicating that this connection point can be omitted
  21290. */
  21291. isOptional: boolean;
  21292. /**
  21293. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21294. */
  21295. isExposedOnFrame: boolean;
  21296. /**
  21297. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21298. */
  21299. define: string;
  21300. /** @hidden */
  21301. _prioritizeVertex: boolean;
  21302. private _target;
  21303. /** Gets or sets the target of that connection point */
  21304. get target(): NodeMaterialBlockTargets;
  21305. set target(value: NodeMaterialBlockTargets);
  21306. /**
  21307. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21308. */
  21309. get isConnected(): boolean;
  21310. /**
  21311. * Gets a boolean indicating that the current point is connected to an input block
  21312. */
  21313. get isConnectedToInputBlock(): boolean;
  21314. /**
  21315. * Gets a the connected input block (if any)
  21316. */
  21317. get connectInputBlock(): Nullable<InputBlock>;
  21318. /** Get the other side of the connection (if any) */
  21319. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21320. /** Get the block that owns this connection point */
  21321. get ownerBlock(): NodeMaterialBlock;
  21322. /** Get the block connected on the other side of this connection (if any) */
  21323. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21324. /** Get the block connected on the endpoints of this connection (if any) */
  21325. get connectedBlocks(): Array<NodeMaterialBlock>;
  21326. /** Gets the list of connected endpoints */
  21327. get endpoints(): NodeMaterialConnectionPoint[];
  21328. /** Gets a boolean indicating if that output point is connected to at least one input */
  21329. get hasEndpoints(): boolean;
  21330. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21331. get isConnectedInVertexShader(): boolean;
  21332. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21333. get isConnectedInFragmentShader(): boolean;
  21334. /**
  21335. * Creates a block suitable to be used as an input for this input point.
  21336. * If null is returned, a block based on the point type will be created.
  21337. * @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
  21338. */
  21339. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21340. /**
  21341. * Creates a new connection point
  21342. * @param name defines the connection point name
  21343. * @param ownerBlock defines the block hosting this connection point
  21344. * @param direction defines the direction of the connection point
  21345. */
  21346. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21347. /**
  21348. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21349. * @returns the class name
  21350. */
  21351. getClassName(): string;
  21352. /**
  21353. * Gets a boolean indicating if the current point can be connected to another point
  21354. * @param connectionPoint defines the other connection point
  21355. * @returns a boolean
  21356. */
  21357. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21358. /**
  21359. * Gets a number indicating if the current point can be connected to another point
  21360. * @param connectionPoint defines the other connection point
  21361. * @returns a number defining the compatibility state
  21362. */
  21363. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21364. /**
  21365. * Connect this point to another connection point
  21366. * @param connectionPoint defines the other connection point
  21367. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21368. * @returns the current connection point
  21369. */
  21370. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Disconnect this point from one of his endpoint
  21373. * @param endpoint defines the other connection point
  21374. * @returns the current connection point
  21375. */
  21376. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21377. /**
  21378. * Serializes this point in a JSON representation
  21379. * @param isInput defines if the connection point is an input (default is true)
  21380. * @returns the serialized point object
  21381. */
  21382. serialize(isInput?: boolean): any;
  21383. /**
  21384. * Release resources
  21385. */
  21386. dispose(): void;
  21387. }
  21388. }
  21389. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21390. /**
  21391. * Enum used to define the material modes
  21392. */
  21393. export enum NodeMaterialModes {
  21394. /** Regular material */
  21395. Material = 0,
  21396. /** For post process */
  21397. PostProcess = 1,
  21398. /** For particle system */
  21399. Particle = 2
  21400. }
  21401. }
  21402. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21405. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21408. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21409. import { Effect } from "babylonjs/Materials/effect";
  21410. import { Mesh } from "babylonjs/Meshes/mesh";
  21411. import { Nullable } from "babylonjs/types";
  21412. import { Texture } from "babylonjs/Materials/Textures/texture";
  21413. import { Scene } from "babylonjs/scene";
  21414. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21415. /**
  21416. * Block used to read a texture from a sampler
  21417. */
  21418. export class TextureBlock extends NodeMaterialBlock {
  21419. private _defineName;
  21420. private _linearDefineName;
  21421. private _gammaDefineName;
  21422. private _tempTextureRead;
  21423. private _samplerName;
  21424. private _transformedUVName;
  21425. private _textureTransformName;
  21426. private _textureInfoName;
  21427. private _mainUVName;
  21428. private _mainUVDefineName;
  21429. private _fragmentOnly;
  21430. /**
  21431. * Gets or sets the texture associated with the node
  21432. */
  21433. texture: Nullable<Texture>;
  21434. /**
  21435. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21436. */
  21437. convertToGammaSpace: boolean;
  21438. /**
  21439. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21440. */
  21441. convertToLinearSpace: boolean;
  21442. /**
  21443. * Create a new TextureBlock
  21444. * @param name defines the block name
  21445. */
  21446. constructor(name: string, fragmentOnly?: boolean);
  21447. /**
  21448. * Gets the current class name
  21449. * @returns the class name
  21450. */
  21451. getClassName(): string;
  21452. /**
  21453. * Gets the uv input component
  21454. */
  21455. get uv(): NodeMaterialConnectionPoint;
  21456. /**
  21457. * Gets the rgba output component
  21458. */
  21459. get rgba(): NodeMaterialConnectionPoint;
  21460. /**
  21461. * Gets the rgb output component
  21462. */
  21463. get rgb(): NodeMaterialConnectionPoint;
  21464. /**
  21465. * Gets the r output component
  21466. */
  21467. get r(): NodeMaterialConnectionPoint;
  21468. /**
  21469. * Gets the g output component
  21470. */
  21471. get g(): NodeMaterialConnectionPoint;
  21472. /**
  21473. * Gets the b output component
  21474. */
  21475. get b(): NodeMaterialConnectionPoint;
  21476. /**
  21477. * Gets the a output component
  21478. */
  21479. get a(): NodeMaterialConnectionPoint;
  21480. get target(): NodeMaterialBlockTargets;
  21481. autoConfigure(material: NodeMaterial): void;
  21482. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21484. isReady(): boolean;
  21485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21486. private get _isMixed();
  21487. private _injectVertexCode;
  21488. private _writeTextureRead;
  21489. private _writeOutput;
  21490. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21491. protected _dumpPropertiesCode(): string;
  21492. serialize(): any;
  21493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21494. }
  21495. }
  21496. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21497. /** @hidden */
  21498. export var reflectionFunction: {
  21499. name: string;
  21500. shader: string;
  21501. };
  21502. }
  21503. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21509. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21510. import { Effect } from "babylonjs/Materials/effect";
  21511. import { Mesh } from "babylonjs/Meshes/mesh";
  21512. import { Nullable } from "babylonjs/types";
  21513. import { Scene } from "babylonjs/scene";
  21514. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21515. /**
  21516. * Base block used to read a reflection texture from a sampler
  21517. */
  21518. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21519. /** @hidden */
  21520. _define3DName: string;
  21521. /** @hidden */
  21522. _defineCubicName: string;
  21523. /** @hidden */
  21524. _defineExplicitName: string;
  21525. /** @hidden */
  21526. _defineProjectionName: string;
  21527. /** @hidden */
  21528. _defineLocalCubicName: string;
  21529. /** @hidden */
  21530. _defineSphericalName: string;
  21531. /** @hidden */
  21532. _definePlanarName: string;
  21533. /** @hidden */
  21534. _defineEquirectangularName: string;
  21535. /** @hidden */
  21536. _defineMirroredEquirectangularFixedName: string;
  21537. /** @hidden */
  21538. _defineEquirectangularFixedName: string;
  21539. /** @hidden */
  21540. _defineSkyboxName: string;
  21541. /** @hidden */
  21542. _defineOppositeZ: string;
  21543. /** @hidden */
  21544. _cubeSamplerName: string;
  21545. /** @hidden */
  21546. _2DSamplerName: string;
  21547. protected _positionUVWName: string;
  21548. protected _directionWName: string;
  21549. protected _reflectionVectorName: string;
  21550. /** @hidden */
  21551. _reflectionCoordsName: string;
  21552. /** @hidden */
  21553. _reflectionMatrixName: string;
  21554. protected _reflectionColorName: string;
  21555. /**
  21556. * Gets or sets the texture associated with the node
  21557. */
  21558. texture: Nullable<BaseTexture>;
  21559. /**
  21560. * Create a new ReflectionTextureBaseBlock
  21561. * @param name defines the block name
  21562. */
  21563. constructor(name: string);
  21564. /**
  21565. * Gets the current class name
  21566. * @returns the class name
  21567. */
  21568. getClassName(): string;
  21569. /**
  21570. * Gets the world position input component
  21571. */
  21572. abstract get position(): NodeMaterialConnectionPoint;
  21573. /**
  21574. * Gets the world position input component
  21575. */
  21576. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21577. /**
  21578. * Gets the world normal input component
  21579. */
  21580. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21581. /**
  21582. * Gets the world input component
  21583. */
  21584. abstract get world(): NodeMaterialConnectionPoint;
  21585. /**
  21586. * Gets the camera (or eye) position component
  21587. */
  21588. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21589. /**
  21590. * Gets the view input component
  21591. */
  21592. abstract get view(): NodeMaterialConnectionPoint;
  21593. protected _getTexture(): Nullable<BaseTexture>;
  21594. autoConfigure(material: NodeMaterial): void;
  21595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21596. isReady(): boolean;
  21597. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21598. /**
  21599. * Gets the code to inject in the vertex shader
  21600. * @param state current state of the node material building
  21601. * @returns the shader code
  21602. */
  21603. handleVertexSide(state: NodeMaterialBuildState): string;
  21604. /**
  21605. * Handles the inits for the fragment code path
  21606. * @param state node material build state
  21607. */
  21608. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21609. /**
  21610. * Generates the reflection coords code for the fragment code path
  21611. * @param worldNormalVarName name of the world normal variable
  21612. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21613. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21614. * @returns the shader code
  21615. */
  21616. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21617. /**
  21618. * Generates the reflection color code for the fragment code path
  21619. * @param lodVarName name of the lod variable
  21620. * @param swizzleLookupTexture swizzle to use for the final color variable
  21621. * @returns the shader code
  21622. */
  21623. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21624. /**
  21625. * Generates the code corresponding to the connected output points
  21626. * @param state node material build state
  21627. * @param varName name of the variable to output
  21628. * @returns the shader code
  21629. */
  21630. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21631. protected _buildBlock(state: NodeMaterialBuildState): this;
  21632. protected _dumpPropertiesCode(): string;
  21633. serialize(): any;
  21634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21635. }
  21636. }
  21637. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21639. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21640. import { Nullable } from "babylonjs/types";
  21641. /**
  21642. * Defines a connection point to be used for points with a custom object type
  21643. */
  21644. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21645. private _blockType;
  21646. private _blockName;
  21647. private _nameForCheking?;
  21648. /**
  21649. * Creates a new connection point
  21650. * @param name defines the connection point name
  21651. * @param ownerBlock defines the block hosting this connection point
  21652. * @param direction defines the direction of the connection point
  21653. */
  21654. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21655. /**
  21656. * Gets a number indicating if the current point can be connected to another point
  21657. * @param connectionPoint defines the other connection point
  21658. * @returns a number defining the compatibility state
  21659. */
  21660. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21661. /**
  21662. * Creates a block suitable to be used as an input for this input point.
  21663. * If null is returned, a block based on the point type will be created.
  21664. * @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
  21665. */
  21666. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21667. }
  21668. }
  21669. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21670. /**
  21671. * Enum defining the type of properties that can be edited in the property pages in the NME
  21672. */
  21673. export enum PropertyTypeForEdition {
  21674. /** property is a boolean */
  21675. Boolean = 0,
  21676. /** property is a float */
  21677. Float = 1,
  21678. /** property is a Vector2 */
  21679. Vector2 = 2,
  21680. /** property is a list of values */
  21681. List = 3
  21682. }
  21683. /**
  21684. * Interface that defines an option in a variable of type list
  21685. */
  21686. export interface IEditablePropertyListOption {
  21687. /** label of the option */
  21688. "label": string;
  21689. /** value of the option */
  21690. "value": number;
  21691. }
  21692. /**
  21693. * Interface that defines the options available for an editable property
  21694. */
  21695. export interface IEditablePropertyOption {
  21696. /** min value */
  21697. "min"?: number;
  21698. /** max value */
  21699. "max"?: number;
  21700. /** notifiers: indicates which actions to take when the property is changed */
  21701. "notifiers"?: {
  21702. /** the material should be rebuilt */
  21703. "rebuild"?: boolean;
  21704. /** the preview should be updated */
  21705. "update"?: boolean;
  21706. };
  21707. /** list of the options for a variable of type list */
  21708. "options"?: IEditablePropertyListOption[];
  21709. }
  21710. /**
  21711. * Interface that describes an editable property
  21712. */
  21713. export interface IPropertyDescriptionForEdition {
  21714. /** name of the property */
  21715. "propertyName": string;
  21716. /** display name of the property */
  21717. "displayName": string;
  21718. /** type of the property */
  21719. "type": PropertyTypeForEdition;
  21720. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21721. "groupName": string;
  21722. /** options for the property */
  21723. "options": IEditablePropertyOption;
  21724. }
  21725. /**
  21726. * Decorator that flags a property in a node material block as being editable
  21727. */
  21728. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21729. }
  21730. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21733. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21735. import { Nullable } from "babylonjs/types";
  21736. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21737. import { Mesh } from "babylonjs/Meshes/mesh";
  21738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21739. import { Effect } from "babylonjs/Materials/effect";
  21740. import { Scene } from "babylonjs/scene";
  21741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21742. /**
  21743. * Block used to implement the refraction part of the sub surface module of the PBR material
  21744. */
  21745. export class RefractionBlock extends NodeMaterialBlock {
  21746. /** @hidden */
  21747. _define3DName: string;
  21748. /** @hidden */
  21749. _refractionMatrixName: string;
  21750. /** @hidden */
  21751. _defineLODRefractionAlpha: string;
  21752. /** @hidden */
  21753. _defineLinearSpecularRefraction: string;
  21754. /** @hidden */
  21755. _defineOppositeZ: string;
  21756. /** @hidden */
  21757. _cubeSamplerName: string;
  21758. /** @hidden */
  21759. _2DSamplerName: string;
  21760. /** @hidden */
  21761. _vRefractionMicrosurfaceInfosName: string;
  21762. /** @hidden */
  21763. _vRefractionInfosName: string;
  21764. private _scene;
  21765. /**
  21766. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21767. * Materials half opaque for instance using refraction could benefit from this control.
  21768. */
  21769. linkRefractionWithTransparency: boolean;
  21770. /**
  21771. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21772. */
  21773. invertRefractionY: boolean;
  21774. /**
  21775. * Gets or sets the texture associated with the node
  21776. */
  21777. texture: Nullable<BaseTexture>;
  21778. /**
  21779. * Create a new RefractionBlock
  21780. * @param name defines the block name
  21781. */
  21782. constructor(name: string);
  21783. /**
  21784. * Gets the current class name
  21785. * @returns the class name
  21786. */
  21787. getClassName(): string;
  21788. /**
  21789. * Gets the intensity input component
  21790. */
  21791. get intensity(): NodeMaterialConnectionPoint;
  21792. /**
  21793. * Gets the index of refraction input component
  21794. */
  21795. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21796. /**
  21797. * Gets the tint at distance input component
  21798. */
  21799. get tintAtDistance(): NodeMaterialConnectionPoint;
  21800. /**
  21801. * Gets the view input component
  21802. */
  21803. get view(): NodeMaterialConnectionPoint;
  21804. /**
  21805. * Gets the refraction object output component
  21806. */
  21807. get refraction(): NodeMaterialConnectionPoint;
  21808. /**
  21809. * Returns true if the block has a texture
  21810. */
  21811. get hasTexture(): boolean;
  21812. protected _getTexture(): Nullable<BaseTexture>;
  21813. autoConfigure(material: NodeMaterial): void;
  21814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21815. isReady(): boolean;
  21816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21817. /**
  21818. * Gets the main code of the block (fragment side)
  21819. * @param state current state of the node material building
  21820. * @returns the shader code
  21821. */
  21822. getCode(state: NodeMaterialBuildState): string;
  21823. protected _buildBlock(state: NodeMaterialBuildState): this;
  21824. protected _dumpPropertiesCode(): string;
  21825. serialize(): any;
  21826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21827. }
  21828. }
  21829. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21832. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21835. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21837. import { Nullable } from "babylonjs/types";
  21838. import { Scene } from "babylonjs/scene";
  21839. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21840. /**
  21841. * Base block used as input for post process
  21842. */
  21843. export class CurrentScreenBlock extends NodeMaterialBlock {
  21844. private _samplerName;
  21845. private _linearDefineName;
  21846. private _gammaDefineName;
  21847. private _mainUVName;
  21848. private _tempTextureRead;
  21849. /**
  21850. * Gets or sets the texture associated with the node
  21851. */
  21852. texture: Nullable<BaseTexture>;
  21853. /**
  21854. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21855. */
  21856. convertToGammaSpace: boolean;
  21857. /**
  21858. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21859. */
  21860. convertToLinearSpace: boolean;
  21861. /**
  21862. * Create a new CurrentScreenBlock
  21863. * @param name defines the block name
  21864. */
  21865. constructor(name: string);
  21866. /**
  21867. * Gets the current class name
  21868. * @returns the class name
  21869. */
  21870. getClassName(): string;
  21871. /**
  21872. * Gets the uv input component
  21873. */
  21874. get uv(): NodeMaterialConnectionPoint;
  21875. /**
  21876. * Gets the rgba output component
  21877. */
  21878. get rgba(): NodeMaterialConnectionPoint;
  21879. /**
  21880. * Gets the rgb output component
  21881. */
  21882. get rgb(): NodeMaterialConnectionPoint;
  21883. /**
  21884. * Gets the r output component
  21885. */
  21886. get r(): NodeMaterialConnectionPoint;
  21887. /**
  21888. * Gets the g output component
  21889. */
  21890. get g(): NodeMaterialConnectionPoint;
  21891. /**
  21892. * Gets the b output component
  21893. */
  21894. get b(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the a output component
  21897. */
  21898. get a(): NodeMaterialConnectionPoint;
  21899. /**
  21900. * Initialize the block and prepare the context for build
  21901. * @param state defines the state that will be used for the build
  21902. */
  21903. initialize(state: NodeMaterialBuildState): void;
  21904. get target(): NodeMaterialBlockTargets;
  21905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21906. isReady(): boolean;
  21907. private _injectVertexCode;
  21908. private _writeTextureRead;
  21909. private _writeOutput;
  21910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21911. serialize(): any;
  21912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21913. }
  21914. }
  21915. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21920. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21922. import { Nullable } from "babylonjs/types";
  21923. import { Scene } from "babylonjs/scene";
  21924. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21925. /**
  21926. * Base block used for the particle texture
  21927. */
  21928. export class ParticleTextureBlock extends NodeMaterialBlock {
  21929. private _samplerName;
  21930. private _linearDefineName;
  21931. private _gammaDefineName;
  21932. private _tempTextureRead;
  21933. /**
  21934. * Gets or sets the texture associated with the node
  21935. */
  21936. texture: Nullable<BaseTexture>;
  21937. /**
  21938. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21939. */
  21940. convertToGammaSpace: boolean;
  21941. /**
  21942. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21943. */
  21944. convertToLinearSpace: boolean;
  21945. /**
  21946. * Create a new ParticleTextureBlock
  21947. * @param name defines the block name
  21948. */
  21949. constructor(name: string);
  21950. /**
  21951. * Gets the current class name
  21952. * @returns the class name
  21953. */
  21954. getClassName(): string;
  21955. /**
  21956. * Gets the uv input component
  21957. */
  21958. get uv(): NodeMaterialConnectionPoint;
  21959. /**
  21960. * Gets the rgba output component
  21961. */
  21962. get rgba(): NodeMaterialConnectionPoint;
  21963. /**
  21964. * Gets the rgb output component
  21965. */
  21966. get rgb(): NodeMaterialConnectionPoint;
  21967. /**
  21968. * Gets the r output component
  21969. */
  21970. get r(): NodeMaterialConnectionPoint;
  21971. /**
  21972. * Gets the g output component
  21973. */
  21974. get g(): NodeMaterialConnectionPoint;
  21975. /**
  21976. * Gets the b output component
  21977. */
  21978. get b(): NodeMaterialConnectionPoint;
  21979. /**
  21980. * Gets the a output component
  21981. */
  21982. get a(): NodeMaterialConnectionPoint;
  21983. /**
  21984. * Initialize the block and prepare the context for build
  21985. * @param state defines the state that will be used for the build
  21986. */
  21987. initialize(state: NodeMaterialBuildState): void;
  21988. autoConfigure(material: NodeMaterial): void;
  21989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21990. isReady(): boolean;
  21991. private _writeOutput;
  21992. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21993. serialize(): any;
  21994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21995. }
  21996. }
  21997. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22000. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22001. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22002. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22003. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22004. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22005. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22006. import { Scene } from "babylonjs/scene";
  22007. /**
  22008. * Class used to store shared data between 2 NodeMaterialBuildState
  22009. */
  22010. export class NodeMaterialBuildStateSharedData {
  22011. /**
  22012. * Gets the list of emitted varyings
  22013. */
  22014. temps: string[];
  22015. /**
  22016. * Gets the list of emitted varyings
  22017. */
  22018. varyings: string[];
  22019. /**
  22020. * Gets the varying declaration string
  22021. */
  22022. varyingDeclaration: string;
  22023. /**
  22024. * Input blocks
  22025. */
  22026. inputBlocks: InputBlock[];
  22027. /**
  22028. * Input blocks
  22029. */
  22030. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22031. /**
  22032. * Bindable blocks (Blocks that need to set data to the effect)
  22033. */
  22034. bindableBlocks: NodeMaterialBlock[];
  22035. /**
  22036. * List of blocks that can provide a compilation fallback
  22037. */
  22038. blocksWithFallbacks: NodeMaterialBlock[];
  22039. /**
  22040. * List of blocks that can provide a define update
  22041. */
  22042. blocksWithDefines: NodeMaterialBlock[];
  22043. /**
  22044. * List of blocks that can provide a repeatable content
  22045. */
  22046. repeatableContentBlocks: NodeMaterialBlock[];
  22047. /**
  22048. * List of blocks that can provide a dynamic list of uniforms
  22049. */
  22050. dynamicUniformBlocks: NodeMaterialBlock[];
  22051. /**
  22052. * List of blocks that can block the isReady function for the material
  22053. */
  22054. blockingBlocks: NodeMaterialBlock[];
  22055. /**
  22056. * Gets the list of animated inputs
  22057. */
  22058. animatedInputs: InputBlock[];
  22059. /**
  22060. * Build Id used to avoid multiple recompilations
  22061. */
  22062. buildId: number;
  22063. /** List of emitted variables */
  22064. variableNames: {
  22065. [key: string]: number;
  22066. };
  22067. /** List of emitted defines */
  22068. defineNames: {
  22069. [key: string]: number;
  22070. };
  22071. /** Should emit comments? */
  22072. emitComments: boolean;
  22073. /** Emit build activity */
  22074. verbose: boolean;
  22075. /** Gets or sets the hosting scene */
  22076. scene: Scene;
  22077. /**
  22078. * Gets the compilation hints emitted at compilation time
  22079. */
  22080. hints: {
  22081. needWorldViewMatrix: boolean;
  22082. needWorldViewProjectionMatrix: boolean;
  22083. needAlphaBlending: boolean;
  22084. needAlphaTesting: boolean;
  22085. };
  22086. /**
  22087. * List of compilation checks
  22088. */
  22089. checks: {
  22090. emitVertex: boolean;
  22091. emitFragment: boolean;
  22092. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22093. };
  22094. /**
  22095. * Is vertex program allowed to be empty?
  22096. */
  22097. allowEmptyVertexProgram: boolean;
  22098. /** Creates a new shared data */
  22099. constructor();
  22100. /**
  22101. * Emits console errors and exceptions if there is a failing check
  22102. */
  22103. emitErrors(): void;
  22104. }
  22105. }
  22106. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22107. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22108. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22109. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22110. /**
  22111. * Class used to store node based material build state
  22112. */
  22113. export class NodeMaterialBuildState {
  22114. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22115. supportUniformBuffers: boolean;
  22116. /**
  22117. * Gets the list of emitted attributes
  22118. */
  22119. attributes: string[];
  22120. /**
  22121. * Gets the list of emitted uniforms
  22122. */
  22123. uniforms: string[];
  22124. /**
  22125. * Gets the list of emitted constants
  22126. */
  22127. constants: string[];
  22128. /**
  22129. * Gets the list of emitted samplers
  22130. */
  22131. samplers: string[];
  22132. /**
  22133. * Gets the list of emitted functions
  22134. */
  22135. functions: {
  22136. [key: string]: string;
  22137. };
  22138. /**
  22139. * Gets the list of emitted extensions
  22140. */
  22141. extensions: {
  22142. [key: string]: string;
  22143. };
  22144. /**
  22145. * Gets the target of the compilation state
  22146. */
  22147. target: NodeMaterialBlockTargets;
  22148. /**
  22149. * Gets the list of emitted counters
  22150. */
  22151. counters: {
  22152. [key: string]: number;
  22153. };
  22154. /**
  22155. * Shared data between multiple NodeMaterialBuildState instances
  22156. */
  22157. sharedData: NodeMaterialBuildStateSharedData;
  22158. /** @hidden */
  22159. _vertexState: NodeMaterialBuildState;
  22160. /** @hidden */
  22161. _attributeDeclaration: string;
  22162. /** @hidden */
  22163. _uniformDeclaration: string;
  22164. /** @hidden */
  22165. _constantDeclaration: string;
  22166. /** @hidden */
  22167. _samplerDeclaration: string;
  22168. /** @hidden */
  22169. _varyingTransfer: string;
  22170. /** @hidden */
  22171. _injectAtEnd: string;
  22172. private _repeatableContentAnchorIndex;
  22173. /** @hidden */
  22174. _builtCompilationString: string;
  22175. /**
  22176. * Gets the emitted compilation strings
  22177. */
  22178. compilationString: string;
  22179. /**
  22180. * Finalize the compilation strings
  22181. * @param state defines the current compilation state
  22182. */
  22183. finalize(state: NodeMaterialBuildState): void;
  22184. /** @hidden */
  22185. get _repeatableContentAnchor(): string;
  22186. /** @hidden */
  22187. _getFreeVariableName(prefix: string): string;
  22188. /** @hidden */
  22189. _getFreeDefineName(prefix: string): string;
  22190. /** @hidden */
  22191. _excludeVariableName(name: string): void;
  22192. /** @hidden */
  22193. _emit2DSampler(name: string): void;
  22194. /** @hidden */
  22195. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22196. /** @hidden */
  22197. _emitExtension(name: string, extension: string, define?: string): void;
  22198. /** @hidden */
  22199. _emitFunction(name: string, code: string, comments: string): void;
  22200. /** @hidden */
  22201. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22202. replaceStrings?: {
  22203. search: RegExp;
  22204. replace: string;
  22205. }[];
  22206. repeatKey?: string;
  22207. }): string;
  22208. /** @hidden */
  22209. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22210. repeatKey?: string;
  22211. removeAttributes?: boolean;
  22212. removeUniforms?: boolean;
  22213. removeVaryings?: boolean;
  22214. removeIfDef?: boolean;
  22215. replaceStrings?: {
  22216. search: RegExp;
  22217. replace: string;
  22218. }[];
  22219. }, storeKey?: string): void;
  22220. /** @hidden */
  22221. _registerTempVariable(name: string): boolean;
  22222. /** @hidden */
  22223. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22224. /** @hidden */
  22225. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22226. /** @hidden */
  22227. _emitFloat(value: number): string;
  22228. }
  22229. }
  22230. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22231. /**
  22232. * Helper class used to generate session unique ID
  22233. */
  22234. export class UniqueIdGenerator {
  22235. private static _UniqueIdCounter;
  22236. /**
  22237. * Gets an unique (relatively to the current scene) Id
  22238. */
  22239. static get UniqueId(): number;
  22240. }
  22241. }
  22242. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22243. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22245. import { Nullable } from "babylonjs/types";
  22246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22247. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22248. import { Effect } from "babylonjs/Materials/effect";
  22249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22250. import { Mesh } from "babylonjs/Meshes/mesh";
  22251. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22252. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22253. import { Scene } from "babylonjs/scene";
  22254. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22255. /**
  22256. * Defines a block that can be used inside a node based material
  22257. */
  22258. export class NodeMaterialBlock {
  22259. private _buildId;
  22260. private _buildTarget;
  22261. private _target;
  22262. private _isFinalMerger;
  22263. private _isInput;
  22264. private _name;
  22265. protected _isUnique: boolean;
  22266. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22267. inputsAreExclusive: boolean;
  22268. /** @hidden */
  22269. _codeVariableName: string;
  22270. /** @hidden */
  22271. _inputs: NodeMaterialConnectionPoint[];
  22272. /** @hidden */
  22273. _outputs: NodeMaterialConnectionPoint[];
  22274. /** @hidden */
  22275. _preparationId: number;
  22276. /**
  22277. * Gets the name of the block
  22278. */
  22279. get name(): string;
  22280. /**
  22281. * Sets the name of the block. Will check if the name is valid.
  22282. */
  22283. set name(newName: string);
  22284. /**
  22285. * Gets or sets the unique id of the node
  22286. */
  22287. uniqueId: number;
  22288. /**
  22289. * Gets or sets the comments associated with this block
  22290. */
  22291. comments: string;
  22292. /**
  22293. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22294. */
  22295. get isUnique(): boolean;
  22296. /**
  22297. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22298. */
  22299. get isFinalMerger(): boolean;
  22300. /**
  22301. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22302. */
  22303. get isInput(): boolean;
  22304. /**
  22305. * Gets or sets the build Id
  22306. */
  22307. get buildId(): number;
  22308. set buildId(value: number);
  22309. /**
  22310. * Gets or sets the target of the block
  22311. */
  22312. get target(): NodeMaterialBlockTargets;
  22313. set target(value: NodeMaterialBlockTargets);
  22314. /**
  22315. * Gets the list of input points
  22316. */
  22317. get inputs(): NodeMaterialConnectionPoint[];
  22318. /** Gets the list of output points */
  22319. get outputs(): NodeMaterialConnectionPoint[];
  22320. /**
  22321. * Find an input by its name
  22322. * @param name defines the name of the input to look for
  22323. * @returns the input or null if not found
  22324. */
  22325. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22326. /**
  22327. * Find an output by its name
  22328. * @param name defines the name of the outputto look for
  22329. * @returns the output or null if not found
  22330. */
  22331. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22332. /**
  22333. * Creates a new NodeMaterialBlock
  22334. * @param name defines the block name
  22335. * @param target defines the target of that block (Vertex by default)
  22336. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22337. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22338. */
  22339. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22340. /**
  22341. * Initialize the block and prepare the context for build
  22342. * @param state defines the state that will be used for the build
  22343. */
  22344. initialize(state: NodeMaterialBuildState): void;
  22345. /**
  22346. * Bind data to effect. Will only be called for blocks with isBindable === true
  22347. * @param effect defines the effect to bind data to
  22348. * @param nodeMaterial defines the hosting NodeMaterial
  22349. * @param mesh defines the mesh that will be rendered
  22350. * @param subMesh defines the submesh that will be rendered
  22351. */
  22352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22353. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22354. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22355. protected _writeFloat(value: number): string;
  22356. /**
  22357. * Gets the current class name e.g. "NodeMaterialBlock"
  22358. * @returns the class name
  22359. */
  22360. getClassName(): string;
  22361. /**
  22362. * Register a new input. Must be called inside a block constructor
  22363. * @param name defines the connection point name
  22364. * @param type defines the connection point type
  22365. * @param isOptional defines a boolean indicating that this input can be omitted
  22366. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22367. * @param point an already created connection point. If not provided, create a new one
  22368. * @returns the current block
  22369. */
  22370. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22371. /**
  22372. * Register a new output. Must be called inside a block constructor
  22373. * @param name defines the connection point name
  22374. * @param type defines the connection point type
  22375. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22376. * @param point an already created connection point. If not provided, create a new one
  22377. * @returns the current block
  22378. */
  22379. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22380. /**
  22381. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22382. * @param forOutput defines an optional connection point to check compatibility with
  22383. * @returns the first available input or null
  22384. */
  22385. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22386. /**
  22387. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22388. * @param forBlock defines an optional block to check compatibility with
  22389. * @returns the first available input or null
  22390. */
  22391. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22392. /**
  22393. * Gets the sibling of the given output
  22394. * @param current defines the current output
  22395. * @returns the next output in the list or null
  22396. */
  22397. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22398. /**
  22399. * Connect current block with another block
  22400. * @param other defines the block to connect with
  22401. * @param options define the various options to help pick the right connections
  22402. * @returns the current block
  22403. */
  22404. connectTo(other: NodeMaterialBlock, options?: {
  22405. input?: string;
  22406. output?: string;
  22407. outputSwizzle?: string;
  22408. }): this | undefined;
  22409. protected _buildBlock(state: NodeMaterialBuildState): void;
  22410. /**
  22411. * Add uniforms, samplers and uniform buffers at compilation time
  22412. * @param state defines the state to update
  22413. * @param nodeMaterial defines the node material requesting the update
  22414. * @param defines defines the material defines to update
  22415. * @param uniformBuffers defines the list of uniform buffer names
  22416. */
  22417. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22418. /**
  22419. * Add potential fallbacks if shader compilation fails
  22420. * @param mesh defines the mesh to be rendered
  22421. * @param fallbacks defines the current prioritized list of fallbacks
  22422. */
  22423. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22424. /**
  22425. * Initialize defines for shader compilation
  22426. * @param mesh defines the mesh to be rendered
  22427. * @param nodeMaterial defines the node material requesting the update
  22428. * @param defines defines the material defines to update
  22429. * @param useInstances specifies that instances should be used
  22430. */
  22431. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22432. /**
  22433. * Update defines for shader compilation
  22434. * @param mesh defines the mesh to be rendered
  22435. * @param nodeMaterial defines the node material requesting the update
  22436. * @param defines defines the material defines to update
  22437. * @param useInstances specifies that instances should be used
  22438. * @param subMesh defines which submesh to render
  22439. */
  22440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22441. /**
  22442. * Lets the block try to connect some inputs automatically
  22443. * @param material defines the hosting NodeMaterial
  22444. */
  22445. autoConfigure(material: NodeMaterial): void;
  22446. /**
  22447. * Function called when a block is declared as repeatable content generator
  22448. * @param vertexShaderState defines the current compilation state for the vertex shader
  22449. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22450. * @param mesh defines the mesh to be rendered
  22451. * @param defines defines the material defines to update
  22452. */
  22453. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22454. /**
  22455. * Checks if the block is ready
  22456. * @param mesh defines the mesh to be rendered
  22457. * @param nodeMaterial defines the node material requesting the update
  22458. * @param defines defines the material defines to update
  22459. * @param useInstances specifies that instances should be used
  22460. * @returns true if the block is ready
  22461. */
  22462. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22463. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22464. private _processBuild;
  22465. /**
  22466. * Validates the new name for the block node.
  22467. * @param newName the new name to be given to the node.
  22468. * @returns false if the name is a reserve word, else true.
  22469. */
  22470. validateBlockName(newName: string): boolean;
  22471. /**
  22472. * Compile the current node and generate the shader code
  22473. * @param state defines the current compilation state (uniforms, samplers, current string)
  22474. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22475. * @returns true if already built
  22476. */
  22477. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22478. protected _inputRename(name: string): string;
  22479. protected _outputRename(name: string): string;
  22480. protected _dumpPropertiesCode(): string;
  22481. /** @hidden */
  22482. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22483. /** @hidden */
  22484. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22485. /**
  22486. * Clone the current block to a new identical block
  22487. * @param scene defines the hosting scene
  22488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22489. * @returns a copy of the current block
  22490. */
  22491. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22492. /**
  22493. * Serializes this block in a JSON representation
  22494. * @returns the serialized block object
  22495. */
  22496. serialize(): any;
  22497. /** @hidden */
  22498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22499. private _deserializePortDisplayNamesAndExposedOnFrame;
  22500. /**
  22501. * Release resources
  22502. */
  22503. dispose(): void;
  22504. }
  22505. }
  22506. declare module "babylonjs/Materials/pushMaterial" {
  22507. import { Nullable } from "babylonjs/types";
  22508. import { Scene } from "babylonjs/scene";
  22509. import { Matrix } from "babylonjs/Maths/math.vector";
  22510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22511. import { Mesh } from "babylonjs/Meshes/mesh";
  22512. import { Material } from "babylonjs/Materials/material";
  22513. import { Effect } from "babylonjs/Materials/effect";
  22514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22515. /**
  22516. * Base class of materials working in push mode in babylon JS
  22517. * @hidden
  22518. */
  22519. export class PushMaterial extends Material {
  22520. protected _activeEffect: Effect;
  22521. protected _normalMatrix: Matrix;
  22522. constructor(name: string, scene: Scene);
  22523. getEffect(): Effect;
  22524. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22525. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22526. /**
  22527. * Binds the given world matrix to the active effect
  22528. *
  22529. * @param world the matrix to bind
  22530. */
  22531. bindOnlyWorldMatrix(world: Matrix): void;
  22532. /**
  22533. * Binds the given normal matrix to the active effect
  22534. *
  22535. * @param normalMatrix the matrix to bind
  22536. */
  22537. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22538. bind(world: Matrix, mesh?: Mesh): void;
  22539. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22540. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22541. }
  22542. }
  22543. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22545. /**
  22546. * Root class for all node material optimizers
  22547. */
  22548. export class NodeMaterialOptimizer {
  22549. /**
  22550. * Function used to optimize a NodeMaterial graph
  22551. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22552. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22553. */
  22554. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22555. }
  22556. }
  22557. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22561. import { Scene } from "babylonjs/scene";
  22562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22563. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22565. /**
  22566. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22567. */
  22568. export class TransformBlock extends NodeMaterialBlock {
  22569. /**
  22570. * Defines the value to use to complement W value to transform it to a Vector4
  22571. */
  22572. complementW: number;
  22573. /**
  22574. * Defines the value to use to complement z value to transform it to a Vector4
  22575. */
  22576. complementZ: number;
  22577. /**
  22578. * Creates a new TransformBlock
  22579. * @param name defines the block name
  22580. */
  22581. constructor(name: string);
  22582. /**
  22583. * Gets the current class name
  22584. * @returns the class name
  22585. */
  22586. getClassName(): string;
  22587. /**
  22588. * Gets the vector input
  22589. */
  22590. get vector(): NodeMaterialConnectionPoint;
  22591. /**
  22592. * Gets the output component
  22593. */
  22594. get output(): NodeMaterialConnectionPoint;
  22595. /**
  22596. * Gets the xyz output component
  22597. */
  22598. get xyz(): NodeMaterialConnectionPoint;
  22599. /**
  22600. * Gets the matrix transform input
  22601. */
  22602. get transform(): NodeMaterialConnectionPoint;
  22603. protected _buildBlock(state: NodeMaterialBuildState): this;
  22604. /**
  22605. * Update defines for shader compilation
  22606. * @param mesh defines the mesh to be rendered
  22607. * @param nodeMaterial defines the node material requesting the update
  22608. * @param defines defines the material defines to update
  22609. * @param useInstances specifies that instances should be used
  22610. * @param subMesh defines which submesh to render
  22611. */
  22612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22613. serialize(): any;
  22614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22615. protected _dumpPropertiesCode(): string;
  22616. }
  22617. }
  22618. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22622. /**
  22623. * Block used to output the vertex position
  22624. */
  22625. export class VertexOutputBlock extends NodeMaterialBlock {
  22626. /**
  22627. * Creates a new VertexOutputBlock
  22628. * @param name defines the block name
  22629. */
  22630. constructor(name: string);
  22631. /**
  22632. * Gets the current class name
  22633. * @returns the class name
  22634. */
  22635. getClassName(): string;
  22636. /**
  22637. * Gets the vector input component
  22638. */
  22639. get vector(): NodeMaterialConnectionPoint;
  22640. protected _buildBlock(state: NodeMaterialBuildState): this;
  22641. }
  22642. }
  22643. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22647. /**
  22648. * Block used to output the final color
  22649. */
  22650. export class FragmentOutputBlock extends NodeMaterialBlock {
  22651. /**
  22652. * Create a new FragmentOutputBlock
  22653. * @param name defines the block name
  22654. */
  22655. constructor(name: string);
  22656. /**
  22657. * Gets the current class name
  22658. * @returns the class name
  22659. */
  22660. getClassName(): string;
  22661. /**
  22662. * Gets the rgba input component
  22663. */
  22664. get rgba(): NodeMaterialConnectionPoint;
  22665. /**
  22666. * Gets the rgb input component
  22667. */
  22668. get rgb(): NodeMaterialConnectionPoint;
  22669. /**
  22670. * Gets the a input component
  22671. */
  22672. get a(): NodeMaterialConnectionPoint;
  22673. protected _buildBlock(state: NodeMaterialBuildState): this;
  22674. }
  22675. }
  22676. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22680. /**
  22681. * Block used for the particle ramp gradient section
  22682. */
  22683. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22684. /**
  22685. * Create a new ParticleRampGradientBlock
  22686. * @param name defines the block name
  22687. */
  22688. constructor(name: string);
  22689. /**
  22690. * Gets the current class name
  22691. * @returns the class name
  22692. */
  22693. getClassName(): string;
  22694. /**
  22695. * Gets the color input component
  22696. */
  22697. get color(): NodeMaterialConnectionPoint;
  22698. /**
  22699. * Gets the rampColor output component
  22700. */
  22701. get rampColor(): NodeMaterialConnectionPoint;
  22702. /**
  22703. * Initialize the block and prepare the context for build
  22704. * @param state defines the state that will be used for the build
  22705. */
  22706. initialize(state: NodeMaterialBuildState): void;
  22707. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22708. }
  22709. }
  22710. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22714. /**
  22715. * Block used for the particle blend multiply section
  22716. */
  22717. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22718. /**
  22719. * Create a new ParticleBlendMultiplyBlock
  22720. * @param name defines the block name
  22721. */
  22722. constructor(name: string);
  22723. /**
  22724. * Gets the current class name
  22725. * @returns the class name
  22726. */
  22727. getClassName(): string;
  22728. /**
  22729. * Gets the color input component
  22730. */
  22731. get color(): NodeMaterialConnectionPoint;
  22732. /**
  22733. * Gets the alphaTexture input component
  22734. */
  22735. get alphaTexture(): NodeMaterialConnectionPoint;
  22736. /**
  22737. * Gets the alphaColor input component
  22738. */
  22739. get alphaColor(): NodeMaterialConnectionPoint;
  22740. /**
  22741. * Gets the blendColor output component
  22742. */
  22743. get blendColor(): NodeMaterialConnectionPoint;
  22744. /**
  22745. * Initialize the block and prepare the context for build
  22746. * @param state defines the state that will be used for the build
  22747. */
  22748. initialize(state: NodeMaterialBuildState): void;
  22749. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22750. }
  22751. }
  22752. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22756. /**
  22757. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22758. */
  22759. export class VectorMergerBlock extends NodeMaterialBlock {
  22760. /**
  22761. * Create a new VectorMergerBlock
  22762. * @param name defines the block name
  22763. */
  22764. constructor(name: string);
  22765. /**
  22766. * Gets the current class name
  22767. * @returns the class name
  22768. */
  22769. getClassName(): string;
  22770. /**
  22771. * Gets the xyz component (input)
  22772. */
  22773. get xyzIn(): NodeMaterialConnectionPoint;
  22774. /**
  22775. * Gets the xy component (input)
  22776. */
  22777. get xyIn(): NodeMaterialConnectionPoint;
  22778. /**
  22779. * Gets the x component (input)
  22780. */
  22781. get x(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Gets the y component (input)
  22784. */
  22785. get y(): NodeMaterialConnectionPoint;
  22786. /**
  22787. * Gets the z component (input)
  22788. */
  22789. get z(): NodeMaterialConnectionPoint;
  22790. /**
  22791. * Gets the w component (input)
  22792. */
  22793. get w(): NodeMaterialConnectionPoint;
  22794. /**
  22795. * Gets the xyzw component (output)
  22796. */
  22797. get xyzw(): NodeMaterialConnectionPoint;
  22798. /**
  22799. * Gets the xyz component (output)
  22800. */
  22801. get xyzOut(): NodeMaterialConnectionPoint;
  22802. /**
  22803. * Gets the xy component (output)
  22804. */
  22805. get xyOut(): NodeMaterialConnectionPoint;
  22806. /**
  22807. * Gets the xy component (output)
  22808. * @deprecated Please use xyOut instead.
  22809. */
  22810. get xy(): NodeMaterialConnectionPoint;
  22811. /**
  22812. * Gets the xyz component (output)
  22813. * @deprecated Please use xyzOut instead.
  22814. */
  22815. get xyz(): NodeMaterialConnectionPoint;
  22816. protected _buildBlock(state: NodeMaterialBuildState): this;
  22817. }
  22818. }
  22819. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22823. import { Vector2 } from "babylonjs/Maths/math.vector";
  22824. import { Scene } from "babylonjs/scene";
  22825. /**
  22826. * Block used to remap a float from a range to a new one
  22827. */
  22828. export class RemapBlock extends NodeMaterialBlock {
  22829. /**
  22830. * Gets or sets the source range
  22831. */
  22832. sourceRange: Vector2;
  22833. /**
  22834. * Gets or sets the target range
  22835. */
  22836. targetRange: Vector2;
  22837. /**
  22838. * Creates a new RemapBlock
  22839. * @param name defines the block name
  22840. */
  22841. constructor(name: string);
  22842. /**
  22843. * Gets the current class name
  22844. * @returns the class name
  22845. */
  22846. getClassName(): string;
  22847. /**
  22848. * Gets the input component
  22849. */
  22850. get input(): NodeMaterialConnectionPoint;
  22851. /**
  22852. * Gets the source min input component
  22853. */
  22854. get sourceMin(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the source max input component
  22857. */
  22858. get sourceMax(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the target min input component
  22861. */
  22862. get targetMin(): NodeMaterialConnectionPoint;
  22863. /**
  22864. * Gets the target max input component
  22865. */
  22866. get targetMax(): NodeMaterialConnectionPoint;
  22867. /**
  22868. * Gets the output component
  22869. */
  22870. get output(): NodeMaterialConnectionPoint;
  22871. protected _buildBlock(state: NodeMaterialBuildState): this;
  22872. protected _dumpPropertiesCode(): string;
  22873. serialize(): any;
  22874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22875. }
  22876. }
  22877. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22881. /**
  22882. * Block used to multiply 2 values
  22883. */
  22884. export class MultiplyBlock extends NodeMaterialBlock {
  22885. /**
  22886. * Creates a new MultiplyBlock
  22887. * @param name defines the block name
  22888. */
  22889. constructor(name: string);
  22890. /**
  22891. * Gets the current class name
  22892. * @returns the class name
  22893. */
  22894. getClassName(): string;
  22895. /**
  22896. * Gets the left operand input component
  22897. */
  22898. get left(): NodeMaterialConnectionPoint;
  22899. /**
  22900. * Gets the right operand input component
  22901. */
  22902. get right(): NodeMaterialConnectionPoint;
  22903. /**
  22904. * Gets the output component
  22905. */
  22906. get output(): NodeMaterialConnectionPoint;
  22907. protected _buildBlock(state: NodeMaterialBuildState): this;
  22908. }
  22909. }
  22910. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22914. /**
  22915. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22916. */
  22917. export class ColorSplitterBlock extends NodeMaterialBlock {
  22918. /**
  22919. * Create a new ColorSplitterBlock
  22920. * @param name defines the block name
  22921. */
  22922. constructor(name: string);
  22923. /**
  22924. * Gets the current class name
  22925. * @returns the class name
  22926. */
  22927. getClassName(): string;
  22928. /**
  22929. * Gets the rgba component (input)
  22930. */
  22931. get rgba(): NodeMaterialConnectionPoint;
  22932. /**
  22933. * Gets the rgb component (input)
  22934. */
  22935. get rgbIn(): NodeMaterialConnectionPoint;
  22936. /**
  22937. * Gets the rgb component (output)
  22938. */
  22939. get rgbOut(): NodeMaterialConnectionPoint;
  22940. /**
  22941. * Gets the r component (output)
  22942. */
  22943. get r(): NodeMaterialConnectionPoint;
  22944. /**
  22945. * Gets the g component (output)
  22946. */
  22947. get g(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the b component (output)
  22950. */
  22951. get b(): NodeMaterialConnectionPoint;
  22952. /**
  22953. * Gets the a component (output)
  22954. */
  22955. get a(): NodeMaterialConnectionPoint;
  22956. protected _inputRename(name: string): string;
  22957. protected _outputRename(name: string): string;
  22958. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22959. }
  22960. }
  22961. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22963. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22964. import { Scene } from "babylonjs/scene";
  22965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22966. import { Matrix } from "babylonjs/Maths/math.vector";
  22967. import { Mesh } from "babylonjs/Meshes/mesh";
  22968. import { Engine } from "babylonjs/Engines/engine";
  22969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22970. import { Observable } from "babylonjs/Misc/observable";
  22971. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22972. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22973. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22974. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22975. import { Nullable } from "babylonjs/types";
  22976. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22977. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22978. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22979. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22980. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22981. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22982. import { Effect } from "babylonjs/Materials/effect";
  22983. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22984. import { Camera } from "babylonjs/Cameras/camera";
  22985. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22986. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22987. /**
  22988. * Interface used to configure the node material editor
  22989. */
  22990. export interface INodeMaterialEditorOptions {
  22991. /** Define the URl to load node editor script */
  22992. editorURL?: string;
  22993. }
  22994. /** @hidden */
  22995. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22996. NORMAL: boolean;
  22997. TANGENT: boolean;
  22998. UV1: boolean;
  22999. /** BONES */
  23000. NUM_BONE_INFLUENCERS: number;
  23001. BonesPerMesh: number;
  23002. BONETEXTURE: boolean;
  23003. /** MORPH TARGETS */
  23004. MORPHTARGETS: boolean;
  23005. MORPHTARGETS_NORMAL: boolean;
  23006. MORPHTARGETS_TANGENT: boolean;
  23007. MORPHTARGETS_UV: boolean;
  23008. NUM_MORPH_INFLUENCERS: number;
  23009. /** IMAGE PROCESSING */
  23010. IMAGEPROCESSING: boolean;
  23011. VIGNETTE: boolean;
  23012. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23013. VIGNETTEBLENDMODEOPAQUE: boolean;
  23014. TONEMAPPING: boolean;
  23015. TONEMAPPING_ACES: boolean;
  23016. CONTRAST: boolean;
  23017. EXPOSURE: boolean;
  23018. COLORCURVES: boolean;
  23019. COLORGRADING: boolean;
  23020. COLORGRADING3D: boolean;
  23021. SAMPLER3DGREENDEPTH: boolean;
  23022. SAMPLER3DBGRMAP: boolean;
  23023. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23024. /** MISC. */
  23025. BUMPDIRECTUV: number;
  23026. constructor();
  23027. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23028. }
  23029. /**
  23030. * Class used to configure NodeMaterial
  23031. */
  23032. export interface INodeMaterialOptions {
  23033. /**
  23034. * Defines if blocks should emit comments
  23035. */
  23036. emitComments: boolean;
  23037. }
  23038. /**
  23039. * Class used to create a node based material built by assembling shader blocks
  23040. */
  23041. export class NodeMaterial extends PushMaterial {
  23042. private static _BuildIdGenerator;
  23043. private _options;
  23044. private _vertexCompilationState;
  23045. private _fragmentCompilationState;
  23046. private _sharedData;
  23047. private _buildId;
  23048. private _buildWasSuccessful;
  23049. private _cachedWorldViewMatrix;
  23050. private _cachedWorldViewProjectionMatrix;
  23051. private _optimizers;
  23052. private _animationFrame;
  23053. /** Define the Url to load node editor script */
  23054. static EditorURL: string;
  23055. /** Define the Url to load snippets */
  23056. static SnippetUrl: string;
  23057. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23058. static IgnoreTexturesAtLoadTime: boolean;
  23059. private BJSNODEMATERIALEDITOR;
  23060. /** Get the inspector from bundle or global */
  23061. private _getGlobalNodeMaterialEditor;
  23062. /**
  23063. * Snippet ID if the material was created from the snippet server
  23064. */
  23065. snippetId: string;
  23066. /**
  23067. * Gets or sets data used by visual editor
  23068. * @see https://nme.babylonjs.com
  23069. */
  23070. editorData: any;
  23071. /**
  23072. * 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)
  23073. */
  23074. ignoreAlpha: boolean;
  23075. /**
  23076. * Defines the maximum number of lights that can be used in the material
  23077. */
  23078. maxSimultaneousLights: number;
  23079. /**
  23080. * Observable raised when the material is built
  23081. */
  23082. onBuildObservable: Observable<NodeMaterial>;
  23083. /**
  23084. * Gets or sets the root nodes of the material vertex shader
  23085. */
  23086. _vertexOutputNodes: NodeMaterialBlock[];
  23087. /**
  23088. * Gets or sets the root nodes of the material fragment (pixel) shader
  23089. */
  23090. _fragmentOutputNodes: NodeMaterialBlock[];
  23091. /** Gets or sets options to control the node material overall behavior */
  23092. get options(): INodeMaterialOptions;
  23093. set options(options: INodeMaterialOptions);
  23094. /**
  23095. * Default configuration related to image processing available in the standard Material.
  23096. */
  23097. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23098. /**
  23099. * Gets the image processing configuration used either in this material.
  23100. */
  23101. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23102. /**
  23103. * Sets the Default image processing configuration used either in the this material.
  23104. *
  23105. * If sets to null, the scene one is in use.
  23106. */
  23107. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23108. /**
  23109. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23110. */
  23111. attachedBlocks: NodeMaterialBlock[];
  23112. /**
  23113. * Specifies the mode of the node material
  23114. * @hidden
  23115. */
  23116. _mode: NodeMaterialModes;
  23117. /**
  23118. * Gets the mode property
  23119. */
  23120. get mode(): NodeMaterialModes;
  23121. /**
  23122. * Create a new node based material
  23123. * @param name defines the material name
  23124. * @param scene defines the hosting scene
  23125. * @param options defines creation option
  23126. */
  23127. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23128. /**
  23129. * Gets the current class name of the material e.g. "NodeMaterial"
  23130. * @returns the class name
  23131. */
  23132. getClassName(): string;
  23133. /**
  23134. * Keep track of the image processing observer to allow dispose and replace.
  23135. */
  23136. private _imageProcessingObserver;
  23137. /**
  23138. * Attaches a new image processing configuration to the Standard Material.
  23139. * @param configuration
  23140. */
  23141. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23142. /**
  23143. * Get a block by its name
  23144. * @param name defines the name of the block to retrieve
  23145. * @returns the required block or null if not found
  23146. */
  23147. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23148. /**
  23149. * Get a block by its name
  23150. * @param predicate defines the predicate used to find the good candidate
  23151. * @returns the required block or null if not found
  23152. */
  23153. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23154. /**
  23155. * Get an input block by its name
  23156. * @param predicate defines the predicate used to find the good candidate
  23157. * @returns the required input block or null if not found
  23158. */
  23159. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23160. /**
  23161. * Gets the list of input blocks attached to this material
  23162. * @returns an array of InputBlocks
  23163. */
  23164. getInputBlocks(): InputBlock[];
  23165. /**
  23166. * Adds a new optimizer to the list of optimizers
  23167. * @param optimizer defines the optimizers to add
  23168. * @returns the current material
  23169. */
  23170. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23171. /**
  23172. * Remove an optimizer from the list of optimizers
  23173. * @param optimizer defines the optimizers to remove
  23174. * @returns the current material
  23175. */
  23176. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23177. /**
  23178. * Add a new block to the list of output nodes
  23179. * @param node defines the node to add
  23180. * @returns the current material
  23181. */
  23182. addOutputNode(node: NodeMaterialBlock): this;
  23183. /**
  23184. * Remove a block from the list of root nodes
  23185. * @param node defines the node to remove
  23186. * @returns the current material
  23187. */
  23188. removeOutputNode(node: NodeMaterialBlock): this;
  23189. private _addVertexOutputNode;
  23190. private _removeVertexOutputNode;
  23191. private _addFragmentOutputNode;
  23192. private _removeFragmentOutputNode;
  23193. /**
  23194. * Specifies if the material will require alpha blending
  23195. * @returns a boolean specifying if alpha blending is needed
  23196. */
  23197. needAlphaBlending(): boolean;
  23198. /**
  23199. * Specifies if this material should be rendered in alpha test mode
  23200. * @returns a boolean specifying if an alpha test is needed.
  23201. */
  23202. needAlphaTesting(): boolean;
  23203. private _initializeBlock;
  23204. private _resetDualBlocks;
  23205. /**
  23206. * Remove a block from the current node material
  23207. * @param block defines the block to remove
  23208. */
  23209. removeBlock(block: NodeMaterialBlock): void;
  23210. /**
  23211. * Build the material and generates the inner effect
  23212. * @param verbose defines if the build should log activity
  23213. */
  23214. build(verbose?: boolean): void;
  23215. /**
  23216. * Runs an otpimization phase to try to improve the shader code
  23217. */
  23218. optimize(): void;
  23219. private _prepareDefinesForAttributes;
  23220. /**
  23221. * Create a post process from the material
  23222. * @param camera The camera to apply the render pass to.
  23223. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23225. * @param engine The engine which the post process will be applied. (default: current engine)
  23226. * @param reusable If the post process can be reused on the same frame. (default: false)
  23227. * @param textureType Type of textures used when performing the post process. (default: 0)
  23228. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23229. * @returns the post process created
  23230. */
  23231. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23232. /**
  23233. * Create the post process effect from the material
  23234. * @param postProcess The post process to create the effect for
  23235. */
  23236. createEffectForPostProcess(postProcess: PostProcess): void;
  23237. private _createEffectOrPostProcess;
  23238. private _createEffectForParticles;
  23239. /**
  23240. * Create the effect to be used as the custom effect for a particle system
  23241. * @param particleSystem Particle system to create the effect for
  23242. * @param onCompiled defines a function to call when the effect creation is successful
  23243. * @param onError defines a function to call when the effect creation has failed
  23244. */
  23245. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23246. private _processDefines;
  23247. /**
  23248. * Get if the submesh is ready to be used and all its information available.
  23249. * Child classes can use it to update shaders
  23250. * @param mesh defines the mesh to check
  23251. * @param subMesh defines which submesh to check
  23252. * @param useInstances specifies that instances should be used
  23253. * @returns a boolean indicating that the submesh is ready or not
  23254. */
  23255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23256. /**
  23257. * Get a string representing the shaders built by the current node graph
  23258. */
  23259. get compiledShaders(): string;
  23260. /**
  23261. * Binds the world matrix to the material
  23262. * @param world defines the world transformation matrix
  23263. */
  23264. bindOnlyWorldMatrix(world: Matrix): void;
  23265. /**
  23266. * Binds the submesh to this material by preparing the effect and shader to draw
  23267. * @param world defines the world transformation matrix
  23268. * @param mesh defines the mesh containing the submesh
  23269. * @param subMesh defines the submesh to bind the material to
  23270. */
  23271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23272. /**
  23273. * Gets the active textures from the material
  23274. * @returns an array of textures
  23275. */
  23276. getActiveTextures(): BaseTexture[];
  23277. /**
  23278. * Gets the list of texture blocks
  23279. * @returns an array of texture blocks
  23280. */
  23281. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23282. /**
  23283. * Specifies if the material uses a texture
  23284. * @param texture defines the texture to check against the material
  23285. * @returns a boolean specifying if the material uses the texture
  23286. */
  23287. hasTexture(texture: BaseTexture): boolean;
  23288. /**
  23289. * Disposes the material
  23290. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23291. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23292. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23293. */
  23294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23295. /** Creates the node editor window. */
  23296. private _createNodeEditor;
  23297. /**
  23298. * Launch the node material editor
  23299. * @param config Define the configuration of the editor
  23300. * @return a promise fulfilled when the node editor is visible
  23301. */
  23302. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23303. /**
  23304. * Clear the current material
  23305. */
  23306. clear(): void;
  23307. /**
  23308. * Clear the current material and set it to a default state
  23309. */
  23310. setToDefault(): void;
  23311. /**
  23312. * Clear the current material and set it to a default state for post process
  23313. */
  23314. setToDefaultPostProcess(): void;
  23315. /**
  23316. * Clear the current material and set it to a default state for particle
  23317. */
  23318. setToDefaultParticle(): void;
  23319. /**
  23320. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23321. * @param url defines the url to load from
  23322. * @returns a promise that will fullfil when the material is fully loaded
  23323. */
  23324. loadAsync(url: string): Promise<void>;
  23325. private _gatherBlocks;
  23326. /**
  23327. * Generate a string containing the code declaration required to create an equivalent of this material
  23328. * @returns a string
  23329. */
  23330. generateCode(): string;
  23331. /**
  23332. * Serializes this material in a JSON representation
  23333. * @returns the serialized material object
  23334. */
  23335. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23336. private _restoreConnections;
  23337. /**
  23338. * Clear the current graph and load a new one from a serialization object
  23339. * @param source defines the JSON representation of the material
  23340. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23341. * @param merge defines whether or not the source must be merged or replace the current content
  23342. */
  23343. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23344. /**
  23345. * Makes a duplicate of the current material.
  23346. * @param name - name to use for the new material.
  23347. */
  23348. clone(name: string): NodeMaterial;
  23349. /**
  23350. * Creates a node material from parsed material data
  23351. * @param source defines the JSON representation of the material
  23352. * @param scene defines the hosting scene
  23353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23354. * @returns a new node material
  23355. */
  23356. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23357. /**
  23358. * Creates a node material from a snippet saved in a remote file
  23359. * @param name defines the name of the material to create
  23360. * @param url defines the url to load from
  23361. * @param scene defines the hosting scene
  23362. * @returns a promise that will resolve to the new node material
  23363. */
  23364. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23365. /**
  23366. * Creates a node material from a snippet saved by the node material editor
  23367. * @param snippetId defines the snippet to load
  23368. * @param scene defines the hosting scene
  23369. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23370. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23371. * @returns a promise that will resolve to the new node material
  23372. */
  23373. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23374. /**
  23375. * Creates a new node material set to default basic configuration
  23376. * @param name defines the name of the material
  23377. * @param scene defines the hosting scene
  23378. * @returns a new NodeMaterial
  23379. */
  23380. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23381. }
  23382. }
  23383. declare module "babylonjs/PostProcesses/postProcess" {
  23384. import { Nullable } from "babylonjs/types";
  23385. import { SmartArray } from "babylonjs/Misc/smartArray";
  23386. import { Observable } from "babylonjs/Misc/observable";
  23387. import { Vector2 } from "babylonjs/Maths/math.vector";
  23388. import { Camera } from "babylonjs/Cameras/camera";
  23389. import { Effect } from "babylonjs/Materials/effect";
  23390. import "babylonjs/Shaders/postprocess.vertex";
  23391. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23392. import { Engine } from "babylonjs/Engines/engine";
  23393. import { Color4 } from "babylonjs/Maths/math.color";
  23394. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23395. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23396. import { Scene } from "babylonjs/scene";
  23397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23398. /**
  23399. * Size options for a post process
  23400. */
  23401. export type PostProcessOptions = {
  23402. width: number;
  23403. height: number;
  23404. };
  23405. /**
  23406. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23407. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23408. */
  23409. export class PostProcess {
  23410. /**
  23411. * Gets or sets the unique id of the post process
  23412. */
  23413. uniqueId: number;
  23414. /** Name of the PostProcess. */
  23415. name: string;
  23416. /**
  23417. * Width of the texture to apply the post process on
  23418. */
  23419. width: number;
  23420. /**
  23421. * Height of the texture to apply the post process on
  23422. */
  23423. height: number;
  23424. /**
  23425. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23426. */
  23427. nodeMaterialSource: Nullable<NodeMaterial>;
  23428. /**
  23429. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23430. * @hidden
  23431. */
  23432. _outputTexture: Nullable<InternalTexture>;
  23433. /**
  23434. * Sampling mode used by the shader
  23435. * See https://doc.babylonjs.com/classes/3.1/texture
  23436. */
  23437. renderTargetSamplingMode: number;
  23438. /**
  23439. * Clear color to use when screen clearing
  23440. */
  23441. clearColor: Color4;
  23442. /**
  23443. * If the buffer needs to be cleared before applying the post process. (default: true)
  23444. * Should be set to false if shader will overwrite all previous pixels.
  23445. */
  23446. autoClear: boolean;
  23447. /**
  23448. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23449. */
  23450. alphaMode: number;
  23451. /**
  23452. * Sets the setAlphaBlendConstants of the babylon engine
  23453. */
  23454. alphaConstants: Color4;
  23455. /**
  23456. * Animations to be used for the post processing
  23457. */
  23458. animations: import("babylonjs/Animations/animation").Animation[];
  23459. /**
  23460. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23461. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23462. */
  23463. enablePixelPerfectMode: boolean;
  23464. /**
  23465. * Force the postprocess to be applied without taking in account viewport
  23466. */
  23467. forceFullscreenViewport: boolean;
  23468. /**
  23469. * List of inspectable custom properties (used by the Inspector)
  23470. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23471. */
  23472. inspectableCustomProperties: IInspectable[];
  23473. /**
  23474. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23475. *
  23476. * | Value | Type | Description |
  23477. * | ----- | ----------------------------------- | ----------- |
  23478. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23479. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23480. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23481. *
  23482. */
  23483. scaleMode: number;
  23484. /**
  23485. * Force textures to be a power of two (default: false)
  23486. */
  23487. alwaysForcePOT: boolean;
  23488. private _samples;
  23489. /**
  23490. * Number of sample textures (default: 1)
  23491. */
  23492. get samples(): number;
  23493. set samples(n: number);
  23494. /**
  23495. * Modify the scale of the post process to be the same as the viewport (default: false)
  23496. */
  23497. adaptScaleToCurrentViewport: boolean;
  23498. private _camera;
  23499. protected _scene: Scene;
  23500. private _engine;
  23501. private _options;
  23502. private _reusable;
  23503. private _textureType;
  23504. private _textureFormat;
  23505. /**
  23506. * Smart array of input and output textures for the post process.
  23507. * @hidden
  23508. */
  23509. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23510. /**
  23511. * The index in _textures that corresponds to the output texture.
  23512. * @hidden
  23513. */
  23514. _currentRenderTextureInd: number;
  23515. private _effect;
  23516. private _samplers;
  23517. private _fragmentUrl;
  23518. private _vertexUrl;
  23519. private _parameters;
  23520. private _scaleRatio;
  23521. protected _indexParameters: any;
  23522. private _shareOutputWithPostProcess;
  23523. private _texelSize;
  23524. private _forcedOutputTexture;
  23525. /**
  23526. * Returns the fragment url or shader name used in the post process.
  23527. * @returns the fragment url or name in the shader store.
  23528. */
  23529. getEffectName(): string;
  23530. /**
  23531. * An event triggered when the postprocess is activated.
  23532. */
  23533. onActivateObservable: Observable<Camera>;
  23534. private _onActivateObserver;
  23535. /**
  23536. * A function that is added to the onActivateObservable
  23537. */
  23538. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23539. /**
  23540. * An event triggered when the postprocess changes its size.
  23541. */
  23542. onSizeChangedObservable: Observable<PostProcess>;
  23543. private _onSizeChangedObserver;
  23544. /**
  23545. * A function that is added to the onSizeChangedObservable
  23546. */
  23547. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23548. /**
  23549. * An event triggered when the postprocess applies its effect.
  23550. */
  23551. onApplyObservable: Observable<Effect>;
  23552. private _onApplyObserver;
  23553. /**
  23554. * A function that is added to the onApplyObservable
  23555. */
  23556. set onApply(callback: (effect: Effect) => void);
  23557. /**
  23558. * An event triggered before rendering the postprocess
  23559. */
  23560. onBeforeRenderObservable: Observable<Effect>;
  23561. private _onBeforeRenderObserver;
  23562. /**
  23563. * A function that is added to the onBeforeRenderObservable
  23564. */
  23565. set onBeforeRender(callback: (effect: Effect) => void);
  23566. /**
  23567. * An event triggered after rendering the postprocess
  23568. */
  23569. onAfterRenderObservable: Observable<Effect>;
  23570. private _onAfterRenderObserver;
  23571. /**
  23572. * A function that is added to the onAfterRenderObservable
  23573. */
  23574. set onAfterRender(callback: (efect: Effect) => void);
  23575. /**
  23576. * 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
  23577. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23578. */
  23579. get inputTexture(): InternalTexture;
  23580. set inputTexture(value: InternalTexture);
  23581. /**
  23582. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23583. * the only way to unset it is to use this function to restore its internal state
  23584. */
  23585. restoreDefaultInputTexture(): void;
  23586. /**
  23587. * Gets the camera which post process is applied to.
  23588. * @returns The camera the post process is applied to.
  23589. */
  23590. getCamera(): Camera;
  23591. /**
  23592. * Gets the texel size of the postprocess.
  23593. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23594. */
  23595. get texelSize(): Vector2;
  23596. /**
  23597. * Creates a new instance PostProcess
  23598. * @param name The name of the PostProcess.
  23599. * @param fragmentUrl The url of the fragment shader to be used.
  23600. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23601. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23602. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23603. * @param camera The camera to apply the render pass to.
  23604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23605. * @param engine The engine which the post process will be applied. (default: current engine)
  23606. * @param reusable If the post process can be reused on the same frame. (default: false)
  23607. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23608. * @param textureType Type of textures used when performing the post process. (default: 0)
  23609. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23610. * @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
  23611. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23612. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23613. */
  23614. 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);
  23615. /**
  23616. * Gets a string identifying the name of the class
  23617. * @returns "PostProcess" string
  23618. */
  23619. getClassName(): string;
  23620. /**
  23621. * Gets the engine which this post process belongs to.
  23622. * @returns The engine the post process was enabled with.
  23623. */
  23624. getEngine(): Engine;
  23625. /**
  23626. * The effect that is created when initializing the post process.
  23627. * @returns The created effect corresponding the the postprocess.
  23628. */
  23629. getEffect(): Effect;
  23630. /**
  23631. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23632. * @param postProcess The post process to share the output with.
  23633. * @returns This post process.
  23634. */
  23635. shareOutputWith(postProcess: PostProcess): PostProcess;
  23636. /**
  23637. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23638. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23639. */
  23640. useOwnOutput(): void;
  23641. /**
  23642. * Updates the effect with the current post process compile time values and recompiles the shader.
  23643. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23644. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23645. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23646. * @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
  23647. * @param onCompiled Called when the shader has been compiled.
  23648. * @param onError Called if there is an error when compiling a shader.
  23649. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23650. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23651. */
  23652. 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;
  23653. /**
  23654. * The post process is reusable if it can be used multiple times within one frame.
  23655. * @returns If the post process is reusable
  23656. */
  23657. isReusable(): boolean;
  23658. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23659. markTextureDirty(): void;
  23660. /**
  23661. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23662. * 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.
  23663. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23664. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23665. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23666. * @returns The target texture that was bound to be written to.
  23667. */
  23668. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23669. /**
  23670. * If the post process is supported.
  23671. */
  23672. get isSupported(): boolean;
  23673. /**
  23674. * The aspect ratio of the output texture.
  23675. */
  23676. get aspectRatio(): number;
  23677. /**
  23678. * Get a value indicating if the post-process is ready to be used
  23679. * @returns true if the post-process is ready (shader is compiled)
  23680. */
  23681. isReady(): boolean;
  23682. /**
  23683. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23684. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23685. */
  23686. apply(): Nullable<Effect>;
  23687. private _disposeTextures;
  23688. /**
  23689. * Disposes the post process.
  23690. * @param camera The camera to dispose the post process on.
  23691. */
  23692. dispose(camera?: Camera): void;
  23693. /**
  23694. * Serializes the particle system to a JSON object
  23695. * @returns the JSON object
  23696. */
  23697. serialize(): any;
  23698. /**
  23699. * Creates a material from parsed material data
  23700. * @param parsedPostProcess defines parsed post process data
  23701. * @param scene defines the hosting scene
  23702. * @param rootUrl defines the root URL to use to load textures
  23703. * @returns a new post process
  23704. */
  23705. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23706. }
  23707. }
  23708. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23709. /** @hidden */
  23710. export var kernelBlurVaryingDeclaration: {
  23711. name: string;
  23712. shader: string;
  23713. };
  23714. }
  23715. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23716. /** @hidden */
  23717. export var kernelBlurFragment: {
  23718. name: string;
  23719. shader: string;
  23720. };
  23721. }
  23722. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23723. /** @hidden */
  23724. export var kernelBlurFragment2: {
  23725. name: string;
  23726. shader: string;
  23727. };
  23728. }
  23729. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23730. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23731. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23732. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23733. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23734. /** @hidden */
  23735. export var kernelBlurPixelShader: {
  23736. name: string;
  23737. shader: string;
  23738. };
  23739. }
  23740. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23741. /** @hidden */
  23742. export var kernelBlurVertex: {
  23743. name: string;
  23744. shader: string;
  23745. };
  23746. }
  23747. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23748. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23749. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23750. /** @hidden */
  23751. export var kernelBlurVertexShader: {
  23752. name: string;
  23753. shader: string;
  23754. };
  23755. }
  23756. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23757. import { Vector2 } from "babylonjs/Maths/math.vector";
  23758. import { Nullable } from "babylonjs/types";
  23759. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23760. import { Camera } from "babylonjs/Cameras/camera";
  23761. import { Effect } from "babylonjs/Materials/effect";
  23762. import { Engine } from "babylonjs/Engines/engine";
  23763. import "babylonjs/Shaders/kernelBlur.fragment";
  23764. import "babylonjs/Shaders/kernelBlur.vertex";
  23765. import { Scene } from "babylonjs/scene";
  23766. /**
  23767. * The Blur Post Process which blurs an image based on a kernel and direction.
  23768. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23769. */
  23770. export class BlurPostProcess extends PostProcess {
  23771. private blockCompilation;
  23772. protected _kernel: number;
  23773. protected _idealKernel: number;
  23774. protected _packedFloat: boolean;
  23775. private _staticDefines;
  23776. /** The direction in which to blur the image. */
  23777. direction: Vector2;
  23778. /**
  23779. * Sets the length in pixels of the blur sample region
  23780. */
  23781. set kernel(v: number);
  23782. /**
  23783. * Gets the length in pixels of the blur sample region
  23784. */
  23785. get kernel(): number;
  23786. /**
  23787. * Sets wether or not the blur needs to unpack/repack floats
  23788. */
  23789. set packedFloat(v: boolean);
  23790. /**
  23791. * Gets wether or not the blur is unpacking/repacking floats
  23792. */
  23793. get packedFloat(): boolean;
  23794. /**
  23795. * Gets a string identifying the name of the class
  23796. * @returns "BlurPostProcess" string
  23797. */
  23798. getClassName(): string;
  23799. /**
  23800. * Creates a new instance BlurPostProcess
  23801. * @param name The name of the effect.
  23802. * @param direction The direction in which to blur the image.
  23803. * @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.
  23804. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23805. * @param camera The camera to apply the render pass to.
  23806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23807. * @param engine The engine which the post process will be applied. (default: current engine)
  23808. * @param reusable If the post process can be reused on the same frame. (default: false)
  23809. * @param textureType Type of textures used when performing the post process. (default: 0)
  23810. * @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)
  23811. */
  23812. 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);
  23813. /**
  23814. * Updates the effect with the current post process compile time values and recompiles the shader.
  23815. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23816. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23817. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23818. * @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
  23819. * @param onCompiled Called when the shader has been compiled.
  23820. * @param onError Called if there is an error when compiling a shader.
  23821. */
  23822. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23823. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23824. /**
  23825. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23826. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23827. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23828. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23829. * The gaps between physical kernels are compensated for in the weighting of the samples
  23830. * @param idealKernel Ideal blur kernel.
  23831. * @return Nearest best kernel.
  23832. */
  23833. protected _nearestBestKernel(idealKernel: number): number;
  23834. /**
  23835. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23836. * @param x The point on the Gaussian distribution to sample.
  23837. * @return the value of the Gaussian function at x.
  23838. */
  23839. protected _gaussianWeight(x: number): number;
  23840. /**
  23841. * Generates a string that can be used as a floating point number in GLSL.
  23842. * @param x Value to print.
  23843. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23844. * @return GLSL float string.
  23845. */
  23846. protected _glslFloat(x: number, decimalFigures?: number): string;
  23847. /** @hidden */
  23848. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23849. }
  23850. }
  23851. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23852. import { Scene } from "babylonjs/scene";
  23853. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23854. import { Plane } from "babylonjs/Maths/math.plane";
  23855. /**
  23856. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23857. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23858. * You can then easily use it as a reflectionTexture on a flat surface.
  23859. * In case the surface is not a plane, please consider relying on reflection probes.
  23860. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23861. */
  23862. export class MirrorTexture extends RenderTargetTexture {
  23863. private scene;
  23864. /**
  23865. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23866. * 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.
  23867. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23868. */
  23869. mirrorPlane: Plane;
  23870. /**
  23871. * Define the blur ratio used to blur the reflection if needed.
  23872. */
  23873. set blurRatio(value: number);
  23874. get blurRatio(): number;
  23875. /**
  23876. * Define the adaptive blur kernel used to blur the reflection if needed.
  23877. * This will autocompute the closest best match for the `blurKernel`
  23878. */
  23879. set adaptiveBlurKernel(value: number);
  23880. /**
  23881. * Define the blur kernel used to blur the reflection if needed.
  23882. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23883. */
  23884. set blurKernel(value: number);
  23885. /**
  23886. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23887. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23888. */
  23889. set blurKernelX(value: number);
  23890. get blurKernelX(): number;
  23891. /**
  23892. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23893. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23894. */
  23895. set blurKernelY(value: number);
  23896. get blurKernelY(): number;
  23897. private _autoComputeBlurKernel;
  23898. protected _onRatioRescale(): void;
  23899. private _updateGammaSpace;
  23900. private _imageProcessingConfigChangeObserver;
  23901. private _transformMatrix;
  23902. private _mirrorMatrix;
  23903. private _savedViewMatrix;
  23904. private _blurX;
  23905. private _blurY;
  23906. private _adaptiveBlurKernel;
  23907. private _blurKernelX;
  23908. private _blurKernelY;
  23909. private _blurRatio;
  23910. /**
  23911. * Instantiates a Mirror Texture.
  23912. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23913. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23914. * You can then easily use it as a reflectionTexture on a flat surface.
  23915. * In case the surface is not a plane, please consider relying on reflection probes.
  23916. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23917. * @param name
  23918. * @param size
  23919. * @param scene
  23920. * @param generateMipMaps
  23921. * @param type
  23922. * @param samplingMode
  23923. * @param generateDepthBuffer
  23924. */
  23925. constructor(name: string, size: number | {
  23926. width: number;
  23927. height: number;
  23928. } | {
  23929. ratio: number;
  23930. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23931. private _preparePostProcesses;
  23932. /**
  23933. * Clone the mirror texture.
  23934. * @returns the cloned texture
  23935. */
  23936. clone(): MirrorTexture;
  23937. /**
  23938. * Serialize the texture to a JSON representation you could use in Parse later on
  23939. * @returns the serialized JSON representation
  23940. */
  23941. serialize(): any;
  23942. /**
  23943. * Dispose the texture and release its associated resources.
  23944. */
  23945. dispose(): void;
  23946. }
  23947. }
  23948. declare module "babylonjs/Materials/Textures/texture" {
  23949. import { Observable } from "babylonjs/Misc/observable";
  23950. import { Nullable } from "babylonjs/types";
  23951. import { Matrix } from "babylonjs/Maths/math.vector";
  23952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23953. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23954. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23955. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23956. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23957. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23958. import { Scene } from "babylonjs/scene";
  23959. /**
  23960. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23961. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23962. */
  23963. export class Texture extends BaseTexture {
  23964. /**
  23965. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23966. */
  23967. static SerializeBuffers: boolean;
  23968. /** @hidden */
  23969. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23970. /** @hidden */
  23971. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23972. /** @hidden */
  23973. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23974. /** nearest is mag = nearest and min = nearest and mip = linear */
  23975. static readonly NEAREST_SAMPLINGMODE: number;
  23976. /** nearest is mag = nearest and min = nearest and mip = linear */
  23977. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23978. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23979. static readonly BILINEAR_SAMPLINGMODE: number;
  23980. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23981. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23982. /** Trilinear is mag = linear and min = linear and mip = linear */
  23983. static readonly TRILINEAR_SAMPLINGMODE: number;
  23984. /** Trilinear is mag = linear and min = linear and mip = linear */
  23985. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23986. /** mag = nearest and min = nearest and mip = nearest */
  23987. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23988. /** mag = nearest and min = linear and mip = nearest */
  23989. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23990. /** mag = nearest and min = linear and mip = linear */
  23991. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23992. /** mag = nearest and min = linear and mip = none */
  23993. static readonly NEAREST_LINEAR: number;
  23994. /** mag = nearest and min = nearest and mip = none */
  23995. static readonly NEAREST_NEAREST: number;
  23996. /** mag = linear and min = nearest and mip = nearest */
  23997. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23998. /** mag = linear and min = nearest and mip = linear */
  23999. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24000. /** mag = linear and min = linear and mip = none */
  24001. static readonly LINEAR_LINEAR: number;
  24002. /** mag = linear and min = nearest and mip = none */
  24003. static readonly LINEAR_NEAREST: number;
  24004. /** Explicit coordinates mode */
  24005. static readonly EXPLICIT_MODE: number;
  24006. /** Spherical coordinates mode */
  24007. static readonly SPHERICAL_MODE: number;
  24008. /** Planar coordinates mode */
  24009. static readonly PLANAR_MODE: number;
  24010. /** Cubic coordinates mode */
  24011. static readonly CUBIC_MODE: number;
  24012. /** Projection coordinates mode */
  24013. static readonly PROJECTION_MODE: number;
  24014. /** Inverse Cubic coordinates mode */
  24015. static readonly SKYBOX_MODE: number;
  24016. /** Inverse Cubic coordinates mode */
  24017. static readonly INVCUBIC_MODE: number;
  24018. /** Equirectangular coordinates mode */
  24019. static readonly EQUIRECTANGULAR_MODE: number;
  24020. /** Equirectangular Fixed coordinates mode */
  24021. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24022. /** Equirectangular Fixed Mirrored coordinates mode */
  24023. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24024. /** Texture is not repeating outside of 0..1 UVs */
  24025. static readonly CLAMP_ADDRESSMODE: number;
  24026. /** Texture is repeating outside of 0..1 UVs */
  24027. static readonly WRAP_ADDRESSMODE: number;
  24028. /** Texture is repeating and mirrored */
  24029. static readonly MIRROR_ADDRESSMODE: number;
  24030. /**
  24031. * 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
  24032. */
  24033. static UseSerializedUrlIfAny: boolean;
  24034. /**
  24035. * Define the url of the texture.
  24036. */
  24037. url: Nullable<string>;
  24038. /**
  24039. * Define an offset on the texture to offset the u coordinates of the UVs
  24040. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24041. */
  24042. uOffset: number;
  24043. /**
  24044. * Define an offset on the texture to offset the v coordinates of the UVs
  24045. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24046. */
  24047. vOffset: number;
  24048. /**
  24049. * Define an offset on the texture to scale the u coordinates of the UVs
  24050. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24051. */
  24052. uScale: number;
  24053. /**
  24054. * Define an offset on the texture to scale the v coordinates of the UVs
  24055. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24056. */
  24057. vScale: number;
  24058. /**
  24059. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24060. * @see https://doc.babylonjs.com/how_to/more_materials
  24061. */
  24062. uAng: number;
  24063. /**
  24064. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24065. * @see https://doc.babylonjs.com/how_to/more_materials
  24066. */
  24067. vAng: number;
  24068. /**
  24069. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24070. * @see https://doc.babylonjs.com/how_to/more_materials
  24071. */
  24072. wAng: number;
  24073. /**
  24074. * Defines the center of rotation (U)
  24075. */
  24076. uRotationCenter: number;
  24077. /**
  24078. * Defines the center of rotation (V)
  24079. */
  24080. vRotationCenter: number;
  24081. /**
  24082. * Defines the center of rotation (W)
  24083. */
  24084. wRotationCenter: number;
  24085. /**
  24086. * Are mip maps generated for this texture or not.
  24087. */
  24088. get noMipmap(): boolean;
  24089. /**
  24090. * List of inspectable custom properties (used by the Inspector)
  24091. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24092. */
  24093. inspectableCustomProperties: Nullable<IInspectable[]>;
  24094. private _noMipmap;
  24095. /** @hidden */
  24096. _invertY: boolean;
  24097. private _rowGenerationMatrix;
  24098. private _cachedTextureMatrix;
  24099. private _projectionModeMatrix;
  24100. private _t0;
  24101. private _t1;
  24102. private _t2;
  24103. private _cachedUOffset;
  24104. private _cachedVOffset;
  24105. private _cachedUScale;
  24106. private _cachedVScale;
  24107. private _cachedUAng;
  24108. private _cachedVAng;
  24109. private _cachedWAng;
  24110. private _cachedProjectionMatrixId;
  24111. private _cachedCoordinatesMode;
  24112. /** @hidden */
  24113. protected _initialSamplingMode: number;
  24114. /** @hidden */
  24115. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24116. private _deleteBuffer;
  24117. protected _format: Nullable<number>;
  24118. private _delayedOnLoad;
  24119. private _delayedOnError;
  24120. private _mimeType?;
  24121. /**
  24122. * Observable triggered once the texture has been loaded.
  24123. */
  24124. onLoadObservable: Observable<Texture>;
  24125. protected _isBlocking: boolean;
  24126. /**
  24127. * Is the texture preventing material to render while loading.
  24128. * If false, a default texture will be used instead of the loading one during the preparation step.
  24129. */
  24130. set isBlocking(value: boolean);
  24131. get isBlocking(): boolean;
  24132. /**
  24133. * Get the current sampling mode associated with the texture.
  24134. */
  24135. get samplingMode(): number;
  24136. /**
  24137. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24138. */
  24139. get invertY(): boolean;
  24140. /**
  24141. * Instantiates a new texture.
  24142. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24143. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24144. * @param url defines the url of the picture to load as a texture
  24145. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24146. * @param noMipmap defines if the texture will require mip maps or not
  24147. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24148. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24149. * @param onLoad defines a callback triggered when the texture has been loaded
  24150. * @param onError defines a callback triggered when an error occurred during the loading session
  24151. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24152. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24153. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24154. * @param mimeType defines an optional mime type information
  24155. */
  24156. 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);
  24157. /**
  24158. * Update the url (and optional buffer) of this texture if url was null during construction.
  24159. * @param url the url of the texture
  24160. * @param buffer the buffer of the texture (defaults to null)
  24161. * @param onLoad callback called when the texture is loaded (defaults to null)
  24162. */
  24163. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24164. /**
  24165. * Finish the loading sequence of a texture flagged as delayed load.
  24166. * @hidden
  24167. */
  24168. delayLoad(): void;
  24169. private _prepareRowForTextureGeneration;
  24170. /**
  24171. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24172. * @returns the transform matrix of the texture.
  24173. */
  24174. getTextureMatrix(uBase?: number): Matrix;
  24175. /**
  24176. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24177. * @returns The reflection texture transform
  24178. */
  24179. getReflectionTextureMatrix(): Matrix;
  24180. /**
  24181. * Clones the texture.
  24182. * @returns the cloned texture
  24183. */
  24184. clone(): Texture;
  24185. /**
  24186. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24187. * @returns The JSON representation of the texture
  24188. */
  24189. serialize(): any;
  24190. /**
  24191. * Get the current class name of the texture useful for serialization or dynamic coding.
  24192. * @returns "Texture"
  24193. */
  24194. getClassName(): string;
  24195. /**
  24196. * Dispose the texture and release its associated resources.
  24197. */
  24198. dispose(): void;
  24199. /**
  24200. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24201. * @param parsedTexture Define the JSON representation of the texture
  24202. * @param scene Define the scene the parsed texture should be instantiated in
  24203. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24204. * @returns The parsed texture if successful
  24205. */
  24206. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24207. /**
  24208. * Creates a texture from its base 64 representation.
  24209. * @param data Define the base64 payload without the data: prefix
  24210. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24211. * @param scene Define the scene the texture should belong to
  24212. * @param noMipmap Forces the texture to not create mip map information if true
  24213. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24214. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24215. * @param onLoad define a callback triggered when the texture has been loaded
  24216. * @param onError define a callback triggered when an error occurred during the loading session
  24217. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24218. * @returns the created texture
  24219. */
  24220. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24221. /**
  24222. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24223. * @param data Define the base64 payload without the data: prefix
  24224. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24225. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24226. * @param scene Define the scene the texture should belong to
  24227. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24228. * @param noMipmap Forces the texture to not create mip map information if true
  24229. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24230. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24231. * @param onLoad define a callback triggered when the texture has been loaded
  24232. * @param onError define a callback triggered when an error occurred during the loading session
  24233. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24234. * @returns the created texture
  24235. */
  24236. 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;
  24237. }
  24238. }
  24239. declare module "babylonjs/PostProcesses/postProcessManager" {
  24240. import { Nullable } from "babylonjs/types";
  24241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24242. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24243. import { Scene } from "babylonjs/scene";
  24244. /**
  24245. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24246. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24247. */
  24248. export class PostProcessManager {
  24249. private _scene;
  24250. private _indexBuffer;
  24251. private _vertexBuffers;
  24252. /**
  24253. * Creates a new instance PostProcess
  24254. * @param scene The scene that the post process is associated with.
  24255. */
  24256. constructor(scene: Scene);
  24257. private _prepareBuffers;
  24258. private _buildIndexBuffer;
  24259. /**
  24260. * Rebuilds the vertex buffers of the manager.
  24261. * @hidden
  24262. */
  24263. _rebuild(): void;
  24264. /**
  24265. * Prepares a frame to be run through a post process.
  24266. * @param sourceTexture The input texture to the post procesess. (default: null)
  24267. * @param postProcesses An array of post processes to be run. (default: null)
  24268. * @returns True if the post processes were able to be run.
  24269. * @hidden
  24270. */
  24271. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24272. /**
  24273. * Manually render a set of post processes to a texture.
  24274. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24275. * @param postProcesses An array of post processes to be run.
  24276. * @param targetTexture The target texture to render to.
  24277. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24278. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24279. * @param lodLevel defines which lod of the texture to render to
  24280. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24281. */
  24282. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24283. /**
  24284. * Finalize the result of the output of the postprocesses.
  24285. * @param doNotPresent If true the result will not be displayed to the screen.
  24286. * @param targetTexture The target texture to render to.
  24287. * @param faceIndex The index of the face to bind the target texture to.
  24288. * @param postProcesses The array of post processes to render.
  24289. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24290. * @hidden
  24291. */
  24292. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24293. /**
  24294. * Disposes of the post process manager.
  24295. */
  24296. dispose(): void;
  24297. }
  24298. }
  24299. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24300. import { Observable } from "babylonjs/Misc/observable";
  24301. import { SmartArray } from "babylonjs/Misc/smartArray";
  24302. import { Nullable, Immutable } from "babylonjs/types";
  24303. import { Camera } from "babylonjs/Cameras/camera";
  24304. import { Scene } from "babylonjs/scene";
  24305. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24306. import { Color4 } from "babylonjs/Maths/math.color";
  24307. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24309. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24311. import { Texture } from "babylonjs/Materials/Textures/texture";
  24312. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24313. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24314. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24315. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24316. import { Engine } from "babylonjs/Engines/engine";
  24317. /**
  24318. * This Helps creating a texture that will be created from a camera in your scene.
  24319. * It is basically a dynamic texture that could be used to create special effects for instance.
  24320. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24321. */
  24322. export class RenderTargetTexture extends Texture {
  24323. isCube: boolean;
  24324. /**
  24325. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24326. */
  24327. static readonly REFRESHRATE_RENDER_ONCE: number;
  24328. /**
  24329. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24330. */
  24331. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24332. /**
  24333. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24334. * the central point of your effect and can save a lot of performances.
  24335. */
  24336. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24337. /**
  24338. * Use this predicate to dynamically define the list of mesh you want to render.
  24339. * If set, the renderList property will be overwritten.
  24340. */
  24341. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24342. private _renderList;
  24343. /**
  24344. * Use this list to define the list of mesh you want to render.
  24345. */
  24346. get renderList(): Nullable<Array<AbstractMesh>>;
  24347. set renderList(value: Nullable<Array<AbstractMesh>>);
  24348. /**
  24349. * Use this function to overload the renderList array at rendering time.
  24350. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24351. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24352. * the cube (if the RTT is a cube, else layerOrFace=0).
  24353. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24354. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24355. * hold dummy elements!
  24356. */
  24357. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24358. private _hookArray;
  24359. /**
  24360. * Define if particles should be rendered in your texture.
  24361. */
  24362. renderParticles: boolean;
  24363. /**
  24364. * Define if sprites should be rendered in your texture.
  24365. */
  24366. renderSprites: boolean;
  24367. /**
  24368. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24369. */
  24370. coordinatesMode: number;
  24371. /**
  24372. * Define the camera used to render the texture.
  24373. */
  24374. activeCamera: Nullable<Camera>;
  24375. /**
  24376. * Override the mesh isReady function with your own one.
  24377. */
  24378. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24379. /**
  24380. * Override the render function of the texture with your own one.
  24381. */
  24382. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24383. /**
  24384. * Define if camera post processes should be use while rendering the texture.
  24385. */
  24386. useCameraPostProcesses: boolean;
  24387. /**
  24388. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24389. */
  24390. ignoreCameraViewport: boolean;
  24391. private _postProcessManager;
  24392. private _postProcesses;
  24393. private _resizeObserver;
  24394. /**
  24395. * An event triggered when the texture is unbind.
  24396. */
  24397. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24398. /**
  24399. * An event triggered when the texture is unbind.
  24400. */
  24401. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24402. private _onAfterUnbindObserver;
  24403. /**
  24404. * Set a after unbind callback in the texture.
  24405. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24406. */
  24407. set onAfterUnbind(callback: () => void);
  24408. /**
  24409. * An event triggered before rendering the texture
  24410. */
  24411. onBeforeRenderObservable: Observable<number>;
  24412. private _onBeforeRenderObserver;
  24413. /**
  24414. * Set a before render callback in the texture.
  24415. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24416. */
  24417. set onBeforeRender(callback: (faceIndex: number) => void);
  24418. /**
  24419. * An event triggered after rendering the texture
  24420. */
  24421. onAfterRenderObservable: Observable<number>;
  24422. private _onAfterRenderObserver;
  24423. /**
  24424. * Set a after render callback in the texture.
  24425. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24426. */
  24427. set onAfterRender(callback: (faceIndex: number) => void);
  24428. /**
  24429. * An event triggered after the texture clear
  24430. */
  24431. onClearObservable: Observable<Engine>;
  24432. private _onClearObserver;
  24433. /**
  24434. * Set a clear callback in the texture.
  24435. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24436. */
  24437. set onClear(callback: (Engine: Engine) => void);
  24438. /**
  24439. * An event triggered when the texture is resized.
  24440. */
  24441. onResizeObservable: Observable<RenderTargetTexture>;
  24442. /**
  24443. * Define the clear color of the Render Target if it should be different from the scene.
  24444. */
  24445. clearColor: Color4;
  24446. protected _size: number | {
  24447. width: number;
  24448. height: number;
  24449. layers?: number;
  24450. };
  24451. protected _initialSizeParameter: number | {
  24452. width: number;
  24453. height: number;
  24454. } | {
  24455. ratio: number;
  24456. };
  24457. protected _sizeRatio: Nullable<number>;
  24458. /** @hidden */
  24459. _generateMipMaps: boolean;
  24460. protected _renderingManager: RenderingManager;
  24461. /** @hidden */
  24462. _waitingRenderList: string[];
  24463. protected _doNotChangeAspectRatio: boolean;
  24464. protected _currentRefreshId: number;
  24465. protected _refreshRate: number;
  24466. protected _textureMatrix: Matrix;
  24467. protected _samples: number;
  24468. protected _renderTargetOptions: RenderTargetCreationOptions;
  24469. /**
  24470. * Gets render target creation options that were used.
  24471. */
  24472. get renderTargetOptions(): RenderTargetCreationOptions;
  24473. protected _onRatioRescale(): void;
  24474. /**
  24475. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24476. * It must define where the camera used to render the texture is set
  24477. */
  24478. boundingBoxPosition: Vector3;
  24479. private _boundingBoxSize;
  24480. /**
  24481. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24482. * When defined, the cubemap will switch to local mode
  24483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24484. * @example https://www.babylonjs-playground.com/#RNASML
  24485. */
  24486. set boundingBoxSize(value: Vector3);
  24487. get boundingBoxSize(): Vector3;
  24488. /**
  24489. * In case the RTT has been created with a depth texture, get the associated
  24490. * depth texture.
  24491. * Otherwise, return null.
  24492. */
  24493. get depthStencilTexture(): Nullable<InternalTexture>;
  24494. /**
  24495. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24496. * or used a shadow, depth texture...
  24497. * @param name The friendly name of the texture
  24498. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  24499. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24500. * @param generateMipMaps True if mip maps need to be generated after render.
  24501. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24502. * @param type The type of the buffer in the RTT (int, half float, float...)
  24503. * @param isCube True if a cube texture needs to be created
  24504. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24505. * @param generateDepthBuffer True to generate a depth buffer
  24506. * @param generateStencilBuffer True to generate a stencil buffer
  24507. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24508. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24509. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24510. */
  24511. constructor(name: string, size: number | {
  24512. width: number;
  24513. height: number;
  24514. layers?: number;
  24515. } | {
  24516. ratio: number;
  24517. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24518. /**
  24519. * Creates a depth stencil texture.
  24520. * This is only available in WebGL 2 or with the depth texture extension available.
  24521. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24522. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24523. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24524. */
  24525. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24526. private _processSizeParameter;
  24527. /**
  24528. * Define the number of samples to use in case of MSAA.
  24529. * It defaults to one meaning no MSAA has been enabled.
  24530. */
  24531. get samples(): number;
  24532. set samples(value: number);
  24533. /**
  24534. * Resets the refresh counter of the texture and start bak from scratch.
  24535. * Could be useful to regenerate the texture if it is setup to render only once.
  24536. */
  24537. resetRefreshCounter(): void;
  24538. /**
  24539. * Define the refresh rate of the texture or the rendering frequency.
  24540. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24541. */
  24542. get refreshRate(): number;
  24543. set refreshRate(value: number);
  24544. /**
  24545. * Adds a post process to the render target rendering passes.
  24546. * @param postProcess define the post process to add
  24547. */
  24548. addPostProcess(postProcess: PostProcess): void;
  24549. /**
  24550. * Clear all the post processes attached to the render target
  24551. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24552. */
  24553. clearPostProcesses(dispose?: boolean): void;
  24554. /**
  24555. * Remove one of the post process from the list of attached post processes to the texture
  24556. * @param postProcess define the post process to remove from the list
  24557. */
  24558. removePostProcess(postProcess: PostProcess): void;
  24559. /** @hidden */
  24560. _shouldRender(): boolean;
  24561. /**
  24562. * Gets the actual render size of the texture.
  24563. * @returns the width of the render size
  24564. */
  24565. getRenderSize(): number;
  24566. /**
  24567. * Gets the actual render width of the texture.
  24568. * @returns the width of the render size
  24569. */
  24570. getRenderWidth(): number;
  24571. /**
  24572. * Gets the actual render height of the texture.
  24573. * @returns the height of the render size
  24574. */
  24575. getRenderHeight(): number;
  24576. /**
  24577. * Gets the actual number of layers of the texture.
  24578. * @returns the number of layers
  24579. */
  24580. getRenderLayers(): number;
  24581. /**
  24582. * Get if the texture can be rescaled or not.
  24583. */
  24584. get canRescale(): boolean;
  24585. /**
  24586. * Resize the texture using a ratio.
  24587. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24588. */
  24589. scale(ratio: number): void;
  24590. /**
  24591. * Get the texture reflection matrix used to rotate/transform the reflection.
  24592. * @returns the reflection matrix
  24593. */
  24594. getReflectionTextureMatrix(): Matrix;
  24595. /**
  24596. * Resize the texture to a new desired size.
  24597. * Be carrefull as it will recreate all the data in the new texture.
  24598. * @param size Define the new size. It can be:
  24599. * - a number for squared texture,
  24600. * - an object containing { width: number, height: number }
  24601. * - or an object containing a ratio { ratio: number }
  24602. */
  24603. resize(size: number | {
  24604. width: number;
  24605. height: number;
  24606. } | {
  24607. ratio: number;
  24608. }): void;
  24609. private _defaultRenderListPrepared;
  24610. /**
  24611. * Renders all the objects from the render list into the texture.
  24612. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24613. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24614. */
  24615. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24616. private _bestReflectionRenderTargetDimension;
  24617. private _prepareRenderingManager;
  24618. /**
  24619. * @hidden
  24620. * @param faceIndex face index to bind to if this is a cubetexture
  24621. * @param layer defines the index of the texture to bind in the array
  24622. */
  24623. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24624. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24625. private renderToTarget;
  24626. /**
  24627. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24628. * This allowed control for front to back rendering or reversly depending of the special needs.
  24629. *
  24630. * @param renderingGroupId The rendering group id corresponding to its index
  24631. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24632. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24633. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24634. */
  24635. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  24636. /**
  24637. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24638. *
  24639. * @param renderingGroupId The rendering group id corresponding to its index
  24640. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24641. */
  24642. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24643. /**
  24644. * Clones the texture.
  24645. * @returns the cloned texture
  24646. */
  24647. clone(): RenderTargetTexture;
  24648. /**
  24649. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24650. * @returns The JSON representation of the texture
  24651. */
  24652. serialize(): any;
  24653. /**
  24654. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24655. */
  24656. disposeFramebufferObjects(): void;
  24657. /**
  24658. * Dispose the texture and release its associated resources.
  24659. */
  24660. dispose(): void;
  24661. /** @hidden */
  24662. _rebuild(): void;
  24663. /**
  24664. * Clear the info related to rendering groups preventing retention point in material dispose.
  24665. */
  24666. freeRenderingGroups(): void;
  24667. /**
  24668. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24669. * @returns the view count
  24670. */
  24671. getViewCount(): number;
  24672. }
  24673. }
  24674. declare module "babylonjs/Misc/guid" {
  24675. /**
  24676. * Class used to manipulate GUIDs
  24677. */
  24678. export class GUID {
  24679. /**
  24680. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24681. * Be aware Math.random() could cause collisions, but:
  24682. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  24683. * @returns a pseudo random id
  24684. */
  24685. static RandomId(): string;
  24686. }
  24687. }
  24688. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24689. import { Nullable } from "babylonjs/types";
  24690. import { Scene } from "babylonjs/scene";
  24691. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24692. import { Material } from "babylonjs/Materials/material";
  24693. import { Effect } from "babylonjs/Materials/effect";
  24694. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24695. /**
  24696. * Options to be used when creating a shadow depth material
  24697. */
  24698. export interface IIOptionShadowDepthMaterial {
  24699. /** Variables in the vertex shader code that need to have their names remapped.
  24700. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24701. * "var_name" should be either: worldPos or vNormalW
  24702. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24703. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24704. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24705. */
  24706. remappedVariables?: string[];
  24707. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24708. standalone?: boolean;
  24709. }
  24710. /**
  24711. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24712. */
  24713. export class ShadowDepthWrapper {
  24714. private _scene;
  24715. private _options?;
  24716. private _baseMaterial;
  24717. private _onEffectCreatedObserver;
  24718. private _subMeshToEffect;
  24719. private _subMeshToDepthEffect;
  24720. private _meshes;
  24721. /** @hidden */
  24722. _matriceNames: any;
  24723. /** Gets the standalone status of the wrapper */
  24724. get standalone(): boolean;
  24725. /** Gets the base material the wrapper is built upon */
  24726. get baseMaterial(): Material;
  24727. /**
  24728. * Instantiate a new shadow depth wrapper.
  24729. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24730. * generate the shadow depth map. For more information, please refer to the documentation:
  24731. * https://doc.babylonjs.com/babylon101/shadows
  24732. * @param baseMaterial Material to wrap
  24733. * @param scene Define the scene the material belongs to
  24734. * @param options Options used to create the wrapper
  24735. */
  24736. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24737. /**
  24738. * Gets the effect to use to generate the depth map
  24739. * @param subMesh subMesh to get the effect for
  24740. * @param shadowGenerator shadow generator to get the effect for
  24741. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24742. */
  24743. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24744. /**
  24745. * Specifies that the submesh is ready to be used for depth rendering
  24746. * @param subMesh submesh to check
  24747. * @param defines the list of defines to take into account when checking the effect
  24748. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24749. * @param useInstances specifies that instances should be used
  24750. * @returns a boolean indicating that the submesh is ready or not
  24751. */
  24752. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24753. /**
  24754. * Disposes the resources
  24755. */
  24756. dispose(): void;
  24757. private _makeEffect;
  24758. }
  24759. }
  24760. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24762. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24763. import { Nullable } from "babylonjs/types";
  24764. module "babylonjs/Engines/thinEngine" {
  24765. interface ThinEngine {
  24766. /**
  24767. * Unbind a list of render target textures from the webGL context
  24768. * This is used only when drawBuffer extension or webGL2 are active
  24769. * @param textures defines the render target textures to unbind
  24770. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24771. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24772. */
  24773. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24774. /**
  24775. * Create a multi render target texture
  24776. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24777. * @param size defines the size of the texture
  24778. * @param options defines the creation options
  24779. * @returns the cube texture as an InternalTexture
  24780. */
  24781. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24782. /**
  24783. * Update the sample count for a given multiple render target texture
  24784. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24785. * @param textures defines the textures to update
  24786. * @param samples defines the sample count to set
  24787. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24788. */
  24789. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24790. /**
  24791. * Select a subsets of attachments to draw to.
  24792. * @param attachments gl attachments
  24793. */
  24794. bindAttachments(attachments: number[]): void;
  24795. }
  24796. }
  24797. }
  24798. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24799. import { Scene } from "babylonjs/scene";
  24800. import { Engine } from "babylonjs/Engines/engine";
  24801. import { Texture } from "babylonjs/Materials/Textures/texture";
  24802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24803. import "babylonjs/Engines/Extensions/engine.multiRender";
  24804. /**
  24805. * Creation options of the multi render target texture.
  24806. */
  24807. export interface IMultiRenderTargetOptions {
  24808. /**
  24809. * Define if the texture needs to create mip maps after render.
  24810. */
  24811. generateMipMaps?: boolean;
  24812. /**
  24813. * Define the types of all the draw buffers we want to create
  24814. */
  24815. types?: number[];
  24816. /**
  24817. * Define the sampling modes of all the draw buffers we want to create
  24818. */
  24819. samplingModes?: number[];
  24820. /**
  24821. * Define if a depth buffer is required
  24822. */
  24823. generateDepthBuffer?: boolean;
  24824. /**
  24825. * Define if a stencil buffer is required
  24826. */
  24827. generateStencilBuffer?: boolean;
  24828. /**
  24829. * Define if a depth texture is required instead of a depth buffer
  24830. */
  24831. generateDepthTexture?: boolean;
  24832. /**
  24833. * Define the number of desired draw buffers
  24834. */
  24835. textureCount?: number;
  24836. /**
  24837. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24838. */
  24839. doNotChangeAspectRatio?: boolean;
  24840. /**
  24841. * Define the default type of the buffers we are creating
  24842. */
  24843. defaultType?: number;
  24844. }
  24845. /**
  24846. * A multi render target, like a render target provides the ability to render to a texture.
  24847. * Unlike the render target, it can render to several draw buffers in one draw.
  24848. * This is specially interesting in deferred rendering or for any effects requiring more than
  24849. * just one color from a single pass.
  24850. */
  24851. export class MultiRenderTarget extends RenderTargetTexture {
  24852. private _internalTextures;
  24853. private _textures;
  24854. private _multiRenderTargetOptions;
  24855. private _count;
  24856. /**
  24857. * Get if draw buffers are currently supported by the used hardware and browser.
  24858. */
  24859. get isSupported(): boolean;
  24860. /**
  24861. * Get the list of textures generated by the multi render target.
  24862. */
  24863. get textures(): Texture[];
  24864. /**
  24865. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24866. */
  24867. get count(): number;
  24868. /**
  24869. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24870. */
  24871. get depthTexture(): Texture;
  24872. /**
  24873. * Set the wrapping mode on U of all the textures we are rendering to.
  24874. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24875. */
  24876. set wrapU(wrap: number);
  24877. /**
  24878. * Set the wrapping mode on V of all the textures we are rendering to.
  24879. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24880. */
  24881. set wrapV(wrap: number);
  24882. /**
  24883. * Instantiate a new multi render target texture.
  24884. * A multi render target, like a render target provides the ability to render to a texture.
  24885. * Unlike the render target, it can render to several draw buffers in one draw.
  24886. * This is specially interesting in deferred rendering or for any effects requiring more than
  24887. * just one color from a single pass.
  24888. * @param name Define the name of the texture
  24889. * @param size Define the size of the buffers to render to
  24890. * @param count Define the number of target we are rendering into
  24891. * @param scene Define the scene the texture belongs to
  24892. * @param options Define the options used to create the multi render target
  24893. */
  24894. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24895. /** @hidden */
  24896. _rebuild(): void;
  24897. private _createInternalTextures;
  24898. private _createTextures;
  24899. /**
  24900. * Define the number of samples used if MSAA is enabled.
  24901. */
  24902. get samples(): number;
  24903. set samples(value: number);
  24904. /**
  24905. * Resize all the textures in the multi render target.
  24906. * Be carrefull as it will recreate all the data in the new texture.
  24907. * @param size Define the new size
  24908. */
  24909. resize(size: any): void;
  24910. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24911. /**
  24912. * Dispose the render targets and their associated resources
  24913. */
  24914. dispose(): void;
  24915. /**
  24916. * Release all the underlying texture used as draw buffers.
  24917. */
  24918. releaseInternalTextures(): void;
  24919. }
  24920. }
  24921. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24922. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24924. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24925. /** @hidden */
  24926. export var imageProcessingPixelShader: {
  24927. name: string;
  24928. shader: string;
  24929. };
  24930. }
  24931. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24932. import { Nullable } from "babylonjs/types";
  24933. import { Color4 } from "babylonjs/Maths/math.color";
  24934. import { Camera } from "babylonjs/Cameras/camera";
  24935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24936. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24937. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24939. import { Engine } from "babylonjs/Engines/engine";
  24940. import "babylonjs/Shaders/imageProcessing.fragment";
  24941. import "babylonjs/Shaders/postprocess.vertex";
  24942. /**
  24943. * ImageProcessingPostProcess
  24944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24945. */
  24946. export class ImageProcessingPostProcess extends PostProcess {
  24947. /**
  24948. * Default configuration related to image processing available in the PBR Material.
  24949. */
  24950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24951. /**
  24952. * Gets the image processing configuration used either in this material.
  24953. */
  24954. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24955. /**
  24956. * Sets the Default image processing configuration used either in the this material.
  24957. *
  24958. * If sets to null, the scene one is in use.
  24959. */
  24960. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24961. /**
  24962. * Keep track of the image processing observer to allow dispose and replace.
  24963. */
  24964. private _imageProcessingObserver;
  24965. /**
  24966. * Attaches a new image processing configuration to the PBR Material.
  24967. * @param configuration
  24968. */
  24969. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24970. /**
  24971. * If the post process is supported.
  24972. */
  24973. get isSupported(): boolean;
  24974. /**
  24975. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24976. */
  24977. get colorCurves(): Nullable<ColorCurves>;
  24978. /**
  24979. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24980. */
  24981. set colorCurves(value: Nullable<ColorCurves>);
  24982. /**
  24983. * Gets wether the color curves effect is enabled.
  24984. */
  24985. get colorCurvesEnabled(): boolean;
  24986. /**
  24987. * Sets wether the color curves effect is enabled.
  24988. */
  24989. set colorCurvesEnabled(value: boolean);
  24990. /**
  24991. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24992. */
  24993. get colorGradingTexture(): Nullable<BaseTexture>;
  24994. /**
  24995. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24996. */
  24997. set colorGradingTexture(value: Nullable<BaseTexture>);
  24998. /**
  24999. * Gets wether the color grading effect is enabled.
  25000. */
  25001. get colorGradingEnabled(): boolean;
  25002. /**
  25003. * Gets wether the color grading effect is enabled.
  25004. */
  25005. set colorGradingEnabled(value: boolean);
  25006. /**
  25007. * Gets exposure used in the effect.
  25008. */
  25009. get exposure(): number;
  25010. /**
  25011. * Sets exposure used in the effect.
  25012. */
  25013. set exposure(value: number);
  25014. /**
  25015. * Gets wether tonemapping is enabled or not.
  25016. */
  25017. get toneMappingEnabled(): boolean;
  25018. /**
  25019. * Sets wether tonemapping is enabled or not
  25020. */
  25021. set toneMappingEnabled(value: boolean);
  25022. /**
  25023. * Gets the type of tone mapping effect.
  25024. */
  25025. get toneMappingType(): number;
  25026. /**
  25027. * Sets the type of tone mapping effect.
  25028. */
  25029. set toneMappingType(value: number);
  25030. /**
  25031. * Gets contrast used in the effect.
  25032. */
  25033. get contrast(): number;
  25034. /**
  25035. * Sets contrast used in the effect.
  25036. */
  25037. set contrast(value: number);
  25038. /**
  25039. * Gets Vignette stretch size.
  25040. */
  25041. get vignetteStretch(): number;
  25042. /**
  25043. * Sets Vignette stretch size.
  25044. */
  25045. set vignetteStretch(value: number);
  25046. /**
  25047. * Gets Vignette centre X Offset.
  25048. */
  25049. get vignetteCentreX(): number;
  25050. /**
  25051. * Sets Vignette centre X Offset.
  25052. */
  25053. set vignetteCentreX(value: number);
  25054. /**
  25055. * Gets Vignette centre Y Offset.
  25056. */
  25057. get vignetteCentreY(): number;
  25058. /**
  25059. * Sets Vignette centre Y Offset.
  25060. */
  25061. set vignetteCentreY(value: number);
  25062. /**
  25063. * Gets Vignette weight or intensity of the vignette effect.
  25064. */
  25065. get vignetteWeight(): number;
  25066. /**
  25067. * Sets Vignette weight or intensity of the vignette effect.
  25068. */
  25069. set vignetteWeight(value: number);
  25070. /**
  25071. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25072. * if vignetteEnabled is set to true.
  25073. */
  25074. get vignetteColor(): Color4;
  25075. /**
  25076. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25077. * if vignetteEnabled is set to true.
  25078. */
  25079. set vignetteColor(value: Color4);
  25080. /**
  25081. * Gets Camera field of view used by the Vignette effect.
  25082. */
  25083. get vignetteCameraFov(): number;
  25084. /**
  25085. * Sets Camera field of view used by the Vignette effect.
  25086. */
  25087. set vignetteCameraFov(value: number);
  25088. /**
  25089. * Gets the vignette blend mode allowing different kind of effect.
  25090. */
  25091. get vignetteBlendMode(): number;
  25092. /**
  25093. * Sets the vignette blend mode allowing different kind of effect.
  25094. */
  25095. set vignetteBlendMode(value: number);
  25096. /**
  25097. * Gets wether the vignette effect is enabled.
  25098. */
  25099. get vignetteEnabled(): boolean;
  25100. /**
  25101. * Sets wether the vignette effect is enabled.
  25102. */
  25103. set vignetteEnabled(value: boolean);
  25104. private _fromLinearSpace;
  25105. /**
  25106. * Gets wether the input of the processing is in Gamma or Linear Space.
  25107. */
  25108. get fromLinearSpace(): boolean;
  25109. /**
  25110. * Sets wether the input of the processing is in Gamma or Linear Space.
  25111. */
  25112. set fromLinearSpace(value: boolean);
  25113. /**
  25114. * Defines cache preventing GC.
  25115. */
  25116. private _defines;
  25117. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25118. /**
  25119. * "ImageProcessingPostProcess"
  25120. * @returns "ImageProcessingPostProcess"
  25121. */
  25122. getClassName(): string;
  25123. /**
  25124. * @hidden
  25125. */
  25126. _updateParameters(): void;
  25127. dispose(camera?: Camera): void;
  25128. }
  25129. }
  25130. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25131. /** @hidden */
  25132. export var fibonacci: {
  25133. name: string;
  25134. shader: string;
  25135. };
  25136. }
  25137. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25138. /** @hidden */
  25139. export var subSurfaceScatteringFunctions: {
  25140. name: string;
  25141. shader: string;
  25142. };
  25143. }
  25144. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25145. /** @hidden */
  25146. export var diffusionProfile: {
  25147. name: string;
  25148. shader: string;
  25149. };
  25150. }
  25151. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25152. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25154. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25155. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25156. /** @hidden */
  25157. export var subSurfaceScatteringPixelShader: {
  25158. name: string;
  25159. shader: string;
  25160. };
  25161. }
  25162. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25163. import { Nullable } from "babylonjs/types";
  25164. import { Camera } from "babylonjs/Cameras/camera";
  25165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25166. import { Engine } from "babylonjs/Engines/engine";
  25167. import { Scene } from "babylonjs/scene";
  25168. import "babylonjs/Shaders/imageProcessing.fragment";
  25169. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25170. import "babylonjs/Shaders/postprocess.vertex";
  25171. /**
  25172. * Sub surface scattering post process
  25173. */
  25174. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25175. /**
  25176. * Gets a string identifying the name of the class
  25177. * @returns "SubSurfaceScatteringPostProcess" string
  25178. */
  25179. getClassName(): string;
  25180. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25181. }
  25182. }
  25183. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25184. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25185. /**
  25186. * Interface for defining prepass effects in the prepass post-process pipeline
  25187. */
  25188. export interface PrePassEffectConfiguration {
  25189. /**
  25190. * Post process to attach for this effect
  25191. */
  25192. postProcess: PostProcess;
  25193. /**
  25194. * Is the effect enabled
  25195. */
  25196. enabled: boolean;
  25197. /**
  25198. * Disposes the effect configuration
  25199. */
  25200. dispose(): void;
  25201. /**
  25202. * Disposes the effect configuration
  25203. */
  25204. createPostProcess: () => PostProcess;
  25205. }
  25206. }
  25207. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25208. import { Scene } from "babylonjs/scene";
  25209. import { Color3 } from "babylonjs/Maths/math.color";
  25210. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25211. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25212. /**
  25213. * Contains all parameters needed for the prepass to perform
  25214. * screen space subsurface scattering
  25215. */
  25216. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25217. private _ssDiffusionS;
  25218. private _ssFilterRadii;
  25219. private _ssDiffusionD;
  25220. /**
  25221. * Post process to attach for screen space subsurface scattering
  25222. */
  25223. postProcess: SubSurfaceScatteringPostProcess;
  25224. /**
  25225. * Diffusion profile color for subsurface scattering
  25226. */
  25227. get ssDiffusionS(): number[];
  25228. /**
  25229. * Diffusion profile max color channel value for subsurface scattering
  25230. */
  25231. get ssDiffusionD(): number[];
  25232. /**
  25233. * Diffusion profile filter radius for subsurface scattering
  25234. */
  25235. get ssFilterRadii(): number[];
  25236. /**
  25237. * Is subsurface enabled
  25238. */
  25239. enabled: boolean;
  25240. /**
  25241. * Diffusion profile colors for subsurface scattering
  25242. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25243. * See ...
  25244. * Note that you can only store up to 5 of them
  25245. */
  25246. ssDiffusionProfileColors: Color3[];
  25247. /**
  25248. * Defines the ratio real world => scene units.
  25249. * Used for subsurface scattering
  25250. */
  25251. metersPerUnit: number;
  25252. private _scene;
  25253. /**
  25254. * Builds a subsurface configuration object
  25255. * @param scene The scene
  25256. */
  25257. constructor(scene: Scene);
  25258. /**
  25259. * Adds a new diffusion profile.
  25260. * Useful for more realistic subsurface scattering on diverse materials.
  25261. * @param color The color of the diffusion profile. Should be the average color of the material.
  25262. * @return The index of the diffusion profile for the material subsurface configuration
  25263. */
  25264. addDiffusionProfile(color: Color3): number;
  25265. /**
  25266. * Creates the sss post process
  25267. * @return The created post process
  25268. */
  25269. createPostProcess(): SubSurfaceScatteringPostProcess;
  25270. /**
  25271. * Deletes all diffusion profiles.
  25272. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25273. */
  25274. clearAllDiffusionProfiles(): void;
  25275. /**
  25276. * Disposes this object
  25277. */
  25278. dispose(): void;
  25279. /**
  25280. * @hidden
  25281. * https://zero-radiance.github.io/post/sampling-diffusion/
  25282. *
  25283. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25284. * ------------------------------------------------------------------------------------
  25285. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25286. * PDF[r, phi, s] = r * R[r, phi, s]
  25287. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25288. * ------------------------------------------------------------------------------------
  25289. * We importance sample the color channel with the widest scattering distance.
  25290. */
  25291. getDiffusionProfileParameters(color: Color3): number;
  25292. /**
  25293. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25294. * 'u' is the random number (the value of the CDF): [0, 1).
  25295. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25296. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25297. */
  25298. private _sampleBurleyDiffusionProfile;
  25299. }
  25300. }
  25301. declare module "babylonjs/Rendering/prePassRenderer" {
  25302. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25303. import { Scene } from "babylonjs/scene";
  25304. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25305. import { Effect } from "babylonjs/Materials/effect";
  25306. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25307. /**
  25308. * Renders a pre pass of the scene
  25309. * This means every mesh in the scene will be rendered to a render target texture
  25310. * And then this texture will be composited to the rendering canvas with post processes
  25311. * It is necessary for effects like subsurface scattering or deferred shading
  25312. */
  25313. export class PrePassRenderer {
  25314. /** @hidden */
  25315. static _SceneComponentInitialization: (scene: Scene) => void;
  25316. private _scene;
  25317. private _engine;
  25318. private _isDirty;
  25319. /**
  25320. * Number of textures in the multi render target texture where the scene is directly rendered
  25321. */
  25322. readonly mrtCount: number;
  25323. /**
  25324. * The render target where the scene is directly rendered
  25325. */
  25326. prePassRT: MultiRenderTarget;
  25327. private _mrtTypes;
  25328. private _multiRenderAttachments;
  25329. private _defaultAttachments;
  25330. private _clearAttachments;
  25331. private _postProcesses;
  25332. private readonly _clearColor;
  25333. /**
  25334. * Image processing post process for composition
  25335. */
  25336. imageProcessingPostProcess: ImageProcessingPostProcess;
  25337. /**
  25338. * Configuration for sub surface scattering post process
  25339. */
  25340. subSurfaceConfiguration: SubSurfaceConfiguration;
  25341. /**
  25342. * Should materials render their geometry on the MRT
  25343. */
  25344. materialsShouldRenderGeometry: boolean;
  25345. /**
  25346. * Should materials render the irradiance information on the MRT
  25347. */
  25348. materialsShouldRenderIrradiance: boolean;
  25349. private _enabled;
  25350. /**
  25351. * Indicates if the prepass is enabled
  25352. */
  25353. get enabled(): boolean;
  25354. /**
  25355. * How many samples are used for MSAA of the scene render target
  25356. */
  25357. get samples(): number;
  25358. set samples(n: number);
  25359. /**
  25360. * Instanciates a prepass renderer
  25361. * @param scene The scene
  25362. */
  25363. constructor(scene: Scene);
  25364. private _initializeAttachments;
  25365. private _createCompositionEffect;
  25366. /**
  25367. * Indicates if rendering a prepass is supported
  25368. */
  25369. get isSupported(): boolean;
  25370. /**
  25371. * Sets the proper output textures to draw in the engine.
  25372. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25373. */
  25374. bindAttachmentsForEffect(effect: Effect): void;
  25375. /**
  25376. * @hidden
  25377. */
  25378. _beforeCameraDraw(): void;
  25379. /**
  25380. * @hidden
  25381. */
  25382. _afterCameraDraw(): void;
  25383. private _checkRTSize;
  25384. private _bindFrameBuffer;
  25385. /**
  25386. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25387. */
  25388. clear(): void;
  25389. private _setState;
  25390. private _enable;
  25391. private _disable;
  25392. private _resetPostProcessChain;
  25393. private _bindPostProcessChain;
  25394. /**
  25395. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25396. */
  25397. markAsDirty(): void;
  25398. private _update;
  25399. /**
  25400. * Disposes the prepass renderer.
  25401. */
  25402. dispose(): void;
  25403. }
  25404. }
  25405. declare module "babylonjs/Materials/material" {
  25406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25407. import { SmartArray } from "babylonjs/Misc/smartArray";
  25408. import { Observable } from "babylonjs/Misc/observable";
  25409. import { Nullable } from "babylonjs/types";
  25410. import { Scene } from "babylonjs/scene";
  25411. import { Matrix } from "babylonjs/Maths/math.vector";
  25412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25414. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25415. import { Effect } from "babylonjs/Materials/effect";
  25416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25418. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25419. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25420. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25421. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25422. import { Mesh } from "babylonjs/Meshes/mesh";
  25423. import { Animation } from "babylonjs/Animations/animation";
  25424. /**
  25425. * Options for compiling materials.
  25426. */
  25427. export interface IMaterialCompilationOptions {
  25428. /**
  25429. * Defines whether clip planes are enabled.
  25430. */
  25431. clipPlane: boolean;
  25432. /**
  25433. * Defines whether instances are enabled.
  25434. */
  25435. useInstances: boolean;
  25436. }
  25437. /**
  25438. * Options passed when calling customShaderNameResolve
  25439. */
  25440. export interface ICustomShaderNameResolveOptions {
  25441. /**
  25442. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  25443. */
  25444. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25445. }
  25446. /**
  25447. * Base class for the main features of a material in Babylon.js
  25448. */
  25449. export class Material implements IAnimatable {
  25450. /**
  25451. * Returns the triangle fill mode
  25452. */
  25453. static readonly TriangleFillMode: number;
  25454. /**
  25455. * Returns the wireframe mode
  25456. */
  25457. static readonly WireFrameFillMode: number;
  25458. /**
  25459. * Returns the point fill mode
  25460. */
  25461. static readonly PointFillMode: number;
  25462. /**
  25463. * Returns the point list draw mode
  25464. */
  25465. static readonly PointListDrawMode: number;
  25466. /**
  25467. * Returns the line list draw mode
  25468. */
  25469. static readonly LineListDrawMode: number;
  25470. /**
  25471. * Returns the line loop draw mode
  25472. */
  25473. static readonly LineLoopDrawMode: number;
  25474. /**
  25475. * Returns the line strip draw mode
  25476. */
  25477. static readonly LineStripDrawMode: number;
  25478. /**
  25479. * Returns the triangle strip draw mode
  25480. */
  25481. static readonly TriangleStripDrawMode: number;
  25482. /**
  25483. * Returns the triangle fan draw mode
  25484. */
  25485. static readonly TriangleFanDrawMode: number;
  25486. /**
  25487. * Stores the clock-wise side orientation
  25488. */
  25489. static readonly ClockWiseSideOrientation: number;
  25490. /**
  25491. * Stores the counter clock-wise side orientation
  25492. */
  25493. static readonly CounterClockWiseSideOrientation: number;
  25494. /**
  25495. * The dirty texture flag value
  25496. */
  25497. static readonly TextureDirtyFlag: number;
  25498. /**
  25499. * The dirty light flag value
  25500. */
  25501. static readonly LightDirtyFlag: number;
  25502. /**
  25503. * The dirty fresnel flag value
  25504. */
  25505. static readonly FresnelDirtyFlag: number;
  25506. /**
  25507. * The dirty attribute flag value
  25508. */
  25509. static readonly AttributesDirtyFlag: number;
  25510. /**
  25511. * The dirty misc flag value
  25512. */
  25513. static readonly MiscDirtyFlag: number;
  25514. /**
  25515. * The all dirty flag value
  25516. */
  25517. static readonly AllDirtyFlag: number;
  25518. /**
  25519. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25520. */
  25521. static readonly MATERIAL_OPAQUE: number;
  25522. /**
  25523. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25524. */
  25525. static readonly MATERIAL_ALPHATEST: number;
  25526. /**
  25527. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25528. */
  25529. static readonly MATERIAL_ALPHABLEND: number;
  25530. /**
  25531. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25532. * They are also discarded below the alpha cutoff threshold to improve performances.
  25533. */
  25534. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25535. /**
  25536. * The Whiteout method is used to blend normals.
  25537. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25538. */
  25539. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25540. /**
  25541. * The Reoriented Normal Mapping method is used to blend normals.
  25542. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25543. */
  25544. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25545. /**
  25546. * Custom callback helping to override the default shader used in the material.
  25547. */
  25548. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25549. /**
  25550. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25551. */
  25552. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25553. /**
  25554. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25555. * This means that the material can keep using a previous shader while a new one is being compiled.
  25556. * This is mostly used when shader parallel compilation is supported (true by default)
  25557. */
  25558. allowShaderHotSwapping: boolean;
  25559. /**
  25560. * The ID of the material
  25561. */
  25562. id: string;
  25563. /**
  25564. * Gets or sets the unique id of the material
  25565. */
  25566. uniqueId: number;
  25567. /**
  25568. * The name of the material
  25569. */
  25570. name: string;
  25571. /**
  25572. * Gets or sets user defined metadata
  25573. */
  25574. metadata: any;
  25575. /**
  25576. * For internal use only. Please do not use.
  25577. */
  25578. reservedDataStore: any;
  25579. /**
  25580. * Specifies if the ready state should be checked on each call
  25581. */
  25582. checkReadyOnEveryCall: boolean;
  25583. /**
  25584. * Specifies if the ready state should be checked once
  25585. */
  25586. checkReadyOnlyOnce: boolean;
  25587. /**
  25588. * The state of the material
  25589. */
  25590. state: string;
  25591. /**
  25592. * If the material can be rendered to several textures with MRT extension
  25593. */
  25594. get canRenderToMRT(): boolean;
  25595. /**
  25596. * The alpha value of the material
  25597. */
  25598. protected _alpha: number;
  25599. /**
  25600. * List of inspectable custom properties (used by the Inspector)
  25601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25602. */
  25603. inspectableCustomProperties: IInspectable[];
  25604. /**
  25605. * Sets the alpha value of the material
  25606. */
  25607. set alpha(value: number);
  25608. /**
  25609. * Gets the alpha value of the material
  25610. */
  25611. get alpha(): number;
  25612. /**
  25613. * Specifies if back face culling is enabled
  25614. */
  25615. protected _backFaceCulling: boolean;
  25616. /**
  25617. * Sets the back-face culling state
  25618. */
  25619. set backFaceCulling(value: boolean);
  25620. /**
  25621. * Gets the back-face culling state
  25622. */
  25623. get backFaceCulling(): boolean;
  25624. /**
  25625. * Stores the value for side orientation
  25626. */
  25627. sideOrientation: number;
  25628. /**
  25629. * Callback triggered when the material is compiled
  25630. */
  25631. onCompiled: Nullable<(effect: Effect) => void>;
  25632. /**
  25633. * Callback triggered when an error occurs
  25634. */
  25635. onError: Nullable<(effect: Effect, errors: string) => void>;
  25636. /**
  25637. * Callback triggered to get the render target textures
  25638. */
  25639. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25640. /**
  25641. * Gets a boolean indicating that current material needs to register RTT
  25642. */
  25643. get hasRenderTargetTextures(): boolean;
  25644. /**
  25645. * Specifies if the material should be serialized
  25646. */
  25647. doNotSerialize: boolean;
  25648. /**
  25649. * @hidden
  25650. */
  25651. _storeEffectOnSubMeshes: boolean;
  25652. /**
  25653. * Stores the animations for the material
  25654. */
  25655. animations: Nullable<Array<Animation>>;
  25656. /**
  25657. * An event triggered when the material is disposed
  25658. */
  25659. onDisposeObservable: Observable<Material>;
  25660. /**
  25661. * An observer which watches for dispose events
  25662. */
  25663. private _onDisposeObserver;
  25664. private _onUnBindObservable;
  25665. /**
  25666. * Called during a dispose event
  25667. */
  25668. set onDispose(callback: () => void);
  25669. private _onBindObservable;
  25670. /**
  25671. * An event triggered when the material is bound
  25672. */
  25673. get onBindObservable(): Observable<AbstractMesh>;
  25674. /**
  25675. * An observer which watches for bind events
  25676. */
  25677. private _onBindObserver;
  25678. /**
  25679. * Called during a bind event
  25680. */
  25681. set onBind(callback: (Mesh: AbstractMesh) => void);
  25682. /**
  25683. * An event triggered when the material is unbound
  25684. */
  25685. get onUnBindObservable(): Observable<Material>;
  25686. protected _onEffectCreatedObservable: Nullable<Observable<{
  25687. effect: Effect;
  25688. subMesh: Nullable<SubMesh>;
  25689. }>>;
  25690. /**
  25691. * An event triggered when the effect is (re)created
  25692. */
  25693. get onEffectCreatedObservable(): Observable<{
  25694. effect: Effect;
  25695. subMesh: Nullable<SubMesh>;
  25696. }>;
  25697. /**
  25698. * Stores the value of the alpha mode
  25699. */
  25700. private _alphaMode;
  25701. /**
  25702. * Sets the value of the alpha mode.
  25703. *
  25704. * | Value | Type | Description |
  25705. * | --- | --- | --- |
  25706. * | 0 | ALPHA_DISABLE | |
  25707. * | 1 | ALPHA_ADD | |
  25708. * | 2 | ALPHA_COMBINE | |
  25709. * | 3 | ALPHA_SUBTRACT | |
  25710. * | 4 | ALPHA_MULTIPLY | |
  25711. * | 5 | ALPHA_MAXIMIZED | |
  25712. * | 6 | ALPHA_ONEONE | |
  25713. * | 7 | ALPHA_PREMULTIPLIED | |
  25714. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25715. * | 9 | ALPHA_INTERPOLATE | |
  25716. * | 10 | ALPHA_SCREENMODE | |
  25717. *
  25718. */
  25719. set alphaMode(value: number);
  25720. /**
  25721. * Gets the value of the alpha mode
  25722. */
  25723. get alphaMode(): number;
  25724. /**
  25725. * Stores the state of the need depth pre-pass value
  25726. */
  25727. private _needDepthPrePass;
  25728. /**
  25729. * Sets the need depth pre-pass value
  25730. */
  25731. set needDepthPrePass(value: boolean);
  25732. /**
  25733. * Gets the depth pre-pass value
  25734. */
  25735. get needDepthPrePass(): boolean;
  25736. /**
  25737. * Specifies if depth writing should be disabled
  25738. */
  25739. disableDepthWrite: boolean;
  25740. /**
  25741. * Specifies if color writing should be disabled
  25742. */
  25743. disableColorWrite: boolean;
  25744. /**
  25745. * Specifies if depth writing should be forced
  25746. */
  25747. forceDepthWrite: boolean;
  25748. /**
  25749. * Specifies the depth function that should be used. 0 means the default engine function
  25750. */
  25751. depthFunction: number;
  25752. /**
  25753. * Specifies if there should be a separate pass for culling
  25754. */
  25755. separateCullingPass: boolean;
  25756. /**
  25757. * Stores the state specifing if fog should be enabled
  25758. */
  25759. private _fogEnabled;
  25760. /**
  25761. * Sets the state for enabling fog
  25762. */
  25763. set fogEnabled(value: boolean);
  25764. /**
  25765. * Gets the value of the fog enabled state
  25766. */
  25767. get fogEnabled(): boolean;
  25768. /**
  25769. * Stores the size of points
  25770. */
  25771. pointSize: number;
  25772. /**
  25773. * Stores the z offset value
  25774. */
  25775. zOffset: number;
  25776. get wireframe(): boolean;
  25777. /**
  25778. * Sets the state of wireframe mode
  25779. */
  25780. set wireframe(value: boolean);
  25781. /**
  25782. * Gets the value specifying if point clouds are enabled
  25783. */
  25784. get pointsCloud(): boolean;
  25785. /**
  25786. * Sets the state of point cloud mode
  25787. */
  25788. set pointsCloud(value: boolean);
  25789. /**
  25790. * Gets the material fill mode
  25791. */
  25792. get fillMode(): number;
  25793. /**
  25794. * Sets the material fill mode
  25795. */
  25796. set fillMode(value: number);
  25797. /**
  25798. * @hidden
  25799. * Stores the effects for the material
  25800. */
  25801. _effect: Nullable<Effect>;
  25802. /**
  25803. * Specifies if uniform buffers should be used
  25804. */
  25805. private _useUBO;
  25806. /**
  25807. * Stores a reference to the scene
  25808. */
  25809. private _scene;
  25810. /**
  25811. * Stores the fill mode state
  25812. */
  25813. private _fillMode;
  25814. /**
  25815. * Specifies if the depth write state should be cached
  25816. */
  25817. private _cachedDepthWriteState;
  25818. /**
  25819. * Specifies if the color write state should be cached
  25820. */
  25821. private _cachedColorWriteState;
  25822. /**
  25823. * Specifies if the depth function state should be cached
  25824. */
  25825. private _cachedDepthFunctionState;
  25826. /**
  25827. * Stores the uniform buffer
  25828. */
  25829. protected _uniformBuffer: UniformBuffer;
  25830. /** @hidden */
  25831. _indexInSceneMaterialArray: number;
  25832. /** @hidden */
  25833. meshMap: Nullable<{
  25834. [id: string]: AbstractMesh | undefined;
  25835. }>;
  25836. /**
  25837. * Creates a material instance
  25838. * @param name defines the name of the material
  25839. * @param scene defines the scene to reference
  25840. * @param doNotAdd specifies if the material should be added to the scene
  25841. */
  25842. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25843. /**
  25844. * Returns a string representation of the current material
  25845. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25846. * @returns a string with material information
  25847. */
  25848. toString(fullDetails?: boolean): string;
  25849. /**
  25850. * Gets the class name of the material
  25851. * @returns a string with the class name of the material
  25852. */
  25853. getClassName(): string;
  25854. /**
  25855. * Specifies if updates for the material been locked
  25856. */
  25857. get isFrozen(): boolean;
  25858. /**
  25859. * Locks updates for the material
  25860. */
  25861. freeze(): void;
  25862. /**
  25863. * Unlocks updates for the material
  25864. */
  25865. unfreeze(): void;
  25866. /**
  25867. * Specifies if the material is ready to be used
  25868. * @param mesh defines the mesh to check
  25869. * @param useInstances specifies if instances should be used
  25870. * @returns a boolean indicating if the material is ready to be used
  25871. */
  25872. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25873. /**
  25874. * Specifies that the submesh is ready to be used
  25875. * @param mesh defines the mesh to check
  25876. * @param subMesh defines which submesh to check
  25877. * @param useInstances specifies that instances should be used
  25878. * @returns a boolean indicating that the submesh is ready or not
  25879. */
  25880. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25881. /**
  25882. * Returns the material effect
  25883. * @returns the effect associated with the material
  25884. */
  25885. getEffect(): Nullable<Effect>;
  25886. /**
  25887. * Returns the current scene
  25888. * @returns a Scene
  25889. */
  25890. getScene(): Scene;
  25891. /**
  25892. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25893. */
  25894. protected _forceAlphaTest: boolean;
  25895. /**
  25896. * The transparency mode of the material.
  25897. */
  25898. protected _transparencyMode: Nullable<number>;
  25899. /**
  25900. * Gets the current transparency mode.
  25901. */
  25902. get transparencyMode(): Nullable<number>;
  25903. /**
  25904. * Sets the transparency mode of the material.
  25905. *
  25906. * | Value | Type | Description |
  25907. * | ----- | ----------------------------------- | ----------- |
  25908. * | 0 | OPAQUE | |
  25909. * | 1 | ALPHATEST | |
  25910. * | 2 | ALPHABLEND | |
  25911. * | 3 | ALPHATESTANDBLEND | |
  25912. *
  25913. */
  25914. set transparencyMode(value: Nullable<number>);
  25915. /**
  25916. * Returns true if alpha blending should be disabled.
  25917. */
  25918. protected get _disableAlphaBlending(): boolean;
  25919. /**
  25920. * Specifies whether or not this material should be rendered in alpha blend mode.
  25921. * @returns a boolean specifying if alpha blending is needed
  25922. */
  25923. needAlphaBlending(): boolean;
  25924. /**
  25925. * Specifies if the mesh will require alpha blending
  25926. * @param mesh defines the mesh to check
  25927. * @returns a boolean specifying if alpha blending is needed for the mesh
  25928. */
  25929. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25930. /**
  25931. * Specifies whether or not this material should be rendered in alpha test mode.
  25932. * @returns a boolean specifying if an alpha test is needed.
  25933. */
  25934. needAlphaTesting(): boolean;
  25935. /**
  25936. * Specifies if material alpha testing should be turned on for the mesh
  25937. * @param mesh defines the mesh to check
  25938. */
  25939. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25940. /**
  25941. * Gets the texture used for the alpha test
  25942. * @returns the texture to use for alpha testing
  25943. */
  25944. getAlphaTestTexture(): Nullable<BaseTexture>;
  25945. /**
  25946. * Marks the material to indicate that it needs to be re-calculated
  25947. */
  25948. markDirty(): void;
  25949. /** @hidden */
  25950. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25951. /**
  25952. * Binds the material to the mesh
  25953. * @param world defines the world transformation matrix
  25954. * @param mesh defines the mesh to bind the material to
  25955. */
  25956. bind(world: Matrix, mesh?: Mesh): void;
  25957. /**
  25958. * Binds the submesh to the material
  25959. * @param world defines the world transformation matrix
  25960. * @param mesh defines the mesh containing the submesh
  25961. * @param subMesh defines the submesh to bind the material to
  25962. */
  25963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25964. /**
  25965. * Binds the world matrix to the material
  25966. * @param world defines the world transformation matrix
  25967. */
  25968. bindOnlyWorldMatrix(world: Matrix): void;
  25969. /**
  25970. * Binds the scene's uniform buffer to the effect.
  25971. * @param effect defines the effect to bind to the scene uniform buffer
  25972. * @param sceneUbo defines the uniform buffer storing scene data
  25973. */
  25974. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25975. /**
  25976. * Binds the view matrix to the effect
  25977. * @param effect defines the effect to bind the view matrix to
  25978. */
  25979. bindView(effect: Effect): void;
  25980. /**
  25981. * Binds the view projection matrix to the effect
  25982. * @param effect defines the effect to bind the view projection matrix to
  25983. */
  25984. bindViewProjection(effect: Effect): void;
  25985. /**
  25986. * Processes to execute after binding the material to a mesh
  25987. * @param mesh defines the rendered mesh
  25988. */
  25989. protected _afterBind(mesh?: Mesh): void;
  25990. /**
  25991. * Unbinds the material from the mesh
  25992. */
  25993. unbind(): void;
  25994. /**
  25995. * Gets the active textures from the material
  25996. * @returns an array of textures
  25997. */
  25998. getActiveTextures(): BaseTexture[];
  25999. /**
  26000. * Specifies if the material uses a texture
  26001. * @param texture defines the texture to check against the material
  26002. * @returns a boolean specifying if the material uses the texture
  26003. */
  26004. hasTexture(texture: BaseTexture): boolean;
  26005. /**
  26006. * Makes a duplicate of the material, and gives it a new name
  26007. * @param name defines the new name for the duplicated material
  26008. * @returns the cloned material
  26009. */
  26010. clone(name: string): Nullable<Material>;
  26011. /**
  26012. * Gets the meshes bound to the material
  26013. * @returns an array of meshes bound to the material
  26014. */
  26015. getBindedMeshes(): AbstractMesh[];
  26016. /**
  26017. * Force shader compilation
  26018. * @param mesh defines the mesh associated with this material
  26019. * @param onCompiled defines a function to execute once the material is compiled
  26020. * @param options defines the options to configure the compilation
  26021. * @param onError defines a function to execute if the material fails compiling
  26022. */
  26023. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26024. /**
  26025. * Force shader compilation
  26026. * @param mesh defines the mesh that will use this material
  26027. * @param options defines additional options for compiling the shaders
  26028. * @returns a promise that resolves when the compilation completes
  26029. */
  26030. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26031. private static readonly _AllDirtyCallBack;
  26032. private static readonly _ImageProcessingDirtyCallBack;
  26033. private static readonly _TextureDirtyCallBack;
  26034. private static readonly _FresnelDirtyCallBack;
  26035. private static readonly _MiscDirtyCallBack;
  26036. private static readonly _LightsDirtyCallBack;
  26037. private static readonly _AttributeDirtyCallBack;
  26038. private static _FresnelAndMiscDirtyCallBack;
  26039. private static _TextureAndMiscDirtyCallBack;
  26040. private static readonly _DirtyCallbackArray;
  26041. private static readonly _RunDirtyCallBacks;
  26042. /**
  26043. * Marks a define in the material to indicate that it needs to be re-computed
  26044. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26045. */
  26046. markAsDirty(flag: number): void;
  26047. /**
  26048. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26049. * @param func defines a function which checks material defines against the submeshes
  26050. */
  26051. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26052. /**
  26053. * Indicates that the scene should check if the rendering now needs a prepass
  26054. */
  26055. protected _markScenePrePassDirty(): void;
  26056. /**
  26057. * Indicates that we need to re-calculated for all submeshes
  26058. */
  26059. protected _markAllSubMeshesAsAllDirty(): void;
  26060. /**
  26061. * Indicates that image processing needs to be re-calculated for all submeshes
  26062. */
  26063. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26064. /**
  26065. * Indicates that textures need to be re-calculated for all submeshes
  26066. */
  26067. protected _markAllSubMeshesAsTexturesDirty(): void;
  26068. /**
  26069. * Indicates that fresnel needs to be re-calculated for all submeshes
  26070. */
  26071. protected _markAllSubMeshesAsFresnelDirty(): void;
  26072. /**
  26073. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26074. */
  26075. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26076. /**
  26077. * Indicates that lights need to be re-calculated for all submeshes
  26078. */
  26079. protected _markAllSubMeshesAsLightsDirty(): void;
  26080. /**
  26081. * Indicates that attributes need to be re-calculated for all submeshes
  26082. */
  26083. protected _markAllSubMeshesAsAttributesDirty(): void;
  26084. /**
  26085. * Indicates that misc needs to be re-calculated for all submeshes
  26086. */
  26087. protected _markAllSubMeshesAsMiscDirty(): void;
  26088. /**
  26089. * Indicates that textures and misc need to be re-calculated for all submeshes
  26090. */
  26091. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26092. /**
  26093. * Sets the required values to the prepass renderer.
  26094. * @param prePassRenderer defines the prepass renderer to setup.
  26095. * @returns true if the pre pass is needed.
  26096. */
  26097. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26098. /**
  26099. * Disposes the material
  26100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26103. */
  26104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26105. /** @hidden */
  26106. private releaseVertexArrayObject;
  26107. /**
  26108. * Serializes this material
  26109. * @returns the serialized material object
  26110. */
  26111. serialize(): any;
  26112. /**
  26113. * Creates a material from parsed material data
  26114. * @param parsedMaterial defines parsed material data
  26115. * @param scene defines the hosting scene
  26116. * @param rootUrl defines the root URL to use to load textures
  26117. * @returns a new material
  26118. */
  26119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26120. }
  26121. }
  26122. declare module "babylonjs/Materials/multiMaterial" {
  26123. import { Nullable } from "babylonjs/types";
  26124. import { Scene } from "babylonjs/scene";
  26125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26128. import { Material } from "babylonjs/Materials/material";
  26129. /**
  26130. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26131. * separate meshes. This can be use to improve performances.
  26132. * @see https://doc.babylonjs.com/how_to/multi_materials
  26133. */
  26134. export class MultiMaterial extends Material {
  26135. private _subMaterials;
  26136. /**
  26137. * Gets or Sets the list of Materials used within the multi material.
  26138. * They need to be ordered according to the submeshes order in the associated mesh
  26139. */
  26140. get subMaterials(): Nullable<Material>[];
  26141. set subMaterials(value: Nullable<Material>[]);
  26142. /**
  26143. * Function used to align with Node.getChildren()
  26144. * @returns the list of Materials used within the multi material
  26145. */
  26146. getChildren(): Nullable<Material>[];
  26147. /**
  26148. * Instantiates a new Multi Material
  26149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26150. * separate meshes. This can be use to improve performances.
  26151. * @see https://doc.babylonjs.com/how_to/multi_materials
  26152. * @param name Define the name in the scene
  26153. * @param scene Define the scene the material belongs to
  26154. */
  26155. constructor(name: string, scene: Scene);
  26156. private _hookArray;
  26157. /**
  26158. * Get one of the submaterial by its index in the submaterials array
  26159. * @param index The index to look the sub material at
  26160. * @returns The Material if the index has been defined
  26161. */
  26162. getSubMaterial(index: number): Nullable<Material>;
  26163. /**
  26164. * Get the list of active textures for the whole sub materials list.
  26165. * @returns All the textures that will be used during the rendering
  26166. */
  26167. getActiveTextures(): BaseTexture[];
  26168. /**
  26169. * Gets the current class name of the material e.g. "MultiMaterial"
  26170. * Mainly use in serialization.
  26171. * @returns the class name
  26172. */
  26173. getClassName(): string;
  26174. /**
  26175. * Checks if the material is ready to render the requested sub mesh
  26176. * @param mesh Define the mesh the submesh belongs to
  26177. * @param subMesh Define the sub mesh to look readyness for
  26178. * @param useInstances Define whether or not the material is used with instances
  26179. * @returns true if ready, otherwise false
  26180. */
  26181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26182. /**
  26183. * Clones the current material and its related sub materials
  26184. * @param name Define the name of the newly cloned material
  26185. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26186. * @returns the cloned material
  26187. */
  26188. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26189. /**
  26190. * Serializes the materials into a JSON representation.
  26191. * @returns the JSON representation
  26192. */
  26193. serialize(): any;
  26194. /**
  26195. * Dispose the material and release its associated resources
  26196. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  26197. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  26198. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  26199. */
  26200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26201. /**
  26202. * Creates a MultiMaterial from parsed MultiMaterial data.
  26203. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26204. * @param scene defines the hosting scene
  26205. * @returns a new MultiMaterial
  26206. */
  26207. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26208. }
  26209. }
  26210. declare module "babylonjs/Meshes/subMesh" {
  26211. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26213. import { Engine } from "babylonjs/Engines/engine";
  26214. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26216. import { Effect } from "babylonjs/Materials/effect";
  26217. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26218. import { Plane } from "babylonjs/Maths/math.plane";
  26219. import { Collider } from "babylonjs/Collisions/collider";
  26220. import { Material } from "babylonjs/Materials/material";
  26221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26223. import { Mesh } from "babylonjs/Meshes/mesh";
  26224. import { Ray } from "babylonjs/Culling/ray";
  26225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26226. /**
  26227. * Defines a subdivision inside a mesh
  26228. */
  26229. export class SubMesh implements ICullable {
  26230. /** the material index to use */
  26231. materialIndex: number;
  26232. /** vertex index start */
  26233. verticesStart: number;
  26234. /** vertices count */
  26235. verticesCount: number;
  26236. /** index start */
  26237. indexStart: number;
  26238. /** indices count */
  26239. indexCount: number;
  26240. /** @hidden */
  26241. _materialDefines: Nullable<MaterialDefines>;
  26242. /** @hidden */
  26243. _materialEffect: Nullable<Effect>;
  26244. /** @hidden */
  26245. _effectOverride: Nullable<Effect>;
  26246. /**
  26247. * Gets material defines used by the effect associated to the sub mesh
  26248. */
  26249. get materialDefines(): Nullable<MaterialDefines>;
  26250. /**
  26251. * Sets material defines used by the effect associated to the sub mesh
  26252. */
  26253. set materialDefines(defines: Nullable<MaterialDefines>);
  26254. /**
  26255. * Gets associated effect
  26256. */
  26257. get effect(): Nullable<Effect>;
  26258. /**
  26259. * Sets associated effect (effect used to render this submesh)
  26260. * @param effect defines the effect to associate with
  26261. * @param defines defines the set of defines used to compile this effect
  26262. */
  26263. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26264. /** @hidden */
  26265. _linesIndexCount: number;
  26266. private _mesh;
  26267. private _renderingMesh;
  26268. private _boundingInfo;
  26269. private _linesIndexBuffer;
  26270. /** @hidden */
  26271. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26272. /** @hidden */
  26273. _trianglePlanes: Plane[];
  26274. /** @hidden */
  26275. _lastColliderTransformMatrix: Nullable<Matrix>;
  26276. /** @hidden */
  26277. _renderId: number;
  26278. /** @hidden */
  26279. _alphaIndex: number;
  26280. /** @hidden */
  26281. _distanceToCamera: number;
  26282. /** @hidden */
  26283. _id: number;
  26284. private _currentMaterial;
  26285. /**
  26286. * Add a new submesh to a mesh
  26287. * @param materialIndex defines the material index to use
  26288. * @param verticesStart defines vertex index start
  26289. * @param verticesCount defines vertices count
  26290. * @param indexStart defines index start
  26291. * @param indexCount defines indices count
  26292. * @param mesh defines the parent mesh
  26293. * @param renderingMesh defines an optional rendering mesh
  26294. * @param createBoundingBox defines if bounding box should be created for this submesh
  26295. * @returns the new submesh
  26296. */
  26297. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26298. /**
  26299. * Creates a new submesh
  26300. * @param materialIndex defines the material index to use
  26301. * @param verticesStart defines vertex index start
  26302. * @param verticesCount defines vertices count
  26303. * @param indexStart defines index start
  26304. * @param indexCount defines indices count
  26305. * @param mesh defines the parent mesh
  26306. * @param renderingMesh defines an optional rendering mesh
  26307. * @param createBoundingBox defines if bounding box should be created for this submesh
  26308. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26309. */
  26310. constructor(
  26311. /** the material index to use */
  26312. materialIndex: number,
  26313. /** vertex index start */
  26314. verticesStart: number,
  26315. /** vertices count */
  26316. verticesCount: number,
  26317. /** index start */
  26318. indexStart: number,
  26319. /** indices count */
  26320. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26321. /**
  26322. * Returns true if this submesh covers the entire parent mesh
  26323. * @ignorenaming
  26324. */
  26325. get IsGlobal(): boolean;
  26326. /**
  26327. * Returns the submesh BoudingInfo object
  26328. * @returns current bounding info (or mesh's one if the submesh is global)
  26329. */
  26330. getBoundingInfo(): BoundingInfo;
  26331. /**
  26332. * Sets the submesh BoundingInfo
  26333. * @param boundingInfo defines the new bounding info to use
  26334. * @returns the SubMesh
  26335. */
  26336. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26337. /**
  26338. * Returns the mesh of the current submesh
  26339. * @return the parent mesh
  26340. */
  26341. getMesh(): AbstractMesh;
  26342. /**
  26343. * Returns the rendering mesh of the submesh
  26344. * @returns the rendering mesh (could be different from parent mesh)
  26345. */
  26346. getRenderingMesh(): Mesh;
  26347. /**
  26348. * Returns the replacement mesh of the submesh
  26349. * @returns the replacement mesh (could be different from parent mesh)
  26350. */
  26351. getReplacementMesh(): Nullable<AbstractMesh>;
  26352. /**
  26353. * Returns the effective mesh of the submesh
  26354. * @returns the effective mesh (could be different from parent mesh)
  26355. */
  26356. getEffectiveMesh(): AbstractMesh;
  26357. /**
  26358. * Returns the submesh material
  26359. * @returns null or the current material
  26360. */
  26361. getMaterial(): Nullable<Material>;
  26362. private _IsMultiMaterial;
  26363. /**
  26364. * Sets a new updated BoundingInfo object to the submesh
  26365. * @param data defines an optional position array to use to determine the bounding info
  26366. * @returns the SubMesh
  26367. */
  26368. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26369. /** @hidden */
  26370. _checkCollision(collider: Collider): boolean;
  26371. /**
  26372. * Updates the submesh BoundingInfo
  26373. * @param world defines the world matrix to use to update the bounding info
  26374. * @returns the submesh
  26375. */
  26376. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26377. /**
  26378. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26379. * @param frustumPlanes defines the frustum planes
  26380. * @returns true if the submesh is intersecting with the frustum
  26381. */
  26382. isInFrustum(frustumPlanes: Plane[]): boolean;
  26383. /**
  26384. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26385. * @param frustumPlanes defines the frustum planes
  26386. * @returns true if the submesh is inside the frustum
  26387. */
  26388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26389. /**
  26390. * Renders the submesh
  26391. * @param enableAlphaMode defines if alpha needs to be used
  26392. * @returns the submesh
  26393. */
  26394. render(enableAlphaMode: boolean): SubMesh;
  26395. /**
  26396. * @hidden
  26397. */
  26398. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26399. /**
  26400. * Checks if the submesh intersects with a ray
  26401. * @param ray defines the ray to test
  26402. * @returns true is the passed ray intersects the submesh bounding box
  26403. */
  26404. canIntersects(ray: Ray): boolean;
  26405. /**
  26406. * Intersects current submesh with a ray
  26407. * @param ray defines the ray to test
  26408. * @param positions defines mesh's positions array
  26409. * @param indices defines mesh's indices array
  26410. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26412. * @returns intersection info or null if no intersection
  26413. */
  26414. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26415. /** @hidden */
  26416. private _intersectLines;
  26417. /** @hidden */
  26418. private _intersectUnIndexedLines;
  26419. /** @hidden */
  26420. private _intersectTriangles;
  26421. /** @hidden */
  26422. private _intersectUnIndexedTriangles;
  26423. /** @hidden */
  26424. _rebuild(): void;
  26425. /**
  26426. * Creates a new submesh from the passed mesh
  26427. * @param newMesh defines the new hosting mesh
  26428. * @param newRenderingMesh defines an optional rendering mesh
  26429. * @returns the new submesh
  26430. */
  26431. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26432. /**
  26433. * Release associated resources
  26434. */
  26435. dispose(): void;
  26436. /**
  26437. * Gets the class name
  26438. * @returns the string "SubMesh".
  26439. */
  26440. getClassName(): string;
  26441. /**
  26442. * Creates a new submesh from indices data
  26443. * @param materialIndex the index of the main mesh material
  26444. * @param startIndex the index where to start the copy in the mesh indices array
  26445. * @param indexCount the number of indices to copy then from the startIndex
  26446. * @param mesh the main mesh to create the submesh from
  26447. * @param renderingMesh the optional rendering mesh
  26448. * @returns a new submesh
  26449. */
  26450. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26451. }
  26452. }
  26453. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26454. /**
  26455. * Class used to represent data loading progression
  26456. */
  26457. export class SceneLoaderFlags {
  26458. private static _ForceFullSceneLoadingForIncremental;
  26459. private static _ShowLoadingScreen;
  26460. private static _CleanBoneMatrixWeights;
  26461. private static _loggingLevel;
  26462. /**
  26463. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26464. */
  26465. static get ForceFullSceneLoadingForIncremental(): boolean;
  26466. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26467. /**
  26468. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26469. */
  26470. static get ShowLoadingScreen(): boolean;
  26471. static set ShowLoadingScreen(value: boolean);
  26472. /**
  26473. * Defines the current logging level (while loading the scene)
  26474. * @ignorenaming
  26475. */
  26476. static get loggingLevel(): number;
  26477. static set loggingLevel(value: number);
  26478. /**
  26479. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26480. */
  26481. static get CleanBoneMatrixWeights(): boolean;
  26482. static set CleanBoneMatrixWeights(value: boolean);
  26483. }
  26484. }
  26485. declare module "babylonjs/Meshes/geometry" {
  26486. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26487. import { Scene } from "babylonjs/scene";
  26488. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26489. import { Engine } from "babylonjs/Engines/engine";
  26490. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26492. import { Effect } from "babylonjs/Materials/effect";
  26493. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26495. import { Mesh } from "babylonjs/Meshes/mesh";
  26496. /**
  26497. * Class used to store geometry data (vertex buffers + index buffer)
  26498. */
  26499. export class Geometry implements IGetSetVerticesData {
  26500. /**
  26501. * Gets or sets the ID of the geometry
  26502. */
  26503. id: string;
  26504. /**
  26505. * Gets or sets the unique ID of the geometry
  26506. */
  26507. uniqueId: number;
  26508. /**
  26509. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26510. */
  26511. delayLoadState: number;
  26512. /**
  26513. * Gets the file containing the data to load when running in delay load state
  26514. */
  26515. delayLoadingFile: Nullable<string>;
  26516. /**
  26517. * Callback called when the geometry is updated
  26518. */
  26519. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26520. private _scene;
  26521. private _engine;
  26522. private _meshes;
  26523. private _totalVertices;
  26524. /** @hidden */
  26525. _indices: IndicesArray;
  26526. /** @hidden */
  26527. _vertexBuffers: {
  26528. [key: string]: VertexBuffer;
  26529. };
  26530. private _isDisposed;
  26531. private _extend;
  26532. private _boundingBias;
  26533. /** @hidden */
  26534. _delayInfo: Array<string>;
  26535. private _indexBuffer;
  26536. private _indexBufferIsUpdatable;
  26537. /** @hidden */
  26538. _boundingInfo: Nullable<BoundingInfo>;
  26539. /** @hidden */
  26540. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26541. /** @hidden */
  26542. _softwareSkinningFrameId: number;
  26543. private _vertexArrayObjects;
  26544. private _updatable;
  26545. /** @hidden */
  26546. _positions: Nullable<Vector3[]>;
  26547. /**
  26548. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  26549. */
  26550. get boundingBias(): Vector2;
  26551. /**
  26552. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  26553. */
  26554. set boundingBias(value: Vector2);
  26555. /**
  26556. * Static function used to attach a new empty geometry to a mesh
  26557. * @param mesh defines the mesh to attach the geometry to
  26558. * @returns the new Geometry
  26559. */
  26560. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26561. /** Get the list of meshes using this geometry */
  26562. get meshes(): Mesh[];
  26563. /**
  26564. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  26565. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26566. */
  26567. useBoundingInfoFromGeometry: boolean;
  26568. /**
  26569. * Creates a new geometry
  26570. * @param id defines the unique ID
  26571. * @param scene defines the hosting scene
  26572. * @param vertexData defines the VertexData used to get geometry data
  26573. * @param updatable defines if geometry must be updatable (false by default)
  26574. * @param mesh defines the mesh that will be associated with the geometry
  26575. */
  26576. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26577. /**
  26578. * Gets the current extend of the geometry
  26579. */
  26580. get extend(): {
  26581. minimum: Vector3;
  26582. maximum: Vector3;
  26583. };
  26584. /**
  26585. * Gets the hosting scene
  26586. * @returns the hosting Scene
  26587. */
  26588. getScene(): Scene;
  26589. /**
  26590. * Gets the hosting engine
  26591. * @returns the hosting Engine
  26592. */
  26593. getEngine(): Engine;
  26594. /**
  26595. * Defines if the geometry is ready to use
  26596. * @returns true if the geometry is ready to be used
  26597. */
  26598. isReady(): boolean;
  26599. /**
  26600. * Gets a value indicating that the geometry should not be serialized
  26601. */
  26602. get doNotSerialize(): boolean;
  26603. /** @hidden */
  26604. _rebuild(): void;
  26605. /**
  26606. * Affects all geometry data in one call
  26607. * @param vertexData defines the geometry data
  26608. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26609. */
  26610. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26611. /**
  26612. * Set specific vertex data
  26613. * @param kind defines the data kind (Position, normal, etc...)
  26614. * @param data defines the vertex data to use
  26615. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26616. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26617. */
  26618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26619. /**
  26620. * Removes a specific vertex data
  26621. * @param kind defines the data kind (Position, normal, etc...)
  26622. */
  26623. removeVerticesData(kind: string): void;
  26624. /**
  26625. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26626. * @param buffer defines the vertex buffer to use
  26627. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26628. */
  26629. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26630. /**
  26631. * Update a specific vertex buffer
  26632. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26633. * It will do nothing if the buffer is not updatable
  26634. * @param kind defines the data kind (Position, normal, etc...)
  26635. * @param data defines the data to use
  26636. * @param offset defines the offset in the target buffer where to store the data
  26637. * @param useBytes set to true if the offset is in bytes
  26638. */
  26639. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26640. /**
  26641. * Update a specific vertex buffer
  26642. * This function will create a new buffer if the current one is not updatable
  26643. * @param kind defines the data kind (Position, normal, etc...)
  26644. * @param data defines the data to use
  26645. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26646. */
  26647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26648. private _updateBoundingInfo;
  26649. /** @hidden */
  26650. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26651. /**
  26652. * Gets total number of vertices
  26653. * @returns the total number of vertices
  26654. */
  26655. getTotalVertices(): number;
  26656. /**
  26657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26658. * @param kind defines the data kind (Position, normal, etc...)
  26659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26661. * @returns a float array containing vertex data
  26662. */
  26663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26664. /**
  26665. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26666. * @param kind defines the data kind (Position, normal, etc...)
  26667. * @returns true if the vertex buffer with the specified kind is updatable
  26668. */
  26669. isVertexBufferUpdatable(kind: string): boolean;
  26670. /**
  26671. * Gets a specific vertex buffer
  26672. * @param kind defines the data kind (Position, normal, etc...)
  26673. * @returns a VertexBuffer
  26674. */
  26675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26676. /**
  26677. * Returns all vertex buffers
  26678. * @return an object holding all vertex buffers indexed by kind
  26679. */
  26680. getVertexBuffers(): Nullable<{
  26681. [key: string]: VertexBuffer;
  26682. }>;
  26683. /**
  26684. * Gets a boolean indicating if specific vertex buffer is present
  26685. * @param kind defines the data kind (Position, normal, etc...)
  26686. * @returns true if data is present
  26687. */
  26688. isVerticesDataPresent(kind: string): boolean;
  26689. /**
  26690. * Gets a list of all attached data kinds (Position, normal, etc...)
  26691. * @returns a list of string containing all kinds
  26692. */
  26693. getVerticesDataKinds(): string[];
  26694. /**
  26695. * Update index buffer
  26696. * @param indices defines the indices to store in the index buffer
  26697. * @param offset defines the offset in the target buffer where to store the data
  26698. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  26699. */
  26700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26701. /**
  26702. * Creates a new index buffer
  26703. * @param indices defines the indices to store in the index buffer
  26704. * @param totalVertices defines the total number of vertices (could be null)
  26705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26706. */
  26707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26708. /**
  26709. * Return the total number of indices
  26710. * @returns the total number of indices
  26711. */
  26712. getTotalIndices(): number;
  26713. /**
  26714. * Gets the index buffer array
  26715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26717. * @returns the index buffer array
  26718. */
  26719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26720. /**
  26721. * Gets the index buffer
  26722. * @return the index buffer
  26723. */
  26724. getIndexBuffer(): Nullable<DataBuffer>;
  26725. /** @hidden */
  26726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26727. /**
  26728. * Release the associated resources for a specific mesh
  26729. * @param mesh defines the source mesh
  26730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26731. */
  26732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26733. /**
  26734. * Apply current geometry to a given mesh
  26735. * @param mesh defines the mesh to apply geometry to
  26736. */
  26737. applyToMesh(mesh: Mesh): void;
  26738. private _updateExtend;
  26739. private _applyToMesh;
  26740. private notifyUpdate;
  26741. /**
  26742. * Load the geometry if it was flagged as delay loaded
  26743. * @param scene defines the hosting scene
  26744. * @param onLoaded defines a callback called when the geometry is loaded
  26745. */
  26746. load(scene: Scene, onLoaded?: () => void): void;
  26747. private _queueLoad;
  26748. /**
  26749. * Invert the geometry to move from a right handed system to a left handed one.
  26750. */
  26751. toLeftHanded(): void;
  26752. /** @hidden */
  26753. _resetPointsArrayCache(): void;
  26754. /** @hidden */
  26755. _generatePointsArray(): boolean;
  26756. /**
  26757. * Gets a value indicating if the geometry is disposed
  26758. * @returns true if the geometry was disposed
  26759. */
  26760. isDisposed(): boolean;
  26761. private _disposeVertexArrayObjects;
  26762. /**
  26763. * Free all associated resources
  26764. */
  26765. dispose(): void;
  26766. /**
  26767. * Clone the current geometry into a new geometry
  26768. * @param id defines the unique ID of the new geometry
  26769. * @returns a new geometry object
  26770. */
  26771. copy(id: string): Geometry;
  26772. /**
  26773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26774. * @return a JSON representation of the current geometry data (without the vertices data)
  26775. */
  26776. serialize(): any;
  26777. private toNumberArray;
  26778. /**
  26779. * Serialize all vertices data into a JSON oject
  26780. * @returns a JSON representation of the current geometry data
  26781. */
  26782. serializeVerticeData(): any;
  26783. /**
  26784. * Extracts a clone of a mesh geometry
  26785. * @param mesh defines the source mesh
  26786. * @param id defines the unique ID of the new geometry object
  26787. * @returns the new geometry object
  26788. */
  26789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26790. /**
  26791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26793. * Be aware Math.random() could cause collisions, but:
  26794. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  26795. * @returns a string containing a new GUID
  26796. */
  26797. static RandomId(): string;
  26798. /** @hidden */
  26799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26800. private static _CleanMatricesWeights;
  26801. /**
  26802. * Create a new geometry from persisted data (Using .babylon file format)
  26803. * @param parsedVertexData defines the persisted data
  26804. * @param scene defines the hosting scene
  26805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26806. * @returns the new geometry object
  26807. */
  26808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26809. }
  26810. }
  26811. declare module "babylonjs/Meshes/mesh.vertexData" {
  26812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26813. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26814. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26815. import { Geometry } from "babylonjs/Meshes/geometry";
  26816. import { Mesh } from "babylonjs/Meshes/mesh";
  26817. /**
  26818. * Define an interface for all classes that will get and set the data on vertices
  26819. */
  26820. export interface IGetSetVerticesData {
  26821. /**
  26822. * Gets a boolean indicating if specific vertex data is present
  26823. * @param kind defines the vertex data kind to use
  26824. * @returns true is data kind is present
  26825. */
  26826. isVerticesDataPresent(kind: string): boolean;
  26827. /**
  26828. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26829. * @param kind defines the data kind (Position, normal, etc...)
  26830. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26832. * @returns a float array containing vertex data
  26833. */
  26834. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26835. /**
  26836. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26837. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  26838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26839. * @returns the indices array or an empty array if the mesh has no geometry
  26840. */
  26841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26842. /**
  26843. * Set specific vertex data
  26844. * @param kind defines the data kind (Position, normal, etc...)
  26845. * @param data defines the vertex data to use
  26846. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26847. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26848. */
  26849. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26850. /**
  26851. * Update a specific associated vertex buffer
  26852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26853. * - VertexBuffer.PositionKind
  26854. * - VertexBuffer.UVKind
  26855. * - VertexBuffer.UV2Kind
  26856. * - VertexBuffer.UV3Kind
  26857. * - VertexBuffer.UV4Kind
  26858. * - VertexBuffer.UV5Kind
  26859. * - VertexBuffer.UV6Kind
  26860. * - VertexBuffer.ColorKind
  26861. * - VertexBuffer.MatricesIndicesKind
  26862. * - VertexBuffer.MatricesIndicesExtraKind
  26863. * - VertexBuffer.MatricesWeightsKind
  26864. * - VertexBuffer.MatricesWeightsExtraKind
  26865. * @param data defines the data source
  26866. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26867. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  26868. */
  26869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26870. /**
  26871. * Creates a new index buffer
  26872. * @param indices defines the indices to store in the index buffer
  26873. * @param totalVertices defines the total number of vertices (could be null)
  26874. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26875. */
  26876. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26877. }
  26878. /**
  26879. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26880. */
  26881. export class VertexData {
  26882. /**
  26883. * Mesh side orientation : usually the external or front surface
  26884. */
  26885. static readonly FRONTSIDE: number;
  26886. /**
  26887. * Mesh side orientation : usually the internal or back surface
  26888. */
  26889. static readonly BACKSIDE: number;
  26890. /**
  26891. * Mesh side orientation : both internal and external or front and back surfaces
  26892. */
  26893. static readonly DOUBLESIDE: number;
  26894. /**
  26895. * Mesh side orientation : by default, `FRONTSIDE`
  26896. */
  26897. static readonly DEFAULTSIDE: number;
  26898. /**
  26899. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26900. */
  26901. positions: Nullable<FloatArray>;
  26902. /**
  26903. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26904. */
  26905. normals: Nullable<FloatArray>;
  26906. /**
  26907. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26908. */
  26909. tangents: Nullable<FloatArray>;
  26910. /**
  26911. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26912. */
  26913. uvs: Nullable<FloatArray>;
  26914. /**
  26915. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26916. */
  26917. uvs2: Nullable<FloatArray>;
  26918. /**
  26919. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26920. */
  26921. uvs3: Nullable<FloatArray>;
  26922. /**
  26923. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26924. */
  26925. uvs4: Nullable<FloatArray>;
  26926. /**
  26927. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26928. */
  26929. uvs5: Nullable<FloatArray>;
  26930. /**
  26931. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26932. */
  26933. uvs6: Nullable<FloatArray>;
  26934. /**
  26935. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26936. */
  26937. colors: Nullable<FloatArray>;
  26938. /**
  26939. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  26940. */
  26941. matricesIndices: Nullable<FloatArray>;
  26942. /**
  26943. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26944. */
  26945. matricesWeights: Nullable<FloatArray>;
  26946. /**
  26947. * An array extending the number of possible indices
  26948. */
  26949. matricesIndicesExtra: Nullable<FloatArray>;
  26950. /**
  26951. * An array extending the number of possible weights when the number of indices is extended
  26952. */
  26953. matricesWeightsExtra: Nullable<FloatArray>;
  26954. /**
  26955. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26956. */
  26957. indices: Nullable<IndicesArray>;
  26958. /**
  26959. * Uses the passed data array to set the set the values for the specified kind of data
  26960. * @param data a linear array of floating numbers
  26961. * @param kind the type of data that is being set, eg positions, colors etc
  26962. */
  26963. set(data: FloatArray, kind: string): void;
  26964. /**
  26965. * Associates the vertexData to the passed Mesh.
  26966. * Sets it as updatable or not (default `false`)
  26967. * @param mesh the mesh the vertexData is applied to
  26968. * @param updatable when used and having the value true allows new data to update the vertexData
  26969. * @returns the VertexData
  26970. */
  26971. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26972. /**
  26973. * Associates the vertexData to the passed Geometry.
  26974. * Sets it as updatable or not (default `false`)
  26975. * @param geometry the geometry the vertexData is applied to
  26976. * @param updatable when used and having the value true allows new data to update the vertexData
  26977. * @returns VertexData
  26978. */
  26979. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26980. /**
  26981. * Updates the associated mesh
  26982. * @param mesh the mesh to be updated
  26983. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26984. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  26985. * @returns VertexData
  26986. */
  26987. updateMesh(mesh: Mesh): VertexData;
  26988. /**
  26989. * Updates the associated geometry
  26990. * @param geometry the geometry to be updated
  26991. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26992. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  26993. * @returns VertexData.
  26994. */
  26995. updateGeometry(geometry: Geometry): VertexData;
  26996. private _applyTo;
  26997. private _update;
  26998. /**
  26999. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27000. * @param matrix the transforming matrix
  27001. * @returns the VertexData
  27002. */
  27003. transform(matrix: Matrix): VertexData;
  27004. /**
  27005. * Merges the passed VertexData into the current one
  27006. * @param other the VertexData to be merged into the current one
  27007. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27008. * @returns the modified VertexData
  27009. */
  27010. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27011. private _mergeElement;
  27012. private _validate;
  27013. /**
  27014. * Serializes the VertexData
  27015. * @returns a serialized object
  27016. */
  27017. serialize(): any;
  27018. /**
  27019. * Extracts the vertexData from a mesh
  27020. * @param mesh the mesh from which to extract the VertexData
  27021. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27022. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27023. * @returns the object VertexData associated to the passed mesh
  27024. */
  27025. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27026. /**
  27027. * Extracts the vertexData from the geometry
  27028. * @param geometry the geometry from which to extract the VertexData
  27029. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27030. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27031. * @returns the object VertexData associated to the passed mesh
  27032. */
  27033. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27034. private static _ExtractFrom;
  27035. /**
  27036. * Creates the VertexData for a Ribbon
  27037. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27038. * * pathArray array of paths, each of which an array of successive Vector3
  27039. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27040. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27041. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  27042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27043. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27044. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27045. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27046. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27047. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27048. * @returns the VertexData of the ribbon
  27049. */
  27050. static CreateRibbon(options: {
  27051. pathArray: Vector3[][];
  27052. closeArray?: boolean;
  27053. closePath?: boolean;
  27054. offset?: number;
  27055. sideOrientation?: number;
  27056. frontUVs?: Vector4;
  27057. backUVs?: Vector4;
  27058. invertUV?: boolean;
  27059. uvs?: Vector2[];
  27060. colors?: Color4[];
  27061. }): VertexData;
  27062. /**
  27063. * Creates the VertexData for a box
  27064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27065. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27066. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27067. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27068. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27069. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27070. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27072. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27073. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27074. * @returns the VertexData of the box
  27075. */
  27076. static CreateBox(options: {
  27077. size?: number;
  27078. width?: number;
  27079. height?: number;
  27080. depth?: number;
  27081. faceUV?: Vector4[];
  27082. faceColors?: Color4[];
  27083. sideOrientation?: number;
  27084. frontUVs?: Vector4;
  27085. backUVs?: Vector4;
  27086. }): VertexData;
  27087. /**
  27088. * Creates the VertexData for a tiled box
  27089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27090. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27091. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27092. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27094. * @returns the VertexData of the box
  27095. */
  27096. static CreateTiledBox(options: {
  27097. pattern?: number;
  27098. width?: number;
  27099. height?: number;
  27100. depth?: number;
  27101. tileSize?: number;
  27102. tileWidth?: number;
  27103. tileHeight?: number;
  27104. alignHorizontal?: number;
  27105. alignVertical?: number;
  27106. faceUV?: Vector4[];
  27107. faceColors?: Color4[];
  27108. sideOrientation?: number;
  27109. }): VertexData;
  27110. /**
  27111. * Creates the VertexData for a tiled plane
  27112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27113. * * pattern a limited pattern arrangement depending on the number
  27114. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27115. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27116. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27118. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27119. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27120. * @returns the VertexData of the tiled plane
  27121. */
  27122. static CreateTiledPlane(options: {
  27123. pattern?: number;
  27124. tileSize?: number;
  27125. tileWidth?: number;
  27126. tileHeight?: number;
  27127. size?: number;
  27128. width?: number;
  27129. height?: number;
  27130. alignHorizontal?: number;
  27131. alignVertical?: number;
  27132. sideOrientation?: number;
  27133. frontUVs?: Vector4;
  27134. backUVs?: Vector4;
  27135. }): VertexData;
  27136. /**
  27137. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27139. * * segments sets the number of horizontal strips optional, default 32
  27140. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27141. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27142. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27143. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27144. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  27145. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  27146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27147. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27148. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27149. * @returns the VertexData of the ellipsoid
  27150. */
  27151. static CreateSphere(options: {
  27152. segments?: number;
  27153. diameter?: number;
  27154. diameterX?: number;
  27155. diameterY?: number;
  27156. diameterZ?: number;
  27157. arc?: number;
  27158. slice?: number;
  27159. sideOrientation?: number;
  27160. frontUVs?: Vector4;
  27161. backUVs?: Vector4;
  27162. }): VertexData;
  27163. /**
  27164. * Creates the VertexData for a cylinder, cone or prism
  27165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27166. * * height sets the height (y direction) of the cylinder, optional, default 2
  27167. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27168. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27169. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27170. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27171. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27172. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  27173. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27174. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27175. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27176. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27178. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27179. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27180. * @returns the VertexData of the cylinder, cone or prism
  27181. */
  27182. static CreateCylinder(options: {
  27183. height?: number;
  27184. diameterTop?: number;
  27185. diameterBottom?: number;
  27186. diameter?: number;
  27187. tessellation?: number;
  27188. subdivisions?: number;
  27189. arc?: number;
  27190. faceColors?: Color4[];
  27191. faceUV?: Vector4[];
  27192. hasRings?: boolean;
  27193. enclose?: boolean;
  27194. sideOrientation?: number;
  27195. frontUVs?: Vector4;
  27196. backUVs?: Vector4;
  27197. }): VertexData;
  27198. /**
  27199. * Creates the VertexData for a torus
  27200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27201. * * diameter the diameter of the torus, optional default 1
  27202. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27205. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27206. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27207. * @returns the VertexData of the torus
  27208. */
  27209. static CreateTorus(options: {
  27210. diameter?: number;
  27211. thickness?: number;
  27212. tessellation?: number;
  27213. sideOrientation?: number;
  27214. frontUVs?: Vector4;
  27215. backUVs?: Vector4;
  27216. }): VertexData;
  27217. /**
  27218. * Creates the VertexData of the LineSystem
  27219. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27220. * - lines an array of lines, each line being an array of successive Vector3
  27221. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27222. * @returns the VertexData of the LineSystem
  27223. */
  27224. static CreateLineSystem(options: {
  27225. lines: Vector3[][];
  27226. colors?: Nullable<Color4[][]>;
  27227. }): VertexData;
  27228. /**
  27229. * Create the VertexData for a DashedLines
  27230. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27231. * - points an array successive Vector3
  27232. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27233. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27234. * - dashNb the intended total number of dashes, optional, default 200
  27235. * @returns the VertexData for the DashedLines
  27236. */
  27237. static CreateDashedLines(options: {
  27238. points: Vector3[];
  27239. dashSize?: number;
  27240. gapSize?: number;
  27241. dashNb?: number;
  27242. }): VertexData;
  27243. /**
  27244. * Creates the VertexData for a Ground
  27245. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27246. * - width the width (x direction) of the ground, optional, default 1
  27247. * - height the height (z direction) of the ground, optional, default 1
  27248. * - subdivisions the number of subdivisions per side, optional, default 1
  27249. * @returns the VertexData of the Ground
  27250. */
  27251. static CreateGround(options: {
  27252. width?: number;
  27253. height?: number;
  27254. subdivisions?: number;
  27255. subdivisionsX?: number;
  27256. subdivisionsY?: number;
  27257. }): VertexData;
  27258. /**
  27259. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27260. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27261. * * xmin the ground minimum X coordinate, optional, default -1
  27262. * * zmin the ground minimum Z coordinate, optional, default -1
  27263. * * xmax the ground maximum X coordinate, optional, default 1
  27264. * * zmax the ground maximum Z coordinate, optional, default 1
  27265. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  27266. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  27267. * @returns the VertexData of the TiledGround
  27268. */
  27269. static CreateTiledGround(options: {
  27270. xmin: number;
  27271. zmin: number;
  27272. xmax: number;
  27273. zmax: number;
  27274. subdivisions?: {
  27275. w: number;
  27276. h: number;
  27277. };
  27278. precision?: {
  27279. w: number;
  27280. h: number;
  27281. };
  27282. }): VertexData;
  27283. /**
  27284. * Creates the VertexData of the Ground designed from a heightmap
  27285. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27286. * * width the width (x direction) of the ground
  27287. * * height the height (z direction) of the ground
  27288. * * subdivisions the number of subdivisions per side
  27289. * * minHeight the minimum altitude on the ground, optional, default 0
  27290. * * maxHeight the maximum altitude on the ground, optional default 1
  27291. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27292. * * buffer the array holding the image color data
  27293. * * bufferWidth the width of image
  27294. * * bufferHeight the height of image
  27295. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27296. * @returns the VertexData of the Ground designed from a heightmap
  27297. */
  27298. static CreateGroundFromHeightMap(options: {
  27299. width: number;
  27300. height: number;
  27301. subdivisions: number;
  27302. minHeight: number;
  27303. maxHeight: number;
  27304. colorFilter: Color3;
  27305. buffer: Uint8Array;
  27306. bufferWidth: number;
  27307. bufferHeight: number;
  27308. alphaFilter: number;
  27309. }): VertexData;
  27310. /**
  27311. * Creates the VertexData for a Plane
  27312. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27313. * * size sets the width and height of the plane to the value of size, optional default 1
  27314. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27315. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27317. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27318. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27319. * @returns the VertexData of the box
  27320. */
  27321. static CreatePlane(options: {
  27322. size?: number;
  27323. width?: number;
  27324. height?: number;
  27325. sideOrientation?: number;
  27326. frontUVs?: Vector4;
  27327. backUVs?: Vector4;
  27328. }): VertexData;
  27329. /**
  27330. * Creates the VertexData of the Disc or regular Polygon
  27331. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27332. * * radius the radius of the disc, optional default 0.5
  27333. * * tessellation the number of polygon sides, optional, default 64
  27334. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  27335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27336. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27337. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27338. * @returns the VertexData of the box
  27339. */
  27340. static CreateDisc(options: {
  27341. radius?: number;
  27342. tessellation?: number;
  27343. arc?: number;
  27344. sideOrientation?: number;
  27345. frontUVs?: Vector4;
  27346. backUVs?: Vector4;
  27347. }): VertexData;
  27348. /**
  27349. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27350. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27351. * @param polygon a mesh built from polygonTriangulation.build()
  27352. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27353. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27354. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27355. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27356. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27357. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27358. * @returns the VertexData of the Polygon
  27359. */
  27360. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27361. /**
  27362. * Creates the VertexData of the IcoSphere
  27363. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27364. * * radius the radius of the IcoSphere, optional default 1
  27365. * * radiusX allows stretching in the x direction, optional, default radius
  27366. * * radiusY allows stretching in the y direction, optional, default radius
  27367. * * radiusZ allows stretching in the z direction, optional, default radius
  27368. * * flat when true creates a flat shaded mesh, optional, default true
  27369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27371. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27372. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27373. * @returns the VertexData of the IcoSphere
  27374. */
  27375. static CreateIcoSphere(options: {
  27376. radius?: number;
  27377. radiusX?: number;
  27378. radiusY?: number;
  27379. radiusZ?: number;
  27380. flat?: boolean;
  27381. subdivisions?: number;
  27382. sideOrientation?: number;
  27383. frontUVs?: Vector4;
  27384. backUVs?: Vector4;
  27385. }): VertexData;
  27386. /**
  27387. * Creates the VertexData for a Polyhedron
  27388. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27389. * * type provided types are:
  27390. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27391. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  27392. * * size the size of the IcoSphere, optional default 1
  27393. * * sizeX allows stretching in the x direction, optional, default size
  27394. * * sizeY allows stretching in the y direction, optional, default size
  27395. * * sizeZ allows stretching in the z direction, optional, default size
  27396. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  27397. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27398. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27399. * * flat when true creates a flat shaded mesh, optional, default true
  27400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27402. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27403. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27404. * @returns the VertexData of the Polyhedron
  27405. */
  27406. static CreatePolyhedron(options: {
  27407. type?: number;
  27408. size?: number;
  27409. sizeX?: number;
  27410. sizeY?: number;
  27411. sizeZ?: number;
  27412. custom?: any;
  27413. faceUV?: Vector4[];
  27414. faceColors?: Color4[];
  27415. flat?: boolean;
  27416. sideOrientation?: number;
  27417. frontUVs?: Vector4;
  27418. backUVs?: Vector4;
  27419. }): VertexData;
  27420. /**
  27421. * Creates the VertexData for a TorusKnot
  27422. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27423. * * radius the radius of the torus knot, optional, default 2
  27424. * * tube the thickness of the tube, optional, default 0.5
  27425. * * radialSegments the number of sides on each tube segments, optional, default 32
  27426. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27427. * * p the number of windings around the z axis, optional, default 2
  27428. * * q the number of windings around the x axis, optional, default 3
  27429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27430. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27431. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27432. * @returns the VertexData of the Torus Knot
  27433. */
  27434. static CreateTorusKnot(options: {
  27435. radius?: number;
  27436. tube?: number;
  27437. radialSegments?: number;
  27438. tubularSegments?: number;
  27439. p?: number;
  27440. q?: number;
  27441. sideOrientation?: number;
  27442. frontUVs?: Vector4;
  27443. backUVs?: Vector4;
  27444. }): VertexData;
  27445. /**
  27446. * Compute normals for given positions and indices
  27447. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27448. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27449. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27450. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27451. * * facetNormals : optional array of facet normals (vector3)
  27452. * * facetPositions : optional array of facet positions (vector3)
  27453. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27454. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27455. * * bInfo : optional bounding info, required for facetPartitioning computation
  27456. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27457. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27458. * * useRightHandedSystem: optional boolean to for right handed system computation
  27459. * * depthSort : optional boolean to enable the facet depth sort computation
  27460. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27461. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27462. */
  27463. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27464. facetNormals?: any;
  27465. facetPositions?: any;
  27466. facetPartitioning?: any;
  27467. ratio?: number;
  27468. bInfo?: any;
  27469. bbSize?: Vector3;
  27470. subDiv?: any;
  27471. useRightHandedSystem?: boolean;
  27472. depthSort?: boolean;
  27473. distanceTo?: Vector3;
  27474. depthSortedFacets?: any;
  27475. }): void;
  27476. /** @hidden */
  27477. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27478. /**
  27479. * Applies VertexData created from the imported parameters to the geometry
  27480. * @param parsedVertexData the parsed data from an imported file
  27481. * @param geometry the geometry to apply the VertexData to
  27482. */
  27483. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27484. }
  27485. }
  27486. declare module "babylonjs/Morph/morphTarget" {
  27487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27488. import { Observable } from "babylonjs/Misc/observable";
  27489. import { Nullable, FloatArray } from "babylonjs/types";
  27490. import { Scene } from "babylonjs/scene";
  27491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27493. /**
  27494. * Defines a target to use with MorphTargetManager
  27495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27496. */
  27497. export class MorphTarget implements IAnimatable {
  27498. /** defines the name of the target */
  27499. name: string;
  27500. /**
  27501. * Gets or sets the list of animations
  27502. */
  27503. animations: import("babylonjs/Animations/animation").Animation[];
  27504. private _scene;
  27505. private _positions;
  27506. private _normals;
  27507. private _tangents;
  27508. private _uvs;
  27509. private _influence;
  27510. private _uniqueId;
  27511. /**
  27512. * Observable raised when the influence changes
  27513. */
  27514. onInfluenceChanged: Observable<boolean>;
  27515. /** @hidden */
  27516. _onDataLayoutChanged: Observable<void>;
  27517. /**
  27518. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27519. */
  27520. get influence(): number;
  27521. set influence(influence: number);
  27522. /**
  27523. * Gets or sets the id of the morph Target
  27524. */
  27525. id: string;
  27526. private _animationPropertiesOverride;
  27527. /**
  27528. * Gets or sets the animation properties override
  27529. */
  27530. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27531. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27532. /**
  27533. * Creates a new MorphTarget
  27534. * @param name defines the name of the target
  27535. * @param influence defines the influence to use
  27536. * @param scene defines the scene the morphtarget belongs to
  27537. */
  27538. constructor(
  27539. /** defines the name of the target */
  27540. name: string, influence?: number, scene?: Nullable<Scene>);
  27541. /**
  27542. * Gets the unique ID of this manager
  27543. */
  27544. get uniqueId(): number;
  27545. /**
  27546. * Gets a boolean defining if the target contains position data
  27547. */
  27548. get hasPositions(): boolean;
  27549. /**
  27550. * Gets a boolean defining if the target contains normal data
  27551. */
  27552. get hasNormals(): boolean;
  27553. /**
  27554. * Gets a boolean defining if the target contains tangent data
  27555. */
  27556. get hasTangents(): boolean;
  27557. /**
  27558. * Gets a boolean defining if the target contains texture coordinates data
  27559. */
  27560. get hasUVs(): boolean;
  27561. /**
  27562. * Affects position data to this target
  27563. * @param data defines the position data to use
  27564. */
  27565. setPositions(data: Nullable<FloatArray>): void;
  27566. /**
  27567. * Gets the position data stored in this target
  27568. * @returns a FloatArray containing the position data (or null if not present)
  27569. */
  27570. getPositions(): Nullable<FloatArray>;
  27571. /**
  27572. * Affects normal data to this target
  27573. * @param data defines the normal data to use
  27574. */
  27575. setNormals(data: Nullable<FloatArray>): void;
  27576. /**
  27577. * Gets the normal data stored in this target
  27578. * @returns a FloatArray containing the normal data (or null if not present)
  27579. */
  27580. getNormals(): Nullable<FloatArray>;
  27581. /**
  27582. * Affects tangent data to this target
  27583. * @param data defines the tangent data to use
  27584. */
  27585. setTangents(data: Nullable<FloatArray>): void;
  27586. /**
  27587. * Gets the tangent data stored in this target
  27588. * @returns a FloatArray containing the tangent data (or null if not present)
  27589. */
  27590. getTangents(): Nullable<FloatArray>;
  27591. /**
  27592. * Affects texture coordinates data to this target
  27593. * @param data defines the texture coordinates data to use
  27594. */
  27595. setUVs(data: Nullable<FloatArray>): void;
  27596. /**
  27597. * Gets the texture coordinates data stored in this target
  27598. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27599. */
  27600. getUVs(): Nullable<FloatArray>;
  27601. /**
  27602. * Clone the current target
  27603. * @returns a new MorphTarget
  27604. */
  27605. clone(): MorphTarget;
  27606. /**
  27607. * Serializes the current target into a Serialization object
  27608. * @returns the serialized object
  27609. */
  27610. serialize(): any;
  27611. /**
  27612. * Returns the string "MorphTarget"
  27613. * @returns "MorphTarget"
  27614. */
  27615. getClassName(): string;
  27616. /**
  27617. * Creates a new target from serialized data
  27618. * @param serializationObject defines the serialized data to use
  27619. * @returns a new MorphTarget
  27620. */
  27621. static Parse(serializationObject: any): MorphTarget;
  27622. /**
  27623. * Creates a MorphTarget from mesh data
  27624. * @param mesh defines the source mesh
  27625. * @param name defines the name to use for the new target
  27626. * @param influence defines the influence to attach to the target
  27627. * @returns a new MorphTarget
  27628. */
  27629. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27630. }
  27631. }
  27632. declare module "babylonjs/Morph/morphTargetManager" {
  27633. import { Nullable } from "babylonjs/types";
  27634. import { Scene } from "babylonjs/scene";
  27635. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27636. /**
  27637. * This class is used to deform meshes using morphing between different targets
  27638. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27639. */
  27640. export class MorphTargetManager {
  27641. private _targets;
  27642. private _targetInfluenceChangedObservers;
  27643. private _targetDataLayoutChangedObservers;
  27644. private _activeTargets;
  27645. private _scene;
  27646. private _influences;
  27647. private _supportsNormals;
  27648. private _supportsTangents;
  27649. private _supportsUVs;
  27650. private _vertexCount;
  27651. private _uniqueId;
  27652. private _tempInfluences;
  27653. /**
  27654. * Gets or sets a boolean indicating if normals must be morphed
  27655. */
  27656. enableNormalMorphing: boolean;
  27657. /**
  27658. * Gets or sets a boolean indicating if tangents must be morphed
  27659. */
  27660. enableTangentMorphing: boolean;
  27661. /**
  27662. * Gets or sets a boolean indicating if UV must be morphed
  27663. */
  27664. enableUVMorphing: boolean;
  27665. /**
  27666. * Creates a new MorphTargetManager
  27667. * @param scene defines the current scene
  27668. */
  27669. constructor(scene?: Nullable<Scene>);
  27670. /**
  27671. * Gets the unique ID of this manager
  27672. */
  27673. get uniqueId(): number;
  27674. /**
  27675. * Gets the number of vertices handled by this manager
  27676. */
  27677. get vertexCount(): number;
  27678. /**
  27679. * Gets a boolean indicating if this manager supports morphing of normals
  27680. */
  27681. get supportsNormals(): boolean;
  27682. /**
  27683. * Gets a boolean indicating if this manager supports morphing of tangents
  27684. */
  27685. get supportsTangents(): boolean;
  27686. /**
  27687. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27688. */
  27689. get supportsUVs(): boolean;
  27690. /**
  27691. * Gets the number of targets stored in this manager
  27692. */
  27693. get numTargets(): number;
  27694. /**
  27695. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27696. */
  27697. get numInfluencers(): number;
  27698. /**
  27699. * Gets the list of influences (one per target)
  27700. */
  27701. get influences(): Float32Array;
  27702. /**
  27703. * Gets the active target at specified index. An active target is a target with an influence > 0
  27704. * @param index defines the index to check
  27705. * @returns the requested target
  27706. */
  27707. getActiveTarget(index: number): MorphTarget;
  27708. /**
  27709. * Gets the target at specified index
  27710. * @param index defines the index to check
  27711. * @returns the requested target
  27712. */
  27713. getTarget(index: number): MorphTarget;
  27714. /**
  27715. * Add a new target to this manager
  27716. * @param target defines the target to add
  27717. */
  27718. addTarget(target: MorphTarget): void;
  27719. /**
  27720. * Removes a target from the manager
  27721. * @param target defines the target to remove
  27722. */
  27723. removeTarget(target: MorphTarget): void;
  27724. /**
  27725. * Clone the current manager
  27726. * @returns a new MorphTargetManager
  27727. */
  27728. clone(): MorphTargetManager;
  27729. /**
  27730. * Serializes the current manager into a Serialization object
  27731. * @returns the serialized object
  27732. */
  27733. serialize(): any;
  27734. private _syncActiveTargets;
  27735. /**
  27736. * Syncrhonize the targets with all the meshes using this morph target manager
  27737. */
  27738. synchronize(): void;
  27739. /**
  27740. * Creates a new MorphTargetManager from serialized data
  27741. * @param serializationObject defines the serialized data
  27742. * @param scene defines the hosting scene
  27743. * @returns the new MorphTargetManager
  27744. */
  27745. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27746. }
  27747. }
  27748. declare module "babylonjs/Meshes/meshLODLevel" {
  27749. import { Mesh } from "babylonjs/Meshes/mesh";
  27750. import { Nullable } from "babylonjs/types";
  27751. /**
  27752. * Class used to represent a specific level of detail of a mesh
  27753. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27754. */
  27755. export class MeshLODLevel {
  27756. /** Defines the distance where this level should start being displayed */
  27757. distance: number;
  27758. /** Defines the mesh to use to render this level */
  27759. mesh: Nullable<Mesh>;
  27760. /**
  27761. * Creates a new LOD level
  27762. * @param distance defines the distance where this level should star being displayed
  27763. * @param mesh defines the mesh to use to render this level
  27764. */
  27765. constructor(
  27766. /** Defines the distance where this level should start being displayed */
  27767. distance: number,
  27768. /** Defines the mesh to use to render this level */
  27769. mesh: Nullable<Mesh>);
  27770. }
  27771. }
  27772. declare module "babylonjs/Misc/canvasGenerator" {
  27773. /**
  27774. * Helper class used to generate a canvas to manipulate images
  27775. */
  27776. export class CanvasGenerator {
  27777. /**
  27778. * Create a new canvas (or offscreen canvas depending on the context)
  27779. * @param width defines the expected width
  27780. * @param height defines the expected height
  27781. * @return a new canvas or offscreen canvas
  27782. */
  27783. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27784. }
  27785. }
  27786. declare module "babylonjs/Meshes/groundMesh" {
  27787. import { Scene } from "babylonjs/scene";
  27788. import { Vector3 } from "babylonjs/Maths/math.vector";
  27789. import { Mesh } from "babylonjs/Meshes/mesh";
  27790. /**
  27791. * Mesh representing the gorund
  27792. */
  27793. export class GroundMesh extends Mesh {
  27794. /** If octree should be generated */
  27795. generateOctree: boolean;
  27796. private _heightQuads;
  27797. /** @hidden */
  27798. _subdivisionsX: number;
  27799. /** @hidden */
  27800. _subdivisionsY: number;
  27801. /** @hidden */
  27802. _width: number;
  27803. /** @hidden */
  27804. _height: number;
  27805. /** @hidden */
  27806. _minX: number;
  27807. /** @hidden */
  27808. _maxX: number;
  27809. /** @hidden */
  27810. _minZ: number;
  27811. /** @hidden */
  27812. _maxZ: number;
  27813. constructor(name: string, scene: Scene);
  27814. /**
  27815. * "GroundMesh"
  27816. * @returns "GroundMesh"
  27817. */
  27818. getClassName(): string;
  27819. /**
  27820. * The minimum of x and y subdivisions
  27821. */
  27822. get subdivisions(): number;
  27823. /**
  27824. * X subdivisions
  27825. */
  27826. get subdivisionsX(): number;
  27827. /**
  27828. * Y subdivisions
  27829. */
  27830. get subdivisionsY(): number;
  27831. /**
  27832. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27834. * @param chunksCount the number of subdivisions for x and y
  27835. * @param octreeBlocksSize (Default: 32)
  27836. */
  27837. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27838. /**
  27839. * Returns a height (y) value in the Worl system :
  27840. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27841. * @param x x coordinate
  27842. * @param z z coordinate
  27843. * @returns the ground y position if (x, z) are outside the ground surface.
  27844. */
  27845. getHeightAtCoordinates(x: number, z: number): number;
  27846. /**
  27847. * Returns a normalized vector (Vector3) orthogonal to the ground
  27848. * at the ground coordinates (x, z) expressed in the World system.
  27849. * @param x x coordinate
  27850. * @param z z coordinate
  27851. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27852. */
  27853. getNormalAtCoordinates(x: number, z: number): Vector3;
  27854. /**
  27855. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27856. * at the ground coordinates (x, z) expressed in the World system.
  27857. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27858. * @param x x coordinate
  27859. * @param z z coordinate
  27860. * @param ref vector to store the result
  27861. * @returns the GroundMesh.
  27862. */
  27863. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27864. /**
  27865. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27866. * if the ground has been updated.
  27867. * This can be used in the render loop.
  27868. * @returns the GroundMesh.
  27869. */
  27870. updateCoordinateHeights(): GroundMesh;
  27871. private _getFacetAt;
  27872. private _initHeightQuads;
  27873. private _computeHeightQuads;
  27874. /**
  27875. * Serializes this ground mesh
  27876. * @param serializationObject object to write serialization to
  27877. */
  27878. serialize(serializationObject: any): void;
  27879. /**
  27880. * Parses a serialized ground mesh
  27881. * @param parsedMesh the serialized mesh
  27882. * @param scene the scene to create the ground mesh in
  27883. * @returns the created ground mesh
  27884. */
  27885. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27886. }
  27887. }
  27888. declare module "babylonjs/Physics/physicsJoint" {
  27889. import { Vector3 } from "babylonjs/Maths/math.vector";
  27890. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27891. /**
  27892. * Interface for Physics-Joint data
  27893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27894. */
  27895. export interface PhysicsJointData {
  27896. /**
  27897. * The main pivot of the joint
  27898. */
  27899. mainPivot?: Vector3;
  27900. /**
  27901. * The connected pivot of the joint
  27902. */
  27903. connectedPivot?: Vector3;
  27904. /**
  27905. * The main axis of the joint
  27906. */
  27907. mainAxis?: Vector3;
  27908. /**
  27909. * The connected axis of the joint
  27910. */
  27911. connectedAxis?: Vector3;
  27912. /**
  27913. * The collision of the joint
  27914. */
  27915. collision?: boolean;
  27916. /**
  27917. * Native Oimo/Cannon/Energy data
  27918. */
  27919. nativeParams?: any;
  27920. }
  27921. /**
  27922. * This is a holder class for the physics joint created by the physics plugin
  27923. * It holds a set of functions to control the underlying joint
  27924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27925. */
  27926. export class PhysicsJoint {
  27927. /**
  27928. * The type of the physics joint
  27929. */
  27930. type: number;
  27931. /**
  27932. * The data for the physics joint
  27933. */
  27934. jointData: PhysicsJointData;
  27935. private _physicsJoint;
  27936. protected _physicsPlugin: IPhysicsEnginePlugin;
  27937. /**
  27938. * Initializes the physics joint
  27939. * @param type The type of the physics joint
  27940. * @param jointData The data for the physics joint
  27941. */
  27942. constructor(
  27943. /**
  27944. * The type of the physics joint
  27945. */
  27946. type: number,
  27947. /**
  27948. * The data for the physics joint
  27949. */
  27950. jointData: PhysicsJointData);
  27951. /**
  27952. * Gets the physics joint
  27953. */
  27954. get physicsJoint(): any;
  27955. /**
  27956. * Sets the physics joint
  27957. */
  27958. set physicsJoint(newJoint: any);
  27959. /**
  27960. * Sets the physics plugin
  27961. */
  27962. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27963. /**
  27964. * Execute a function that is physics-plugin specific.
  27965. * @param {Function} func the function that will be executed.
  27966. * It accepts two parameters: the physics world and the physics joint
  27967. */
  27968. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27969. /**
  27970. * Distance-Joint type
  27971. */
  27972. static DistanceJoint: number;
  27973. /**
  27974. * Hinge-Joint type
  27975. */
  27976. static HingeJoint: number;
  27977. /**
  27978. * Ball-and-Socket joint type
  27979. */
  27980. static BallAndSocketJoint: number;
  27981. /**
  27982. * Wheel-Joint type
  27983. */
  27984. static WheelJoint: number;
  27985. /**
  27986. * Slider-Joint type
  27987. */
  27988. static SliderJoint: number;
  27989. /**
  27990. * Prismatic-Joint type
  27991. */
  27992. static PrismaticJoint: number;
  27993. /**
  27994. * Universal-Joint type
  27995. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27996. */
  27997. static UniversalJoint: number;
  27998. /**
  27999. * Hinge-Joint 2 type
  28000. */
  28001. static Hinge2Joint: number;
  28002. /**
  28003. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28004. */
  28005. static PointToPointJoint: number;
  28006. /**
  28007. * Spring-Joint type
  28008. */
  28009. static SpringJoint: number;
  28010. /**
  28011. * Lock-Joint type
  28012. */
  28013. static LockJoint: number;
  28014. }
  28015. /**
  28016. * A class representing a physics distance joint
  28017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28018. */
  28019. export class DistanceJoint extends PhysicsJoint {
  28020. /**
  28021. *
  28022. * @param jointData The data for the Distance-Joint
  28023. */
  28024. constructor(jointData: DistanceJointData);
  28025. /**
  28026. * Update the predefined distance.
  28027. * @param maxDistance The maximum preferred distance
  28028. * @param minDistance The minimum preferred distance
  28029. */
  28030. updateDistance(maxDistance: number, minDistance?: number): void;
  28031. }
  28032. /**
  28033. * Represents a Motor-Enabled Joint
  28034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28035. */
  28036. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28037. /**
  28038. * Initializes the Motor-Enabled Joint
  28039. * @param type The type of the joint
  28040. * @param jointData The physica joint data for the joint
  28041. */
  28042. constructor(type: number, jointData: PhysicsJointData);
  28043. /**
  28044. * Set the motor values.
  28045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28046. * @param force the force to apply
  28047. * @param maxForce max force for this motor.
  28048. */
  28049. setMotor(force?: number, maxForce?: number): void;
  28050. /**
  28051. * Set the motor's limits.
  28052. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28053. * @param upperLimit The upper limit of the motor
  28054. * @param lowerLimit The lower limit of the motor
  28055. */
  28056. setLimit(upperLimit: number, lowerLimit?: number): void;
  28057. }
  28058. /**
  28059. * This class represents a single physics Hinge-Joint
  28060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28061. */
  28062. export class HingeJoint extends MotorEnabledJoint {
  28063. /**
  28064. * Initializes the Hinge-Joint
  28065. * @param jointData The joint data for the Hinge-Joint
  28066. */
  28067. constructor(jointData: PhysicsJointData);
  28068. /**
  28069. * Set the motor values.
  28070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28071. * @param {number} force the force to apply
  28072. * @param {number} maxForce max force for this motor.
  28073. */
  28074. setMotor(force?: number, maxForce?: number): void;
  28075. /**
  28076. * Set the motor's limits.
  28077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28078. * @param upperLimit The upper limit of the motor
  28079. * @param lowerLimit The lower limit of the motor
  28080. */
  28081. setLimit(upperLimit: number, lowerLimit?: number): void;
  28082. }
  28083. /**
  28084. * This class represents a dual hinge physics joint (same as wheel joint)
  28085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28086. */
  28087. export class Hinge2Joint extends MotorEnabledJoint {
  28088. /**
  28089. * Initializes the Hinge2-Joint
  28090. * @param jointData The joint data for the Hinge2-Joint
  28091. */
  28092. constructor(jointData: PhysicsJointData);
  28093. /**
  28094. * Set the motor values.
  28095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28096. * @param {number} targetSpeed the speed the motor is to reach
  28097. * @param {number} maxForce max force for this motor.
  28098. * @param {motorIndex} the motor's index, 0 or 1.
  28099. */
  28100. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28101. /**
  28102. * Set the motor limits.
  28103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28104. * @param {number} upperLimit the upper limit
  28105. * @param {number} lowerLimit lower limit
  28106. * @param {motorIndex} the motor's index, 0 or 1.
  28107. */
  28108. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28109. }
  28110. /**
  28111. * Interface for a motor enabled joint
  28112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28113. */
  28114. export interface IMotorEnabledJoint {
  28115. /**
  28116. * Physics joint
  28117. */
  28118. physicsJoint: any;
  28119. /**
  28120. * Sets the motor of the motor-enabled joint
  28121. * @param force The force of the motor
  28122. * @param maxForce The maximum force of the motor
  28123. * @param motorIndex The index of the motor
  28124. */
  28125. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28126. /**
  28127. * Sets the limit of the motor
  28128. * @param upperLimit The upper limit of the motor
  28129. * @param lowerLimit The lower limit of the motor
  28130. * @param motorIndex The index of the motor
  28131. */
  28132. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28133. }
  28134. /**
  28135. * Joint data for a Distance-Joint
  28136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28137. */
  28138. export interface DistanceJointData extends PhysicsJointData {
  28139. /**
  28140. * Max distance the 2 joint objects can be apart
  28141. */
  28142. maxDistance: number;
  28143. }
  28144. /**
  28145. * Joint data from a spring joint
  28146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28147. */
  28148. export interface SpringJointData extends PhysicsJointData {
  28149. /**
  28150. * Length of the spring
  28151. */
  28152. length: number;
  28153. /**
  28154. * Stiffness of the spring
  28155. */
  28156. stiffness: number;
  28157. /**
  28158. * Damping of the spring
  28159. */
  28160. damping: number;
  28161. /** this callback will be called when applying the force to the impostors. */
  28162. forceApplicationCallback: () => void;
  28163. }
  28164. }
  28165. declare module "babylonjs/Physics/physicsRaycastResult" {
  28166. import { Vector3 } from "babylonjs/Maths/math.vector";
  28167. /**
  28168. * Holds the data for the raycast result
  28169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28170. */
  28171. export class PhysicsRaycastResult {
  28172. private _hasHit;
  28173. private _hitDistance;
  28174. private _hitNormalWorld;
  28175. private _hitPointWorld;
  28176. private _rayFromWorld;
  28177. private _rayToWorld;
  28178. /**
  28179. * Gets if there was a hit
  28180. */
  28181. get hasHit(): boolean;
  28182. /**
  28183. * Gets the distance from the hit
  28184. */
  28185. get hitDistance(): number;
  28186. /**
  28187. * Gets the hit normal/direction in the world
  28188. */
  28189. get hitNormalWorld(): Vector3;
  28190. /**
  28191. * Gets the hit point in the world
  28192. */
  28193. get hitPointWorld(): Vector3;
  28194. /**
  28195. * Gets the ray "start point" of the ray in the world
  28196. */
  28197. get rayFromWorld(): Vector3;
  28198. /**
  28199. * Gets the ray "end point" of the ray in the world
  28200. */
  28201. get rayToWorld(): Vector3;
  28202. /**
  28203. * Sets the hit data (normal & point in world space)
  28204. * @param hitNormalWorld defines the normal in world space
  28205. * @param hitPointWorld defines the point in world space
  28206. */
  28207. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28208. /**
  28209. * Sets the distance from the start point to the hit point
  28210. * @param distance
  28211. */
  28212. setHitDistance(distance: number): void;
  28213. /**
  28214. * Calculates the distance manually
  28215. */
  28216. calculateHitDistance(): void;
  28217. /**
  28218. * Resets all the values to default
  28219. * @param from The from point on world space
  28220. * @param to The to point on world space
  28221. */
  28222. reset(from?: Vector3, to?: Vector3): void;
  28223. }
  28224. /**
  28225. * Interface for the size containing width and height
  28226. */
  28227. interface IXYZ {
  28228. /**
  28229. * X
  28230. */
  28231. x: number;
  28232. /**
  28233. * Y
  28234. */
  28235. y: number;
  28236. /**
  28237. * Z
  28238. */
  28239. z: number;
  28240. }
  28241. }
  28242. declare module "babylonjs/Physics/IPhysicsEngine" {
  28243. import { Nullable } from "babylonjs/types";
  28244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28246. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28249. /**
  28250. * Interface used to describe a physics joint
  28251. */
  28252. export interface PhysicsImpostorJoint {
  28253. /** Defines the main impostor to which the joint is linked */
  28254. mainImpostor: PhysicsImpostor;
  28255. /** Defines the impostor that is connected to the main impostor using this joint */
  28256. connectedImpostor: PhysicsImpostor;
  28257. /** Defines the joint itself */
  28258. joint: PhysicsJoint;
  28259. }
  28260. /** @hidden */
  28261. export interface IPhysicsEnginePlugin {
  28262. world: any;
  28263. name: string;
  28264. setGravity(gravity: Vector3): void;
  28265. setTimeStep(timeStep: number): void;
  28266. getTimeStep(): number;
  28267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28271. removePhysicsBody(impostor: PhysicsImpostor): void;
  28272. generateJoint(joint: PhysicsImpostorJoint): void;
  28273. removeJoint(joint: PhysicsImpostorJoint): void;
  28274. isSupported(): boolean;
  28275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28282. getBodyMass(impostor: PhysicsImpostor): number;
  28283. getBodyFriction(impostor: PhysicsImpostor): number;
  28284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28285. getBodyRestitution(impostor: PhysicsImpostor): number;
  28286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28287. getBodyPressure?(impostor: PhysicsImpostor): number;
  28288. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28289. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28290. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28291. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28292. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28293. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28294. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28295. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28296. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28297. sleepBody(impostor: PhysicsImpostor): void;
  28298. wakeUpBody(impostor: PhysicsImpostor): void;
  28299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28301. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28303. getRadius(impostor: PhysicsImpostor): number;
  28304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28306. dispose(): void;
  28307. }
  28308. /**
  28309. * Interface used to define a physics engine
  28310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28311. */
  28312. export interface IPhysicsEngine {
  28313. /**
  28314. * Gets the gravity vector used by the simulation
  28315. */
  28316. gravity: Vector3;
  28317. /**
  28318. * Sets the gravity vector used by the simulation
  28319. * @param gravity defines the gravity vector to use
  28320. */
  28321. setGravity(gravity: Vector3): void;
  28322. /**
  28323. * Set the time step of the physics engine.
  28324. * Default is 1/60.
  28325. * To slow it down, enter 1/600 for example.
  28326. * To speed it up, 1/30
  28327. * @param newTimeStep the new timestep to apply to this world.
  28328. */
  28329. setTimeStep(newTimeStep: number): void;
  28330. /**
  28331. * Get the time step of the physics engine.
  28332. * @returns the current time step
  28333. */
  28334. getTimeStep(): number;
  28335. /**
  28336. * Set the sub time step of the physics engine.
  28337. * Default is 0 meaning there is no sub steps
  28338. * To increase physics resolution precision, set a small value (like 1 ms)
  28339. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28340. */
  28341. setSubTimeStep(subTimeStep: number): void;
  28342. /**
  28343. * Get the sub time step of the physics engine.
  28344. * @returns the current sub time step
  28345. */
  28346. getSubTimeStep(): number;
  28347. /**
  28348. * Release all resources
  28349. */
  28350. dispose(): void;
  28351. /**
  28352. * Gets the name of the current physics plugin
  28353. * @returns the name of the plugin
  28354. */
  28355. getPhysicsPluginName(): string;
  28356. /**
  28357. * Adding a new impostor for the impostor tracking.
  28358. * This will be done by the impostor itself.
  28359. * @param impostor the impostor to add
  28360. */
  28361. addImpostor(impostor: PhysicsImpostor): void;
  28362. /**
  28363. * Remove an impostor from the engine.
  28364. * This impostor and its mesh will not longer be updated by the physics engine.
  28365. * @param impostor the impostor to remove
  28366. */
  28367. removeImpostor(impostor: PhysicsImpostor): void;
  28368. /**
  28369. * Add a joint to the physics engine
  28370. * @param mainImpostor defines the main impostor to which the joint is added.
  28371. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28372. * @param joint defines the joint that will connect both impostors.
  28373. */
  28374. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28375. /**
  28376. * Removes a joint from the simulation
  28377. * @param mainImpostor defines the impostor used with the joint
  28378. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28379. * @param joint defines the joint to remove
  28380. */
  28381. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28382. /**
  28383. * Gets the current plugin used to run the simulation
  28384. * @returns current plugin
  28385. */
  28386. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28387. /**
  28388. * Gets the list of physic impostors
  28389. * @returns an array of PhysicsImpostor
  28390. */
  28391. getImpostors(): Array<PhysicsImpostor>;
  28392. /**
  28393. * Gets the impostor for a physics enabled object
  28394. * @param object defines the object impersonated by the impostor
  28395. * @returns the PhysicsImpostor or null if not found
  28396. */
  28397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28398. /**
  28399. * Gets the impostor for a physics body object
  28400. * @param body defines physics body used by the impostor
  28401. * @returns the PhysicsImpostor or null if not found
  28402. */
  28403. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28404. /**
  28405. * Does a raycast in the physics world
  28406. * @param from when should the ray start?
  28407. * @param to when should the ray end?
  28408. * @returns PhysicsRaycastResult
  28409. */
  28410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28411. /**
  28412. * Called by the scene. No need to call it.
  28413. * @param delta defines the timespam between frames
  28414. */
  28415. _step(delta: number): void;
  28416. }
  28417. }
  28418. declare module "babylonjs/Physics/physicsImpostor" {
  28419. import { Nullable, IndicesArray } from "babylonjs/types";
  28420. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28423. import { Scene } from "babylonjs/scene";
  28424. import { Bone } from "babylonjs/Bones/bone";
  28425. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28426. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28427. import { Space } from "babylonjs/Maths/math.axis";
  28428. /**
  28429. * The interface for the physics imposter parameters
  28430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28431. */
  28432. export interface PhysicsImpostorParameters {
  28433. /**
  28434. * The mass of the physics imposter
  28435. */
  28436. mass: number;
  28437. /**
  28438. * The friction of the physics imposter
  28439. */
  28440. friction?: number;
  28441. /**
  28442. * The coefficient of restitution of the physics imposter
  28443. */
  28444. restitution?: number;
  28445. /**
  28446. * The native options of the physics imposter
  28447. */
  28448. nativeOptions?: any;
  28449. /**
  28450. * Specifies if the parent should be ignored
  28451. */
  28452. ignoreParent?: boolean;
  28453. /**
  28454. * Specifies if bi-directional transformations should be disabled
  28455. */
  28456. disableBidirectionalTransformation?: boolean;
  28457. /**
  28458. * The pressure inside the physics imposter, soft object only
  28459. */
  28460. pressure?: number;
  28461. /**
  28462. * The stiffness the physics imposter, soft object only
  28463. */
  28464. stiffness?: number;
  28465. /**
  28466. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28467. */
  28468. velocityIterations?: number;
  28469. /**
  28470. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28471. */
  28472. positionIterations?: number;
  28473. /**
  28474. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28475. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28476. * Add to fix multiple points
  28477. */
  28478. fixedPoints?: number;
  28479. /**
  28480. * The collision margin around a soft object
  28481. */
  28482. margin?: number;
  28483. /**
  28484. * The collision margin around a soft object
  28485. */
  28486. damping?: number;
  28487. /**
  28488. * The path for a rope based on an extrusion
  28489. */
  28490. path?: any;
  28491. /**
  28492. * The shape of an extrusion used for a rope based on an extrusion
  28493. */
  28494. shape?: any;
  28495. }
  28496. /**
  28497. * Interface for a physics-enabled object
  28498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28499. */
  28500. export interface IPhysicsEnabledObject {
  28501. /**
  28502. * The position of the physics-enabled object
  28503. */
  28504. position: Vector3;
  28505. /**
  28506. * The rotation of the physics-enabled object
  28507. */
  28508. rotationQuaternion: Nullable<Quaternion>;
  28509. /**
  28510. * The scale of the physics-enabled object
  28511. */
  28512. scaling: Vector3;
  28513. /**
  28514. * The rotation of the physics-enabled object
  28515. */
  28516. rotation?: Vector3;
  28517. /**
  28518. * The parent of the physics-enabled object
  28519. */
  28520. parent?: any;
  28521. /**
  28522. * The bounding info of the physics-enabled object
  28523. * @returns The bounding info of the physics-enabled object
  28524. */
  28525. getBoundingInfo(): BoundingInfo;
  28526. /**
  28527. * Computes the world matrix
  28528. * @param force Specifies if the world matrix should be computed by force
  28529. * @returns A world matrix
  28530. */
  28531. computeWorldMatrix(force: boolean): Matrix;
  28532. /**
  28533. * Gets the world matrix
  28534. * @returns A world matrix
  28535. */
  28536. getWorldMatrix?(): Matrix;
  28537. /**
  28538. * Gets the child meshes
  28539. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28540. * @returns An array of abstract meshes
  28541. */
  28542. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28543. /**
  28544. * Gets the vertex data
  28545. * @param kind The type of vertex data
  28546. * @returns A nullable array of numbers, or a float32 array
  28547. */
  28548. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28549. /**
  28550. * Gets the indices from the mesh
  28551. * @returns A nullable array of index arrays
  28552. */
  28553. getIndices?(): Nullable<IndicesArray>;
  28554. /**
  28555. * Gets the scene from the mesh
  28556. * @returns the indices array or null
  28557. */
  28558. getScene?(): Scene;
  28559. /**
  28560. * Gets the absolute position from the mesh
  28561. * @returns the absolute position
  28562. */
  28563. getAbsolutePosition(): Vector3;
  28564. /**
  28565. * Gets the absolute pivot point from the mesh
  28566. * @returns the absolute pivot point
  28567. */
  28568. getAbsolutePivotPoint(): Vector3;
  28569. /**
  28570. * Rotates the mesh
  28571. * @param axis The axis of rotation
  28572. * @param amount The amount of rotation
  28573. * @param space The space of the rotation
  28574. * @returns The rotation transform node
  28575. */
  28576. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28577. /**
  28578. * Translates the mesh
  28579. * @param axis The axis of translation
  28580. * @param distance The distance of translation
  28581. * @param space The space of the translation
  28582. * @returns The transform node
  28583. */
  28584. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28585. /**
  28586. * Sets the absolute position of the mesh
  28587. * @param absolutePosition The absolute position of the mesh
  28588. * @returns The transform node
  28589. */
  28590. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28591. /**
  28592. * Gets the class name of the mesh
  28593. * @returns The class name
  28594. */
  28595. getClassName(): string;
  28596. }
  28597. /**
  28598. * Represents a physics imposter
  28599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28600. */
  28601. export class PhysicsImpostor {
  28602. /**
  28603. * The physics-enabled object used as the physics imposter
  28604. */
  28605. object: IPhysicsEnabledObject;
  28606. /**
  28607. * The type of the physics imposter
  28608. */
  28609. type: number;
  28610. private _options;
  28611. private _scene?;
  28612. /**
  28613. * The default object size of the imposter
  28614. */
  28615. static DEFAULT_OBJECT_SIZE: Vector3;
  28616. /**
  28617. * The identity quaternion of the imposter
  28618. */
  28619. static IDENTITY_QUATERNION: Quaternion;
  28620. /** @hidden */
  28621. _pluginData: any;
  28622. private _physicsEngine;
  28623. private _physicsBody;
  28624. private _bodyUpdateRequired;
  28625. private _onBeforePhysicsStepCallbacks;
  28626. private _onAfterPhysicsStepCallbacks;
  28627. /** @hidden */
  28628. _onPhysicsCollideCallbacks: Array<{
  28629. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28630. otherImpostors: Array<PhysicsImpostor>;
  28631. }>;
  28632. private _deltaPosition;
  28633. private _deltaRotation;
  28634. private _deltaRotationConjugated;
  28635. /** @hidden */
  28636. _isFromLine: boolean;
  28637. private _parent;
  28638. private _isDisposed;
  28639. private static _tmpVecs;
  28640. private static _tmpQuat;
  28641. /**
  28642. * Specifies if the physics imposter is disposed
  28643. */
  28644. get isDisposed(): boolean;
  28645. /**
  28646. * Gets the mass of the physics imposter
  28647. */
  28648. get mass(): number;
  28649. set mass(value: number);
  28650. /**
  28651. * Gets the coefficient of friction
  28652. */
  28653. get friction(): number;
  28654. /**
  28655. * Sets the coefficient of friction
  28656. */
  28657. set friction(value: number);
  28658. /**
  28659. * Gets the coefficient of restitution
  28660. */
  28661. get restitution(): number;
  28662. /**
  28663. * Sets the coefficient of restitution
  28664. */
  28665. set restitution(value: number);
  28666. /**
  28667. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28668. */
  28669. get pressure(): number;
  28670. /**
  28671. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28672. */
  28673. set pressure(value: number);
  28674. /**
  28675. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28676. */
  28677. get stiffness(): number;
  28678. /**
  28679. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28680. */
  28681. set stiffness(value: number);
  28682. /**
  28683. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28684. */
  28685. get velocityIterations(): number;
  28686. /**
  28687. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28688. */
  28689. set velocityIterations(value: number);
  28690. /**
  28691. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28692. */
  28693. get positionIterations(): number;
  28694. /**
  28695. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28696. */
  28697. set positionIterations(value: number);
  28698. /**
  28699. * The unique id of the physics imposter
  28700. * set by the physics engine when adding this impostor to the array
  28701. */
  28702. uniqueId: number;
  28703. /**
  28704. * @hidden
  28705. */
  28706. soft: boolean;
  28707. /**
  28708. * @hidden
  28709. */
  28710. segments: number;
  28711. private _joints;
  28712. /**
  28713. * Initializes the physics imposter
  28714. * @param object The physics-enabled object used as the physics imposter
  28715. * @param type The type of the physics imposter
  28716. * @param _options The options for the physics imposter
  28717. * @param _scene The Babylon scene
  28718. */
  28719. constructor(
  28720. /**
  28721. * The physics-enabled object used as the physics imposter
  28722. */
  28723. object: IPhysicsEnabledObject,
  28724. /**
  28725. * The type of the physics imposter
  28726. */
  28727. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28728. /**
  28729. * This function will completly initialize this impostor.
  28730. * It will create a new body - but only if this mesh has no parent.
  28731. * If it has, this impostor will not be used other than to define the impostor
  28732. * of the child mesh.
  28733. * @hidden
  28734. */
  28735. _init(): void;
  28736. private _getPhysicsParent;
  28737. /**
  28738. * Should a new body be generated.
  28739. * @returns boolean specifying if body initialization is required
  28740. */
  28741. isBodyInitRequired(): boolean;
  28742. /**
  28743. * Sets the updated scaling
  28744. * @param updated Specifies if the scaling is updated
  28745. */
  28746. setScalingUpdated(): void;
  28747. /**
  28748. * Force a regeneration of this or the parent's impostor's body.
  28749. * Use under cautious - This will remove all joints already implemented.
  28750. */
  28751. forceUpdate(): void;
  28752. /**
  28753. * Gets the body that holds this impostor. Either its own, or its parent.
  28754. */
  28755. get physicsBody(): any;
  28756. /**
  28757. * Get the parent of the physics imposter
  28758. * @returns Physics imposter or null
  28759. */
  28760. get parent(): Nullable<PhysicsImpostor>;
  28761. /**
  28762. * Sets the parent of the physics imposter
  28763. */
  28764. set parent(value: Nullable<PhysicsImpostor>);
  28765. /**
  28766. * Set the physics body. Used mainly by the physics engine/plugin
  28767. */
  28768. set physicsBody(physicsBody: any);
  28769. /**
  28770. * Resets the update flags
  28771. */
  28772. resetUpdateFlags(): void;
  28773. /**
  28774. * Gets the object extend size
  28775. * @returns the object extend size
  28776. */
  28777. getObjectExtendSize(): Vector3;
  28778. /**
  28779. * Gets the object center
  28780. * @returns The object center
  28781. */
  28782. getObjectCenter(): Vector3;
  28783. /**
  28784. * Get a specific parameter from the options parameters
  28785. * @param paramName The object parameter name
  28786. * @returns The object parameter
  28787. */
  28788. getParam(paramName: string): any;
  28789. /**
  28790. * Sets a specific parameter in the options given to the physics plugin
  28791. * @param paramName The parameter name
  28792. * @param value The value of the parameter
  28793. */
  28794. setParam(paramName: string, value: number): void;
  28795. /**
  28796. * Specifically change the body's mass option. Won't recreate the physics body object
  28797. * @param mass The mass of the physics imposter
  28798. */
  28799. setMass(mass: number): void;
  28800. /**
  28801. * Gets the linear velocity
  28802. * @returns linear velocity or null
  28803. */
  28804. getLinearVelocity(): Nullable<Vector3>;
  28805. /**
  28806. * Sets the linear velocity
  28807. * @param velocity linear velocity or null
  28808. */
  28809. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28810. /**
  28811. * Gets the angular velocity
  28812. * @returns angular velocity or null
  28813. */
  28814. getAngularVelocity(): Nullable<Vector3>;
  28815. /**
  28816. * Sets the angular velocity
  28817. * @param velocity The velocity or null
  28818. */
  28819. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28820. /**
  28821. * Execute a function with the physics plugin native code
  28822. * Provide a function the will have two variables - the world object and the physics body object
  28823. * @param func The function to execute with the physics plugin native code
  28824. */
  28825. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28826. /**
  28827. * Register a function that will be executed before the physics world is stepping forward
  28828. * @param func The function to execute before the physics world is stepped forward
  28829. */
  28830. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28831. /**
  28832. * Unregister a function that will be executed before the physics world is stepping forward
  28833. * @param func The function to execute before the physics world is stepped forward
  28834. */
  28835. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28836. /**
  28837. * Register a function that will be executed after the physics step
  28838. * @param func The function to execute after physics step
  28839. */
  28840. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28841. /**
  28842. * Unregisters a function that will be executed after the physics step
  28843. * @param func The function to execute after physics step
  28844. */
  28845. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28846. /**
  28847. * register a function that will be executed when this impostor collides against a different body
  28848. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28849. * @param func Callback that is executed on collision
  28850. */
  28851. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28852. /**
  28853. * Unregisters the physics imposter on contact
  28854. * @param collideAgainst The physics object to collide against
  28855. * @param func Callback to execute on collision
  28856. */
  28857. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28858. private _tmpQuat;
  28859. private _tmpQuat2;
  28860. /**
  28861. * Get the parent rotation
  28862. * @returns The parent rotation
  28863. */
  28864. getParentsRotation(): Quaternion;
  28865. /**
  28866. * this function is executed by the physics engine.
  28867. */
  28868. beforeStep: () => void;
  28869. /**
  28870. * this function is executed by the physics engine
  28871. */
  28872. afterStep: () => void;
  28873. /**
  28874. * Legacy collision detection event support
  28875. */
  28876. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28877. /**
  28878. * event and body object due to cannon's event-based architecture.
  28879. */
  28880. onCollide: (e: {
  28881. body: any;
  28882. }) => void;
  28883. /**
  28884. * Apply a force
  28885. * @param force The force to apply
  28886. * @param contactPoint The contact point for the force
  28887. * @returns The physics imposter
  28888. */
  28889. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28890. /**
  28891. * Apply an impulse
  28892. * @param force The impulse force
  28893. * @param contactPoint The contact point for the impulse force
  28894. * @returns The physics imposter
  28895. */
  28896. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28897. /**
  28898. * A help function to create a joint
  28899. * @param otherImpostor A physics imposter used to create a joint
  28900. * @param jointType The type of joint
  28901. * @param jointData The data for the joint
  28902. * @returns The physics imposter
  28903. */
  28904. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28905. /**
  28906. * Add a joint to this impostor with a different impostor
  28907. * @param otherImpostor A physics imposter used to add a joint
  28908. * @param joint The joint to add
  28909. * @returns The physics imposter
  28910. */
  28911. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28912. /**
  28913. * Add an anchor to a cloth impostor
  28914. * @param otherImpostor rigid impostor to anchor to
  28915. * @param width ratio across width from 0 to 1
  28916. * @param height ratio up height from 0 to 1
  28917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28918. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28919. * @returns impostor the soft imposter
  28920. */
  28921. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28922. /**
  28923. * Add a hook to a rope impostor
  28924. * @param otherImpostor rigid impostor to anchor to
  28925. * @param length ratio across rope from 0 to 1
  28926. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28928. * @returns impostor the rope imposter
  28929. */
  28930. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28931. /**
  28932. * Will keep this body still, in a sleep mode.
  28933. * @returns the physics imposter
  28934. */
  28935. sleep(): PhysicsImpostor;
  28936. /**
  28937. * Wake the body up.
  28938. * @returns The physics imposter
  28939. */
  28940. wakeUp(): PhysicsImpostor;
  28941. /**
  28942. * Clones the physics imposter
  28943. * @param newObject The physics imposter clones to this physics-enabled object
  28944. * @returns A nullable physics imposter
  28945. */
  28946. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28947. /**
  28948. * Disposes the physics imposter
  28949. */
  28950. dispose(): void;
  28951. /**
  28952. * Sets the delta position
  28953. * @param position The delta position amount
  28954. */
  28955. setDeltaPosition(position: Vector3): void;
  28956. /**
  28957. * Sets the delta rotation
  28958. * @param rotation The delta rotation amount
  28959. */
  28960. setDeltaRotation(rotation: Quaternion): void;
  28961. /**
  28962. * Gets the box size of the physics imposter and stores the result in the input parameter
  28963. * @param result Stores the box size
  28964. * @returns The physics imposter
  28965. */
  28966. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28967. /**
  28968. * Gets the radius of the physics imposter
  28969. * @returns Radius of the physics imposter
  28970. */
  28971. getRadius(): number;
  28972. /**
  28973. * Sync a bone with this impostor
  28974. * @param bone The bone to sync to the impostor.
  28975. * @param boneMesh The mesh that the bone is influencing.
  28976. * @param jointPivot The pivot of the joint / bone in local space.
  28977. * @param distToJoint Optional distance from the impostor to the joint.
  28978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28979. */
  28980. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28981. /**
  28982. * Sync impostor to a bone
  28983. * @param bone The bone that the impostor will be synced to.
  28984. * @param boneMesh The mesh that the bone is influencing.
  28985. * @param jointPivot The pivot of the joint / bone in local space.
  28986. * @param distToJoint Optional distance from the impostor to the joint.
  28987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28988. * @param boneAxis Optional vector3 axis the bone is aligned with
  28989. */
  28990. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28991. /**
  28992. * No-Imposter type
  28993. */
  28994. static NoImpostor: number;
  28995. /**
  28996. * Sphere-Imposter type
  28997. */
  28998. static SphereImpostor: number;
  28999. /**
  29000. * Box-Imposter type
  29001. */
  29002. static BoxImpostor: number;
  29003. /**
  29004. * Plane-Imposter type
  29005. */
  29006. static PlaneImpostor: number;
  29007. /**
  29008. * Mesh-imposter type
  29009. */
  29010. static MeshImpostor: number;
  29011. /**
  29012. * Capsule-Impostor type (Ammo.js plugin only)
  29013. */
  29014. static CapsuleImpostor: number;
  29015. /**
  29016. * Cylinder-Imposter type
  29017. */
  29018. static CylinderImpostor: number;
  29019. /**
  29020. * Particle-Imposter type
  29021. */
  29022. static ParticleImpostor: number;
  29023. /**
  29024. * Heightmap-Imposter type
  29025. */
  29026. static HeightmapImpostor: number;
  29027. /**
  29028. * ConvexHull-Impostor type (Ammo.js plugin only)
  29029. */
  29030. static ConvexHullImpostor: number;
  29031. /**
  29032. * Custom-Imposter type (Ammo.js plugin only)
  29033. */
  29034. static CustomImpostor: number;
  29035. /**
  29036. * Rope-Imposter type
  29037. */
  29038. static RopeImpostor: number;
  29039. /**
  29040. * Cloth-Imposter type
  29041. */
  29042. static ClothImpostor: number;
  29043. /**
  29044. * Softbody-Imposter type
  29045. */
  29046. static SoftbodyImpostor: number;
  29047. }
  29048. }
  29049. declare module "babylonjs/Meshes/mesh" {
  29050. import { Observable } from "babylonjs/Misc/observable";
  29051. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29052. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29053. import { Camera } from "babylonjs/Cameras/camera";
  29054. import { Scene } from "babylonjs/scene";
  29055. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29056. import { Color4 } from "babylonjs/Maths/math.color";
  29057. import { Engine } from "babylonjs/Engines/engine";
  29058. import { Node } from "babylonjs/node";
  29059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29060. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29061. import { Buffer } from "babylonjs/Meshes/buffer";
  29062. import { Geometry } from "babylonjs/Meshes/geometry";
  29063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29065. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29066. import { Effect } from "babylonjs/Materials/effect";
  29067. import { Material } from "babylonjs/Materials/material";
  29068. import { Skeleton } from "babylonjs/Bones/skeleton";
  29069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29070. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29071. import { Path3D } from "babylonjs/Maths/math.path";
  29072. import { Plane } from "babylonjs/Maths/math.plane";
  29073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29074. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29075. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29076. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29077. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29079. /**
  29080. * @hidden
  29081. **/
  29082. export class _CreationDataStorage {
  29083. closePath?: boolean;
  29084. closeArray?: boolean;
  29085. idx: number[];
  29086. dashSize: number;
  29087. gapSize: number;
  29088. path3D: Path3D;
  29089. pathArray: Vector3[][];
  29090. arc: number;
  29091. radius: number;
  29092. cap: number;
  29093. tessellation: number;
  29094. }
  29095. /**
  29096. * @hidden
  29097. **/
  29098. class _InstanceDataStorage {
  29099. visibleInstances: any;
  29100. batchCache: _InstancesBatch;
  29101. instancesBufferSize: number;
  29102. instancesBuffer: Nullable<Buffer>;
  29103. instancesData: Float32Array;
  29104. overridenInstanceCount: number;
  29105. isFrozen: boolean;
  29106. previousBatch: Nullable<_InstancesBatch>;
  29107. hardwareInstancedRendering: boolean;
  29108. sideOrientation: number;
  29109. manualUpdate: boolean;
  29110. }
  29111. /**
  29112. * @hidden
  29113. **/
  29114. export class _InstancesBatch {
  29115. mustReturn: boolean;
  29116. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29117. renderSelf: boolean[];
  29118. hardwareInstancedRendering: boolean[];
  29119. }
  29120. /**
  29121. * @hidden
  29122. **/
  29123. class _ThinInstanceDataStorage {
  29124. instancesCount: number;
  29125. matrixBuffer: Nullable<Buffer>;
  29126. matrixBufferSize: number;
  29127. matrixData: Nullable<Float32Array>;
  29128. boundingVectors: Array<Vector3>;
  29129. worldMatrices: Nullable<Matrix[]>;
  29130. }
  29131. /**
  29132. * Class used to represent renderable models
  29133. */
  29134. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29135. /**
  29136. * Mesh side orientation : usually the external or front surface
  29137. */
  29138. static readonly FRONTSIDE: number;
  29139. /**
  29140. * Mesh side orientation : usually the internal or back surface
  29141. */
  29142. static readonly BACKSIDE: number;
  29143. /**
  29144. * Mesh side orientation : both internal and external or front and back surfaces
  29145. */
  29146. static readonly DOUBLESIDE: number;
  29147. /**
  29148. * Mesh side orientation : by default, `FRONTSIDE`
  29149. */
  29150. static readonly DEFAULTSIDE: number;
  29151. /**
  29152. * Mesh cap setting : no cap
  29153. */
  29154. static readonly NO_CAP: number;
  29155. /**
  29156. * Mesh cap setting : one cap at the beginning of the mesh
  29157. */
  29158. static readonly CAP_START: number;
  29159. /**
  29160. * Mesh cap setting : one cap at the end of the mesh
  29161. */
  29162. static readonly CAP_END: number;
  29163. /**
  29164. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29165. */
  29166. static readonly CAP_ALL: number;
  29167. /**
  29168. * Mesh pattern setting : no flip or rotate
  29169. */
  29170. static readonly NO_FLIP: number;
  29171. /**
  29172. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29173. */
  29174. static readonly FLIP_TILE: number;
  29175. /**
  29176. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29177. */
  29178. static readonly ROTATE_TILE: number;
  29179. /**
  29180. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29181. */
  29182. static readonly FLIP_ROW: number;
  29183. /**
  29184. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29185. */
  29186. static readonly ROTATE_ROW: number;
  29187. /**
  29188. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29189. */
  29190. static readonly FLIP_N_ROTATE_TILE: number;
  29191. /**
  29192. * Mesh pattern setting : rotate pattern and rotate
  29193. */
  29194. static readonly FLIP_N_ROTATE_ROW: number;
  29195. /**
  29196. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29197. */
  29198. static readonly CENTER: number;
  29199. /**
  29200. * Mesh tile positioning : part tiles on left
  29201. */
  29202. static readonly LEFT: number;
  29203. /**
  29204. * Mesh tile positioning : part tiles on right
  29205. */
  29206. static readonly RIGHT: number;
  29207. /**
  29208. * Mesh tile positioning : part tiles on top
  29209. */
  29210. static readonly TOP: number;
  29211. /**
  29212. * Mesh tile positioning : part tiles on bottom
  29213. */
  29214. static readonly BOTTOM: number;
  29215. /**
  29216. * Gets the default side orientation.
  29217. * @param orientation the orientation to value to attempt to get
  29218. * @returns the default orientation
  29219. * @hidden
  29220. */
  29221. static _GetDefaultSideOrientation(orientation?: number): number;
  29222. private _internalMeshDataInfo;
  29223. get computeBonesUsingShaders(): boolean;
  29224. set computeBonesUsingShaders(value: boolean);
  29225. /**
  29226. * An event triggered before rendering the mesh
  29227. */
  29228. get onBeforeRenderObservable(): Observable<Mesh>;
  29229. /**
  29230. * An event triggered before binding the mesh
  29231. */
  29232. get onBeforeBindObservable(): Observable<Mesh>;
  29233. /**
  29234. * An event triggered after rendering the mesh
  29235. */
  29236. get onAfterRenderObservable(): Observable<Mesh>;
  29237. /**
  29238. * An event triggered before drawing the mesh
  29239. */
  29240. get onBeforeDrawObservable(): Observable<Mesh>;
  29241. private _onBeforeDrawObserver;
  29242. /**
  29243. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29244. */
  29245. set onBeforeDraw(callback: () => void);
  29246. get hasInstances(): boolean;
  29247. get hasThinInstances(): boolean;
  29248. /**
  29249. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29250. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29251. */
  29252. delayLoadState: number;
  29253. /**
  29254. * Gets the list of instances created from this mesh
  29255. * it is not supposed to be modified manually.
  29256. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29257. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29258. */
  29259. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29260. /**
  29261. * Gets the file containing delay loading data for this mesh
  29262. */
  29263. delayLoadingFile: string;
  29264. /** @hidden */
  29265. _binaryInfo: any;
  29266. /**
  29267. * User defined function used to change how LOD level selection is done
  29268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29269. */
  29270. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29271. /**
  29272. * Gets or sets the morph target manager
  29273. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29274. */
  29275. get morphTargetManager(): Nullable<MorphTargetManager>;
  29276. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29277. /** @hidden */
  29278. _creationDataStorage: Nullable<_CreationDataStorage>;
  29279. /** @hidden */
  29280. _geometry: Nullable<Geometry>;
  29281. /** @hidden */
  29282. _delayInfo: Array<string>;
  29283. /** @hidden */
  29284. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29285. /** @hidden */
  29286. _instanceDataStorage: _InstanceDataStorage;
  29287. /** @hidden */
  29288. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29289. private _effectiveMaterial;
  29290. /** @hidden */
  29291. _shouldGenerateFlatShading: boolean;
  29292. /** @hidden */
  29293. _originalBuilderSideOrientation: number;
  29294. /**
  29295. * Use this property to change the original side orientation defined at construction time
  29296. */
  29297. overrideMaterialSideOrientation: Nullable<number>;
  29298. /**
  29299. * Gets the source mesh (the one used to clone this one from)
  29300. */
  29301. get source(): Nullable<Mesh>;
  29302. /**
  29303. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29304. */
  29305. get isUnIndexed(): boolean;
  29306. set isUnIndexed(value: boolean);
  29307. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29308. get worldMatrixInstancedBuffer(): Float32Array;
  29309. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29310. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29311. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29312. /**
  29313. * @constructor
  29314. * @param name The value used by scene.getMeshByName() to do a lookup.
  29315. * @param scene The scene to add this mesh to.
  29316. * @param parent The parent of this mesh, if it has one
  29317. * @param source An optional Mesh from which geometry is shared, cloned.
  29318. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29319. * When false, achieved by calling a clone(), also passing False.
  29320. * This will make creation of children, recursive.
  29321. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29322. */
  29323. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29324. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29325. doNotInstantiate: boolean;
  29326. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29327. /**
  29328. * Gets the class name
  29329. * @returns the string "Mesh".
  29330. */
  29331. getClassName(): string;
  29332. /** @hidden */
  29333. get _isMesh(): boolean;
  29334. /**
  29335. * Returns a description of this mesh
  29336. * @param fullDetails define if full details about this mesh must be used
  29337. * @returns a descriptive string representing this mesh
  29338. */
  29339. toString(fullDetails?: boolean): string;
  29340. /** @hidden */
  29341. _unBindEffect(): void;
  29342. /**
  29343. * Gets a boolean indicating if this mesh has LOD
  29344. */
  29345. get hasLODLevels(): boolean;
  29346. /**
  29347. * Gets the list of MeshLODLevel associated with the current mesh
  29348. * @returns an array of MeshLODLevel
  29349. */
  29350. getLODLevels(): MeshLODLevel[];
  29351. private _sortLODLevels;
  29352. /**
  29353. * Add a mesh as LOD level triggered at the given distance.
  29354. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29355. * @param distance The distance from the center of the object to show this level
  29356. * @param mesh The mesh to be added as LOD level (can be null)
  29357. * @return This mesh (for chaining)
  29358. */
  29359. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29360. /**
  29361. * Returns the LOD level mesh at the passed distance or null if not found.
  29362. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29363. * @param distance The distance from the center of the object to show this level
  29364. * @returns a Mesh or `null`
  29365. */
  29366. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29367. /**
  29368. * Remove a mesh from the LOD array
  29369. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29370. * @param mesh defines the mesh to be removed
  29371. * @return This mesh (for chaining)
  29372. */
  29373. removeLODLevel(mesh: Mesh): Mesh;
  29374. /**
  29375. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29376. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29377. * @param camera defines the camera to use to compute distance
  29378. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29379. * @return This mesh (for chaining)
  29380. */
  29381. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29382. /**
  29383. * Gets the mesh internal Geometry object
  29384. */
  29385. get geometry(): Nullable<Geometry>;
  29386. /**
  29387. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29388. * @returns the total number of vertices
  29389. */
  29390. getTotalVertices(): number;
  29391. /**
  29392. * Returns the content of an associated vertex buffer
  29393. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29394. * - VertexBuffer.PositionKind
  29395. * - VertexBuffer.UVKind
  29396. * - VertexBuffer.UV2Kind
  29397. * - VertexBuffer.UV3Kind
  29398. * - VertexBuffer.UV4Kind
  29399. * - VertexBuffer.UV5Kind
  29400. * - VertexBuffer.UV6Kind
  29401. * - VertexBuffer.ColorKind
  29402. * - VertexBuffer.MatricesIndicesKind
  29403. * - VertexBuffer.MatricesIndicesExtraKind
  29404. * - VertexBuffer.MatricesWeightsKind
  29405. * - VertexBuffer.MatricesWeightsExtraKind
  29406. * @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
  29407. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29408. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29409. */
  29410. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29411. /**
  29412. * Returns the mesh VertexBuffer object from the requested `kind`
  29413. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29414. * - VertexBuffer.PositionKind
  29415. * - VertexBuffer.NormalKind
  29416. * - VertexBuffer.UVKind
  29417. * - VertexBuffer.UV2Kind
  29418. * - VertexBuffer.UV3Kind
  29419. * - VertexBuffer.UV4Kind
  29420. * - VertexBuffer.UV5Kind
  29421. * - VertexBuffer.UV6Kind
  29422. * - VertexBuffer.ColorKind
  29423. * - VertexBuffer.MatricesIndicesKind
  29424. * - VertexBuffer.MatricesIndicesExtraKind
  29425. * - VertexBuffer.MatricesWeightsKind
  29426. * - VertexBuffer.MatricesWeightsExtraKind
  29427. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29428. */
  29429. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29430. /**
  29431. * Tests if a specific vertex buffer is associated with this mesh
  29432. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29433. * - VertexBuffer.PositionKind
  29434. * - VertexBuffer.NormalKind
  29435. * - VertexBuffer.UVKind
  29436. * - VertexBuffer.UV2Kind
  29437. * - VertexBuffer.UV3Kind
  29438. * - VertexBuffer.UV4Kind
  29439. * - VertexBuffer.UV5Kind
  29440. * - VertexBuffer.UV6Kind
  29441. * - VertexBuffer.ColorKind
  29442. * - VertexBuffer.MatricesIndicesKind
  29443. * - VertexBuffer.MatricesIndicesExtraKind
  29444. * - VertexBuffer.MatricesWeightsKind
  29445. * - VertexBuffer.MatricesWeightsExtraKind
  29446. * @returns a boolean
  29447. */
  29448. isVerticesDataPresent(kind: string): boolean;
  29449. /**
  29450. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29451. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29452. * - VertexBuffer.PositionKind
  29453. * - VertexBuffer.UVKind
  29454. * - VertexBuffer.UV2Kind
  29455. * - VertexBuffer.UV3Kind
  29456. * - VertexBuffer.UV4Kind
  29457. * - VertexBuffer.UV5Kind
  29458. * - VertexBuffer.UV6Kind
  29459. * - VertexBuffer.ColorKind
  29460. * - VertexBuffer.MatricesIndicesKind
  29461. * - VertexBuffer.MatricesIndicesExtraKind
  29462. * - VertexBuffer.MatricesWeightsKind
  29463. * - VertexBuffer.MatricesWeightsExtraKind
  29464. * @returns a boolean
  29465. */
  29466. isVertexBufferUpdatable(kind: string): boolean;
  29467. /**
  29468. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29469. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29470. * - VertexBuffer.PositionKind
  29471. * - VertexBuffer.NormalKind
  29472. * - VertexBuffer.UVKind
  29473. * - VertexBuffer.UV2Kind
  29474. * - VertexBuffer.UV3Kind
  29475. * - VertexBuffer.UV4Kind
  29476. * - VertexBuffer.UV5Kind
  29477. * - VertexBuffer.UV6Kind
  29478. * - VertexBuffer.ColorKind
  29479. * - VertexBuffer.MatricesIndicesKind
  29480. * - VertexBuffer.MatricesIndicesExtraKind
  29481. * - VertexBuffer.MatricesWeightsKind
  29482. * - VertexBuffer.MatricesWeightsExtraKind
  29483. * @returns an array of strings
  29484. */
  29485. getVerticesDataKinds(): string[];
  29486. /**
  29487. * Returns a positive integer : the total number of indices in this mesh geometry.
  29488. * @returns the numner of indices or zero if the mesh has no geometry.
  29489. */
  29490. getTotalIndices(): number;
  29491. /**
  29492. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29493. * @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.
  29494. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29495. * @returns the indices array or an empty array if the mesh has no geometry
  29496. */
  29497. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29498. get isBlocked(): boolean;
  29499. /**
  29500. * Determine if the current mesh is ready to be rendered
  29501. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29502. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29503. * @returns true if all associated assets are ready (material, textures, shaders)
  29504. */
  29505. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29506. /**
  29507. * 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.
  29508. */
  29509. get areNormalsFrozen(): boolean;
  29510. /**
  29511. * 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.
  29512. * @returns the current mesh
  29513. */
  29514. freezeNormals(): Mesh;
  29515. /**
  29516. * 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
  29517. * @returns the current mesh
  29518. */
  29519. unfreezeNormals(): Mesh;
  29520. /**
  29521. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29522. */
  29523. set overridenInstanceCount(count: number);
  29524. /** @hidden */
  29525. _preActivate(): Mesh;
  29526. /** @hidden */
  29527. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29528. /** @hidden */
  29529. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29530. protected _afterComputeWorldMatrix(): void;
  29531. /** @hidden */
  29532. _postActivate(): void;
  29533. /**
  29534. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29535. * This means the mesh underlying bounding box and sphere are recomputed.
  29536. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29537. * @returns the current mesh
  29538. */
  29539. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29540. /** @hidden */
  29541. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29542. /**
  29543. * This function will subdivide the mesh into multiple submeshes
  29544. * @param count defines the expected number of submeshes
  29545. */
  29546. subdivide(count: number): void;
  29547. /**
  29548. * Copy a FloatArray into a specific associated vertex buffer
  29549. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29550. * - VertexBuffer.PositionKind
  29551. * - VertexBuffer.UVKind
  29552. * - VertexBuffer.UV2Kind
  29553. * - VertexBuffer.UV3Kind
  29554. * - VertexBuffer.UV4Kind
  29555. * - VertexBuffer.UV5Kind
  29556. * - VertexBuffer.UV6Kind
  29557. * - VertexBuffer.ColorKind
  29558. * - VertexBuffer.MatricesIndicesKind
  29559. * - VertexBuffer.MatricesIndicesExtraKind
  29560. * - VertexBuffer.MatricesWeightsKind
  29561. * - VertexBuffer.MatricesWeightsExtraKind
  29562. * @param data defines the data source
  29563. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29564. * @param stride defines the data stride size (can be null)
  29565. * @returns the current mesh
  29566. */
  29567. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29568. /**
  29569. * Delete a vertex buffer associated with this mesh
  29570. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29571. * - VertexBuffer.PositionKind
  29572. * - VertexBuffer.UVKind
  29573. * - VertexBuffer.UV2Kind
  29574. * - VertexBuffer.UV3Kind
  29575. * - VertexBuffer.UV4Kind
  29576. * - VertexBuffer.UV5Kind
  29577. * - VertexBuffer.UV6Kind
  29578. * - VertexBuffer.ColorKind
  29579. * - VertexBuffer.MatricesIndicesKind
  29580. * - VertexBuffer.MatricesIndicesExtraKind
  29581. * - VertexBuffer.MatricesWeightsKind
  29582. * - VertexBuffer.MatricesWeightsExtraKind
  29583. */
  29584. removeVerticesData(kind: string): void;
  29585. /**
  29586. * Flags an associated vertex buffer as updatable
  29587. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29588. * - VertexBuffer.PositionKind
  29589. * - VertexBuffer.UVKind
  29590. * - VertexBuffer.UV2Kind
  29591. * - VertexBuffer.UV3Kind
  29592. * - VertexBuffer.UV4Kind
  29593. * - VertexBuffer.UV5Kind
  29594. * - VertexBuffer.UV6Kind
  29595. * - VertexBuffer.ColorKind
  29596. * - VertexBuffer.MatricesIndicesKind
  29597. * - VertexBuffer.MatricesIndicesExtraKind
  29598. * - VertexBuffer.MatricesWeightsKind
  29599. * - VertexBuffer.MatricesWeightsExtraKind
  29600. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29601. */
  29602. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29603. /**
  29604. * Sets the mesh global Vertex Buffer
  29605. * @param buffer defines the buffer to use
  29606. * @returns the current mesh
  29607. */
  29608. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29609. /**
  29610. * Update a specific associated vertex buffer
  29611. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29612. * - VertexBuffer.PositionKind
  29613. * - VertexBuffer.UVKind
  29614. * - VertexBuffer.UV2Kind
  29615. * - VertexBuffer.UV3Kind
  29616. * - VertexBuffer.UV4Kind
  29617. * - VertexBuffer.UV5Kind
  29618. * - VertexBuffer.UV6Kind
  29619. * - VertexBuffer.ColorKind
  29620. * - VertexBuffer.MatricesIndicesKind
  29621. * - VertexBuffer.MatricesIndicesExtraKind
  29622. * - VertexBuffer.MatricesWeightsKind
  29623. * - VertexBuffer.MatricesWeightsExtraKind
  29624. * @param data defines the data source
  29625. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29626. * @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)
  29627. * @returns the current mesh
  29628. */
  29629. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29630. /**
  29631. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29632. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29633. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29634. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29635. * @returns the current mesh
  29636. */
  29637. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29638. /**
  29639. * Creates a un-shared specific occurence of the geometry for the mesh.
  29640. * @returns the current mesh
  29641. */
  29642. makeGeometryUnique(): Mesh;
  29643. /**
  29644. * Set the index buffer of this mesh
  29645. * @param indices defines the source data
  29646. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29647. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29648. * @returns the current mesh
  29649. */
  29650. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29651. /**
  29652. * Update the current index buffer
  29653. * @param indices defines the source data
  29654. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29655. * @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)
  29656. * @returns the current mesh
  29657. */
  29658. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29659. /**
  29660. * Invert the geometry to move from a right handed system to a left handed one.
  29661. * @returns the current mesh
  29662. */
  29663. toLeftHanded(): Mesh;
  29664. /** @hidden */
  29665. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29666. /** @hidden */
  29667. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29668. /**
  29669. * Registers for this mesh a javascript function called just before the rendering process
  29670. * @param func defines the function to call before rendering this mesh
  29671. * @returns the current mesh
  29672. */
  29673. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29674. /**
  29675. * Disposes a previously registered javascript function called before the rendering
  29676. * @param func defines the function to remove
  29677. * @returns the current mesh
  29678. */
  29679. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29680. /**
  29681. * Registers for this mesh a javascript function called just after the rendering is complete
  29682. * @param func defines the function to call after rendering this mesh
  29683. * @returns the current mesh
  29684. */
  29685. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29686. /**
  29687. * Disposes a previously registered javascript function called after the rendering.
  29688. * @param func defines the function to remove
  29689. * @returns the current mesh
  29690. */
  29691. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29692. /** @hidden */
  29693. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29694. /** @hidden */
  29695. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29696. /** @hidden */
  29697. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29698. /** @hidden */
  29699. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29700. /** @hidden */
  29701. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29702. /** @hidden */
  29703. _rebuild(): void;
  29704. /** @hidden */
  29705. _freeze(): void;
  29706. /** @hidden */
  29707. _unFreeze(): void;
  29708. /**
  29709. * 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
  29710. * @param subMesh defines the subMesh to render
  29711. * @param enableAlphaMode defines if alpha mode can be changed
  29712. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29713. * @returns the current mesh
  29714. */
  29715. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29716. private _onBeforeDraw;
  29717. /**
  29718. * Renormalize the mesh and patch it up if there are no weights
  29719. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29720. * However in the case of zero weights then we set just a single influence to 1.
  29721. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29722. */
  29723. cleanMatrixWeights(): void;
  29724. private normalizeSkinFourWeights;
  29725. private normalizeSkinWeightsAndExtra;
  29726. /**
  29727. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29728. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29729. * the user know there was an issue with importing the mesh
  29730. * @returns a validation object with skinned, valid and report string
  29731. */
  29732. validateSkinning(): {
  29733. skinned: boolean;
  29734. valid: boolean;
  29735. report: string;
  29736. };
  29737. /** @hidden */
  29738. _checkDelayState(): Mesh;
  29739. private _queueLoad;
  29740. /**
  29741. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29742. * A mesh is in the frustum if its bounding box intersects the frustum
  29743. * @param frustumPlanes defines the frustum to test
  29744. * @returns true if the mesh is in the frustum planes
  29745. */
  29746. isInFrustum(frustumPlanes: Plane[]): boolean;
  29747. /**
  29748. * Sets the mesh material by the material or multiMaterial `id` property
  29749. * @param id is a string identifying the material or the multiMaterial
  29750. * @returns the current mesh
  29751. */
  29752. setMaterialByID(id: string): Mesh;
  29753. /**
  29754. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29755. * @returns an array of IAnimatable
  29756. */
  29757. getAnimatables(): IAnimatable[];
  29758. /**
  29759. * Modifies the mesh geometry according to the passed transformation matrix.
  29760. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29761. * The mesh normals are modified using the same transformation.
  29762. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29763. * @param transform defines the transform matrix to use
  29764. * @see https://doc.babylonjs.com/resources/baking_transformations
  29765. * @returns the current mesh
  29766. */
  29767. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29768. /**
  29769. * Modifies the mesh geometry according to its own current World Matrix.
  29770. * The mesh World Matrix is then reset.
  29771. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29772. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29773. * @see https://doc.babylonjs.com/resources/baking_transformations
  29774. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29775. * @returns the current mesh
  29776. */
  29777. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29778. /** @hidden */
  29779. get _positions(): Nullable<Vector3[]>;
  29780. /** @hidden */
  29781. _resetPointsArrayCache(): Mesh;
  29782. /** @hidden */
  29783. _generatePointsArray(): boolean;
  29784. /**
  29785. * Returns a new Mesh object generated from the current mesh properties.
  29786. * This method must not get confused with createInstance()
  29787. * @param name is a string, the name given to the new mesh
  29788. * @param newParent can be any Node object (default `null`)
  29789. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29790. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29791. * @returns a new mesh
  29792. */
  29793. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29794. /**
  29795. * Releases resources associated with this mesh.
  29796. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29797. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29798. */
  29799. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29800. /** @hidden */
  29801. _disposeInstanceSpecificData(): void;
  29802. /** @hidden */
  29803. _disposeThinInstanceSpecificData(): void;
  29804. /**
  29805. * Modifies the mesh geometry according to a displacement map.
  29806. * 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.
  29807. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29808. * @param url is a string, the URL from the image file is to be downloaded.
  29809. * @param minHeight is the lower limit of the displacement.
  29810. * @param maxHeight is the upper limit of the displacement.
  29811. * @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.
  29812. * @param uvOffset is an optional vector2 used to offset UV.
  29813. * @param uvScale is an optional vector2 used to scale UV.
  29814. * @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.
  29815. * @returns the Mesh.
  29816. */
  29817. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29818. /**
  29819. * Modifies the mesh geometry according to a displacementMap buffer.
  29820. * 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.
  29821. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29822. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29823. * @param heightMapWidth is the width of the buffer image.
  29824. * @param heightMapHeight is the height of the buffer image.
  29825. * @param minHeight is the lower limit of the displacement.
  29826. * @param maxHeight is the upper limit of the displacement.
  29827. * @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.
  29828. * @param uvOffset is an optional vector2 used to offset UV.
  29829. * @param uvScale is an optional vector2 used to scale UV.
  29830. * @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.
  29831. * @returns the Mesh.
  29832. */
  29833. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29834. /**
  29835. * Modify the mesh to get a flat shading rendering.
  29836. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29837. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29838. * @returns current mesh
  29839. */
  29840. convertToFlatShadedMesh(): Mesh;
  29841. /**
  29842. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29843. * In other words, more vertices, no more indices and a single bigger VBO.
  29844. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29845. * @returns current mesh
  29846. */
  29847. convertToUnIndexedMesh(): Mesh;
  29848. /**
  29849. * Inverses facet orientations.
  29850. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29851. * @param flipNormals will also inverts the normals
  29852. * @returns current mesh
  29853. */
  29854. flipFaces(flipNormals?: boolean): Mesh;
  29855. /**
  29856. * Increase the number of facets and hence vertices in a mesh
  29857. * Vertex normals are interpolated from existing vertex normals
  29858. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29859. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29860. */
  29861. increaseVertices(numberPerEdge: number): void;
  29862. /**
  29863. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29864. * This will undo any application of covertToFlatShadedMesh
  29865. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29866. */
  29867. forceSharedVertices(): void;
  29868. /** @hidden */
  29869. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29870. /** @hidden */
  29871. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29872. /**
  29873. * Creates a new InstancedMesh object from the mesh model.
  29874. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29875. * @param name defines the name of the new instance
  29876. * @returns a new InstancedMesh
  29877. */
  29878. createInstance(name: string): InstancedMesh;
  29879. /**
  29880. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29881. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29882. * @returns the current mesh
  29883. */
  29884. synchronizeInstances(): Mesh;
  29885. /**
  29886. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29887. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29888. * This should be used together with the simplification to avoid disappearing triangles.
  29889. * @param successCallback an optional success callback to be called after the optimization finished.
  29890. * @returns the current mesh
  29891. */
  29892. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29893. /**
  29894. * Serialize current mesh
  29895. * @param serializationObject defines the object which will receive the serialization data
  29896. */
  29897. serialize(serializationObject: any): void;
  29898. /** @hidden */
  29899. _syncGeometryWithMorphTargetManager(): void;
  29900. /** @hidden */
  29901. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29902. /**
  29903. * Returns a new Mesh object parsed from the source provided.
  29904. * @param parsedMesh is the source
  29905. * @param scene defines the hosting scene
  29906. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29907. * @returns a new Mesh
  29908. */
  29909. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29910. /**
  29911. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29913. * @param name defines the name of the mesh to create
  29914. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29915. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29916. * @param closePath creates a seam between the first and the last points of each path of the path array
  29917. * @param offset is taken in account only if the `pathArray` is containing a single path
  29918. * @param scene defines the hosting scene
  29919. * @param updatable defines if the mesh must be flagged as updatable
  29920. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29921. * @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)
  29922. * @returns a new Mesh
  29923. */
  29924. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29925. /**
  29926. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29927. * @param name defines the name of the mesh to create
  29928. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29929. * @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
  29930. * @param scene defines the hosting scene
  29931. * @param updatable defines if the mesh must be flagged as updatable
  29932. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29933. * @returns a new Mesh
  29934. */
  29935. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29936. /**
  29937. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29938. * @param name defines the name of the mesh to create
  29939. * @param size sets the size (float) of each box side (default 1)
  29940. * @param scene defines the hosting scene
  29941. * @param updatable defines if the mesh must be flagged as updatable
  29942. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29943. * @returns a new Mesh
  29944. */
  29945. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29946. /**
  29947. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29948. * @param name defines the name of the mesh to create
  29949. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29950. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29951. * @param scene defines the hosting scene
  29952. * @param updatable defines if the mesh must be flagged as updatable
  29953. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29954. * @returns a new Mesh
  29955. */
  29956. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29957. /**
  29958. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29959. * @param name defines the name of the mesh to create
  29960. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29961. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29962. * @param scene defines the hosting scene
  29963. * @returns a new Mesh
  29964. */
  29965. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29966. /**
  29967. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29968. * @param name defines the name of the mesh to create
  29969. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29970. * @param diameterTop set the top cap diameter (floats, default 1)
  29971. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29972. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29973. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29974. * @param scene defines the hosting scene
  29975. * @param updatable defines if the mesh must be flagged as updatable
  29976. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29977. * @returns a new Mesh
  29978. */
  29979. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29980. /**
  29981. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29982. * @param name defines the name of the mesh to create
  29983. * @param diameter sets the diameter size (float) of the torus (default 1)
  29984. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29985. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29986. * @param scene defines the hosting scene
  29987. * @param updatable defines if the mesh must be flagged as updatable
  29988. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29989. * @returns a new Mesh
  29990. */
  29991. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29992. /**
  29993. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29994. * @param name defines the name of the mesh to create
  29995. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29996. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29997. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29998. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29999. * @param p the number of windings on X axis (positive integers, default 2)
  30000. * @param q the number of windings on Y axis (positive integers, default 3)
  30001. * @param scene defines the hosting scene
  30002. * @param updatable defines if the mesh must be flagged as updatable
  30003. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30004. * @returns a new Mesh
  30005. */
  30006. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30007. /**
  30008. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30009. * @param name defines the name of the mesh to create
  30010. * @param points is an array successive Vector3
  30011. * @param scene defines the hosting scene
  30012. * @param updatable defines if the mesh must be flagged as updatable
  30013. * @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).
  30014. * @returns a new Mesh
  30015. */
  30016. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30017. /**
  30018. * Creates a dashed line 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 points is an array successive Vector3
  30021. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30022. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30023. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30024. * @param scene defines the hosting scene
  30025. * @param updatable defines if the mesh must be flagged as updatable
  30026. * @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)
  30027. * @returns a new Mesh
  30028. */
  30029. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30030. /**
  30031. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30032. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30033. * 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.
  30034. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30035. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30036. * Remember you can only change the shape positions, not their number when updating a polygon.
  30037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30038. * @param name defines the name of the mesh to create
  30039. * @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
  30040. * @param scene defines the hosting scene
  30041. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30042. * @param updatable defines if the mesh must be flagged as updatable
  30043. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30044. * @param earcutInjection can be used to inject your own earcut reference
  30045. * @returns a new Mesh
  30046. */
  30047. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30048. /**
  30049. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30051. * @param name defines the name of the mesh to create
  30052. * @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
  30053. * @param depth defines the height of extrusion
  30054. * @param scene defines the hosting scene
  30055. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  30059. * @returns a new Mesh
  30060. */
  30061. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30062. /**
  30063. * Creates an extruded shape mesh.
  30064. * 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
  30065. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30067. * @param name defines the name of the mesh to create
  30068. * @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
  30069. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30070. * @param scale is the value to scale the shape
  30071. * @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
  30072. * @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
  30073. * @param scene defines the hosting scene
  30074. * @param updatable defines if the mesh must be flagged as updatable
  30075. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30076. * @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)
  30077. * @returns a new Mesh
  30078. */
  30079. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30080. /**
  30081. * Creates an custom extruded shape mesh.
  30082. * The custom extrusion is a parametric shape.
  30083. * It has no predefined shape. Its final shape will depend on the input parameters.
  30084. * Please consider using the same method from the MeshBuilder class instead
  30085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30086. * @param name defines the name of the mesh to create
  30087. * @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
  30088. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30089. * @param scaleFunction is a custom Javascript function called on each path point
  30090. * @param rotationFunction is a custom Javascript function called on each path point
  30091. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30092. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30093. * @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
  30094. * @param scene defines the hosting scene
  30095. * @param updatable defines if the mesh must be flagged as updatable
  30096. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30097. * @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)
  30098. * @returns a new Mesh
  30099. */
  30100. 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;
  30101. /**
  30102. * Creates lathe mesh.
  30103. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30104. * Please consider using the same method from the MeshBuilder class instead
  30105. * @param name defines the name of the mesh to create
  30106. * @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
  30107. * @param radius is the radius value of the lathe
  30108. * @param tessellation is the side number of the lathe.
  30109. * @param scene defines the hosting scene
  30110. * @param updatable defines if the mesh must be flagged as updatable
  30111. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30112. * @returns a new Mesh
  30113. */
  30114. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30115. /**
  30116. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30117. * @param name defines the name of the mesh to create
  30118. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30119. * @param scene defines the hosting scene
  30120. * @param updatable defines if the mesh must be flagged as updatable
  30121. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30122. * @returns a new Mesh
  30123. */
  30124. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30125. /**
  30126. * Creates a ground mesh.
  30127. * Please consider using the same method from the MeshBuilder class instead
  30128. * @param name defines the name of the mesh to create
  30129. * @param width set the width of the ground
  30130. * @param height set the height of the ground
  30131. * @param subdivisions sets the number of subdivisions per side
  30132. * @param scene defines the hosting scene
  30133. * @param updatable defines if the mesh must be flagged as updatable
  30134. * @returns a new Mesh
  30135. */
  30136. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30137. /**
  30138. * Creates a tiled ground mesh.
  30139. * Please consider using the same method from the MeshBuilder class instead
  30140. * @param name defines the name of the mesh to create
  30141. * @param xmin set the ground minimum X coordinate
  30142. * @param zmin set the ground minimum Y coordinate
  30143. * @param xmax set the ground maximum X coordinate
  30144. * @param zmax set the ground maximum Z coordinate
  30145. * @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
  30146. * @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
  30147. * @param scene defines the hosting scene
  30148. * @param updatable defines if the mesh must be flagged as updatable
  30149. * @returns a new Mesh
  30150. */
  30151. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30152. w: number;
  30153. h: number;
  30154. }, precision: {
  30155. w: number;
  30156. h: number;
  30157. }, scene: Scene, updatable?: boolean): Mesh;
  30158. /**
  30159. * Creates a ground mesh from a height map.
  30160. * Please consider using the same method from the MeshBuilder class instead
  30161. * @see https://doc.babylonjs.com/babylon101/height_map
  30162. * @param name defines the name of the mesh to create
  30163. * @param url sets the URL of the height map image resource
  30164. * @param width set the ground width size
  30165. * @param height set the ground height size
  30166. * @param subdivisions sets the number of subdivision per side
  30167. * @param minHeight is the minimum altitude on the ground
  30168. * @param maxHeight is the maximum altitude on the ground
  30169. * @param scene defines the hosting scene
  30170. * @param updatable defines if the mesh must be flagged as updatable
  30171. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30172. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30173. * @returns a new Mesh
  30174. */
  30175. 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;
  30176. /**
  30177. * Creates a tube mesh.
  30178. * The tube is a parametric shape.
  30179. * It has no predefined shape. Its final shape will depend on the input parameters.
  30180. * Please consider using the same method from the MeshBuilder class instead
  30181. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30182. * @param name defines the name of the mesh to create
  30183. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30184. * @param radius sets the tube radius size
  30185. * @param tessellation is the number of sides on the tubular surface
  30186. * @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
  30187. * @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
  30188. * @param scene defines the hosting scene
  30189. * @param updatable defines if the mesh must be flagged as updatable
  30190. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30191. * @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)
  30192. * @returns a new Mesh
  30193. */
  30194. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30195. (i: number, distance: number): number;
  30196. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30197. /**
  30198. * Creates a polyhedron mesh.
  30199. * Please consider using the same method from the MeshBuilder class instead.
  30200. * * 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
  30201. * * The parameter `size` (positive float, default 1) sets the polygon size
  30202. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30203. * * 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`
  30204. * * 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
  30205. * * 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)`)
  30206. * * 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
  30207. * * 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
  30208. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30211. * @param name defines the name of the mesh to create
  30212. * @param options defines the options used to create the mesh
  30213. * @param scene defines the hosting scene
  30214. * @returns a new Mesh
  30215. */
  30216. static CreatePolyhedron(name: string, options: {
  30217. type?: number;
  30218. size?: number;
  30219. sizeX?: number;
  30220. sizeY?: number;
  30221. sizeZ?: number;
  30222. custom?: any;
  30223. faceUV?: Vector4[];
  30224. faceColors?: Color4[];
  30225. updatable?: boolean;
  30226. sideOrientation?: number;
  30227. }, scene: Scene): Mesh;
  30228. /**
  30229. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30230. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30231. * * 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`)
  30232. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30233. * * 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
  30234. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30237. * @param name defines the name of the mesh
  30238. * @param options defines the options used to create the mesh
  30239. * @param scene defines the hosting scene
  30240. * @returns a new Mesh
  30241. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30242. */
  30243. static CreateIcoSphere(name: string, options: {
  30244. radius?: number;
  30245. flat?: boolean;
  30246. subdivisions?: number;
  30247. sideOrientation?: number;
  30248. updatable?: boolean;
  30249. }, scene: Scene): Mesh;
  30250. /**
  30251. * Creates a decal mesh.
  30252. * Please consider using the same method from the MeshBuilder class instead.
  30253. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30254. * @param name defines the name of the mesh
  30255. * @param sourceMesh defines the mesh receiving the decal
  30256. * @param position sets the position of the decal in world coordinates
  30257. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30258. * @param size sets the decal scaling
  30259. * @param angle sets the angle to rotate the decal
  30260. * @returns a new Mesh
  30261. */
  30262. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30263. /**
  30264. * Prepare internal position array for software CPU skinning
  30265. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30266. */
  30267. setPositionsForCPUSkinning(): Float32Array;
  30268. /**
  30269. * Prepare internal normal array for software CPU skinning
  30270. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30271. */
  30272. setNormalsForCPUSkinning(): Float32Array;
  30273. /**
  30274. * Updates the vertex buffer by applying transformation from the bones
  30275. * @param skeleton defines the skeleton to apply to current mesh
  30276. * @returns the current mesh
  30277. */
  30278. applySkeleton(skeleton: Skeleton): Mesh;
  30279. /**
  30280. * 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
  30281. * @param meshes defines the list of meshes to scan
  30282. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30283. */
  30284. static MinMax(meshes: AbstractMesh[]): {
  30285. min: Vector3;
  30286. max: Vector3;
  30287. };
  30288. /**
  30289. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30290. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30291. * @returns a vector3
  30292. */
  30293. static Center(meshesOrMinMaxVector: {
  30294. min: Vector3;
  30295. max: Vector3;
  30296. } | AbstractMesh[]): Vector3;
  30297. /**
  30298. * Merge the array of meshes into a single mesh for performance reasons.
  30299. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30300. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30301. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30302. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30303. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30304. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30305. * @returns a new mesh
  30306. */
  30307. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30308. /** @hidden */
  30309. addInstance(instance: InstancedMesh): void;
  30310. /** @hidden */
  30311. removeInstance(instance: InstancedMesh): void;
  30312. }
  30313. }
  30314. declare module "babylonjs/Cameras/camera" {
  30315. import { SmartArray } from "babylonjs/Misc/smartArray";
  30316. import { Observable } from "babylonjs/Misc/observable";
  30317. import { Nullable } from "babylonjs/types";
  30318. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30319. import { Scene } from "babylonjs/scene";
  30320. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30321. import { Node } from "babylonjs/node";
  30322. import { Mesh } from "babylonjs/Meshes/mesh";
  30323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30324. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30325. import { Viewport } from "babylonjs/Maths/math.viewport";
  30326. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30328. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30329. import { Ray } from "babylonjs/Culling/ray";
  30330. /**
  30331. * This is the base class of all the camera used in the application.
  30332. * @see https://doc.babylonjs.com/features/cameras
  30333. */
  30334. export class Camera extends Node {
  30335. /** @hidden */
  30336. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30337. /**
  30338. * This is the default projection mode used by the cameras.
  30339. * It helps recreating a feeling of perspective and better appreciate depth.
  30340. * This is the best way to simulate real life cameras.
  30341. */
  30342. static readonly PERSPECTIVE_CAMERA: number;
  30343. /**
  30344. * This helps creating camera with an orthographic mode.
  30345. * 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.
  30346. */
  30347. static readonly ORTHOGRAPHIC_CAMERA: number;
  30348. /**
  30349. * This is the default FOV mode for perspective cameras.
  30350. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30351. */
  30352. static readonly FOVMODE_VERTICAL_FIXED: number;
  30353. /**
  30354. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30355. */
  30356. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30357. /**
  30358. * This specifies ther is no need for a camera rig.
  30359. * Basically only one eye is rendered corresponding to the camera.
  30360. */
  30361. static readonly RIG_MODE_NONE: number;
  30362. /**
  30363. * Simulates a camera Rig with one blue eye and one red eye.
  30364. * This can be use with 3d blue and red glasses.
  30365. */
  30366. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30367. /**
  30368. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30369. */
  30370. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30371. /**
  30372. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30373. */
  30374. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30375. /**
  30376. * Defines that both eyes of the camera will be rendered over under each other.
  30377. */
  30378. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30379. /**
  30380. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30381. */
  30382. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30383. /**
  30384. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30385. */
  30386. static readonly RIG_MODE_VR: number;
  30387. /**
  30388. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30389. */
  30390. static readonly RIG_MODE_WEBVR: number;
  30391. /**
  30392. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30393. */
  30394. static readonly RIG_MODE_CUSTOM: number;
  30395. /**
  30396. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30397. */
  30398. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30399. /**
  30400. * Define the input manager associated with the camera.
  30401. */
  30402. inputs: CameraInputsManager<Camera>;
  30403. /** @hidden */
  30404. _position: Vector3;
  30405. /**
  30406. * Define the current local position of the camera in the scene
  30407. */
  30408. get position(): Vector3;
  30409. set position(newPosition: Vector3);
  30410. /**
  30411. * The vector the camera should consider as up.
  30412. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30413. */
  30414. upVector: Vector3;
  30415. /**
  30416. * Define the current limit on the left side for an orthographic camera
  30417. * In scene unit
  30418. */
  30419. orthoLeft: Nullable<number>;
  30420. /**
  30421. * Define the current limit on the right side for an orthographic camera
  30422. * In scene unit
  30423. */
  30424. orthoRight: Nullable<number>;
  30425. /**
  30426. * Define the current limit on the bottom side for an orthographic camera
  30427. * In scene unit
  30428. */
  30429. orthoBottom: Nullable<number>;
  30430. /**
  30431. * Define the current limit on the top side for an orthographic camera
  30432. * In scene unit
  30433. */
  30434. orthoTop: Nullable<number>;
  30435. /**
  30436. * Field Of View is set in Radians. (default is 0.8)
  30437. */
  30438. fov: number;
  30439. /**
  30440. * Define the minimum distance the camera can see from.
  30441. * This is important to note that the depth buffer are not infinite and the closer it starts
  30442. * the more your scene might encounter depth fighting issue.
  30443. */
  30444. minZ: number;
  30445. /**
  30446. * Define the maximum distance the camera can see to.
  30447. * This is important to note that the depth buffer are not infinite and the further it end
  30448. * the more your scene might encounter depth fighting issue.
  30449. */
  30450. maxZ: number;
  30451. /**
  30452. * Define the default inertia of the camera.
  30453. * This helps giving a smooth feeling to the camera movement.
  30454. */
  30455. inertia: number;
  30456. /**
  30457. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30458. */
  30459. mode: number;
  30460. /**
  30461. * Define whether the camera is intermediate.
  30462. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30463. */
  30464. isIntermediate: boolean;
  30465. /**
  30466. * Define the viewport of the camera.
  30467. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30468. */
  30469. viewport: Viewport;
  30470. /**
  30471. * Restricts the camera to viewing objects with the same layerMask.
  30472. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30473. */
  30474. layerMask: number;
  30475. /**
  30476. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30477. */
  30478. fovMode: number;
  30479. /**
  30480. * Rig mode of the camera.
  30481. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30482. * This is normally controlled byt the camera themselves as internal use.
  30483. */
  30484. cameraRigMode: number;
  30485. /**
  30486. * Defines the distance between both "eyes" in case of a RIG
  30487. */
  30488. interaxialDistance: number;
  30489. /**
  30490. * Defines if stereoscopic rendering is done side by side or over under.
  30491. */
  30492. isStereoscopicSideBySide: boolean;
  30493. /**
  30494. * 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
  30495. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30496. * else in the scene. (Eg. security camera)
  30497. *
  30498. * 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)
  30499. */
  30500. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30501. /**
  30502. * When set, the camera will render to this render target instead of the default canvas
  30503. *
  30504. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30505. */
  30506. outputRenderTarget: Nullable<RenderTargetTexture>;
  30507. /**
  30508. * Observable triggered when the camera view matrix has changed.
  30509. */
  30510. onViewMatrixChangedObservable: Observable<Camera>;
  30511. /**
  30512. * Observable triggered when the camera Projection matrix has changed.
  30513. */
  30514. onProjectionMatrixChangedObservable: Observable<Camera>;
  30515. /**
  30516. * Observable triggered when the inputs have been processed.
  30517. */
  30518. onAfterCheckInputsObservable: Observable<Camera>;
  30519. /**
  30520. * Observable triggered when reset has been called and applied to the camera.
  30521. */
  30522. onRestoreStateObservable: Observable<Camera>;
  30523. /**
  30524. * Is this camera a part of a rig system?
  30525. */
  30526. isRigCamera: boolean;
  30527. /**
  30528. * If isRigCamera set to true this will be set with the parent camera.
  30529. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30530. */
  30531. rigParent?: Camera;
  30532. /** @hidden */
  30533. _cameraRigParams: any;
  30534. /** @hidden */
  30535. _rigCameras: Camera[];
  30536. /** @hidden */
  30537. _rigPostProcess: Nullable<PostProcess>;
  30538. protected _webvrViewMatrix: Matrix;
  30539. /** @hidden */
  30540. _skipRendering: boolean;
  30541. /** @hidden */
  30542. _projectionMatrix: Matrix;
  30543. /** @hidden */
  30544. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30545. /** @hidden */
  30546. _activeMeshes: SmartArray<AbstractMesh>;
  30547. protected _globalPosition: Vector3;
  30548. /** @hidden */
  30549. _computedViewMatrix: Matrix;
  30550. private _doNotComputeProjectionMatrix;
  30551. private _transformMatrix;
  30552. private _frustumPlanes;
  30553. private _refreshFrustumPlanes;
  30554. private _storedFov;
  30555. private _stateStored;
  30556. /**
  30557. * Instantiates a new camera object.
  30558. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30559. * @see https://doc.babylonjs.com/features/cameras
  30560. * @param name Defines the name of the camera in the scene
  30561. * @param position Defines the position of the camera
  30562. * @param scene Defines the scene the camera belongs too
  30563. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30564. */
  30565. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30566. /**
  30567. * Store current camera state (fov, position, etc..)
  30568. * @returns the camera
  30569. */
  30570. storeState(): Camera;
  30571. /**
  30572. * Restores the camera state values if it has been stored. You must call storeState() first
  30573. */
  30574. protected _restoreStateValues(): boolean;
  30575. /**
  30576. * Restored camera state. You must call storeState() first.
  30577. * @returns true if restored and false otherwise
  30578. */
  30579. restoreState(): boolean;
  30580. /**
  30581. * Gets the class name of the camera.
  30582. * @returns the class name
  30583. */
  30584. getClassName(): string;
  30585. /** @hidden */
  30586. readonly _isCamera: boolean;
  30587. /**
  30588. * Gets a string representation of the camera useful for debug purpose.
  30589. * @param fullDetails Defines that a more verboe level of logging is required
  30590. * @returns the string representation
  30591. */
  30592. toString(fullDetails?: boolean): string;
  30593. /**
  30594. * Gets the current world space position of the camera.
  30595. */
  30596. get globalPosition(): Vector3;
  30597. /**
  30598. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30599. * @returns the active meshe list
  30600. */
  30601. getActiveMeshes(): SmartArray<AbstractMesh>;
  30602. /**
  30603. * Check whether a mesh is part of the current active mesh list of the camera
  30604. * @param mesh Defines the mesh to check
  30605. * @returns true if active, false otherwise
  30606. */
  30607. isActiveMesh(mesh: Mesh): boolean;
  30608. /**
  30609. * Is this camera ready to be used/rendered
  30610. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30611. * @return true if the camera is ready
  30612. */
  30613. isReady(completeCheck?: boolean): boolean;
  30614. /** @hidden */
  30615. _initCache(): void;
  30616. /** @hidden */
  30617. _updateCache(ignoreParentClass?: boolean): void;
  30618. /** @hidden */
  30619. _isSynchronized(): boolean;
  30620. /** @hidden */
  30621. _isSynchronizedViewMatrix(): boolean;
  30622. /** @hidden */
  30623. _isSynchronizedProjectionMatrix(): boolean;
  30624. /**
  30625. * Attach the input controls to a specific dom element to get the input from.
  30626. * @param element Defines the element the controls should be listened from
  30627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30628. */
  30629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30630. /**
  30631. * Detach the current controls from the specified dom element.
  30632. * @param element Defines the element to stop listening the inputs from
  30633. */
  30634. detachControl(element: HTMLElement): void;
  30635. /**
  30636. * Update the camera state according to the different inputs gathered during the frame.
  30637. */
  30638. update(): void;
  30639. /** @hidden */
  30640. _checkInputs(): void;
  30641. /** @hidden */
  30642. get rigCameras(): Camera[];
  30643. /**
  30644. * Gets the post process used by the rig cameras
  30645. */
  30646. get rigPostProcess(): Nullable<PostProcess>;
  30647. /**
  30648. * Internal, gets the first post proces.
  30649. * @returns the first post process to be run on this camera.
  30650. */
  30651. _getFirstPostProcess(): Nullable<PostProcess>;
  30652. private _cascadePostProcessesToRigCams;
  30653. /**
  30654. * Attach a post process to the camera.
  30655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30656. * @param postProcess The post process to attach to the camera
  30657. * @param insertAt The position of the post process in case several of them are in use in the scene
  30658. * @returns the position the post process has been inserted at
  30659. */
  30660. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30661. /**
  30662. * Detach a post process to the camera.
  30663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30664. * @param postProcess The post process to detach from the camera
  30665. */
  30666. detachPostProcess(postProcess: PostProcess): void;
  30667. /**
  30668. * Gets the current world matrix of the camera
  30669. */
  30670. getWorldMatrix(): Matrix;
  30671. /** @hidden */
  30672. _getViewMatrix(): Matrix;
  30673. /**
  30674. * Gets the current view matrix of the camera.
  30675. * @param force forces the camera to recompute the matrix without looking at the cached state
  30676. * @returns the view matrix
  30677. */
  30678. getViewMatrix(force?: boolean): Matrix;
  30679. /**
  30680. * Freeze the projection matrix.
  30681. * It will prevent the cache check of the camera projection compute and can speed up perf
  30682. * if no parameter of the camera are meant to change
  30683. * @param projection Defines manually a projection if necessary
  30684. */
  30685. freezeProjectionMatrix(projection?: Matrix): void;
  30686. /**
  30687. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30688. */
  30689. unfreezeProjectionMatrix(): void;
  30690. /**
  30691. * Gets the current projection matrix of the camera.
  30692. * @param force forces the camera to recompute the matrix without looking at the cached state
  30693. * @returns the projection matrix
  30694. */
  30695. getProjectionMatrix(force?: boolean): Matrix;
  30696. /**
  30697. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30698. * @returns a Matrix
  30699. */
  30700. getTransformationMatrix(): Matrix;
  30701. private _updateFrustumPlanes;
  30702. /**
  30703. * Checks if a cullable object (mesh...) is in the camera frustum
  30704. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30705. * @param target The object to check
  30706. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30707. * @returns true if the object is in frustum otherwise false
  30708. */
  30709. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30710. /**
  30711. * Checks if a cullable object (mesh...) is in the camera frustum
  30712. * Unlike isInFrustum this cheks the full bounding box
  30713. * @param target The object to check
  30714. * @returns true if the object is in frustum otherwise false
  30715. */
  30716. isCompletelyInFrustum(target: ICullable): boolean;
  30717. /**
  30718. * Gets a ray in the forward direction from the camera.
  30719. * @param length Defines the length of the ray to create
  30720. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30721. * @param origin Defines the start point of the ray which defaults to the camera position
  30722. * @returns the forward ray
  30723. */
  30724. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30725. /**
  30726. * Gets a ray in the forward direction from the camera.
  30727. * @param refRay the ray to (re)use when setting the values
  30728. * @param length Defines the length of the ray to create
  30729. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30730. * @param origin Defines the start point of the ray which defaults to the camera position
  30731. * @returns the forward ray
  30732. */
  30733. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30734. /**
  30735. * Releases resources associated with this node.
  30736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30738. */
  30739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30740. /** @hidden */
  30741. _isLeftCamera: boolean;
  30742. /**
  30743. * Gets the left camera of a rig setup in case of Rigged Camera
  30744. */
  30745. get isLeftCamera(): boolean;
  30746. /** @hidden */
  30747. _isRightCamera: boolean;
  30748. /**
  30749. * Gets the right camera of a rig setup in case of Rigged Camera
  30750. */
  30751. get isRightCamera(): boolean;
  30752. /**
  30753. * Gets the left camera of a rig setup in case of Rigged Camera
  30754. */
  30755. get leftCamera(): Nullable<FreeCamera>;
  30756. /**
  30757. * Gets the right camera of a rig setup in case of Rigged Camera
  30758. */
  30759. get rightCamera(): Nullable<FreeCamera>;
  30760. /**
  30761. * Gets the left camera target of a rig setup in case of Rigged Camera
  30762. * @returns the target position
  30763. */
  30764. getLeftTarget(): Nullable<Vector3>;
  30765. /**
  30766. * Gets the right camera target of a rig setup in case of Rigged Camera
  30767. * @returns the target position
  30768. */
  30769. getRightTarget(): Nullable<Vector3>;
  30770. /**
  30771. * @hidden
  30772. */
  30773. setCameraRigMode(mode: number, rigParams: any): void;
  30774. /** @hidden */
  30775. static _setStereoscopicRigMode(camera: Camera): void;
  30776. /** @hidden */
  30777. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30778. /** @hidden */
  30779. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30780. /** @hidden */
  30781. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30782. /** @hidden */
  30783. _getVRProjectionMatrix(): Matrix;
  30784. protected _updateCameraRotationMatrix(): void;
  30785. protected _updateWebVRCameraRotationMatrix(): void;
  30786. /**
  30787. * This function MUST be overwritten by the different WebVR cameras available.
  30788. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30789. * @hidden
  30790. */
  30791. _getWebVRProjectionMatrix(): Matrix;
  30792. /**
  30793. * This function MUST be overwritten by the different WebVR cameras available.
  30794. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30795. * @hidden
  30796. */
  30797. _getWebVRViewMatrix(): Matrix;
  30798. /** @hidden */
  30799. setCameraRigParameter(name: string, value: any): void;
  30800. /**
  30801. * needs to be overridden by children so sub has required properties to be copied
  30802. * @hidden
  30803. */
  30804. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30805. /**
  30806. * May need to be overridden by children
  30807. * @hidden
  30808. */
  30809. _updateRigCameras(): void;
  30810. /** @hidden */
  30811. _setupInputs(): void;
  30812. /**
  30813. * Serialiaze the camera setup to a json represention
  30814. * @returns the JSON representation
  30815. */
  30816. serialize(): any;
  30817. /**
  30818. * Clones the current camera.
  30819. * @param name The cloned camera name
  30820. * @returns the cloned camera
  30821. */
  30822. clone(name: string): Camera;
  30823. /**
  30824. * Gets the direction of the camera relative to a given local axis.
  30825. * @param localAxis Defines the reference axis to provide a relative direction.
  30826. * @return the direction
  30827. */
  30828. getDirection(localAxis: Vector3): Vector3;
  30829. /**
  30830. * Returns the current camera absolute rotation
  30831. */
  30832. get absoluteRotation(): Quaternion;
  30833. /**
  30834. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30835. * @param localAxis Defines the reference axis to provide a relative direction.
  30836. * @param result Defines the vector to store the result in
  30837. */
  30838. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30839. /**
  30840. * Gets a camera constructor for a given camera type
  30841. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30842. * @param name The name of the camera the result will be able to instantiate
  30843. * @param scene The scene the result will construct the camera in
  30844. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30845. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30846. * @returns a factory method to construc the camera
  30847. */
  30848. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30849. /**
  30850. * Compute the world matrix of the camera.
  30851. * @returns the camera world matrix
  30852. */
  30853. computeWorldMatrix(): Matrix;
  30854. /**
  30855. * Parse a JSON and creates the camera from the parsed information
  30856. * @param parsedCamera The JSON to parse
  30857. * @param scene The scene to instantiate the camera in
  30858. * @returns the newly constructed camera
  30859. */
  30860. static Parse(parsedCamera: any, scene: Scene): Camera;
  30861. }
  30862. }
  30863. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30864. import { Nullable } from "babylonjs/types";
  30865. import { Scene } from "babylonjs/scene";
  30866. import { Vector4 } from "babylonjs/Maths/math.vector";
  30867. import { Mesh } from "babylonjs/Meshes/mesh";
  30868. /**
  30869. * Class containing static functions to help procedurally build meshes
  30870. */
  30871. export class DiscBuilder {
  30872. /**
  30873. * Creates a plane polygonal mesh. By default, this is a disc
  30874. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30875. * * 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
  30876. * * 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
  30877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30880. * @param name defines the name of the mesh
  30881. * @param options defines the options used to create the mesh
  30882. * @param scene defines the hosting scene
  30883. * @returns the plane polygonal mesh
  30884. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30885. */
  30886. static CreateDisc(name: string, options: {
  30887. radius?: number;
  30888. tessellation?: number;
  30889. arc?: number;
  30890. updatable?: boolean;
  30891. sideOrientation?: number;
  30892. frontUVs?: Vector4;
  30893. backUVs?: Vector4;
  30894. }, scene?: Nullable<Scene>): Mesh;
  30895. }
  30896. }
  30897. declare module "babylonjs/Materials/fresnelParameters" {
  30898. import { DeepImmutable } from "babylonjs/types";
  30899. import { Color3 } from "babylonjs/Maths/math.color";
  30900. /**
  30901. * Options to be used when creating a FresnelParameters.
  30902. */
  30903. export type IFresnelParametersCreationOptions = {
  30904. /**
  30905. * Define the color used on edges (grazing angle)
  30906. */
  30907. leftColor?: Color3;
  30908. /**
  30909. * Define the color used on center
  30910. */
  30911. rightColor?: Color3;
  30912. /**
  30913. * Define bias applied to computed fresnel term
  30914. */
  30915. bias?: number;
  30916. /**
  30917. * Defined the power exponent applied to fresnel term
  30918. */
  30919. power?: number;
  30920. /**
  30921. * Define if the fresnel effect is enable or not.
  30922. */
  30923. isEnabled?: boolean;
  30924. };
  30925. /**
  30926. * Serialized format for FresnelParameters.
  30927. */
  30928. export type IFresnelParametersSerialized = {
  30929. /**
  30930. * Define the color used on edges (grazing angle) [as an array]
  30931. */
  30932. leftColor: number[];
  30933. /**
  30934. * Define the color used on center [as an array]
  30935. */
  30936. rightColor: number[];
  30937. /**
  30938. * Define bias applied to computed fresnel term
  30939. */
  30940. bias: number;
  30941. /**
  30942. * Defined the power exponent applied to fresnel term
  30943. */
  30944. power?: number;
  30945. /**
  30946. * Define if the fresnel effect is enable or not.
  30947. */
  30948. isEnabled: boolean;
  30949. };
  30950. /**
  30951. * This represents all the required information to add a fresnel effect on a material:
  30952. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30953. */
  30954. export class FresnelParameters {
  30955. private _isEnabled;
  30956. /**
  30957. * Define if the fresnel effect is enable or not.
  30958. */
  30959. get isEnabled(): boolean;
  30960. set isEnabled(value: boolean);
  30961. /**
  30962. * Define the color used on edges (grazing angle)
  30963. */
  30964. leftColor: Color3;
  30965. /**
  30966. * Define the color used on center
  30967. */
  30968. rightColor: Color3;
  30969. /**
  30970. * Define bias applied to computed fresnel term
  30971. */
  30972. bias: number;
  30973. /**
  30974. * Defined the power exponent applied to fresnel term
  30975. */
  30976. power: number;
  30977. /**
  30978. * Creates a new FresnelParameters object.
  30979. *
  30980. * @param options provide your own settings to optionally to override defaults
  30981. */
  30982. constructor(options?: IFresnelParametersCreationOptions);
  30983. /**
  30984. * Clones the current fresnel and its valuues
  30985. * @returns a clone fresnel configuration
  30986. */
  30987. clone(): FresnelParameters;
  30988. /**
  30989. * Determines equality between FresnelParameters objects
  30990. * @param otherFresnelParameters defines the second operand
  30991. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30992. */
  30993. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30994. /**
  30995. * Serializes the current fresnel parameters to a JSON representation.
  30996. * @return the JSON serialization
  30997. */
  30998. serialize(): IFresnelParametersSerialized;
  30999. /**
  31000. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31001. * @param parsedFresnelParameters Define the JSON representation
  31002. * @returns the parsed parameters
  31003. */
  31004. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31005. }
  31006. }
  31007. declare module "babylonjs/Materials/materialFlags" {
  31008. /**
  31009. * This groups all the flags used to control the materials channel.
  31010. */
  31011. export class MaterialFlags {
  31012. private static _DiffuseTextureEnabled;
  31013. /**
  31014. * Are diffuse textures enabled in the application.
  31015. */
  31016. static get DiffuseTextureEnabled(): boolean;
  31017. static set DiffuseTextureEnabled(value: boolean);
  31018. private static _DetailTextureEnabled;
  31019. /**
  31020. * Are detail textures enabled in the application.
  31021. */
  31022. static get DetailTextureEnabled(): boolean;
  31023. static set DetailTextureEnabled(value: boolean);
  31024. private static _AmbientTextureEnabled;
  31025. /**
  31026. * Are ambient textures enabled in the application.
  31027. */
  31028. static get AmbientTextureEnabled(): boolean;
  31029. static set AmbientTextureEnabled(value: boolean);
  31030. private static _OpacityTextureEnabled;
  31031. /**
  31032. * Are opacity textures enabled in the application.
  31033. */
  31034. static get OpacityTextureEnabled(): boolean;
  31035. static set OpacityTextureEnabled(value: boolean);
  31036. private static _ReflectionTextureEnabled;
  31037. /**
  31038. * Are reflection textures enabled in the application.
  31039. */
  31040. static get ReflectionTextureEnabled(): boolean;
  31041. static set ReflectionTextureEnabled(value: boolean);
  31042. private static _EmissiveTextureEnabled;
  31043. /**
  31044. * Are emissive textures enabled in the application.
  31045. */
  31046. static get EmissiveTextureEnabled(): boolean;
  31047. static set EmissiveTextureEnabled(value: boolean);
  31048. private static _SpecularTextureEnabled;
  31049. /**
  31050. * Are specular textures enabled in the application.
  31051. */
  31052. static get SpecularTextureEnabled(): boolean;
  31053. static set SpecularTextureEnabled(value: boolean);
  31054. private static _BumpTextureEnabled;
  31055. /**
  31056. * Are bump textures enabled in the application.
  31057. */
  31058. static get BumpTextureEnabled(): boolean;
  31059. static set BumpTextureEnabled(value: boolean);
  31060. private static _LightmapTextureEnabled;
  31061. /**
  31062. * Are lightmap textures enabled in the application.
  31063. */
  31064. static get LightmapTextureEnabled(): boolean;
  31065. static set LightmapTextureEnabled(value: boolean);
  31066. private static _RefractionTextureEnabled;
  31067. /**
  31068. * Are refraction textures enabled in the application.
  31069. */
  31070. static get RefractionTextureEnabled(): boolean;
  31071. static set RefractionTextureEnabled(value: boolean);
  31072. private static _ColorGradingTextureEnabled;
  31073. /**
  31074. * Are color grading textures enabled in the application.
  31075. */
  31076. static get ColorGradingTextureEnabled(): boolean;
  31077. static set ColorGradingTextureEnabled(value: boolean);
  31078. private static _FresnelEnabled;
  31079. /**
  31080. * Are fresnels enabled in the application.
  31081. */
  31082. static get FresnelEnabled(): boolean;
  31083. static set FresnelEnabled(value: boolean);
  31084. private static _ClearCoatTextureEnabled;
  31085. /**
  31086. * Are clear coat textures enabled in the application.
  31087. */
  31088. static get ClearCoatTextureEnabled(): boolean;
  31089. static set ClearCoatTextureEnabled(value: boolean);
  31090. private static _ClearCoatBumpTextureEnabled;
  31091. /**
  31092. * Are clear coat bump textures enabled in the application.
  31093. */
  31094. static get ClearCoatBumpTextureEnabled(): boolean;
  31095. static set ClearCoatBumpTextureEnabled(value: boolean);
  31096. private static _ClearCoatTintTextureEnabled;
  31097. /**
  31098. * Are clear coat tint textures enabled in the application.
  31099. */
  31100. static get ClearCoatTintTextureEnabled(): boolean;
  31101. static set ClearCoatTintTextureEnabled(value: boolean);
  31102. private static _SheenTextureEnabled;
  31103. /**
  31104. * Are sheen textures enabled in the application.
  31105. */
  31106. static get SheenTextureEnabled(): boolean;
  31107. static set SheenTextureEnabled(value: boolean);
  31108. private static _AnisotropicTextureEnabled;
  31109. /**
  31110. * Are anisotropic textures enabled in the application.
  31111. */
  31112. static get AnisotropicTextureEnabled(): boolean;
  31113. static set AnisotropicTextureEnabled(value: boolean);
  31114. private static _ThicknessTextureEnabled;
  31115. /**
  31116. * Are thickness textures enabled in the application.
  31117. */
  31118. static get ThicknessTextureEnabled(): boolean;
  31119. static set ThicknessTextureEnabled(value: boolean);
  31120. }
  31121. }
  31122. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31123. /** @hidden */
  31124. export var defaultFragmentDeclaration: {
  31125. name: string;
  31126. shader: string;
  31127. };
  31128. }
  31129. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31130. /** @hidden */
  31131. export var defaultUboDeclaration: {
  31132. name: string;
  31133. shader: string;
  31134. };
  31135. }
  31136. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31137. /** @hidden */
  31138. export var prePassDeclaration: {
  31139. name: string;
  31140. shader: string;
  31141. };
  31142. }
  31143. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31144. /** @hidden */
  31145. export var lightFragmentDeclaration: {
  31146. name: string;
  31147. shader: string;
  31148. };
  31149. }
  31150. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31151. /** @hidden */
  31152. export var lightUboDeclaration: {
  31153. name: string;
  31154. shader: string;
  31155. };
  31156. }
  31157. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31158. /** @hidden */
  31159. export var lightsFragmentFunctions: {
  31160. name: string;
  31161. shader: string;
  31162. };
  31163. }
  31164. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31165. /** @hidden */
  31166. export var shadowsFragmentFunctions: {
  31167. name: string;
  31168. shader: string;
  31169. };
  31170. }
  31171. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31172. /** @hidden */
  31173. export var fresnelFunction: {
  31174. name: string;
  31175. shader: string;
  31176. };
  31177. }
  31178. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31179. /** @hidden */
  31180. export var bumpFragmentMainFunctions: {
  31181. name: string;
  31182. shader: string;
  31183. };
  31184. }
  31185. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31186. /** @hidden */
  31187. export var bumpFragmentFunctions: {
  31188. name: string;
  31189. shader: string;
  31190. };
  31191. }
  31192. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31193. /** @hidden */
  31194. export var logDepthDeclaration: {
  31195. name: string;
  31196. shader: string;
  31197. };
  31198. }
  31199. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31200. /** @hidden */
  31201. export var bumpFragment: {
  31202. name: string;
  31203. shader: string;
  31204. };
  31205. }
  31206. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31207. /** @hidden */
  31208. export var depthPrePass: {
  31209. name: string;
  31210. shader: string;
  31211. };
  31212. }
  31213. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31214. /** @hidden */
  31215. export var lightFragment: {
  31216. name: string;
  31217. shader: string;
  31218. };
  31219. }
  31220. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31221. /** @hidden */
  31222. export var logDepthFragment: {
  31223. name: string;
  31224. shader: string;
  31225. };
  31226. }
  31227. declare module "babylonjs/Shaders/default.fragment" {
  31228. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31229. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31230. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31231. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31232. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31233. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31234. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31235. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31236. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31237. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31238. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31239. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31240. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31241. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31242. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31243. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31244. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31245. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31246. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31247. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31248. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31249. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31250. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31251. /** @hidden */
  31252. export var defaultPixelShader: {
  31253. name: string;
  31254. shader: string;
  31255. };
  31256. }
  31257. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31258. /** @hidden */
  31259. export var defaultVertexDeclaration: {
  31260. name: string;
  31261. shader: string;
  31262. };
  31263. }
  31264. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31265. /** @hidden */
  31266. export var bumpVertexDeclaration: {
  31267. name: string;
  31268. shader: string;
  31269. };
  31270. }
  31271. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31272. /** @hidden */
  31273. export var bumpVertex: {
  31274. name: string;
  31275. shader: string;
  31276. };
  31277. }
  31278. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31279. /** @hidden */
  31280. export var fogVertex: {
  31281. name: string;
  31282. shader: string;
  31283. };
  31284. }
  31285. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31286. /** @hidden */
  31287. export var shadowsVertex: {
  31288. name: string;
  31289. shader: string;
  31290. };
  31291. }
  31292. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31293. /** @hidden */
  31294. export var pointCloudVertex: {
  31295. name: string;
  31296. shader: string;
  31297. };
  31298. }
  31299. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31300. /** @hidden */
  31301. export var logDepthVertex: {
  31302. name: string;
  31303. shader: string;
  31304. };
  31305. }
  31306. declare module "babylonjs/Shaders/default.vertex" {
  31307. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31308. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31309. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31310. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31311. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31312. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31313. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31314. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31315. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31316. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31319. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31320. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31321. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31322. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31323. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31324. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31325. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31326. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31327. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31328. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31329. /** @hidden */
  31330. export var defaultVertexShader: {
  31331. name: string;
  31332. shader: string;
  31333. };
  31334. }
  31335. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31336. import { Nullable } from "babylonjs/types";
  31337. import { Scene } from "babylonjs/scene";
  31338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31339. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31340. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31341. /**
  31342. * @hidden
  31343. */
  31344. export interface IMaterialDetailMapDefines {
  31345. DETAIL: boolean;
  31346. DETAILDIRECTUV: number;
  31347. DETAIL_NORMALBLENDMETHOD: number;
  31348. /** @hidden */
  31349. _areTexturesDirty: boolean;
  31350. }
  31351. /**
  31352. * Define the code related to the detail map parameters of a material
  31353. *
  31354. * Inspired from:
  31355. * 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
  31356. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31357. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31358. */
  31359. export class DetailMapConfiguration {
  31360. private _texture;
  31361. /**
  31362. * The detail texture of the material.
  31363. */
  31364. texture: Nullable<BaseTexture>;
  31365. /**
  31366. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31367. * Bigger values mean stronger blending
  31368. */
  31369. diffuseBlendLevel: number;
  31370. /**
  31371. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31372. * Bigger values mean stronger blending. Only used with PBR materials
  31373. */
  31374. roughnessBlendLevel: number;
  31375. /**
  31376. * Defines how strong the bump effect from the detail map is
  31377. * Bigger values mean stronger effect
  31378. */
  31379. bumpLevel: number;
  31380. private _normalBlendMethod;
  31381. /**
  31382. * The method used to blend the bump and detail normals together
  31383. */
  31384. normalBlendMethod: number;
  31385. private _isEnabled;
  31386. /**
  31387. * Enable or disable the detail map on this material
  31388. */
  31389. isEnabled: boolean;
  31390. /** @hidden */
  31391. private _internalMarkAllSubMeshesAsTexturesDirty;
  31392. /** @hidden */
  31393. _markAllSubMeshesAsTexturesDirty(): void;
  31394. /**
  31395. * Instantiate a new detail map
  31396. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31397. */
  31398. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31399. /**
  31400. * Gets whether the submesh is ready to be used or not.
  31401. * @param defines the list of "defines" to update.
  31402. * @param scene defines the scene the material belongs to.
  31403. * @returns - boolean indicating that the submesh is ready or not.
  31404. */
  31405. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31406. /**
  31407. * Update the defines for detail map usage
  31408. * @param defines the list of "defines" to update.
  31409. * @param scene defines the scene the material belongs to.
  31410. */
  31411. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31412. /**
  31413. * Binds the material data.
  31414. * @param uniformBuffer defines the Uniform buffer to fill in.
  31415. * @param scene defines the scene the material belongs to.
  31416. * @param isFrozen defines whether the material is frozen or not.
  31417. */
  31418. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31419. /**
  31420. * Checks to see if a texture is used in the material.
  31421. * @param texture - Base texture to use.
  31422. * @returns - Boolean specifying if a texture is used in the material.
  31423. */
  31424. hasTexture(texture: BaseTexture): boolean;
  31425. /**
  31426. * Returns an array of the actively used textures.
  31427. * @param activeTextures Array of BaseTextures
  31428. */
  31429. getActiveTextures(activeTextures: BaseTexture[]): void;
  31430. /**
  31431. * Returns the animatable textures.
  31432. * @param animatables Array of animatable textures.
  31433. */
  31434. getAnimatables(animatables: IAnimatable[]): void;
  31435. /**
  31436. * Disposes the resources of the material.
  31437. * @param forceDisposeTextures - Forces the disposal of all textures.
  31438. */
  31439. dispose(forceDisposeTextures?: boolean): void;
  31440. /**
  31441. * Get the current class name useful for serialization or dynamic coding.
  31442. * @returns "DetailMap"
  31443. */
  31444. getClassName(): string;
  31445. /**
  31446. * Add the required uniforms to the current list.
  31447. * @param uniforms defines the current uniform list.
  31448. */
  31449. static AddUniforms(uniforms: string[]): void;
  31450. /**
  31451. * Add the required samplers to the current list.
  31452. * @param samplers defines the current sampler list.
  31453. */
  31454. static AddSamplers(samplers: string[]): void;
  31455. /**
  31456. * Add the required uniforms to the current buffer.
  31457. * @param uniformBuffer defines the current uniform buffer.
  31458. */
  31459. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31460. /**
  31461. * Makes a duplicate of the current instance into another one.
  31462. * @param detailMap define the instance where to copy the info
  31463. */
  31464. copyTo(detailMap: DetailMapConfiguration): void;
  31465. /**
  31466. * Serializes this detail map instance
  31467. * @returns - An object with the serialized instance.
  31468. */
  31469. serialize(): any;
  31470. /**
  31471. * Parses a detail map setting from a serialized object.
  31472. * @param source - Serialized object.
  31473. * @param scene Defines the scene we are parsing for
  31474. * @param rootUrl Defines the rootUrl to load from
  31475. */
  31476. parse(source: any, scene: Scene, rootUrl: string): void;
  31477. }
  31478. }
  31479. declare module "babylonjs/Materials/standardMaterial" {
  31480. import { SmartArray } from "babylonjs/Misc/smartArray";
  31481. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31482. import { Nullable } from "babylonjs/types";
  31483. import { Scene } from "babylonjs/scene";
  31484. import { Matrix } from "babylonjs/Maths/math.vector";
  31485. import { Color3 } from "babylonjs/Maths/math.color";
  31486. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31488. import { Mesh } from "babylonjs/Meshes/mesh";
  31489. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31490. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31491. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31492. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31493. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31496. import "babylonjs/Shaders/default.fragment";
  31497. import "babylonjs/Shaders/default.vertex";
  31498. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31499. /** @hidden */
  31500. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31501. MAINUV1: boolean;
  31502. MAINUV2: boolean;
  31503. DIFFUSE: boolean;
  31504. DIFFUSEDIRECTUV: number;
  31505. DETAIL: boolean;
  31506. DETAILDIRECTUV: number;
  31507. DETAIL_NORMALBLENDMETHOD: number;
  31508. AMBIENT: boolean;
  31509. AMBIENTDIRECTUV: number;
  31510. OPACITY: boolean;
  31511. OPACITYDIRECTUV: number;
  31512. OPACITYRGB: boolean;
  31513. REFLECTION: boolean;
  31514. EMISSIVE: boolean;
  31515. EMISSIVEDIRECTUV: number;
  31516. SPECULAR: boolean;
  31517. SPECULARDIRECTUV: number;
  31518. BUMP: boolean;
  31519. BUMPDIRECTUV: number;
  31520. PARALLAX: boolean;
  31521. PARALLAXOCCLUSION: boolean;
  31522. SPECULAROVERALPHA: boolean;
  31523. CLIPPLANE: boolean;
  31524. CLIPPLANE2: boolean;
  31525. CLIPPLANE3: boolean;
  31526. CLIPPLANE4: boolean;
  31527. CLIPPLANE5: boolean;
  31528. CLIPPLANE6: boolean;
  31529. ALPHATEST: boolean;
  31530. DEPTHPREPASS: boolean;
  31531. ALPHAFROMDIFFUSE: boolean;
  31532. POINTSIZE: boolean;
  31533. FOG: boolean;
  31534. SPECULARTERM: boolean;
  31535. DIFFUSEFRESNEL: boolean;
  31536. OPACITYFRESNEL: boolean;
  31537. REFLECTIONFRESNEL: boolean;
  31538. REFRACTIONFRESNEL: boolean;
  31539. EMISSIVEFRESNEL: boolean;
  31540. FRESNEL: boolean;
  31541. NORMAL: boolean;
  31542. UV1: boolean;
  31543. UV2: boolean;
  31544. VERTEXCOLOR: boolean;
  31545. VERTEXALPHA: boolean;
  31546. NUM_BONE_INFLUENCERS: number;
  31547. BonesPerMesh: number;
  31548. BONETEXTURE: boolean;
  31549. INSTANCES: boolean;
  31550. THIN_INSTANCES: boolean;
  31551. GLOSSINESS: boolean;
  31552. ROUGHNESS: boolean;
  31553. EMISSIVEASILLUMINATION: boolean;
  31554. LINKEMISSIVEWITHDIFFUSE: boolean;
  31555. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31556. LIGHTMAP: boolean;
  31557. LIGHTMAPDIRECTUV: number;
  31558. OBJECTSPACE_NORMALMAP: boolean;
  31559. USELIGHTMAPASSHADOWMAP: boolean;
  31560. REFLECTIONMAP_3D: boolean;
  31561. REFLECTIONMAP_SPHERICAL: boolean;
  31562. REFLECTIONMAP_PLANAR: boolean;
  31563. REFLECTIONMAP_CUBIC: boolean;
  31564. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31565. REFLECTIONMAP_PROJECTION: boolean;
  31566. REFLECTIONMAP_SKYBOX: boolean;
  31567. REFLECTIONMAP_EXPLICIT: boolean;
  31568. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31569. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31570. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31571. INVERTCUBICMAP: boolean;
  31572. LOGARITHMICDEPTH: boolean;
  31573. REFRACTION: boolean;
  31574. REFRACTIONMAP_3D: boolean;
  31575. REFLECTIONOVERALPHA: boolean;
  31576. TWOSIDEDLIGHTING: boolean;
  31577. SHADOWFLOAT: boolean;
  31578. MORPHTARGETS: boolean;
  31579. MORPHTARGETS_NORMAL: boolean;
  31580. MORPHTARGETS_TANGENT: boolean;
  31581. MORPHTARGETS_UV: boolean;
  31582. NUM_MORPH_INFLUENCERS: number;
  31583. NONUNIFORMSCALING: boolean;
  31584. PREMULTIPLYALPHA: boolean;
  31585. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31586. ALPHABLEND: boolean;
  31587. PREPASS: boolean;
  31588. SCENE_MRT_COUNT: number;
  31589. RGBDLIGHTMAP: boolean;
  31590. RGBDREFLECTION: boolean;
  31591. RGBDREFRACTION: boolean;
  31592. IMAGEPROCESSING: boolean;
  31593. VIGNETTE: boolean;
  31594. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31595. VIGNETTEBLENDMODEOPAQUE: boolean;
  31596. TONEMAPPING: boolean;
  31597. TONEMAPPING_ACES: boolean;
  31598. CONTRAST: boolean;
  31599. COLORCURVES: boolean;
  31600. COLORGRADING: boolean;
  31601. COLORGRADING3D: boolean;
  31602. SAMPLER3DGREENDEPTH: boolean;
  31603. SAMPLER3DBGRMAP: boolean;
  31604. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31605. MULTIVIEW: boolean;
  31606. /**
  31607. * If the reflection texture on this material is in linear color space
  31608. * @hidden
  31609. */
  31610. IS_REFLECTION_LINEAR: boolean;
  31611. /**
  31612. * If the refraction texture on this material is in linear color space
  31613. * @hidden
  31614. */
  31615. IS_REFRACTION_LINEAR: boolean;
  31616. EXPOSURE: boolean;
  31617. constructor();
  31618. setReflectionMode(modeToEnable: string): void;
  31619. }
  31620. /**
  31621. * This is the default material used in Babylon. It is the best trade off between quality
  31622. * and performances.
  31623. * @see https://doc.babylonjs.com/babylon101/materials
  31624. */
  31625. export class StandardMaterial extends PushMaterial {
  31626. private _diffuseTexture;
  31627. /**
  31628. * The basic texture of the material as viewed under a light.
  31629. */
  31630. diffuseTexture: Nullable<BaseTexture>;
  31631. private _ambientTexture;
  31632. /**
  31633. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31634. */
  31635. ambientTexture: Nullable<BaseTexture>;
  31636. private _opacityTexture;
  31637. /**
  31638. * Define the transparency of the material from a texture.
  31639. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31640. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31641. */
  31642. opacityTexture: Nullable<BaseTexture>;
  31643. private _reflectionTexture;
  31644. /**
  31645. * Define the texture used to display the reflection.
  31646. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31647. */
  31648. reflectionTexture: Nullable<BaseTexture>;
  31649. private _emissiveTexture;
  31650. /**
  31651. * Define texture of the material as if self lit.
  31652. * This will be mixed in the final result even in the absence of light.
  31653. */
  31654. emissiveTexture: Nullable<BaseTexture>;
  31655. private _specularTexture;
  31656. /**
  31657. * Define how the color and intensity of the highlight given by the light in the material.
  31658. */
  31659. specularTexture: Nullable<BaseTexture>;
  31660. private _bumpTexture;
  31661. /**
  31662. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31663. * 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.
  31664. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31665. */
  31666. bumpTexture: Nullable<BaseTexture>;
  31667. private _lightmapTexture;
  31668. /**
  31669. * Complex lighting can be computationally expensive to compute at runtime.
  31670. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31671. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31672. */
  31673. lightmapTexture: Nullable<BaseTexture>;
  31674. private _refractionTexture;
  31675. /**
  31676. * Define the texture used to display the refraction.
  31677. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31678. */
  31679. refractionTexture: Nullable<BaseTexture>;
  31680. /**
  31681. * The color of the material lit by the environmental background lighting.
  31682. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31683. */
  31684. ambientColor: Color3;
  31685. /**
  31686. * The basic color of the material as viewed under a light.
  31687. */
  31688. diffuseColor: Color3;
  31689. /**
  31690. * Define how the color and intensity of the highlight given by the light in the material.
  31691. */
  31692. specularColor: Color3;
  31693. /**
  31694. * Define the color of the material as if self lit.
  31695. * This will be mixed in the final result even in the absence of light.
  31696. */
  31697. emissiveColor: Color3;
  31698. /**
  31699. * Defines how sharp are the highlights in the material.
  31700. * The bigger the value the sharper giving a more glossy feeling to the result.
  31701. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31702. */
  31703. specularPower: number;
  31704. private _useAlphaFromDiffuseTexture;
  31705. /**
  31706. * Does the transparency come from the diffuse texture alpha channel.
  31707. */
  31708. useAlphaFromDiffuseTexture: boolean;
  31709. private _useEmissiveAsIllumination;
  31710. /**
  31711. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31712. */
  31713. useEmissiveAsIllumination: boolean;
  31714. private _linkEmissiveWithDiffuse;
  31715. /**
  31716. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31717. * the emissive level when the final color is close to one.
  31718. */
  31719. linkEmissiveWithDiffuse: boolean;
  31720. private _useSpecularOverAlpha;
  31721. /**
  31722. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31723. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31724. */
  31725. useSpecularOverAlpha: boolean;
  31726. private _useReflectionOverAlpha;
  31727. /**
  31728. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31729. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31730. */
  31731. useReflectionOverAlpha: boolean;
  31732. private _disableLighting;
  31733. /**
  31734. * Does lights from the scene impacts this material.
  31735. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31736. */
  31737. disableLighting: boolean;
  31738. private _useObjectSpaceNormalMap;
  31739. /**
  31740. * Allows using an object space normal map (instead of tangent space).
  31741. */
  31742. useObjectSpaceNormalMap: boolean;
  31743. private _useParallax;
  31744. /**
  31745. * Is parallax enabled or not.
  31746. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31747. */
  31748. useParallax: boolean;
  31749. private _useParallaxOcclusion;
  31750. /**
  31751. * Is parallax occlusion enabled or not.
  31752. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31753. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31754. */
  31755. useParallaxOcclusion: boolean;
  31756. /**
  31757. * 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.
  31758. */
  31759. parallaxScaleBias: number;
  31760. private _roughness;
  31761. /**
  31762. * Helps to define how blurry the reflections should appears in the material.
  31763. */
  31764. roughness: number;
  31765. /**
  31766. * In case of refraction, define the value of the index of refraction.
  31767. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31768. */
  31769. indexOfRefraction: number;
  31770. /**
  31771. * Invert the refraction texture alongside the y axis.
  31772. * It can be useful with procedural textures or probe for instance.
  31773. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31774. */
  31775. invertRefractionY: boolean;
  31776. /**
  31777. * Defines the alpha limits in alpha test mode.
  31778. */
  31779. alphaCutOff: number;
  31780. private _useLightmapAsShadowmap;
  31781. /**
  31782. * In case of light mapping, define whether the map contains light or shadow informations.
  31783. */
  31784. useLightmapAsShadowmap: boolean;
  31785. private _diffuseFresnelParameters;
  31786. /**
  31787. * Define the diffuse fresnel parameters of the material.
  31788. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31789. */
  31790. diffuseFresnelParameters: FresnelParameters;
  31791. private _opacityFresnelParameters;
  31792. /**
  31793. * Define the opacity fresnel parameters of the material.
  31794. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31795. */
  31796. opacityFresnelParameters: FresnelParameters;
  31797. private _reflectionFresnelParameters;
  31798. /**
  31799. * Define the reflection fresnel parameters of the material.
  31800. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31801. */
  31802. reflectionFresnelParameters: FresnelParameters;
  31803. private _refractionFresnelParameters;
  31804. /**
  31805. * Define the refraction fresnel parameters of the material.
  31806. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31807. */
  31808. refractionFresnelParameters: FresnelParameters;
  31809. private _emissiveFresnelParameters;
  31810. /**
  31811. * Define the emissive fresnel parameters of the material.
  31812. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31813. */
  31814. emissiveFresnelParameters: FresnelParameters;
  31815. private _useReflectionFresnelFromSpecular;
  31816. /**
  31817. * If true automatically deducts the fresnels values from the material specularity.
  31818. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31819. */
  31820. useReflectionFresnelFromSpecular: boolean;
  31821. private _useGlossinessFromSpecularMapAlpha;
  31822. /**
  31823. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31824. */
  31825. useGlossinessFromSpecularMapAlpha: boolean;
  31826. private _maxSimultaneousLights;
  31827. /**
  31828. * Defines the maximum number of lights that can be used in the material
  31829. */
  31830. maxSimultaneousLights: number;
  31831. private _invertNormalMapX;
  31832. /**
  31833. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31834. */
  31835. invertNormalMapX: boolean;
  31836. private _invertNormalMapY;
  31837. /**
  31838. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31839. */
  31840. invertNormalMapY: boolean;
  31841. private _twoSidedLighting;
  31842. /**
  31843. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31844. */
  31845. twoSidedLighting: boolean;
  31846. /**
  31847. * Default configuration related to image processing available in the standard Material.
  31848. */
  31849. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31850. /**
  31851. * Gets the image processing configuration used either in this material.
  31852. */
  31853. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31854. /**
  31855. * Sets the Default image processing configuration used either in the this material.
  31856. *
  31857. * If sets to null, the scene one is in use.
  31858. */
  31859. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31860. /**
  31861. * Keep track of the image processing observer to allow dispose and replace.
  31862. */
  31863. private _imageProcessingObserver;
  31864. /**
  31865. * Attaches a new image processing configuration to the Standard Material.
  31866. * @param configuration
  31867. */
  31868. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31869. /**
  31870. * Gets wether the color curves effect is enabled.
  31871. */
  31872. get cameraColorCurvesEnabled(): boolean;
  31873. /**
  31874. * Sets wether the color curves effect is enabled.
  31875. */
  31876. set cameraColorCurvesEnabled(value: boolean);
  31877. /**
  31878. * Gets wether the color grading effect is enabled.
  31879. */
  31880. get cameraColorGradingEnabled(): boolean;
  31881. /**
  31882. * Gets wether the color grading effect is enabled.
  31883. */
  31884. set cameraColorGradingEnabled(value: boolean);
  31885. /**
  31886. * Gets wether tonemapping is enabled or not.
  31887. */
  31888. get cameraToneMappingEnabled(): boolean;
  31889. /**
  31890. * Sets wether tonemapping is enabled or not
  31891. */
  31892. set cameraToneMappingEnabled(value: boolean);
  31893. /**
  31894. * The camera exposure used on this material.
  31895. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31896. * This corresponds to a photographic exposure.
  31897. */
  31898. get cameraExposure(): number;
  31899. /**
  31900. * The camera exposure used on this material.
  31901. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31902. * This corresponds to a photographic exposure.
  31903. */
  31904. set cameraExposure(value: number);
  31905. /**
  31906. * Gets The camera contrast used on this material.
  31907. */
  31908. get cameraContrast(): number;
  31909. /**
  31910. * Sets The camera contrast used on this material.
  31911. */
  31912. set cameraContrast(value: number);
  31913. /**
  31914. * Gets the Color Grading 2D Lookup Texture.
  31915. */
  31916. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31917. /**
  31918. * Sets the Color Grading 2D Lookup Texture.
  31919. */
  31920. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31921. /**
  31922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31924. * 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;
  31925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31926. */
  31927. get cameraColorCurves(): Nullable<ColorCurves>;
  31928. /**
  31929. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31930. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31931. * 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;
  31932. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31933. */
  31934. set cameraColorCurves(value: Nullable<ColorCurves>);
  31935. /**
  31936. * Can this material render to several textures at once
  31937. */
  31938. get canRenderToMRT(): boolean;
  31939. /**
  31940. * Defines the detail map parameters for the material.
  31941. */
  31942. readonly detailMap: DetailMapConfiguration;
  31943. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31944. protected _worldViewProjectionMatrix: Matrix;
  31945. protected _globalAmbientColor: Color3;
  31946. protected _useLogarithmicDepth: boolean;
  31947. protected _rebuildInParallel: boolean;
  31948. /**
  31949. * Instantiates a new standard material.
  31950. * This is the default material used in Babylon. It is the best trade off between quality
  31951. * and performances.
  31952. * @see https://doc.babylonjs.com/babylon101/materials
  31953. * @param name Define the name of the material in the scene
  31954. * @param scene Define the scene the material belong to
  31955. */
  31956. constructor(name: string, scene: Scene);
  31957. /**
  31958. * Gets a boolean indicating that current material needs to register RTT
  31959. */
  31960. get hasRenderTargetTextures(): boolean;
  31961. /**
  31962. * Gets the current class name of the material e.g. "StandardMaterial"
  31963. * Mainly use in serialization.
  31964. * @returns the class name
  31965. */
  31966. getClassName(): string;
  31967. /**
  31968. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31969. * You can try switching to logarithmic depth.
  31970. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31971. */
  31972. get useLogarithmicDepth(): boolean;
  31973. set useLogarithmicDepth(value: boolean);
  31974. /**
  31975. * Specifies if the material will require alpha blending
  31976. * @returns a boolean specifying if alpha blending is needed
  31977. */
  31978. needAlphaBlending(): boolean;
  31979. /**
  31980. * Specifies if this material should be rendered in alpha test mode
  31981. * @returns a boolean specifying if an alpha test is needed.
  31982. */
  31983. needAlphaTesting(): boolean;
  31984. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31985. /**
  31986. * Get the texture used for alpha test purpose.
  31987. * @returns the diffuse texture in case of the standard material.
  31988. */
  31989. getAlphaTestTexture(): Nullable<BaseTexture>;
  31990. /**
  31991. * Get if the submesh is ready to be used and all its information available.
  31992. * Child classes can use it to update shaders
  31993. * @param mesh defines the mesh to check
  31994. * @param subMesh defines which submesh to check
  31995. * @param useInstances specifies that instances should be used
  31996. * @returns a boolean indicating that the submesh is ready or not
  31997. */
  31998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31999. /**
  32000. * Builds the material UBO layouts.
  32001. * Used internally during the effect preparation.
  32002. */
  32003. buildUniformLayout(): void;
  32004. /**
  32005. * Unbinds the material from the mesh
  32006. */
  32007. unbind(): void;
  32008. /**
  32009. * Binds the submesh to this material by preparing the effect and shader to draw
  32010. * @param world defines the world transformation matrix
  32011. * @param mesh defines the mesh containing the submesh
  32012. * @param subMesh defines the submesh to bind the material to
  32013. */
  32014. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32015. /**
  32016. * Get the list of animatables in the material.
  32017. * @returns the list of animatables object used in the material
  32018. */
  32019. getAnimatables(): IAnimatable[];
  32020. /**
  32021. * Gets the active textures from the material
  32022. * @returns an array of textures
  32023. */
  32024. getActiveTextures(): BaseTexture[];
  32025. /**
  32026. * Specifies if the material uses a texture
  32027. * @param texture defines the texture to check against the material
  32028. * @returns a boolean specifying if the material uses the texture
  32029. */
  32030. hasTexture(texture: BaseTexture): boolean;
  32031. /**
  32032. * Disposes the material
  32033. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32034. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32035. */
  32036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32037. /**
  32038. * Makes a duplicate of the material, and gives it a new name
  32039. * @param name defines the new name for the duplicated material
  32040. * @returns the cloned material
  32041. */
  32042. clone(name: string): StandardMaterial;
  32043. /**
  32044. * Serializes this material in a JSON representation
  32045. * @returns the serialized material object
  32046. */
  32047. serialize(): any;
  32048. /**
  32049. * Creates a standard material from parsed material data
  32050. * @param source defines the JSON representation of the material
  32051. * @param scene defines the hosting scene
  32052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32053. * @returns a new standard material
  32054. */
  32055. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32056. /**
  32057. * Are diffuse textures enabled in the application.
  32058. */
  32059. static get DiffuseTextureEnabled(): boolean;
  32060. static set DiffuseTextureEnabled(value: boolean);
  32061. /**
  32062. * Are detail textures enabled in the application.
  32063. */
  32064. static get DetailTextureEnabled(): boolean;
  32065. static set DetailTextureEnabled(value: boolean);
  32066. /**
  32067. * Are ambient textures enabled in the application.
  32068. */
  32069. static get AmbientTextureEnabled(): boolean;
  32070. static set AmbientTextureEnabled(value: boolean);
  32071. /**
  32072. * Are opacity textures enabled in the application.
  32073. */
  32074. static get OpacityTextureEnabled(): boolean;
  32075. static set OpacityTextureEnabled(value: boolean);
  32076. /**
  32077. * Are reflection textures enabled in the application.
  32078. */
  32079. static get ReflectionTextureEnabled(): boolean;
  32080. static set ReflectionTextureEnabled(value: boolean);
  32081. /**
  32082. * Are emissive textures enabled in the application.
  32083. */
  32084. static get EmissiveTextureEnabled(): boolean;
  32085. static set EmissiveTextureEnabled(value: boolean);
  32086. /**
  32087. * Are specular textures enabled in the application.
  32088. */
  32089. static get SpecularTextureEnabled(): boolean;
  32090. static set SpecularTextureEnabled(value: boolean);
  32091. /**
  32092. * Are bump textures enabled in the application.
  32093. */
  32094. static get BumpTextureEnabled(): boolean;
  32095. static set BumpTextureEnabled(value: boolean);
  32096. /**
  32097. * Are lightmap textures enabled in the application.
  32098. */
  32099. static get LightmapTextureEnabled(): boolean;
  32100. static set LightmapTextureEnabled(value: boolean);
  32101. /**
  32102. * Are refraction textures enabled in the application.
  32103. */
  32104. static get RefractionTextureEnabled(): boolean;
  32105. static set RefractionTextureEnabled(value: boolean);
  32106. /**
  32107. * Are color grading textures enabled in the application.
  32108. */
  32109. static get ColorGradingTextureEnabled(): boolean;
  32110. static set ColorGradingTextureEnabled(value: boolean);
  32111. /**
  32112. * Are fresnels enabled in the application.
  32113. */
  32114. static get FresnelEnabled(): boolean;
  32115. static set FresnelEnabled(value: boolean);
  32116. }
  32117. }
  32118. declare module "babylonjs/Particles/solidParticleSystem" {
  32119. import { Nullable } from "babylonjs/types";
  32120. import { Mesh } from "babylonjs/Meshes/mesh";
  32121. import { Scene, IDisposable } from "babylonjs/scene";
  32122. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32123. import { Material } from "babylonjs/Materials/material";
  32124. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32125. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32126. /**
  32127. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32128. *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.
  32129. * The SPS is also a particle system. It provides some methods to manage the particles.
  32130. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32131. *
  32132. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32133. */
  32134. export class SolidParticleSystem implements IDisposable {
  32135. /**
  32136. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32137. * Example : var p = SPS.particles[i];
  32138. */
  32139. particles: SolidParticle[];
  32140. /**
  32141. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32142. */
  32143. nbParticles: number;
  32144. /**
  32145. * If the particles must ever face the camera (default false). Useful for planar particles.
  32146. */
  32147. billboard: boolean;
  32148. /**
  32149. * Recompute normals when adding a shape
  32150. */
  32151. recomputeNormals: boolean;
  32152. /**
  32153. * This a counter ofr your own usage. It's not set by any SPS functions.
  32154. */
  32155. counter: number;
  32156. /**
  32157. * The SPS name. This name is also given to the underlying mesh.
  32158. */
  32159. name: string;
  32160. /**
  32161. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32162. */
  32163. mesh: Mesh;
  32164. /**
  32165. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32166. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32167. */
  32168. vars: any;
  32169. /**
  32170. * This array is populated when the SPS is set as 'pickable'.
  32171. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32172. * Each element of this array is an object `{idx: int, faceId: int}`.
  32173. * `idx` is the picked particle index in the `SPS.particles` array
  32174. * `faceId` is the picked face index counted within this particle.
  32175. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32176. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32177. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32178. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32179. */
  32180. pickedParticles: {
  32181. idx: number;
  32182. faceId: number;
  32183. }[];
  32184. /**
  32185. * This array is populated when the SPS is set as 'pickable'
  32186. * Each key of this array is a submesh index.
  32187. * Each element of this array is a second array defined like this :
  32188. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32189. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32190. * `idx` is the picked particle index in the `SPS.particles` array
  32191. * `faceId` is the picked face index counted within this particle.
  32192. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32193. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32194. */
  32195. pickedBySubMesh: {
  32196. idx: number;
  32197. faceId: number;
  32198. }[][];
  32199. /**
  32200. * This array is populated when `enableDepthSort` is set to true.
  32201. * Each element of this array is an instance of the class DepthSortedParticle.
  32202. */
  32203. depthSortedParticles: DepthSortedParticle[];
  32204. /**
  32205. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32206. * @hidden
  32207. */
  32208. _bSphereOnly: boolean;
  32209. /**
  32210. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32211. * @hidden
  32212. */
  32213. _bSphereRadiusFactor: number;
  32214. private _scene;
  32215. private _positions;
  32216. private _indices;
  32217. private _normals;
  32218. private _colors;
  32219. private _uvs;
  32220. private _indices32;
  32221. private _positions32;
  32222. private _normals32;
  32223. private _fixedNormal32;
  32224. private _colors32;
  32225. private _uvs32;
  32226. private _index;
  32227. private _updatable;
  32228. private _pickable;
  32229. private _isVisibilityBoxLocked;
  32230. private _alwaysVisible;
  32231. private _depthSort;
  32232. private _expandable;
  32233. private _shapeCounter;
  32234. private _copy;
  32235. private _color;
  32236. private _computeParticleColor;
  32237. private _computeParticleTexture;
  32238. private _computeParticleRotation;
  32239. private _computeParticleVertex;
  32240. private _computeBoundingBox;
  32241. private _depthSortParticles;
  32242. private _camera;
  32243. private _mustUnrotateFixedNormals;
  32244. private _particlesIntersect;
  32245. private _needs32Bits;
  32246. private _isNotBuilt;
  32247. private _lastParticleId;
  32248. private _idxOfId;
  32249. private _multimaterialEnabled;
  32250. private _useModelMaterial;
  32251. private _indicesByMaterial;
  32252. private _materialIndexes;
  32253. private _depthSortFunction;
  32254. private _materialSortFunction;
  32255. private _materials;
  32256. private _multimaterial;
  32257. private _materialIndexesById;
  32258. private _defaultMaterial;
  32259. private _autoUpdateSubMeshes;
  32260. private _tmpVertex;
  32261. /**
  32262. * Creates a SPS (Solid Particle System) object.
  32263. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32264. * @param scene (Scene) is the scene in which the SPS is added.
  32265. * @param options defines the options of the sps e.g.
  32266. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32267. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32268. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32269. * * 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.
  32270. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32271. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32272. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32273. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32274. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32275. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32276. */
  32277. constructor(name: string, scene: Scene, options?: {
  32278. updatable?: boolean;
  32279. isPickable?: boolean;
  32280. enableDepthSort?: boolean;
  32281. particleIntersection?: boolean;
  32282. boundingSphereOnly?: boolean;
  32283. bSphereRadiusFactor?: number;
  32284. expandable?: boolean;
  32285. useModelMaterial?: boolean;
  32286. enableMultiMaterial?: boolean;
  32287. });
  32288. /**
  32289. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32290. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32291. * @returns the created mesh
  32292. */
  32293. buildMesh(): Mesh;
  32294. /**
  32295. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32296. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32297. * Thus the particles generated from `digest()` have their property `position` set yet.
  32298. * @param mesh ( Mesh ) is the mesh to be digested
  32299. * @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
  32300. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32301. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32302. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32303. * @returns the current SPS
  32304. */
  32305. digest(mesh: Mesh, options?: {
  32306. facetNb?: number;
  32307. number?: number;
  32308. delta?: number;
  32309. storage?: [];
  32310. }): SolidParticleSystem;
  32311. /**
  32312. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32313. * @hidden
  32314. */
  32315. private _unrotateFixedNormals;
  32316. /**
  32317. * Resets the temporary working copy particle
  32318. * @hidden
  32319. */
  32320. private _resetCopy;
  32321. /**
  32322. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32323. * @param p the current index in the positions array to be updated
  32324. * @param ind the current index in the indices array
  32325. * @param shape a Vector3 array, the shape geometry
  32326. * @param positions the positions array to be updated
  32327. * @param meshInd the shape indices array
  32328. * @param indices the indices array to be updated
  32329. * @param meshUV the shape uv array
  32330. * @param uvs the uv array to be updated
  32331. * @param meshCol the shape color array
  32332. * @param colors the color array to be updated
  32333. * @param meshNor the shape normals array
  32334. * @param normals the normals array to be updated
  32335. * @param idx the particle index
  32336. * @param idxInShape the particle index in its shape
  32337. * @param options the addShape() method passed options
  32338. * @model the particle model
  32339. * @hidden
  32340. */
  32341. private _meshBuilder;
  32342. /**
  32343. * Returns a shape Vector3 array from positions float array
  32344. * @param positions float array
  32345. * @returns a vector3 array
  32346. * @hidden
  32347. */
  32348. private _posToShape;
  32349. /**
  32350. * Returns a shapeUV array from a float uvs (array deep copy)
  32351. * @param uvs as a float array
  32352. * @returns a shapeUV array
  32353. * @hidden
  32354. */
  32355. private _uvsToShapeUV;
  32356. /**
  32357. * Adds a new particle object in the particles array
  32358. * @param idx particle index in particles array
  32359. * @param id particle id
  32360. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32361. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32362. * @param model particle ModelShape object
  32363. * @param shapeId model shape identifier
  32364. * @param idxInShape index of the particle in the current model
  32365. * @param bInfo model bounding info object
  32366. * @param storage target storage array, if any
  32367. * @hidden
  32368. */
  32369. private _addParticle;
  32370. /**
  32371. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32372. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32373. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32374. * @param nb (positive integer) the number of particles to be created from this model
  32375. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32376. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32377. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32378. * @returns the number of shapes in the system
  32379. */
  32380. addShape(mesh: Mesh, nb: number, options?: {
  32381. positionFunction?: any;
  32382. vertexFunction?: any;
  32383. storage?: [];
  32384. }): number;
  32385. /**
  32386. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32387. * @hidden
  32388. */
  32389. private _rebuildParticle;
  32390. /**
  32391. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32392. * @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.
  32393. * @returns the SPS.
  32394. */
  32395. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32396. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32397. * Returns an array with the removed particles.
  32398. * 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.
  32399. * The SPS can't be empty so at least one particle needs to remain in place.
  32400. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32401. * @param start index of the first particle to remove
  32402. * @param end index of the last particle to remove (included)
  32403. * @returns an array populated with the removed particles
  32404. */
  32405. removeParticles(start: number, end: number): SolidParticle[];
  32406. /**
  32407. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32408. * @param solidParticleArray an array populated with Solid Particles objects
  32409. * @returns the SPS
  32410. */
  32411. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32412. /**
  32413. * Creates a new particle and modifies the SPS mesh geometry :
  32414. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32415. * - calls _addParticle() to populate the particle array
  32416. * factorized code from addShape() and insertParticlesFromArray()
  32417. * @param idx particle index in the particles array
  32418. * @param i particle index in its shape
  32419. * @param modelShape particle ModelShape object
  32420. * @param shape shape vertex array
  32421. * @param meshInd shape indices array
  32422. * @param meshUV shape uv array
  32423. * @param meshCol shape color array
  32424. * @param meshNor shape normals array
  32425. * @param bbInfo shape bounding info
  32426. * @param storage target particle storage
  32427. * @options addShape() passed options
  32428. * @hidden
  32429. */
  32430. private _insertNewParticle;
  32431. /**
  32432. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32433. * This method calls `updateParticle()` for each particle of the SPS.
  32434. * For an animated SPS, it is usually called within the render loop.
  32435. * 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.
  32436. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32437. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32438. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32439. * @returns the SPS.
  32440. */
  32441. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32442. /**
  32443. * Disposes the SPS.
  32444. */
  32445. dispose(): void;
  32446. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32447. * idx is the particle index in the SPS
  32448. * faceId is the picked face index counted within this particle.
  32449. * Returns null if the pickInfo can't identify a picked particle.
  32450. * @param pickingInfo (PickingInfo object)
  32451. * @returns {idx: number, faceId: number} or null
  32452. */
  32453. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32454. idx: number;
  32455. faceId: number;
  32456. }>;
  32457. /**
  32458. * Returns a SolidParticle object from its identifier : particle.id
  32459. * @param id (integer) the particle Id
  32460. * @returns the searched particle or null if not found in the SPS.
  32461. */
  32462. getParticleById(id: number): Nullable<SolidParticle>;
  32463. /**
  32464. * Returns a new array populated with the particles having the passed shapeId.
  32465. * @param shapeId (integer) the shape identifier
  32466. * @returns a new solid particle array
  32467. */
  32468. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32469. /**
  32470. * Populates the passed array "ref" with the particles having the passed shapeId.
  32471. * @param shapeId the shape identifier
  32472. * @returns the SPS
  32473. * @param ref
  32474. */
  32475. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32476. /**
  32477. * Computes the required SubMeshes according the materials assigned to the particles.
  32478. * @returns the solid particle system.
  32479. * Does nothing if called before the SPS mesh is built.
  32480. */
  32481. computeSubMeshes(): SolidParticleSystem;
  32482. /**
  32483. * Sorts the solid particles by material when MultiMaterial is enabled.
  32484. * Updates the indices32 array.
  32485. * Updates the indicesByMaterial array.
  32486. * Updates the mesh indices array.
  32487. * @returns the SPS
  32488. * @hidden
  32489. */
  32490. private _sortParticlesByMaterial;
  32491. /**
  32492. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32493. * @hidden
  32494. */
  32495. private _setMaterialIndexesById;
  32496. /**
  32497. * Returns an array with unique values of Materials from the passed array
  32498. * @param array the material array to be checked and filtered
  32499. * @hidden
  32500. */
  32501. private _filterUniqueMaterialId;
  32502. /**
  32503. * Sets a new Standard Material as _defaultMaterial if not already set.
  32504. * @hidden
  32505. */
  32506. private _setDefaultMaterial;
  32507. /**
  32508. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32509. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32510. * @returns the SPS.
  32511. */
  32512. refreshVisibleSize(): SolidParticleSystem;
  32513. /**
  32514. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32515. * @param size the size (float) of the visibility box
  32516. * note : this doesn't lock the SPS mesh bounding box.
  32517. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32518. */
  32519. setVisibilityBox(size: number): void;
  32520. /**
  32521. * Gets whether the SPS as always visible or not
  32522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32523. */
  32524. get isAlwaysVisible(): boolean;
  32525. /**
  32526. * Sets the SPS as always visible or not
  32527. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32528. */
  32529. set isAlwaysVisible(val: boolean);
  32530. /**
  32531. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32532. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32533. */
  32534. set isVisibilityBoxLocked(val: boolean);
  32535. /**
  32536. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32537. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32538. */
  32539. get isVisibilityBoxLocked(): boolean;
  32540. /**
  32541. * Tells to `setParticles()` to compute the particle rotations or not.
  32542. * Default value : true. The SPS is faster when it's set to false.
  32543. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32544. */
  32545. set computeParticleRotation(val: boolean);
  32546. /**
  32547. * Tells to `setParticles()` to compute the particle colors or not.
  32548. * Default value : true. The SPS is faster when it's set to false.
  32549. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32550. */
  32551. set computeParticleColor(val: boolean);
  32552. set computeParticleTexture(val: boolean);
  32553. /**
  32554. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32555. * Default value : false. The SPS is faster when it's set to false.
  32556. * Note : the particle custom vertex positions aren't stored values.
  32557. */
  32558. set computeParticleVertex(val: boolean);
  32559. /**
  32560. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32561. */
  32562. set computeBoundingBox(val: boolean);
  32563. /**
  32564. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32565. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32566. * Default : `true`
  32567. */
  32568. set depthSortParticles(val: boolean);
  32569. /**
  32570. * Gets if `setParticles()` computes the particle rotations or not.
  32571. * Default value : true. The SPS is faster when it's set to false.
  32572. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32573. */
  32574. get computeParticleRotation(): boolean;
  32575. /**
  32576. * Gets if `setParticles()` computes the particle colors or not.
  32577. * Default value : true. The SPS is faster when it's set to false.
  32578. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32579. */
  32580. get computeParticleColor(): boolean;
  32581. /**
  32582. * Gets if `setParticles()` computes the particle textures or not.
  32583. * Default value : true. The SPS is faster when it's set to false.
  32584. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32585. */
  32586. get computeParticleTexture(): boolean;
  32587. /**
  32588. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32589. * Default value : false. The SPS is faster when it's set to false.
  32590. * Note : the particle custom vertex positions aren't stored values.
  32591. */
  32592. get computeParticleVertex(): boolean;
  32593. /**
  32594. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32595. */
  32596. get computeBoundingBox(): boolean;
  32597. /**
  32598. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32599. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32600. * Default : `true`
  32601. */
  32602. get depthSortParticles(): boolean;
  32603. /**
  32604. * Gets if the SPS is created as expandable at construction time.
  32605. * Default : `false`
  32606. */
  32607. get expandable(): boolean;
  32608. /**
  32609. * Gets if the SPS supports the Multi Materials
  32610. */
  32611. get multimaterialEnabled(): boolean;
  32612. /**
  32613. * Gets if the SPS uses the model materials for its own multimaterial.
  32614. */
  32615. get useModelMaterial(): boolean;
  32616. /**
  32617. * The SPS used material array.
  32618. */
  32619. get materials(): Material[];
  32620. /**
  32621. * Sets the SPS MultiMaterial from the passed materials.
  32622. * Note : the passed array is internally copied and not used then by reference.
  32623. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32624. */
  32625. setMultiMaterial(materials: Material[]): void;
  32626. /**
  32627. * The SPS computed multimaterial object
  32628. */
  32629. get multimaterial(): MultiMaterial;
  32630. set multimaterial(mm: MultiMaterial);
  32631. /**
  32632. * If the subMeshes must be updated on the next call to setParticles()
  32633. */
  32634. get autoUpdateSubMeshes(): boolean;
  32635. set autoUpdateSubMeshes(val: boolean);
  32636. /**
  32637. * This function does nothing. It may be overwritten to set all the particle first values.
  32638. * The SPS doesn't call this function, you may have to call it by your own.
  32639. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32640. */
  32641. initParticles(): void;
  32642. /**
  32643. * This function does nothing. It may be overwritten to recycle a particle.
  32644. * The SPS doesn't call this function, you may have to call it by your own.
  32645. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32646. * @param particle The particle to recycle
  32647. * @returns the recycled particle
  32648. */
  32649. recycleParticle(particle: SolidParticle): SolidParticle;
  32650. /**
  32651. * Updates a particle : this function should be overwritten by the user.
  32652. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32653. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32654. * @example : just set a particle position or velocity and recycle conditions
  32655. * @param particle The particle to update
  32656. * @returns the updated particle
  32657. */
  32658. updateParticle(particle: SolidParticle): SolidParticle;
  32659. /**
  32660. * Updates a vertex of a particle : it can be overwritten by the user.
  32661. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32662. * @param particle the current particle
  32663. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32664. * @param pt the index of the current vertex in the particle shape
  32665. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32666. * @example : just set a vertex particle position or color
  32667. * @returns the sps
  32668. */
  32669. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32670. /**
  32671. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32672. * This does nothing and may be overwritten by the user.
  32673. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32674. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32675. * @param update the boolean update value actually passed to setParticles()
  32676. */
  32677. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32678. /**
  32679. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32680. * This will be passed three parameters.
  32681. * This does nothing and may be overwritten by the user.
  32682. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32683. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32684. * @param update the boolean update value actually passed to setParticles()
  32685. */
  32686. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32687. }
  32688. }
  32689. declare module "babylonjs/Particles/solidParticle" {
  32690. import { Nullable } from "babylonjs/types";
  32691. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32692. import { Color4 } from "babylonjs/Maths/math.color";
  32693. import { Mesh } from "babylonjs/Meshes/mesh";
  32694. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32695. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32696. import { Plane } from "babylonjs/Maths/math.plane";
  32697. import { Material } from "babylonjs/Materials/material";
  32698. /**
  32699. * Represents one particle of a solid particle system.
  32700. */
  32701. export class SolidParticle {
  32702. /**
  32703. * particle global index
  32704. */
  32705. idx: number;
  32706. /**
  32707. * particle identifier
  32708. */
  32709. id: number;
  32710. /**
  32711. * The color of the particle
  32712. */
  32713. color: Nullable<Color4>;
  32714. /**
  32715. * The world space position of the particle.
  32716. */
  32717. position: Vector3;
  32718. /**
  32719. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32720. */
  32721. rotation: Vector3;
  32722. /**
  32723. * The world space rotation quaternion of the particle.
  32724. */
  32725. rotationQuaternion: Nullable<Quaternion>;
  32726. /**
  32727. * The scaling of the particle.
  32728. */
  32729. scaling: Vector3;
  32730. /**
  32731. * The uvs of the particle.
  32732. */
  32733. uvs: Vector4;
  32734. /**
  32735. * The current speed of the particle.
  32736. */
  32737. velocity: Vector3;
  32738. /**
  32739. * The pivot point in the particle local space.
  32740. */
  32741. pivot: Vector3;
  32742. /**
  32743. * Must the particle be translated from its pivot point in its local space ?
  32744. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32745. * Default : false
  32746. */
  32747. translateFromPivot: boolean;
  32748. /**
  32749. * Is the particle active or not ?
  32750. */
  32751. alive: boolean;
  32752. /**
  32753. * Is the particle visible or not ?
  32754. */
  32755. isVisible: boolean;
  32756. /**
  32757. * Index of this particle in the global "positions" array (Internal use)
  32758. * @hidden
  32759. */
  32760. _pos: number;
  32761. /**
  32762. * @hidden Index of this particle in the global "indices" array (Internal use)
  32763. */
  32764. _ind: number;
  32765. /**
  32766. * @hidden ModelShape of this particle (Internal use)
  32767. */
  32768. _model: ModelShape;
  32769. /**
  32770. * ModelShape id of this particle
  32771. */
  32772. shapeId: number;
  32773. /**
  32774. * Index of the particle in its shape id
  32775. */
  32776. idxInShape: number;
  32777. /**
  32778. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32779. */
  32780. _modelBoundingInfo: BoundingInfo;
  32781. /**
  32782. * @hidden Particle BoundingInfo object (Internal use)
  32783. */
  32784. _boundingInfo: BoundingInfo;
  32785. /**
  32786. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32787. */
  32788. _sps: SolidParticleSystem;
  32789. /**
  32790. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32791. */
  32792. _stillInvisible: boolean;
  32793. /**
  32794. * @hidden Last computed particle rotation matrix
  32795. */
  32796. _rotationMatrix: number[];
  32797. /**
  32798. * Parent particle Id, if any.
  32799. * Default null.
  32800. */
  32801. parentId: Nullable<number>;
  32802. /**
  32803. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32804. */
  32805. materialIndex: Nullable<number>;
  32806. /**
  32807. * Custom object or properties.
  32808. */
  32809. props: Nullable<any>;
  32810. /**
  32811. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32812. * The possible values are :
  32813. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32814. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32815. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32816. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32817. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32818. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32819. * */
  32820. cullingStrategy: number;
  32821. /**
  32822. * @hidden Internal global position in the SPS.
  32823. */
  32824. _globalPosition: Vector3;
  32825. /**
  32826. * Creates a Solid Particle object.
  32827. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32828. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32829. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32830. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32831. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32832. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32833. * @param shapeId (integer) is the model shape identifier in the SPS.
  32834. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32835. * @param sps defines the sps it is associated to
  32836. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32837. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32838. */
  32839. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32840. /**
  32841. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32842. * @param target the particle target
  32843. * @returns the current particle
  32844. */
  32845. copyToRef(target: SolidParticle): SolidParticle;
  32846. /**
  32847. * Legacy support, changed scale to scaling
  32848. */
  32849. get scale(): Vector3;
  32850. /**
  32851. * Legacy support, changed scale to scaling
  32852. */
  32853. set scale(scale: Vector3);
  32854. /**
  32855. * Legacy support, changed quaternion to rotationQuaternion
  32856. */
  32857. get quaternion(): Nullable<Quaternion>;
  32858. /**
  32859. * Legacy support, changed quaternion to rotationQuaternion
  32860. */
  32861. set quaternion(q: Nullable<Quaternion>);
  32862. /**
  32863. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32864. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32865. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32866. * @returns true if it intersects
  32867. */
  32868. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32869. /**
  32870. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32871. * A particle is in the frustum if its bounding box intersects the frustum
  32872. * @param frustumPlanes defines the frustum to test
  32873. * @returns true if the particle is in the frustum planes
  32874. */
  32875. isInFrustum(frustumPlanes: Plane[]): boolean;
  32876. /**
  32877. * get the rotation matrix of the particle
  32878. * @hidden
  32879. */
  32880. getRotationMatrix(m: Matrix): void;
  32881. }
  32882. /**
  32883. * Represents the shape of the model used by one particle of a solid particle system.
  32884. * SPS internal tool, don't use it manually.
  32885. */
  32886. export class ModelShape {
  32887. /**
  32888. * The shape id
  32889. * @hidden
  32890. */
  32891. shapeID: number;
  32892. /**
  32893. * flat array of model positions (internal use)
  32894. * @hidden
  32895. */
  32896. _shape: Vector3[];
  32897. /**
  32898. * flat array of model UVs (internal use)
  32899. * @hidden
  32900. */
  32901. _shapeUV: number[];
  32902. /**
  32903. * color array of the model
  32904. * @hidden
  32905. */
  32906. _shapeColors: number[];
  32907. /**
  32908. * indices array of the model
  32909. * @hidden
  32910. */
  32911. _indices: number[];
  32912. /**
  32913. * normals array of the model
  32914. * @hidden
  32915. */
  32916. _normals: number[];
  32917. /**
  32918. * length of the shape in the model indices array (internal use)
  32919. * @hidden
  32920. */
  32921. _indicesLength: number;
  32922. /**
  32923. * Custom position function (internal use)
  32924. * @hidden
  32925. */
  32926. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32927. /**
  32928. * Custom vertex function (internal use)
  32929. * @hidden
  32930. */
  32931. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32932. /**
  32933. * Model material (internal use)
  32934. * @hidden
  32935. */
  32936. _material: Nullable<Material>;
  32937. /**
  32938. * 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.
  32939. * SPS internal tool, don't use it manually.
  32940. * @hidden
  32941. */
  32942. 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>);
  32943. }
  32944. /**
  32945. * Represents a Depth Sorted Particle in the solid particle system.
  32946. * @hidden
  32947. */
  32948. export class DepthSortedParticle {
  32949. /**
  32950. * Particle index
  32951. */
  32952. idx: number;
  32953. /**
  32954. * Index of the particle in the "indices" array
  32955. */
  32956. ind: number;
  32957. /**
  32958. * Length of the particle shape in the "indices" array
  32959. */
  32960. indicesLength: number;
  32961. /**
  32962. * Squared distance from the particle to the camera
  32963. */
  32964. sqDistance: number;
  32965. /**
  32966. * Material index when used with MultiMaterials
  32967. */
  32968. materialIndex: number;
  32969. /**
  32970. * Creates a new sorted particle
  32971. * @param materialIndex
  32972. */
  32973. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32974. }
  32975. /**
  32976. * Represents a solid particle vertex
  32977. */
  32978. export class SolidParticleVertex {
  32979. /**
  32980. * Vertex position
  32981. */
  32982. position: Vector3;
  32983. /**
  32984. * Vertex color
  32985. */
  32986. color: Color4;
  32987. /**
  32988. * Vertex UV
  32989. */
  32990. uv: Vector2;
  32991. /**
  32992. * Creates a new solid particle vertex
  32993. */
  32994. constructor();
  32995. /** Vertex x coordinate */
  32996. get x(): number;
  32997. set x(val: number);
  32998. /** Vertex y coordinate */
  32999. get y(): number;
  33000. set y(val: number);
  33001. /** Vertex z coordinate */
  33002. get z(): number;
  33003. set z(val: number);
  33004. }
  33005. }
  33006. declare module "babylonjs/Collisions/meshCollisionData" {
  33007. import { Collider } from "babylonjs/Collisions/collider";
  33008. import { Vector3 } from "babylonjs/Maths/math.vector";
  33009. import { Nullable } from "babylonjs/types";
  33010. import { Observer } from "babylonjs/Misc/observable";
  33011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33012. /**
  33013. * @hidden
  33014. */
  33015. export class _MeshCollisionData {
  33016. _checkCollisions: boolean;
  33017. _collisionMask: number;
  33018. _collisionGroup: number;
  33019. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33020. _collider: Nullable<Collider>;
  33021. _oldPositionForCollisions: Vector3;
  33022. _diffPositionForCollisions: Vector3;
  33023. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33024. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33025. }
  33026. }
  33027. declare module "babylonjs/Meshes/abstractMesh" {
  33028. import { Observable } from "babylonjs/Misc/observable";
  33029. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33030. import { Camera } from "babylonjs/Cameras/camera";
  33031. import { Scene, IDisposable } from "babylonjs/scene";
  33032. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33033. import { Node } from "babylonjs/node";
  33034. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33035. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33037. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33038. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33039. import { Material } from "babylonjs/Materials/material";
  33040. import { Light } from "babylonjs/Lights/light";
  33041. import { Skeleton } from "babylonjs/Bones/skeleton";
  33042. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33043. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33044. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33045. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33046. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33047. import { Plane } from "babylonjs/Maths/math.plane";
  33048. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33049. import { Ray } from "babylonjs/Culling/ray";
  33050. import { Collider } from "babylonjs/Collisions/collider";
  33051. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33052. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33053. /** @hidden */
  33054. class _FacetDataStorage {
  33055. facetPositions: Vector3[];
  33056. facetNormals: Vector3[];
  33057. facetPartitioning: number[][];
  33058. facetNb: number;
  33059. partitioningSubdivisions: number;
  33060. partitioningBBoxRatio: number;
  33061. facetDataEnabled: boolean;
  33062. facetParameters: any;
  33063. bbSize: Vector3;
  33064. subDiv: {
  33065. max: number;
  33066. X: number;
  33067. Y: number;
  33068. Z: number;
  33069. };
  33070. facetDepthSort: boolean;
  33071. facetDepthSortEnabled: boolean;
  33072. depthSortedIndices: IndicesArray;
  33073. depthSortedFacets: {
  33074. ind: number;
  33075. sqDistance: number;
  33076. }[];
  33077. facetDepthSortFunction: (f1: {
  33078. ind: number;
  33079. sqDistance: number;
  33080. }, f2: {
  33081. ind: number;
  33082. sqDistance: number;
  33083. }) => number;
  33084. facetDepthSortFrom: Vector3;
  33085. facetDepthSortOrigin: Vector3;
  33086. invertedMatrix: Matrix;
  33087. }
  33088. /**
  33089. * @hidden
  33090. **/
  33091. class _InternalAbstractMeshDataInfo {
  33092. _hasVertexAlpha: boolean;
  33093. _useVertexColors: boolean;
  33094. _numBoneInfluencers: number;
  33095. _applyFog: boolean;
  33096. _receiveShadows: boolean;
  33097. _facetData: _FacetDataStorage;
  33098. _visibility: number;
  33099. _skeleton: Nullable<Skeleton>;
  33100. _layerMask: number;
  33101. _computeBonesUsingShaders: boolean;
  33102. _isActive: boolean;
  33103. _onlyForInstances: boolean;
  33104. _isActiveIntermediate: boolean;
  33105. _onlyForInstancesIntermediate: boolean;
  33106. _actAsRegularMesh: boolean;
  33107. }
  33108. /**
  33109. * Class used to store all common mesh properties
  33110. */
  33111. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33112. /** No occlusion */
  33113. static OCCLUSION_TYPE_NONE: number;
  33114. /** Occlusion set to optimisitic */
  33115. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33116. /** Occlusion set to strict */
  33117. static OCCLUSION_TYPE_STRICT: number;
  33118. /** Use an accurante occlusion algorithm */
  33119. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33120. /** Use a conservative occlusion algorithm */
  33121. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33122. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33123. * Test order :
  33124. * Is the bounding sphere outside the frustum ?
  33125. * If not, are the bounding box vertices outside the frustum ?
  33126. * It not, then the cullable object is in the frustum.
  33127. */
  33128. static readonly CULLINGSTRATEGY_STANDARD: number;
  33129. /** Culling strategy : Bounding Sphere Only.
  33130. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33131. * It's also less accurate than the standard because some not visible objects can still be selected.
  33132. * Test : is the bounding sphere outside the frustum ?
  33133. * If not, then the cullable object is in the frustum.
  33134. */
  33135. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33136. /** Culling strategy : Optimistic Inclusion.
  33137. * This in an inclusion test first, then the standard exclusion test.
  33138. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33139. * 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.
  33140. * Anyway, it's as accurate as the standard strategy.
  33141. * Test :
  33142. * Is the cullable object bounding sphere center in the frustum ?
  33143. * If not, apply the default culling strategy.
  33144. */
  33145. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33146. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33147. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33148. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33149. * 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.
  33150. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33151. * Test :
  33152. * Is the cullable object bounding sphere center in the frustum ?
  33153. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33154. */
  33155. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33156. /**
  33157. * No billboard
  33158. */
  33159. static get BILLBOARDMODE_NONE(): number;
  33160. /** Billboard on X axis */
  33161. static get BILLBOARDMODE_X(): number;
  33162. /** Billboard on Y axis */
  33163. static get BILLBOARDMODE_Y(): number;
  33164. /** Billboard on Z axis */
  33165. static get BILLBOARDMODE_Z(): number;
  33166. /** Billboard on all axes */
  33167. static get BILLBOARDMODE_ALL(): number;
  33168. /** Billboard on using position instead of orientation */
  33169. static get BILLBOARDMODE_USE_POSITION(): number;
  33170. /** @hidden */
  33171. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33172. /**
  33173. * The culling strategy to use to check whether the mesh must be rendered or not.
  33174. * This value can be changed at any time and will be used on the next render mesh selection.
  33175. * The possible values are :
  33176. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33177. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33178. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33179. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33180. * Please read each static variable documentation to get details about the culling process.
  33181. * */
  33182. cullingStrategy: number;
  33183. /**
  33184. * Gets the number of facets in the mesh
  33185. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33186. */
  33187. get facetNb(): number;
  33188. /**
  33189. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33190. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33191. */
  33192. get partitioningSubdivisions(): number;
  33193. set partitioningSubdivisions(nb: number);
  33194. /**
  33195. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33196. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33198. */
  33199. get partitioningBBoxRatio(): number;
  33200. set partitioningBBoxRatio(ratio: number);
  33201. /**
  33202. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33203. * Works only for updatable meshes.
  33204. * Doesn't work with multi-materials
  33205. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33206. */
  33207. get mustDepthSortFacets(): boolean;
  33208. set mustDepthSortFacets(sort: boolean);
  33209. /**
  33210. * The location (Vector3) where the facet depth sort must be computed from.
  33211. * By default, the active camera position.
  33212. * Used only when facet depth sort is enabled
  33213. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33214. */
  33215. get facetDepthSortFrom(): Vector3;
  33216. set facetDepthSortFrom(location: Vector3);
  33217. /**
  33218. * gets a boolean indicating if facetData is enabled
  33219. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33220. */
  33221. get isFacetDataEnabled(): boolean;
  33222. /** @hidden */
  33223. _updateNonUniformScalingState(value: boolean): boolean;
  33224. /**
  33225. * An event triggered when this mesh collides with another one
  33226. */
  33227. onCollideObservable: Observable<AbstractMesh>;
  33228. /** Set a function to call when this mesh collides with another one */
  33229. set onCollide(callback: () => void);
  33230. /**
  33231. * An event triggered when the collision's position changes
  33232. */
  33233. onCollisionPositionChangeObservable: Observable<Vector3>;
  33234. /** Set a function to call when the collision's position changes */
  33235. set onCollisionPositionChange(callback: () => void);
  33236. /**
  33237. * An event triggered when material is changed
  33238. */
  33239. onMaterialChangedObservable: Observable<AbstractMesh>;
  33240. /**
  33241. * Gets or sets the orientation for POV movement & rotation
  33242. */
  33243. definedFacingForward: boolean;
  33244. /** @hidden */
  33245. _occlusionQuery: Nullable<WebGLQuery>;
  33246. /** @hidden */
  33247. _renderingGroup: Nullable<RenderingGroup>;
  33248. /**
  33249. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33250. */
  33251. get visibility(): number;
  33252. /**
  33253. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33254. */
  33255. set visibility(value: number);
  33256. /** Gets or sets the alpha index used to sort transparent meshes
  33257. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33258. */
  33259. alphaIndex: number;
  33260. /**
  33261. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33262. */
  33263. isVisible: boolean;
  33264. /**
  33265. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33266. */
  33267. isPickable: boolean;
  33268. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33269. showSubMeshesBoundingBox: boolean;
  33270. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33271. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33272. */
  33273. isBlocker: boolean;
  33274. /**
  33275. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33276. */
  33277. enablePointerMoveEvents: boolean;
  33278. /**
  33279. * Specifies the rendering group id for this mesh (0 by default)
  33280. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33281. */
  33282. renderingGroupId: number;
  33283. private _material;
  33284. /** Gets or sets current material */
  33285. get material(): Nullable<Material>;
  33286. set material(value: Nullable<Material>);
  33287. /**
  33288. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33289. * @see https://doc.babylonjs.com/babylon101/shadows
  33290. */
  33291. get receiveShadows(): boolean;
  33292. set receiveShadows(value: boolean);
  33293. /** Defines color to use when rendering outline */
  33294. outlineColor: Color3;
  33295. /** Define width to use when rendering outline */
  33296. outlineWidth: number;
  33297. /** Defines color to use when rendering overlay */
  33298. overlayColor: Color3;
  33299. /** Defines alpha to use when rendering overlay */
  33300. overlayAlpha: number;
  33301. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33302. get hasVertexAlpha(): boolean;
  33303. set hasVertexAlpha(value: boolean);
  33304. /** 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) */
  33305. get useVertexColors(): boolean;
  33306. set useVertexColors(value: boolean);
  33307. /**
  33308. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33309. */
  33310. get computeBonesUsingShaders(): boolean;
  33311. set computeBonesUsingShaders(value: boolean);
  33312. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33313. get numBoneInfluencers(): number;
  33314. set numBoneInfluencers(value: number);
  33315. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33316. get applyFog(): boolean;
  33317. set applyFog(value: boolean);
  33318. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33319. useOctreeForRenderingSelection: boolean;
  33320. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33321. useOctreeForPicking: boolean;
  33322. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33323. useOctreeForCollisions: boolean;
  33324. /**
  33325. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33326. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33327. */
  33328. get layerMask(): number;
  33329. set layerMask(value: number);
  33330. /**
  33331. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33332. */
  33333. alwaysSelectAsActiveMesh: boolean;
  33334. /**
  33335. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33336. */
  33337. doNotSyncBoundingInfo: boolean;
  33338. /**
  33339. * Gets or sets the current action manager
  33340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33341. */
  33342. actionManager: Nullable<AbstractActionManager>;
  33343. private _meshCollisionData;
  33344. /**
  33345. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33346. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33347. */
  33348. ellipsoid: Vector3;
  33349. /**
  33350. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33351. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33352. */
  33353. ellipsoidOffset: Vector3;
  33354. /**
  33355. * Gets or sets a collision mask used to mask collisions (default is -1).
  33356. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33357. */
  33358. get collisionMask(): number;
  33359. set collisionMask(mask: number);
  33360. /**
  33361. * Gets or sets the current collision group mask (-1 by default).
  33362. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33363. */
  33364. get collisionGroup(): number;
  33365. set collisionGroup(mask: number);
  33366. /**
  33367. * Gets or sets current surrounding meshes (null by default).
  33368. *
  33369. * By default collision detection is tested against every mesh in the scene.
  33370. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33371. * meshes will be tested for the collision.
  33372. *
  33373. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33374. */
  33375. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33376. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33377. /**
  33378. * Defines edge width used when edgesRenderer is enabled
  33379. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33380. */
  33381. edgesWidth: number;
  33382. /**
  33383. * Defines edge color used when edgesRenderer is enabled
  33384. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33385. */
  33386. edgesColor: Color4;
  33387. /** @hidden */
  33388. _edgesRenderer: Nullable<IEdgesRenderer>;
  33389. /** @hidden */
  33390. _masterMesh: Nullable<AbstractMesh>;
  33391. /** @hidden */
  33392. _boundingInfo: Nullable<BoundingInfo>;
  33393. /** @hidden */
  33394. _renderId: number;
  33395. /**
  33396. * Gets or sets the list of subMeshes
  33397. * @see https://doc.babylonjs.com/how_to/multi_materials
  33398. */
  33399. subMeshes: SubMesh[];
  33400. /** @hidden */
  33401. _intersectionsInProgress: AbstractMesh[];
  33402. /** @hidden */
  33403. _unIndexed: boolean;
  33404. /** @hidden */
  33405. _lightSources: Light[];
  33406. /** Gets the list of lights affecting that mesh */
  33407. get lightSources(): Light[];
  33408. /** @hidden */
  33409. get _positions(): Nullable<Vector3[]>;
  33410. /** @hidden */
  33411. _waitingData: {
  33412. lods: Nullable<any>;
  33413. actions: Nullable<any>;
  33414. freezeWorldMatrix: Nullable<boolean>;
  33415. };
  33416. /** @hidden */
  33417. _bonesTransformMatrices: Nullable<Float32Array>;
  33418. /** @hidden */
  33419. _transformMatrixTexture: Nullable<RawTexture>;
  33420. /**
  33421. * Gets or sets a skeleton to apply skining transformations
  33422. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33423. */
  33424. set skeleton(value: Nullable<Skeleton>);
  33425. get skeleton(): Nullable<Skeleton>;
  33426. /**
  33427. * An event triggered when the mesh is rebuilt.
  33428. */
  33429. onRebuildObservable: Observable<AbstractMesh>;
  33430. /**
  33431. * Creates a new AbstractMesh
  33432. * @param name defines the name of the mesh
  33433. * @param scene defines the hosting scene
  33434. */
  33435. constructor(name: string, scene?: Nullable<Scene>);
  33436. /**
  33437. * Returns the string "AbstractMesh"
  33438. * @returns "AbstractMesh"
  33439. */
  33440. getClassName(): string;
  33441. /**
  33442. * Gets a string representation of the current mesh
  33443. * @param fullDetails defines a boolean indicating if full details must be included
  33444. * @returns a string representation of the current mesh
  33445. */
  33446. toString(fullDetails?: boolean): string;
  33447. /**
  33448. * @hidden
  33449. */
  33450. protected _getEffectiveParent(): Nullable<Node>;
  33451. /** @hidden */
  33452. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33453. /** @hidden */
  33454. _rebuild(): void;
  33455. /** @hidden */
  33456. _resyncLightSources(): void;
  33457. /** @hidden */
  33458. _resyncLightSource(light: Light): void;
  33459. /** @hidden */
  33460. _unBindEffect(): void;
  33461. /** @hidden */
  33462. _removeLightSource(light: Light, dispose: boolean): void;
  33463. private _markSubMeshesAsDirty;
  33464. /** @hidden */
  33465. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33466. /** @hidden */
  33467. _markSubMeshesAsAttributesDirty(): void;
  33468. /** @hidden */
  33469. _markSubMeshesAsMiscDirty(): void;
  33470. /**
  33471. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33472. */
  33473. get scaling(): Vector3;
  33474. set scaling(newScaling: Vector3);
  33475. /**
  33476. * Returns true if the mesh is blocked. Implemented by child classes
  33477. */
  33478. get isBlocked(): boolean;
  33479. /**
  33480. * Returns the mesh itself by default. Implemented by child classes
  33481. * @param camera defines the camera to use to pick the right LOD level
  33482. * @returns the currentAbstractMesh
  33483. */
  33484. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33485. /**
  33486. * Returns 0 by default. Implemented by child classes
  33487. * @returns an integer
  33488. */
  33489. getTotalVertices(): number;
  33490. /**
  33491. * Returns a positive integer : the total number of indices in this mesh geometry.
  33492. * @returns the numner of indices or zero if the mesh has no geometry.
  33493. */
  33494. getTotalIndices(): number;
  33495. /**
  33496. * Returns null by default. Implemented by child classes
  33497. * @returns null
  33498. */
  33499. getIndices(): Nullable<IndicesArray>;
  33500. /**
  33501. * Returns the array of the requested vertex data kind. Implemented by child classes
  33502. * @param kind defines the vertex data kind to use
  33503. * @returns null
  33504. */
  33505. getVerticesData(kind: string): Nullable<FloatArray>;
  33506. /**
  33507. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33508. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33509. * Note that a new underlying VertexBuffer object is created each call.
  33510. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33511. * @param kind defines vertex data kind:
  33512. * * VertexBuffer.PositionKind
  33513. * * VertexBuffer.UVKind
  33514. * * VertexBuffer.UV2Kind
  33515. * * VertexBuffer.UV3Kind
  33516. * * VertexBuffer.UV4Kind
  33517. * * VertexBuffer.UV5Kind
  33518. * * VertexBuffer.UV6Kind
  33519. * * VertexBuffer.ColorKind
  33520. * * VertexBuffer.MatricesIndicesKind
  33521. * * VertexBuffer.MatricesIndicesExtraKind
  33522. * * VertexBuffer.MatricesWeightsKind
  33523. * * VertexBuffer.MatricesWeightsExtraKind
  33524. * @param data defines the data source
  33525. * @param updatable defines if the data must be flagged as updatable (or static)
  33526. * @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
  33527. * @returns the current mesh
  33528. */
  33529. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33530. /**
  33531. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33532. * If the mesh has no geometry, it is simply returned as it is.
  33533. * @param kind defines vertex data kind:
  33534. * * VertexBuffer.PositionKind
  33535. * * VertexBuffer.UVKind
  33536. * * VertexBuffer.UV2Kind
  33537. * * VertexBuffer.UV3Kind
  33538. * * VertexBuffer.UV4Kind
  33539. * * VertexBuffer.UV5Kind
  33540. * * VertexBuffer.UV6Kind
  33541. * * VertexBuffer.ColorKind
  33542. * * VertexBuffer.MatricesIndicesKind
  33543. * * VertexBuffer.MatricesIndicesExtraKind
  33544. * * VertexBuffer.MatricesWeightsKind
  33545. * * VertexBuffer.MatricesWeightsExtraKind
  33546. * @param data defines the data source
  33547. * @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
  33548. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33549. * @returns the current mesh
  33550. */
  33551. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33552. /**
  33553. * Sets the mesh indices,
  33554. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33555. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33556. * @param totalVertices Defines the total number of vertices
  33557. * @returns the current mesh
  33558. */
  33559. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33560. /**
  33561. * Gets a boolean indicating if specific vertex data is present
  33562. * @param kind defines the vertex data kind to use
  33563. * @returns true is data kind is present
  33564. */
  33565. isVerticesDataPresent(kind: string): boolean;
  33566. /**
  33567. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33568. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33569. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33570. * @returns a BoundingInfo
  33571. */
  33572. getBoundingInfo(): BoundingInfo;
  33573. /**
  33574. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33575. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33576. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33577. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33578. * @returns the current mesh
  33579. */
  33580. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33581. /**
  33582. * Overwrite the current bounding info
  33583. * @param boundingInfo defines the new bounding info
  33584. * @returns the current mesh
  33585. */
  33586. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33587. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33588. get useBones(): boolean;
  33589. /** @hidden */
  33590. _preActivate(): void;
  33591. /** @hidden */
  33592. _preActivateForIntermediateRendering(renderId: number): void;
  33593. /** @hidden */
  33594. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33595. /** @hidden */
  33596. _postActivate(): void;
  33597. /** @hidden */
  33598. _freeze(): void;
  33599. /** @hidden */
  33600. _unFreeze(): void;
  33601. /**
  33602. * Gets the current world matrix
  33603. * @returns a Matrix
  33604. */
  33605. getWorldMatrix(): Matrix;
  33606. /** @hidden */
  33607. _getWorldMatrixDeterminant(): number;
  33608. /**
  33609. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33610. */
  33611. get isAnInstance(): boolean;
  33612. /**
  33613. * Gets a boolean indicating if this mesh has instances
  33614. */
  33615. get hasInstances(): boolean;
  33616. /**
  33617. * Gets a boolean indicating if this mesh has thin instances
  33618. */
  33619. get hasThinInstances(): boolean;
  33620. /**
  33621. * Perform relative position change from the point of view of behind the front of the mesh.
  33622. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33623. * Supports definition of mesh facing forward or backward
  33624. * @param amountRight defines the distance on the right axis
  33625. * @param amountUp defines the distance on the up axis
  33626. * @param amountForward defines the distance on the forward axis
  33627. * @returns the current mesh
  33628. */
  33629. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33630. /**
  33631. * Calculate relative position change from the point of view of behind the front of the mesh.
  33632. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33633. * Supports definition of mesh facing forward or backward
  33634. * @param amountRight defines the distance on the right axis
  33635. * @param amountUp defines the distance on the up axis
  33636. * @param amountForward defines the distance on the forward axis
  33637. * @returns the new displacement vector
  33638. */
  33639. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33640. /**
  33641. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33642. * Supports definition of mesh facing forward or backward
  33643. * @param flipBack defines the flip
  33644. * @param twirlClockwise defines the twirl
  33645. * @param tiltRight defines the tilt
  33646. * @returns the current mesh
  33647. */
  33648. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33649. /**
  33650. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33651. * Supports definition of mesh facing forward or backward.
  33652. * @param flipBack defines the flip
  33653. * @param twirlClockwise defines the twirl
  33654. * @param tiltRight defines the tilt
  33655. * @returns the new rotation vector
  33656. */
  33657. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33658. /**
  33659. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33660. * This means the mesh underlying bounding box and sphere are recomputed.
  33661. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33662. * @returns the current mesh
  33663. */
  33664. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33665. /** @hidden */
  33666. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33667. /** @hidden */
  33668. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33669. /** @hidden */
  33670. _updateBoundingInfo(): AbstractMesh;
  33671. /** @hidden */
  33672. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33673. /** @hidden */
  33674. protected _afterComputeWorldMatrix(): void;
  33675. /** @hidden */
  33676. get _effectiveMesh(): AbstractMesh;
  33677. /**
  33678. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33679. * A mesh is in the frustum if its bounding box intersects the frustum
  33680. * @param frustumPlanes defines the frustum to test
  33681. * @returns true if the mesh is in the frustum planes
  33682. */
  33683. isInFrustum(frustumPlanes: Plane[]): boolean;
  33684. /**
  33685. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33686. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33687. * @param frustumPlanes defines the frustum to test
  33688. * @returns true if the mesh is completely in the frustum planes
  33689. */
  33690. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33691. /**
  33692. * True if the mesh intersects another mesh or a SolidParticle object
  33693. * @param mesh defines a target mesh or SolidParticle to test
  33694. * @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)
  33695. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33696. * @returns true if there is an intersection
  33697. */
  33698. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33699. /**
  33700. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33701. * @param point defines the point to test
  33702. * @returns true if there is an intersection
  33703. */
  33704. intersectsPoint(point: Vector3): boolean;
  33705. /**
  33706. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33707. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33708. */
  33709. get checkCollisions(): boolean;
  33710. set checkCollisions(collisionEnabled: boolean);
  33711. /**
  33712. * Gets Collider object used to compute collisions (not physics)
  33713. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33714. */
  33715. get collider(): Nullable<Collider>;
  33716. /**
  33717. * Move the mesh using collision engine
  33718. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33719. * @param displacement defines the requested displacement vector
  33720. * @returns the current mesh
  33721. */
  33722. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33723. private _onCollisionPositionChange;
  33724. /** @hidden */
  33725. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33726. /** @hidden */
  33727. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33728. /** @hidden */
  33729. _checkCollision(collider: Collider): AbstractMesh;
  33730. /** @hidden */
  33731. _generatePointsArray(): boolean;
  33732. /**
  33733. * Checks if the passed Ray intersects with the mesh
  33734. * @param ray defines the ray to use
  33735. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33736. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33737. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33738. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33739. * @returns the picking info
  33740. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33741. */
  33742. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33743. /**
  33744. * Clones the current mesh
  33745. * @param name defines the mesh name
  33746. * @param newParent defines the new mesh parent
  33747. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33748. * @returns the new mesh
  33749. */
  33750. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33751. /**
  33752. * Disposes all the submeshes of the current meshnp
  33753. * @returns the current mesh
  33754. */
  33755. releaseSubMeshes(): AbstractMesh;
  33756. /**
  33757. * Releases resources associated with this abstract mesh.
  33758. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33759. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33760. */
  33761. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33762. /**
  33763. * Adds the passed mesh as a child to the current mesh
  33764. * @param mesh defines the child mesh
  33765. * @returns the current mesh
  33766. */
  33767. addChild(mesh: AbstractMesh): AbstractMesh;
  33768. /**
  33769. * Removes the passed mesh from the current mesh children list
  33770. * @param mesh defines the child mesh
  33771. * @returns the current mesh
  33772. */
  33773. removeChild(mesh: AbstractMesh): AbstractMesh;
  33774. /** @hidden */
  33775. private _initFacetData;
  33776. /**
  33777. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33778. * This method can be called within the render loop.
  33779. * 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
  33780. * @returns the current mesh
  33781. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33782. */
  33783. updateFacetData(): AbstractMesh;
  33784. /**
  33785. * Returns the facetLocalNormals array.
  33786. * The normals are expressed in the mesh local spac
  33787. * @returns an array of Vector3
  33788. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33789. */
  33790. getFacetLocalNormals(): Vector3[];
  33791. /**
  33792. * Returns the facetLocalPositions array.
  33793. * The facet positions are expressed in the mesh local space
  33794. * @returns an array of Vector3
  33795. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33796. */
  33797. getFacetLocalPositions(): Vector3[];
  33798. /**
  33799. * Returns the facetLocalPartioning array
  33800. * @returns an array of array of numbers
  33801. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33802. */
  33803. getFacetLocalPartitioning(): number[][];
  33804. /**
  33805. * Returns the i-th facet position in the world system.
  33806. * This method allocates a new Vector3 per call
  33807. * @param i defines the facet index
  33808. * @returns a new Vector3
  33809. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33810. */
  33811. getFacetPosition(i: number): Vector3;
  33812. /**
  33813. * Sets the reference Vector3 with the i-th facet position in the world system
  33814. * @param i defines the facet index
  33815. * @param ref defines the target vector
  33816. * @returns the current mesh
  33817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33818. */
  33819. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33820. /**
  33821. * Returns the i-th facet normal in the world system.
  33822. * This method allocates a new Vector3 per call
  33823. * @param i defines the facet index
  33824. * @returns a new Vector3
  33825. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33826. */
  33827. getFacetNormal(i: number): Vector3;
  33828. /**
  33829. * Sets the reference Vector3 with the i-th facet normal in the world system
  33830. * @param i defines the facet index
  33831. * @param ref defines the target vector
  33832. * @returns the current mesh
  33833. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33834. */
  33835. getFacetNormalToRef(i: number, ref: Vector3): this;
  33836. /**
  33837. * 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)
  33838. * @param x defines x coordinate
  33839. * @param y defines y coordinate
  33840. * @param z defines z coordinate
  33841. * @returns the array of facet indexes
  33842. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33843. */
  33844. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33845. /**
  33846. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33847. * @param projected sets as the (x,y,z) world projection on the facet
  33848. * @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
  33849. * @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
  33850. * @param x defines x coordinate
  33851. * @param y defines y coordinate
  33852. * @param z defines z coordinate
  33853. * @returns the face index if found (or null instead)
  33854. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33855. */
  33856. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33857. /**
  33858. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33859. * @param projected sets as the (x,y,z) local projection on the facet
  33860. * @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
  33861. * @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
  33862. * @param x defines x coordinate
  33863. * @param y defines y coordinate
  33864. * @param z defines z coordinate
  33865. * @returns the face index if found (or null instead)
  33866. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33867. */
  33868. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33869. /**
  33870. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33871. * @returns the parameters
  33872. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33873. */
  33874. getFacetDataParameters(): any;
  33875. /**
  33876. * Disables the feature FacetData and frees the related memory
  33877. * @returns the current mesh
  33878. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33879. */
  33880. disableFacetData(): AbstractMesh;
  33881. /**
  33882. * Updates the AbstractMesh indices array
  33883. * @param indices defines the data source
  33884. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33885. * @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)
  33886. * @returns the current mesh
  33887. */
  33888. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33889. /**
  33890. * Creates new normals data for the mesh
  33891. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33892. * @returns the current mesh
  33893. */
  33894. createNormals(updatable: boolean): AbstractMesh;
  33895. /**
  33896. * Align the mesh with a normal
  33897. * @param normal defines the normal to use
  33898. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33899. * @returns the current mesh
  33900. */
  33901. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33902. /** @hidden */
  33903. _checkOcclusionQuery(): boolean;
  33904. /**
  33905. * Disables the mesh edge rendering mode
  33906. * @returns the currentAbstractMesh
  33907. */
  33908. disableEdgesRendering(): AbstractMesh;
  33909. /**
  33910. * Enables the edge rendering mode on the mesh.
  33911. * This mode makes the mesh edges visible
  33912. * @param epsilon defines the maximal distance between two angles to detect a face
  33913. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33914. * @returns the currentAbstractMesh
  33915. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33916. */
  33917. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33918. /**
  33919. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33920. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33921. */
  33922. getConnectedParticleSystems(): IParticleSystem[];
  33923. }
  33924. }
  33925. declare module "babylonjs/Actions/actionEvent" {
  33926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33927. import { Nullable } from "babylonjs/types";
  33928. import { Sprite } from "babylonjs/Sprites/sprite";
  33929. import { Scene } from "babylonjs/scene";
  33930. import { Vector2 } from "babylonjs/Maths/math.vector";
  33931. /**
  33932. * Interface used to define ActionEvent
  33933. */
  33934. export interface IActionEvent {
  33935. /** The mesh or sprite that triggered the action */
  33936. source: any;
  33937. /** The X mouse cursor position at the time of the event */
  33938. pointerX: number;
  33939. /** The Y mouse cursor position at the time of the event */
  33940. pointerY: number;
  33941. /** The mesh that is currently pointed at (can be null) */
  33942. meshUnderPointer: Nullable<AbstractMesh>;
  33943. /** the original (browser) event that triggered the ActionEvent */
  33944. sourceEvent?: any;
  33945. /** additional data for the event */
  33946. additionalData?: any;
  33947. }
  33948. /**
  33949. * ActionEvent is the event being sent when an action is triggered.
  33950. */
  33951. export class ActionEvent implements IActionEvent {
  33952. /** The mesh or sprite that triggered the action */
  33953. source: any;
  33954. /** The X mouse cursor position at the time of the event */
  33955. pointerX: number;
  33956. /** The Y mouse cursor position at the time of the event */
  33957. pointerY: number;
  33958. /** The mesh that is currently pointed at (can be null) */
  33959. meshUnderPointer: Nullable<AbstractMesh>;
  33960. /** the original (browser) event that triggered the ActionEvent */
  33961. sourceEvent?: any;
  33962. /** additional data for the event */
  33963. additionalData?: any;
  33964. /**
  33965. * Creates a new ActionEvent
  33966. * @param source The mesh or sprite that triggered the action
  33967. * @param pointerX The X mouse cursor position at the time of the event
  33968. * @param pointerY The Y mouse cursor position at the time of the event
  33969. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33970. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33971. * @param additionalData additional data for the event
  33972. */
  33973. constructor(
  33974. /** The mesh or sprite that triggered the action */
  33975. source: any,
  33976. /** The X mouse cursor position at the time of the event */
  33977. pointerX: number,
  33978. /** The Y mouse cursor position at the time of the event */
  33979. pointerY: number,
  33980. /** The mesh that is currently pointed at (can be null) */
  33981. meshUnderPointer: Nullable<AbstractMesh>,
  33982. /** the original (browser) event that triggered the ActionEvent */
  33983. sourceEvent?: any,
  33984. /** additional data for the event */
  33985. additionalData?: any);
  33986. /**
  33987. * Helper function to auto-create an ActionEvent from a source mesh.
  33988. * @param source The source mesh that triggered the event
  33989. * @param evt The original (browser) event
  33990. * @param additionalData additional data for the event
  33991. * @returns the new ActionEvent
  33992. */
  33993. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33994. /**
  33995. * Helper function to auto-create an ActionEvent from a source sprite
  33996. * @param source The source sprite that triggered the event
  33997. * @param scene Scene associated with the sprite
  33998. * @param evt The original (browser) event
  33999. * @param additionalData additional data for the event
  34000. * @returns the new ActionEvent
  34001. */
  34002. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34003. /**
  34004. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34005. * @param scene the scene where the event occurred
  34006. * @param evt The original (browser) event
  34007. * @returns the new ActionEvent
  34008. */
  34009. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34010. /**
  34011. * Helper function to auto-create an ActionEvent from a primitive
  34012. * @param prim defines the target primitive
  34013. * @param pointerPos defines the pointer position
  34014. * @param evt The original (browser) event
  34015. * @param additionalData additional data for the event
  34016. * @returns the new ActionEvent
  34017. */
  34018. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34019. }
  34020. }
  34021. declare module "babylonjs/Actions/abstractActionManager" {
  34022. import { IDisposable } from "babylonjs/scene";
  34023. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34024. import { IAction } from "babylonjs/Actions/action";
  34025. import { Nullable } from "babylonjs/types";
  34026. /**
  34027. * Abstract class used to decouple action Manager from scene and meshes.
  34028. * Do not instantiate.
  34029. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34030. */
  34031. export abstract class AbstractActionManager implements IDisposable {
  34032. /** Gets the list of active triggers */
  34033. static Triggers: {
  34034. [key: string]: number;
  34035. };
  34036. /** Gets the cursor to use when hovering items */
  34037. hoverCursor: string;
  34038. /** Gets the list of actions */
  34039. actions: IAction[];
  34040. /**
  34041. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34042. */
  34043. isRecursive: boolean;
  34044. /**
  34045. * Releases all associated resources
  34046. */
  34047. abstract dispose(): void;
  34048. /**
  34049. * Does this action manager has pointer triggers
  34050. */
  34051. abstract get hasPointerTriggers(): boolean;
  34052. /**
  34053. * Does this action manager has pick triggers
  34054. */
  34055. abstract get hasPickTriggers(): boolean;
  34056. /**
  34057. * Process a specific trigger
  34058. * @param trigger defines the trigger to process
  34059. * @param evt defines the event details to be processed
  34060. */
  34061. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34062. /**
  34063. * Does this action manager handles actions of any of the given triggers
  34064. * @param triggers defines the triggers to be tested
  34065. * @return a boolean indicating whether one (or more) of the triggers is handled
  34066. */
  34067. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34068. /**
  34069. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34070. * speed.
  34071. * @param triggerA defines the trigger to be tested
  34072. * @param triggerB defines the trigger to be tested
  34073. * @return a boolean indicating whether one (or more) of the triggers is handled
  34074. */
  34075. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34076. /**
  34077. * Does this action manager handles actions of a given trigger
  34078. * @param trigger defines the trigger to be tested
  34079. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34080. * @return whether the trigger is handled
  34081. */
  34082. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34083. /**
  34084. * Serialize this manager to a JSON object
  34085. * @param name defines the property name to store this manager
  34086. * @returns a JSON representation of this manager
  34087. */
  34088. abstract serialize(name: string): any;
  34089. /**
  34090. * Registers an action to this action manager
  34091. * @param action defines the action to be registered
  34092. * @return the action amended (prepared) after registration
  34093. */
  34094. abstract registerAction(action: IAction): Nullable<IAction>;
  34095. /**
  34096. * Unregisters an action to this action manager
  34097. * @param action defines the action to be unregistered
  34098. * @return a boolean indicating whether the action has been unregistered
  34099. */
  34100. abstract unregisterAction(action: IAction): Boolean;
  34101. /**
  34102. * Does exist one action manager with at least one trigger
  34103. **/
  34104. static get HasTriggers(): boolean;
  34105. /**
  34106. * Does exist one action manager with at least one pick trigger
  34107. **/
  34108. static get HasPickTriggers(): boolean;
  34109. /**
  34110. * Does exist one action manager that handles actions of a given trigger
  34111. * @param trigger defines the trigger to be tested
  34112. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34113. **/
  34114. static HasSpecificTrigger(trigger: number): boolean;
  34115. }
  34116. }
  34117. declare module "babylonjs/node" {
  34118. import { Scene } from "babylonjs/scene";
  34119. import { Nullable } from "babylonjs/types";
  34120. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34121. import { Engine } from "babylonjs/Engines/engine";
  34122. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34123. import { Observable } from "babylonjs/Misc/observable";
  34124. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34125. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34126. import { Animatable } from "babylonjs/Animations/animatable";
  34127. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34128. import { Animation } from "babylonjs/Animations/animation";
  34129. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34131. /**
  34132. * Defines how a node can be built from a string name.
  34133. */
  34134. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34135. /**
  34136. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34137. */
  34138. export class Node implements IBehaviorAware<Node> {
  34139. /** @hidden */
  34140. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34141. private static _NodeConstructors;
  34142. /**
  34143. * Add a new node constructor
  34144. * @param type defines the type name of the node to construct
  34145. * @param constructorFunc defines the constructor function
  34146. */
  34147. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34148. /**
  34149. * Returns a node constructor based on type name
  34150. * @param type defines the type name
  34151. * @param name defines the new node name
  34152. * @param scene defines the hosting scene
  34153. * @param options defines optional options to transmit to constructors
  34154. * @returns the new constructor or null
  34155. */
  34156. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34157. /**
  34158. * Gets or sets the name of the node
  34159. */
  34160. name: string;
  34161. /**
  34162. * Gets or sets the id of the node
  34163. */
  34164. id: string;
  34165. /**
  34166. * Gets or sets the unique id of the node
  34167. */
  34168. uniqueId: number;
  34169. /**
  34170. * Gets or sets a string used to store user defined state for the node
  34171. */
  34172. state: string;
  34173. /**
  34174. * Gets or sets an object used to store user defined information for the node
  34175. */
  34176. metadata: any;
  34177. /**
  34178. * For internal use only. Please do not use.
  34179. */
  34180. reservedDataStore: any;
  34181. /**
  34182. * List of inspectable custom properties (used by the Inspector)
  34183. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34184. */
  34185. inspectableCustomProperties: IInspectable[];
  34186. private _doNotSerialize;
  34187. /**
  34188. * Gets or sets a boolean used to define if the node must be serialized
  34189. */
  34190. get doNotSerialize(): boolean;
  34191. set doNotSerialize(value: boolean);
  34192. /** @hidden */
  34193. _isDisposed: boolean;
  34194. /**
  34195. * Gets a list of Animations associated with the node
  34196. */
  34197. animations: import("babylonjs/Animations/animation").Animation[];
  34198. protected _ranges: {
  34199. [name: string]: Nullable<AnimationRange>;
  34200. };
  34201. /**
  34202. * Callback raised when the node is ready to be used
  34203. */
  34204. onReady: Nullable<(node: Node) => void>;
  34205. private _isEnabled;
  34206. private _isParentEnabled;
  34207. private _isReady;
  34208. /** @hidden */
  34209. _currentRenderId: number;
  34210. private _parentUpdateId;
  34211. /** @hidden */
  34212. _childUpdateId: number;
  34213. /** @hidden */
  34214. _waitingParentId: Nullable<string>;
  34215. /** @hidden */
  34216. _scene: Scene;
  34217. /** @hidden */
  34218. _cache: any;
  34219. private _parentNode;
  34220. private _children;
  34221. /** @hidden */
  34222. _worldMatrix: Matrix;
  34223. /** @hidden */
  34224. _worldMatrixDeterminant: number;
  34225. /** @hidden */
  34226. _worldMatrixDeterminantIsDirty: boolean;
  34227. /** @hidden */
  34228. private _sceneRootNodesIndex;
  34229. /**
  34230. * Gets a boolean indicating if the node has been disposed
  34231. * @returns true if the node was disposed
  34232. */
  34233. isDisposed(): boolean;
  34234. /**
  34235. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34236. * @see https://doc.babylonjs.com/how_to/parenting
  34237. */
  34238. set parent(parent: Nullable<Node>);
  34239. get parent(): Nullable<Node>;
  34240. /** @hidden */
  34241. _addToSceneRootNodes(): void;
  34242. /** @hidden */
  34243. _removeFromSceneRootNodes(): void;
  34244. private _animationPropertiesOverride;
  34245. /**
  34246. * Gets or sets the animation properties override
  34247. */
  34248. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34249. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34250. /**
  34251. * Gets a string identifying the name of the class
  34252. * @returns "Node" string
  34253. */
  34254. getClassName(): string;
  34255. /** @hidden */
  34256. readonly _isNode: boolean;
  34257. /**
  34258. * An event triggered when the mesh is disposed
  34259. */
  34260. onDisposeObservable: Observable<Node>;
  34261. private _onDisposeObserver;
  34262. /**
  34263. * Sets a callback that will be raised when the node will be disposed
  34264. */
  34265. set onDispose(callback: () => void);
  34266. /**
  34267. * Creates a new Node
  34268. * @param name the name and id to be given to this node
  34269. * @param scene the scene this node will be added to
  34270. */
  34271. constructor(name: string, scene?: Nullable<Scene>);
  34272. /**
  34273. * Gets the scene of the node
  34274. * @returns a scene
  34275. */
  34276. getScene(): Scene;
  34277. /**
  34278. * Gets the engine of the node
  34279. * @returns a Engine
  34280. */
  34281. getEngine(): Engine;
  34282. private _behaviors;
  34283. /**
  34284. * Attach a behavior to the node
  34285. * @see https://doc.babylonjs.com/features/behaviour
  34286. * @param behavior defines the behavior to attach
  34287. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34288. * @returns the current Node
  34289. */
  34290. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34291. /**
  34292. * Remove an attached behavior
  34293. * @see https://doc.babylonjs.com/features/behaviour
  34294. * @param behavior defines the behavior to attach
  34295. * @returns the current Node
  34296. */
  34297. removeBehavior(behavior: Behavior<Node>): Node;
  34298. /**
  34299. * Gets the list of attached behaviors
  34300. * @see https://doc.babylonjs.com/features/behaviour
  34301. */
  34302. get behaviors(): Behavior<Node>[];
  34303. /**
  34304. * Gets an attached behavior by name
  34305. * @param name defines the name of the behavior to look for
  34306. * @see https://doc.babylonjs.com/features/behaviour
  34307. * @returns null if behavior was not found else the requested behavior
  34308. */
  34309. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34310. /**
  34311. * Returns the latest update of the World matrix
  34312. * @returns a Matrix
  34313. */
  34314. getWorldMatrix(): Matrix;
  34315. /** @hidden */
  34316. _getWorldMatrixDeterminant(): number;
  34317. /**
  34318. * Returns directly the latest state of the mesh World matrix.
  34319. * A Matrix is returned.
  34320. */
  34321. get worldMatrixFromCache(): Matrix;
  34322. /** @hidden */
  34323. _initCache(): void;
  34324. /** @hidden */
  34325. updateCache(force?: boolean): void;
  34326. /** @hidden */
  34327. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34328. /** @hidden */
  34329. _updateCache(ignoreParentClass?: boolean): void;
  34330. /** @hidden */
  34331. _isSynchronized(): boolean;
  34332. /** @hidden */
  34333. _markSyncedWithParent(): void;
  34334. /** @hidden */
  34335. isSynchronizedWithParent(): boolean;
  34336. /** @hidden */
  34337. isSynchronized(): boolean;
  34338. /**
  34339. * Is this node ready to be used/rendered
  34340. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34341. * @return true if the node is ready
  34342. */
  34343. isReady(completeCheck?: boolean): boolean;
  34344. /**
  34345. * Is this node enabled?
  34346. * 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
  34347. * @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
  34348. * @return whether this node (and its parent) is enabled
  34349. */
  34350. isEnabled(checkAncestors?: boolean): boolean;
  34351. /** @hidden */
  34352. protected _syncParentEnabledState(): void;
  34353. /**
  34354. * Set the enabled state of this node
  34355. * @param value defines the new enabled state
  34356. */
  34357. setEnabled(value: boolean): void;
  34358. /**
  34359. * Is this node a descendant of the given node?
  34360. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34361. * @param ancestor defines the parent node to inspect
  34362. * @returns a boolean indicating if this node is a descendant of the given node
  34363. */
  34364. isDescendantOf(ancestor: Node): boolean;
  34365. /** @hidden */
  34366. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34367. /**
  34368. * Will return all nodes that have this node as ascendant
  34369. * @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
  34370. * @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
  34371. * @return all children nodes of all types
  34372. */
  34373. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34374. /**
  34375. * Get all child-meshes of this node
  34376. * @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)
  34377. * @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
  34378. * @returns an array of AbstractMesh
  34379. */
  34380. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34381. /**
  34382. * Get all direct children of this node
  34383. * @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
  34384. * @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)
  34385. * @returns an array of Node
  34386. */
  34387. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34388. /** @hidden */
  34389. _setReady(state: boolean): void;
  34390. /**
  34391. * Get an animation by name
  34392. * @param name defines the name of the animation to look for
  34393. * @returns null if not found else the requested animation
  34394. */
  34395. getAnimationByName(name: string): Nullable<Animation>;
  34396. /**
  34397. * Creates an animation range for this node
  34398. * @param name defines the name of the range
  34399. * @param from defines the starting key
  34400. * @param to defines the end key
  34401. */
  34402. createAnimationRange(name: string, from: number, to: number): void;
  34403. /**
  34404. * Delete a specific animation range
  34405. * @param name defines the name of the range to delete
  34406. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34407. */
  34408. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34409. /**
  34410. * Get an animation range by name
  34411. * @param name defines the name of the animation range to look for
  34412. * @returns null if not found else the requested animation range
  34413. */
  34414. getAnimationRange(name: string): Nullable<AnimationRange>;
  34415. /**
  34416. * Gets the list of all animation ranges defined on this node
  34417. * @returns an array
  34418. */
  34419. getAnimationRanges(): Nullable<AnimationRange>[];
  34420. /**
  34421. * Will start the animation sequence
  34422. * @param name defines the range frames for animation sequence
  34423. * @param loop defines if the animation should loop (false by default)
  34424. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34425. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34426. * @returns the object created for this animation. If range does not exist, it will return null
  34427. */
  34428. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34429. /**
  34430. * Serialize animation ranges into a JSON compatible object
  34431. * @returns serialization object
  34432. */
  34433. serializeAnimationRanges(): any;
  34434. /**
  34435. * Computes the world matrix of the node
  34436. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34437. * @returns the world matrix
  34438. */
  34439. computeWorldMatrix(force?: boolean): Matrix;
  34440. /**
  34441. * Releases resources associated with this node.
  34442. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34443. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34444. */
  34445. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34446. /**
  34447. * Parse animation range data from a serialization object and store them into a given node
  34448. * @param node defines where to store the animation ranges
  34449. * @param parsedNode defines the serialization object to read data from
  34450. * @param scene defines the hosting scene
  34451. */
  34452. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34453. /**
  34454. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34455. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34456. * @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
  34457. * @returns the new bounding vectors
  34458. */
  34459. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34460. min: Vector3;
  34461. max: Vector3;
  34462. };
  34463. }
  34464. }
  34465. declare module "babylonjs/Animations/animation" {
  34466. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34467. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34468. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34469. import { Nullable } from "babylonjs/types";
  34470. import { Scene } from "babylonjs/scene";
  34471. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34472. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34473. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34474. import { Node } from "babylonjs/node";
  34475. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34476. import { Size } from "babylonjs/Maths/math.size";
  34477. import { Animatable } from "babylonjs/Animations/animatable";
  34478. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34479. /**
  34480. * @hidden
  34481. */
  34482. export class _IAnimationState {
  34483. key: number;
  34484. repeatCount: number;
  34485. workValue?: any;
  34486. loopMode?: number;
  34487. offsetValue?: any;
  34488. highLimitValue?: any;
  34489. }
  34490. /**
  34491. * Class used to store any kind of animation
  34492. */
  34493. export class Animation {
  34494. /**Name of the animation */
  34495. name: string;
  34496. /**Property to animate */
  34497. targetProperty: string;
  34498. /**The frames per second of the animation */
  34499. framePerSecond: number;
  34500. /**The data type of the animation */
  34501. dataType: number;
  34502. /**The loop mode of the animation */
  34503. loopMode?: number | undefined;
  34504. /**Specifies if blending should be enabled */
  34505. enableBlending?: boolean | undefined;
  34506. /**
  34507. * Use matrix interpolation instead of using direct key value when animating matrices
  34508. */
  34509. static AllowMatricesInterpolation: boolean;
  34510. /**
  34511. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34512. */
  34513. static AllowMatrixDecomposeForInterpolation: boolean;
  34514. /** Define the Url to load snippets */
  34515. static SnippetUrl: string;
  34516. /** Snippet ID if the animation was created from the snippet server */
  34517. snippetId: string;
  34518. /**
  34519. * Stores the key frames of the animation
  34520. */
  34521. private _keys;
  34522. /**
  34523. * Stores the easing function of the animation
  34524. */
  34525. private _easingFunction;
  34526. /**
  34527. * @hidden Internal use only
  34528. */
  34529. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34530. /**
  34531. * The set of event that will be linked to this animation
  34532. */
  34533. private _events;
  34534. /**
  34535. * Stores an array of target property paths
  34536. */
  34537. targetPropertyPath: string[];
  34538. /**
  34539. * Stores the blending speed of the animation
  34540. */
  34541. blendingSpeed: number;
  34542. /**
  34543. * Stores the animation ranges for the animation
  34544. */
  34545. private _ranges;
  34546. /**
  34547. * @hidden Internal use
  34548. */
  34549. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34550. /**
  34551. * Sets up an animation
  34552. * @param property The property to animate
  34553. * @param animationType The animation type to apply
  34554. * @param framePerSecond The frames per second of the animation
  34555. * @param easingFunction The easing function used in the animation
  34556. * @returns The created animation
  34557. */
  34558. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34559. /**
  34560. * Create and start an animation on a node
  34561. * @param name defines the name of the global animation that will be run on all nodes
  34562. * @param node defines the root node where the animation will take place
  34563. * @param targetProperty defines property to animate
  34564. * @param framePerSecond defines the number of frame per second yo use
  34565. * @param totalFrame defines the number of frames in total
  34566. * @param from defines the initial value
  34567. * @param to defines the final value
  34568. * @param loopMode defines which loop mode you want to use (off by default)
  34569. * @param easingFunction defines the easing function to use (linear by default)
  34570. * @param onAnimationEnd defines the callback to call when animation end
  34571. * @returns the animatable created for this animation
  34572. */
  34573. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34574. /**
  34575. * Create and start an animation on a node and its descendants
  34576. * @param name defines the name of the global animation that will be run on all nodes
  34577. * @param node defines the root node where the animation will take place
  34578. * @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
  34579. * @param targetProperty defines property to animate
  34580. * @param framePerSecond defines the number of frame per second to use
  34581. * @param totalFrame defines the number of frames in total
  34582. * @param from defines the initial value
  34583. * @param to defines the final value
  34584. * @param loopMode defines which loop mode you want to use (off by default)
  34585. * @param easingFunction defines the easing function to use (linear by default)
  34586. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34587. * @returns the list of animatables created for all nodes
  34588. * @example https://www.babylonjs-playground.com/#MH0VLI
  34589. */
  34590. 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[]>;
  34591. /**
  34592. * Creates a new animation, merges it with the existing animations and starts it
  34593. * @param name Name of the animation
  34594. * @param node Node which contains the scene that begins the animations
  34595. * @param targetProperty Specifies which property to animate
  34596. * @param framePerSecond The frames per second of the animation
  34597. * @param totalFrame The total number of frames
  34598. * @param from The frame at the beginning of the animation
  34599. * @param to The frame at the end of the animation
  34600. * @param loopMode Specifies the loop mode of the animation
  34601. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34602. * @param onAnimationEnd Callback to run once the animation is complete
  34603. * @returns Nullable animation
  34604. */
  34605. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34606. /**
  34607. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34608. * @param sourceAnimation defines the Animation containing keyframes to convert
  34609. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34610. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34611. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34612. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34613. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34614. */
  34615. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34616. /**
  34617. * Transition property of an host to the target Value
  34618. * @param property The property to transition
  34619. * @param targetValue The target Value of the property
  34620. * @param host The object where the property to animate belongs
  34621. * @param scene Scene used to run the animation
  34622. * @param frameRate Framerate (in frame/s) to use
  34623. * @param transition The transition type we want to use
  34624. * @param duration The duration of the animation, in milliseconds
  34625. * @param onAnimationEnd Callback trigger at the end of the animation
  34626. * @returns Nullable animation
  34627. */
  34628. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34629. /**
  34630. * Return the array of runtime animations currently using this animation
  34631. */
  34632. get runtimeAnimations(): RuntimeAnimation[];
  34633. /**
  34634. * Specifies if any of the runtime animations are currently running
  34635. */
  34636. get hasRunningRuntimeAnimations(): boolean;
  34637. /**
  34638. * Initializes the animation
  34639. * @param name Name of the animation
  34640. * @param targetProperty Property to animate
  34641. * @param framePerSecond The frames per second of the animation
  34642. * @param dataType The data type of the animation
  34643. * @param loopMode The loop mode of the animation
  34644. * @param enableBlending Specifies if blending should be enabled
  34645. */
  34646. constructor(
  34647. /**Name of the animation */
  34648. name: string,
  34649. /**Property to animate */
  34650. targetProperty: string,
  34651. /**The frames per second of the animation */
  34652. framePerSecond: number,
  34653. /**The data type of the animation */
  34654. dataType: number,
  34655. /**The loop mode of the animation */
  34656. loopMode?: number | undefined,
  34657. /**Specifies if blending should be enabled */
  34658. enableBlending?: boolean | undefined);
  34659. /**
  34660. * Converts the animation to a string
  34661. * @param fullDetails support for multiple levels of logging within scene loading
  34662. * @returns String form of the animation
  34663. */
  34664. toString(fullDetails?: boolean): string;
  34665. /**
  34666. * Add an event to this animation
  34667. * @param event Event to add
  34668. */
  34669. addEvent(event: AnimationEvent): void;
  34670. /**
  34671. * Remove all events found at the given frame
  34672. * @param frame The frame to remove events from
  34673. */
  34674. removeEvents(frame: number): void;
  34675. /**
  34676. * Retrieves all the events from the animation
  34677. * @returns Events from the animation
  34678. */
  34679. getEvents(): AnimationEvent[];
  34680. /**
  34681. * Creates an animation range
  34682. * @param name Name of the animation range
  34683. * @param from Starting frame of the animation range
  34684. * @param to Ending frame of the animation
  34685. */
  34686. createRange(name: string, from: number, to: number): void;
  34687. /**
  34688. * Deletes an animation range by name
  34689. * @param name Name of the animation range to delete
  34690. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34691. */
  34692. deleteRange(name: string, deleteFrames?: boolean): void;
  34693. /**
  34694. * Gets the animation range by name, or null if not defined
  34695. * @param name Name of the animation range
  34696. * @returns Nullable animation range
  34697. */
  34698. getRange(name: string): Nullable<AnimationRange>;
  34699. /**
  34700. * Gets the key frames from the animation
  34701. * @returns The key frames of the animation
  34702. */
  34703. getKeys(): Array<IAnimationKey>;
  34704. /**
  34705. * Gets the highest frame rate of the animation
  34706. * @returns Highest frame rate of the animation
  34707. */
  34708. getHighestFrame(): number;
  34709. /**
  34710. * Gets the easing function of the animation
  34711. * @returns Easing function of the animation
  34712. */
  34713. getEasingFunction(): IEasingFunction;
  34714. /**
  34715. * Sets the easing function of the animation
  34716. * @param easingFunction A custom mathematical formula for animation
  34717. */
  34718. setEasingFunction(easingFunction: EasingFunction): void;
  34719. /**
  34720. * Interpolates a scalar linearly
  34721. * @param startValue Start value of the animation curve
  34722. * @param endValue End value of the animation curve
  34723. * @param gradient Scalar amount to interpolate
  34724. * @returns Interpolated scalar value
  34725. */
  34726. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34727. /**
  34728. * Interpolates a scalar cubically
  34729. * @param startValue Start value of the animation curve
  34730. * @param outTangent End tangent of the animation
  34731. * @param endValue End value of the animation curve
  34732. * @param inTangent Start tangent of the animation curve
  34733. * @param gradient Scalar amount to interpolate
  34734. * @returns Interpolated scalar value
  34735. */
  34736. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34737. /**
  34738. * Interpolates a quaternion using a spherical linear interpolation
  34739. * @param startValue Start value of the animation curve
  34740. * @param endValue End value of the animation curve
  34741. * @param gradient Scalar amount to interpolate
  34742. * @returns Interpolated quaternion value
  34743. */
  34744. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34745. /**
  34746. * Interpolates a quaternion cubically
  34747. * @param startValue Start value of the animation curve
  34748. * @param outTangent End tangent of the animation curve
  34749. * @param endValue End value of the animation curve
  34750. * @param inTangent Start tangent of the animation curve
  34751. * @param gradient Scalar amount to interpolate
  34752. * @returns Interpolated quaternion value
  34753. */
  34754. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34755. /**
  34756. * Interpolates a Vector3 linearl
  34757. * @param startValue Start value of the animation curve
  34758. * @param endValue End value of the animation curve
  34759. * @param gradient Scalar amount to interpolate
  34760. * @returns Interpolated scalar value
  34761. */
  34762. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34763. /**
  34764. * Interpolates a Vector3 cubically
  34765. * @param startValue Start value of the animation curve
  34766. * @param outTangent End tangent of the animation
  34767. * @param endValue End value of the animation curve
  34768. * @param inTangent Start tangent of the animation curve
  34769. * @param gradient Scalar amount to interpolate
  34770. * @returns InterpolatedVector3 value
  34771. */
  34772. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34773. /**
  34774. * Interpolates a Vector2 linearly
  34775. * @param startValue Start value of the animation curve
  34776. * @param endValue End value of the animation curve
  34777. * @param gradient Scalar amount to interpolate
  34778. * @returns Interpolated Vector2 value
  34779. */
  34780. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34781. /**
  34782. * Interpolates a Vector2 cubically
  34783. * @param startValue Start value of the animation curve
  34784. * @param outTangent End tangent of the animation
  34785. * @param endValue End value of the animation curve
  34786. * @param inTangent Start tangent of the animation curve
  34787. * @param gradient Scalar amount to interpolate
  34788. * @returns Interpolated Vector2 value
  34789. */
  34790. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34791. /**
  34792. * Interpolates a size linearly
  34793. * @param startValue Start value of the animation curve
  34794. * @param endValue End value of the animation curve
  34795. * @param gradient Scalar amount to interpolate
  34796. * @returns Interpolated Size value
  34797. */
  34798. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34799. /**
  34800. * Interpolates a Color3 linearly
  34801. * @param startValue Start value of the animation curve
  34802. * @param endValue End value of the animation curve
  34803. * @param gradient Scalar amount to interpolate
  34804. * @returns Interpolated Color3 value
  34805. */
  34806. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34807. /**
  34808. * Interpolates a Color4 linearly
  34809. * @param startValue Start value of the animation curve
  34810. * @param endValue End value of the animation curve
  34811. * @param gradient Scalar amount to interpolate
  34812. * @returns Interpolated Color3 value
  34813. */
  34814. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34815. /**
  34816. * @hidden Internal use only
  34817. */
  34818. _getKeyValue(value: any): any;
  34819. /**
  34820. * @hidden Internal use only
  34821. */
  34822. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34823. /**
  34824. * Defines the function to use to interpolate matrices
  34825. * @param startValue defines the start matrix
  34826. * @param endValue defines the end matrix
  34827. * @param gradient defines the gradient between both matrices
  34828. * @param result defines an optional target matrix where to store the interpolation
  34829. * @returns the interpolated matrix
  34830. */
  34831. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34832. /**
  34833. * Makes a copy of the animation
  34834. * @returns Cloned animation
  34835. */
  34836. clone(): Animation;
  34837. /**
  34838. * Sets the key frames of the animation
  34839. * @param values The animation key frames to set
  34840. */
  34841. setKeys(values: Array<IAnimationKey>): void;
  34842. /**
  34843. * Serializes the animation to an object
  34844. * @returns Serialized object
  34845. */
  34846. serialize(): any;
  34847. /**
  34848. * Float animation type
  34849. */
  34850. static readonly ANIMATIONTYPE_FLOAT: number;
  34851. /**
  34852. * Vector3 animation type
  34853. */
  34854. static readonly ANIMATIONTYPE_VECTOR3: number;
  34855. /**
  34856. * Quaternion animation type
  34857. */
  34858. static readonly ANIMATIONTYPE_QUATERNION: number;
  34859. /**
  34860. * Matrix animation type
  34861. */
  34862. static readonly ANIMATIONTYPE_MATRIX: number;
  34863. /**
  34864. * Color3 animation type
  34865. */
  34866. static readonly ANIMATIONTYPE_COLOR3: number;
  34867. /**
  34868. * Color3 animation type
  34869. */
  34870. static readonly ANIMATIONTYPE_COLOR4: number;
  34871. /**
  34872. * Vector2 animation type
  34873. */
  34874. static readonly ANIMATIONTYPE_VECTOR2: number;
  34875. /**
  34876. * Size animation type
  34877. */
  34878. static readonly ANIMATIONTYPE_SIZE: number;
  34879. /**
  34880. * Relative Loop Mode
  34881. */
  34882. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34883. /**
  34884. * Cycle Loop Mode
  34885. */
  34886. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34887. /**
  34888. * Constant Loop Mode
  34889. */
  34890. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34891. /** @hidden */
  34892. static _UniversalLerp(left: any, right: any, amount: number): any;
  34893. /**
  34894. * Parses an animation object and creates an animation
  34895. * @param parsedAnimation Parsed animation object
  34896. * @returns Animation object
  34897. */
  34898. static Parse(parsedAnimation: any): Animation;
  34899. /**
  34900. * Appends the serialized animations from the source animations
  34901. * @param source Source containing the animations
  34902. * @param destination Target to store the animations
  34903. */
  34904. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34905. /**
  34906. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34907. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34908. * @param url defines the url to load from
  34909. * @returns a promise that will resolve to the new animation or an array of animations
  34910. */
  34911. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34912. /**
  34913. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34914. * @param snippetId defines the snippet to load
  34915. * @returns a promise that will resolve to the new animation or a new array of animations
  34916. */
  34917. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34918. }
  34919. }
  34920. declare module "babylonjs/Animations/animatable.interface" {
  34921. import { Nullable } from "babylonjs/types";
  34922. import { Animation } from "babylonjs/Animations/animation";
  34923. /**
  34924. * Interface containing an array of animations
  34925. */
  34926. export interface IAnimatable {
  34927. /**
  34928. * Array of animations
  34929. */
  34930. animations: Nullable<Array<Animation>>;
  34931. }
  34932. }
  34933. declare module "babylonjs/Misc/decorators" {
  34934. import { Nullable } from "babylonjs/types";
  34935. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34936. import { Scene } from "babylonjs/scene";
  34937. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34938. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34939. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34941. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34942. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34943. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34944. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34945. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34946. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34947. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34948. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34949. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34950. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34951. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34952. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34953. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34954. /**
  34955. * Decorator used to define property that can be serialized as reference to a camera
  34956. * @param sourceName defines the name of the property to decorate
  34957. */
  34958. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34959. /**
  34960. * Class used to help serialization objects
  34961. */
  34962. export class SerializationHelper {
  34963. /** @hidden */
  34964. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34965. /** @hidden */
  34966. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34967. /** @hidden */
  34968. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34969. /** @hidden */
  34970. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34971. /**
  34972. * Appends the serialized animations from the source animations
  34973. * @param source Source containing the animations
  34974. * @param destination Target to store the animations
  34975. */
  34976. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34977. /**
  34978. * Static function used to serialized a specific entity
  34979. * @param entity defines the entity to serialize
  34980. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34981. * @returns a JSON compatible object representing the serialization of the entity
  34982. */
  34983. static Serialize<T>(entity: T, serializationObject?: any): any;
  34984. /**
  34985. * Creates a new entity from a serialization data object
  34986. * @param creationFunction defines a function used to instanciated the new entity
  34987. * @param source defines the source serialization data
  34988. * @param scene defines the hosting scene
  34989. * @param rootUrl defines the root url for resources
  34990. * @returns a new entity
  34991. */
  34992. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34993. /**
  34994. * Clones an object
  34995. * @param creationFunction defines the function used to instanciate the new object
  34996. * @param source defines the source object
  34997. * @returns the cloned object
  34998. */
  34999. static Clone<T>(creationFunction: () => T, source: T): T;
  35000. /**
  35001. * Instanciates a new object based on a source one (some data will be shared between both object)
  35002. * @param creationFunction defines the function used to instanciate the new object
  35003. * @param source defines the source object
  35004. * @returns the new object
  35005. */
  35006. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35007. }
  35008. }
  35009. declare module "babylonjs/Materials/Textures/baseTexture" {
  35010. import { Observable } from "babylonjs/Misc/observable";
  35011. import { Nullable } from "babylonjs/types";
  35012. import { Scene } from "babylonjs/scene";
  35013. import { Matrix } from "babylonjs/Maths/math.vector";
  35014. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35015. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35016. import { ISize } from "babylonjs/Maths/math.size";
  35017. import "babylonjs/Misc/fileTools";
  35018. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35019. /**
  35020. * Base class of all the textures in babylon.
  35021. * It groups all the common properties the materials, post process, lights... might need
  35022. * in order to make a correct use of the texture.
  35023. */
  35024. export class BaseTexture implements IAnimatable {
  35025. /**
  35026. * Default anisotropic filtering level for the application.
  35027. * It is set to 4 as a good tradeoff between perf and quality.
  35028. */
  35029. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35030. /**
  35031. * Gets or sets the unique id of the texture
  35032. */
  35033. uniqueId: number;
  35034. /**
  35035. * Define the name of the texture.
  35036. */
  35037. name: string;
  35038. /**
  35039. * Gets or sets an object used to store user defined information.
  35040. */
  35041. metadata: any;
  35042. /**
  35043. * For internal use only. Please do not use.
  35044. */
  35045. reservedDataStore: any;
  35046. private _hasAlpha;
  35047. /**
  35048. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35049. */
  35050. set hasAlpha(value: boolean);
  35051. get hasAlpha(): boolean;
  35052. /**
  35053. * Defines if the alpha value should be determined via the rgb values.
  35054. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35055. */
  35056. getAlphaFromRGB: boolean;
  35057. /**
  35058. * Intensity or strength of the texture.
  35059. * It is commonly used by materials to fine tune the intensity of the texture
  35060. */
  35061. level: number;
  35062. /**
  35063. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35064. * This is part of the texture as textures usually maps to one uv set.
  35065. */
  35066. coordinatesIndex: number;
  35067. private _coordinatesMode;
  35068. /**
  35069. * How a texture is mapped.
  35070. *
  35071. * | Value | Type | Description |
  35072. * | ----- | ----------------------------------- | ----------- |
  35073. * | 0 | EXPLICIT_MODE | |
  35074. * | 1 | SPHERICAL_MODE | |
  35075. * | 2 | PLANAR_MODE | |
  35076. * | 3 | CUBIC_MODE | |
  35077. * | 4 | PROJECTION_MODE | |
  35078. * | 5 | SKYBOX_MODE | |
  35079. * | 6 | INVCUBIC_MODE | |
  35080. * | 7 | EQUIRECTANGULAR_MODE | |
  35081. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35082. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35083. */
  35084. set coordinatesMode(value: number);
  35085. get coordinatesMode(): number;
  35086. /**
  35087. * | Value | Type | Description |
  35088. * | ----- | ------------------ | ----------- |
  35089. * | 0 | CLAMP_ADDRESSMODE | |
  35090. * | 1 | WRAP_ADDRESSMODE | |
  35091. * | 2 | MIRROR_ADDRESSMODE | |
  35092. */
  35093. wrapU: number;
  35094. /**
  35095. * | Value | Type | Description |
  35096. * | ----- | ------------------ | ----------- |
  35097. * | 0 | CLAMP_ADDRESSMODE | |
  35098. * | 1 | WRAP_ADDRESSMODE | |
  35099. * | 2 | MIRROR_ADDRESSMODE | |
  35100. */
  35101. wrapV: number;
  35102. /**
  35103. * | Value | Type | Description |
  35104. * | ----- | ------------------ | ----------- |
  35105. * | 0 | CLAMP_ADDRESSMODE | |
  35106. * | 1 | WRAP_ADDRESSMODE | |
  35107. * | 2 | MIRROR_ADDRESSMODE | |
  35108. */
  35109. wrapR: number;
  35110. /**
  35111. * With compliant hardware and browser (supporting anisotropic filtering)
  35112. * this defines the level of anisotropic filtering in the texture.
  35113. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35114. */
  35115. anisotropicFilteringLevel: number;
  35116. /**
  35117. * Define if the texture is a cube texture or if false a 2d texture.
  35118. */
  35119. get isCube(): boolean;
  35120. set isCube(value: boolean);
  35121. /**
  35122. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35123. */
  35124. get is3D(): boolean;
  35125. set is3D(value: boolean);
  35126. /**
  35127. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35128. */
  35129. get is2DArray(): boolean;
  35130. set is2DArray(value: boolean);
  35131. /**
  35132. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35133. * HDR texture are usually stored in linear space.
  35134. * This only impacts the PBR and Background materials
  35135. */
  35136. gammaSpace: boolean;
  35137. /**
  35138. * Gets or sets whether or not the texture contains RGBD data.
  35139. */
  35140. get isRGBD(): boolean;
  35141. set isRGBD(value: boolean);
  35142. /**
  35143. * Is Z inverted in the texture (useful in a cube texture).
  35144. */
  35145. invertZ: boolean;
  35146. /**
  35147. * Are mip maps generated for this texture or not.
  35148. */
  35149. get noMipmap(): boolean;
  35150. /**
  35151. * @hidden
  35152. */
  35153. lodLevelInAlpha: boolean;
  35154. /**
  35155. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35156. */
  35157. get lodGenerationOffset(): number;
  35158. set lodGenerationOffset(value: number);
  35159. /**
  35160. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35161. */
  35162. get lodGenerationScale(): number;
  35163. set lodGenerationScale(value: number);
  35164. /**
  35165. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35166. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35167. * average roughness values.
  35168. */
  35169. get linearSpecularLOD(): boolean;
  35170. set linearSpecularLOD(value: boolean);
  35171. /**
  35172. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35173. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35174. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35175. */
  35176. get irradianceTexture(): Nullable<BaseTexture>;
  35177. set irradianceTexture(value: Nullable<BaseTexture>);
  35178. /**
  35179. * Define if the texture is a render target.
  35180. */
  35181. isRenderTarget: boolean;
  35182. /**
  35183. * Define the unique id of the texture in the scene.
  35184. */
  35185. get uid(): string;
  35186. /** @hidden */
  35187. _prefiltered: boolean;
  35188. /**
  35189. * Return a string representation of the texture.
  35190. * @returns the texture as a string
  35191. */
  35192. toString(): string;
  35193. /**
  35194. * Get the class name of the texture.
  35195. * @returns "BaseTexture"
  35196. */
  35197. getClassName(): string;
  35198. /**
  35199. * Define the list of animation attached to the texture.
  35200. */
  35201. animations: import("babylonjs/Animations/animation").Animation[];
  35202. /**
  35203. * An event triggered when the texture is disposed.
  35204. */
  35205. onDisposeObservable: Observable<BaseTexture>;
  35206. private _onDisposeObserver;
  35207. /**
  35208. * Callback triggered when the texture has been disposed.
  35209. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35210. */
  35211. set onDispose(callback: () => void);
  35212. /**
  35213. * Define the current state of the loading sequence when in delayed load mode.
  35214. */
  35215. delayLoadState: number;
  35216. protected _scene: Nullable<Scene>;
  35217. protected _engine: Nullable<ThinEngine>;
  35218. /** @hidden */
  35219. _texture: Nullable<InternalTexture>;
  35220. private _uid;
  35221. /**
  35222. * Define if the texture is preventinga material to render or not.
  35223. * If not and the texture is not ready, the engine will use a default black texture instead.
  35224. */
  35225. get isBlocking(): boolean;
  35226. /**
  35227. * Instantiates a new BaseTexture.
  35228. * Base class of all the textures in babylon.
  35229. * It groups all the common properties the materials, post process, lights... might need
  35230. * in order to make a correct use of the texture.
  35231. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35232. */
  35233. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35234. /**
  35235. * Get the scene the texture belongs to.
  35236. * @returns the scene or null if undefined
  35237. */
  35238. getScene(): Nullable<Scene>;
  35239. /** @hidden */
  35240. protected _getEngine(): Nullable<ThinEngine>;
  35241. /**
  35242. * Get the texture transform matrix used to offset tile the texture for istance.
  35243. * @returns the transformation matrix
  35244. */
  35245. getTextureMatrix(): Matrix;
  35246. /**
  35247. * Get the texture reflection matrix used to rotate/transform the reflection.
  35248. * @returns the reflection matrix
  35249. */
  35250. getReflectionTextureMatrix(): Matrix;
  35251. /**
  35252. * Get the underlying lower level texture from Babylon.
  35253. * @returns the insternal texture
  35254. */
  35255. getInternalTexture(): Nullable<InternalTexture>;
  35256. /**
  35257. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35258. * @returns true if ready or not blocking
  35259. */
  35260. isReadyOrNotBlocking(): boolean;
  35261. /**
  35262. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35263. * @returns true if fully ready
  35264. */
  35265. isReady(): boolean;
  35266. private _cachedSize;
  35267. /**
  35268. * Get the size of the texture.
  35269. * @returns the texture size.
  35270. */
  35271. getSize(): ISize;
  35272. /**
  35273. * Get the base size of the texture.
  35274. * It can be different from the size if the texture has been resized for POT for instance
  35275. * @returns the base size
  35276. */
  35277. getBaseSize(): ISize;
  35278. /**
  35279. * Update the sampling mode of the texture.
  35280. * Default is Trilinear mode.
  35281. *
  35282. * | Value | Type | Description |
  35283. * | ----- | ------------------ | ----------- |
  35284. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35285. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35286. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35287. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35288. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35289. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35290. * | 7 | NEAREST_LINEAR | |
  35291. * | 8 | NEAREST_NEAREST | |
  35292. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35293. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35294. * | 11 | LINEAR_LINEAR | |
  35295. * | 12 | LINEAR_NEAREST | |
  35296. *
  35297. * > _mag_: magnification filter (close to the viewer)
  35298. * > _min_: minification filter (far from the viewer)
  35299. * > _mip_: filter used between mip map levels
  35300. *@param samplingMode Define the new sampling mode of the texture
  35301. */
  35302. updateSamplingMode(samplingMode: number): void;
  35303. /**
  35304. * Scales the texture if is `canRescale()`
  35305. * @param ratio the resize factor we want to use to rescale
  35306. */
  35307. scale(ratio: number): void;
  35308. /**
  35309. * Get if the texture can rescale.
  35310. */
  35311. get canRescale(): boolean;
  35312. /** @hidden */
  35313. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35314. /** @hidden */
  35315. _rebuild(): void;
  35316. /**
  35317. * Triggers the load sequence in delayed load mode.
  35318. */
  35319. delayLoad(): void;
  35320. /**
  35321. * Clones the texture.
  35322. * @returns the cloned texture
  35323. */
  35324. clone(): Nullable<BaseTexture>;
  35325. /**
  35326. * Get the texture underlying type (INT, FLOAT...)
  35327. */
  35328. get textureType(): number;
  35329. /**
  35330. * Get the texture underlying format (RGB, RGBA...)
  35331. */
  35332. get textureFormat(): number;
  35333. /**
  35334. * Indicates that textures need to be re-calculated for all materials
  35335. */
  35336. protected _markAllSubMeshesAsTexturesDirty(): void;
  35337. /**
  35338. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35339. * This will returns an RGBA array buffer containing either in values (0-255) or
  35340. * float values (0-1) depending of the underlying buffer type.
  35341. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35342. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35343. * @param buffer defines a user defined buffer to fill with data (can be null)
  35344. * @returns The Array buffer containing the pixels data.
  35345. */
  35346. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35347. /**
  35348. * Release and destroy the underlying lower level texture aka internalTexture.
  35349. */
  35350. releaseInternalTexture(): void;
  35351. /** @hidden */
  35352. get _lodTextureHigh(): Nullable<BaseTexture>;
  35353. /** @hidden */
  35354. get _lodTextureMid(): Nullable<BaseTexture>;
  35355. /** @hidden */
  35356. get _lodTextureLow(): Nullable<BaseTexture>;
  35357. /**
  35358. * Dispose the texture and release its associated resources.
  35359. */
  35360. dispose(): void;
  35361. /**
  35362. * Serialize the texture into a JSON representation that can be parsed later on.
  35363. * @returns the JSON representation of the texture
  35364. */
  35365. serialize(): any;
  35366. /**
  35367. * Helper function to be called back once a list of texture contains only ready textures.
  35368. * @param textures Define the list of textures to wait for
  35369. * @param callback Define the callback triggered once the entire list will be ready
  35370. */
  35371. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35372. private static _isScene;
  35373. }
  35374. }
  35375. declare module "babylonjs/Materials/effect" {
  35376. import { Observable } from "babylonjs/Misc/observable";
  35377. import { Nullable } from "babylonjs/types";
  35378. import { IDisposable } from "babylonjs/scene";
  35379. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35380. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35381. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35382. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35383. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35384. import { Engine } from "babylonjs/Engines/engine";
  35385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35388. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35389. /**
  35390. * Options to be used when creating an effect.
  35391. */
  35392. export interface IEffectCreationOptions {
  35393. /**
  35394. * Atrributes that will be used in the shader.
  35395. */
  35396. attributes: string[];
  35397. /**
  35398. * Uniform varible names that will be set in the shader.
  35399. */
  35400. uniformsNames: string[];
  35401. /**
  35402. * Uniform buffer variable names that will be set in the shader.
  35403. */
  35404. uniformBuffersNames: string[];
  35405. /**
  35406. * Sampler texture variable names that will be set in the shader.
  35407. */
  35408. samplers: string[];
  35409. /**
  35410. * Define statements that will be set in the shader.
  35411. */
  35412. defines: any;
  35413. /**
  35414. * Possible fallbacks for this effect to improve performance when needed.
  35415. */
  35416. fallbacks: Nullable<IEffectFallbacks>;
  35417. /**
  35418. * Callback that will be called when the shader is compiled.
  35419. */
  35420. onCompiled: Nullable<(effect: Effect) => void>;
  35421. /**
  35422. * Callback that will be called if an error occurs during shader compilation.
  35423. */
  35424. onError: Nullable<(effect: Effect, errors: string) => void>;
  35425. /**
  35426. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35427. */
  35428. indexParameters?: any;
  35429. /**
  35430. * Max number of lights that can be used in the shader.
  35431. */
  35432. maxSimultaneousLights?: number;
  35433. /**
  35434. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35435. */
  35436. transformFeedbackVaryings?: Nullable<string[]>;
  35437. /**
  35438. * 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
  35439. */
  35440. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35441. /**
  35442. * Is this effect rendering to several color attachments ?
  35443. */
  35444. multiTarget?: boolean;
  35445. }
  35446. /**
  35447. * Effect containing vertex and fragment shader that can be executed on an object.
  35448. */
  35449. export class Effect implements IDisposable {
  35450. /**
  35451. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35452. */
  35453. static ShadersRepository: string;
  35454. /**
  35455. * Enable logging of the shader code when a compilation error occurs
  35456. */
  35457. static LogShaderCodeOnCompilationError: boolean;
  35458. /**
  35459. * Name of the effect.
  35460. */
  35461. name: any;
  35462. /**
  35463. * String container all the define statements that should be set on the shader.
  35464. */
  35465. defines: string;
  35466. /**
  35467. * Callback that will be called when the shader is compiled.
  35468. */
  35469. onCompiled: Nullable<(effect: Effect) => void>;
  35470. /**
  35471. * Callback that will be called if an error occurs during shader compilation.
  35472. */
  35473. onError: Nullable<(effect: Effect, errors: string) => void>;
  35474. /**
  35475. * Callback that will be called when effect is bound.
  35476. */
  35477. onBind: Nullable<(effect: Effect) => void>;
  35478. /**
  35479. * Unique ID of the effect.
  35480. */
  35481. uniqueId: number;
  35482. /**
  35483. * Observable that will be called when the shader is compiled.
  35484. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35485. */
  35486. onCompileObservable: Observable<Effect>;
  35487. /**
  35488. * Observable that will be called if an error occurs during shader compilation.
  35489. */
  35490. onErrorObservable: Observable<Effect>;
  35491. /** @hidden */
  35492. _onBindObservable: Nullable<Observable<Effect>>;
  35493. /**
  35494. * @hidden
  35495. * Specifies if the effect was previously ready
  35496. */
  35497. _wasPreviouslyReady: boolean;
  35498. /**
  35499. * Observable that will be called when effect is bound.
  35500. */
  35501. get onBindObservable(): Observable<Effect>;
  35502. /** @hidden */
  35503. _bonesComputationForcedToCPU: boolean;
  35504. /** @hidden */
  35505. _multiTarget: boolean;
  35506. private static _uniqueIdSeed;
  35507. private _engine;
  35508. private _uniformBuffersNames;
  35509. private _uniformBuffersNamesList;
  35510. private _uniformsNames;
  35511. private _samplerList;
  35512. private _samplers;
  35513. private _isReady;
  35514. private _compilationError;
  35515. private _allFallbacksProcessed;
  35516. private _attributesNames;
  35517. private _attributes;
  35518. private _attributeLocationByName;
  35519. private _uniforms;
  35520. /**
  35521. * Key for the effect.
  35522. * @hidden
  35523. */
  35524. _key: string;
  35525. private _indexParameters;
  35526. private _fallbacks;
  35527. private _vertexSourceCode;
  35528. private _fragmentSourceCode;
  35529. private _vertexSourceCodeOverride;
  35530. private _fragmentSourceCodeOverride;
  35531. private _transformFeedbackVaryings;
  35532. /**
  35533. * Compiled shader to webGL program.
  35534. * @hidden
  35535. */
  35536. _pipelineContext: Nullable<IPipelineContext>;
  35537. private _valueCache;
  35538. private static _baseCache;
  35539. /**
  35540. * Instantiates an effect.
  35541. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35542. * @param baseName Name of the effect.
  35543. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35544. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35545. * @param samplers List of sampler variables that will be passed to the shader.
  35546. * @param engine Engine to be used to render the effect
  35547. * @param defines Define statements to be added to the shader.
  35548. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35549. * @param onCompiled Callback that will be called when the shader is compiled.
  35550. * @param onError Callback that will be called if an error occurs during shader compilation.
  35551. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35552. */
  35553. 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);
  35554. private _useFinalCode;
  35555. /**
  35556. * Unique key for this effect
  35557. */
  35558. get key(): string;
  35559. /**
  35560. * If the effect has been compiled and prepared.
  35561. * @returns if the effect is compiled and prepared.
  35562. */
  35563. isReady(): boolean;
  35564. private _isReadyInternal;
  35565. /**
  35566. * The engine the effect was initialized with.
  35567. * @returns the engine.
  35568. */
  35569. getEngine(): Engine;
  35570. /**
  35571. * The pipeline context for this effect
  35572. * @returns the associated pipeline context
  35573. */
  35574. getPipelineContext(): Nullable<IPipelineContext>;
  35575. /**
  35576. * The set of names of attribute variables for the shader.
  35577. * @returns An array of attribute names.
  35578. */
  35579. getAttributesNames(): string[];
  35580. /**
  35581. * Returns the attribute at the given index.
  35582. * @param index The index of the attribute.
  35583. * @returns The location of the attribute.
  35584. */
  35585. getAttributeLocation(index: number): number;
  35586. /**
  35587. * Returns the attribute based on the name of the variable.
  35588. * @param name of the attribute to look up.
  35589. * @returns the attribute location.
  35590. */
  35591. getAttributeLocationByName(name: string): number;
  35592. /**
  35593. * The number of attributes.
  35594. * @returns the numnber of attributes.
  35595. */
  35596. getAttributesCount(): number;
  35597. /**
  35598. * Gets the index of a uniform variable.
  35599. * @param uniformName of the uniform to look up.
  35600. * @returns the index.
  35601. */
  35602. getUniformIndex(uniformName: string): number;
  35603. /**
  35604. * Returns the attribute based on the name of the variable.
  35605. * @param uniformName of the uniform to look up.
  35606. * @returns the location of the uniform.
  35607. */
  35608. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35609. /**
  35610. * Returns an array of sampler variable names
  35611. * @returns The array of sampler variable names.
  35612. */
  35613. getSamplers(): string[];
  35614. /**
  35615. * Returns an array of uniform variable names
  35616. * @returns The array of uniform variable names.
  35617. */
  35618. getUniformNames(): string[];
  35619. /**
  35620. * Returns an array of uniform buffer variable names
  35621. * @returns The array of uniform buffer variable names.
  35622. */
  35623. getUniformBuffersNames(): string[];
  35624. /**
  35625. * Returns the index parameters used to create the effect
  35626. * @returns The index parameters object
  35627. */
  35628. getIndexParameters(): any;
  35629. /**
  35630. * The error from the last compilation.
  35631. * @returns the error string.
  35632. */
  35633. getCompilationError(): string;
  35634. /**
  35635. * Gets a boolean indicating that all fallbacks were used during compilation
  35636. * @returns true if all fallbacks were used
  35637. */
  35638. allFallbacksProcessed(): boolean;
  35639. /**
  35640. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35641. * @param func The callback to be used.
  35642. */
  35643. executeWhenCompiled(func: (effect: Effect) => void): void;
  35644. private _checkIsReady;
  35645. private _loadShader;
  35646. /**
  35647. * Gets the vertex shader source code of this effect
  35648. */
  35649. get vertexSourceCode(): string;
  35650. /**
  35651. * Gets the fragment shader source code of this effect
  35652. */
  35653. get fragmentSourceCode(): string;
  35654. /**
  35655. * Recompiles the webGL program
  35656. * @param vertexSourceCode The source code for the vertex shader.
  35657. * @param fragmentSourceCode The source code for the fragment shader.
  35658. * @param onCompiled Callback called when completed.
  35659. * @param onError Callback called on error.
  35660. * @hidden
  35661. */
  35662. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35663. /**
  35664. * Prepares the effect
  35665. * @hidden
  35666. */
  35667. _prepareEffect(): void;
  35668. private _getShaderCodeAndErrorLine;
  35669. private _processCompilationErrors;
  35670. /**
  35671. * Checks if the effect is supported. (Must be called after compilation)
  35672. */
  35673. get isSupported(): boolean;
  35674. /**
  35675. * Binds a texture to the engine to be used as output of the shader.
  35676. * @param channel Name of the output variable.
  35677. * @param texture Texture to bind.
  35678. * @hidden
  35679. */
  35680. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35681. /**
  35682. * Sets a texture on the engine to be used in the shader.
  35683. * @param channel Name of the sampler variable.
  35684. * @param texture Texture to set.
  35685. */
  35686. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35687. /**
  35688. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35689. * @param channel Name of the sampler variable.
  35690. * @param texture Texture to set.
  35691. */
  35692. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35693. /**
  35694. * Sets an array of textures on the engine to be used in the shader.
  35695. * @param channel Name of the variable.
  35696. * @param textures Textures to set.
  35697. */
  35698. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35699. /**
  35700. * 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)
  35701. * @param channel Name of the sampler variable.
  35702. * @param postProcess Post process to get the input texture from.
  35703. */
  35704. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35705. /**
  35706. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35707. * 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)
  35708. * @param channel Name of the sampler variable.
  35709. * @param postProcess Post process to get the output texture from.
  35710. */
  35711. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35712. /** @hidden */
  35713. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35714. /** @hidden */
  35715. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35716. /** @hidden */
  35717. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35718. /** @hidden */
  35719. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35720. /**
  35721. * Binds a buffer to a uniform.
  35722. * @param buffer Buffer to bind.
  35723. * @param name Name of the uniform variable to bind to.
  35724. */
  35725. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35726. /**
  35727. * Binds block to a uniform.
  35728. * @param blockName Name of the block to bind.
  35729. * @param index Index to bind.
  35730. */
  35731. bindUniformBlock(blockName: string, index: number): void;
  35732. /**
  35733. * Sets an interger value on a uniform variable.
  35734. * @param uniformName Name of the variable.
  35735. * @param value Value to be set.
  35736. * @returns this effect.
  35737. */
  35738. setInt(uniformName: string, value: number): Effect;
  35739. /**
  35740. * Sets an int array on a uniform variable.
  35741. * @param uniformName Name of the variable.
  35742. * @param array array to be set.
  35743. * @returns this effect.
  35744. */
  35745. setIntArray(uniformName: string, array: Int32Array): Effect;
  35746. /**
  35747. * 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)
  35748. * @param uniformName Name of the variable.
  35749. * @param array array to be set.
  35750. * @returns this effect.
  35751. */
  35752. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35753. /**
  35754. * 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)
  35755. * @param uniformName Name of the variable.
  35756. * @param array array to be set.
  35757. * @returns this effect.
  35758. */
  35759. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35760. /**
  35761. * 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)
  35762. * @param uniformName Name of the variable.
  35763. * @param array array to be set.
  35764. * @returns this effect.
  35765. */
  35766. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35767. /**
  35768. * Sets an float array on a uniform variable.
  35769. * @param uniformName Name of the variable.
  35770. * @param array array to be set.
  35771. * @returns this effect.
  35772. */
  35773. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35774. /**
  35775. * 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)
  35776. * @param uniformName Name of the variable.
  35777. * @param array array to be set.
  35778. * @returns this effect.
  35779. */
  35780. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35781. /**
  35782. * 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)
  35783. * @param uniformName Name of the variable.
  35784. * @param array array to be set.
  35785. * @returns this effect.
  35786. */
  35787. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35788. /**
  35789. * 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)
  35790. * @param uniformName Name of the variable.
  35791. * @param array array to be set.
  35792. * @returns this effect.
  35793. */
  35794. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35795. /**
  35796. * Sets an array on a uniform variable.
  35797. * @param uniformName Name of the variable.
  35798. * @param array array to be set.
  35799. * @returns this effect.
  35800. */
  35801. setArray(uniformName: string, array: number[]): Effect;
  35802. /**
  35803. * 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)
  35804. * @param uniformName Name of the variable.
  35805. * @param array array to be set.
  35806. * @returns this effect.
  35807. */
  35808. setArray2(uniformName: string, array: number[]): Effect;
  35809. /**
  35810. * 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)
  35811. * @param uniformName Name of the variable.
  35812. * @param array array to be set.
  35813. * @returns this effect.
  35814. */
  35815. setArray3(uniformName: string, array: number[]): Effect;
  35816. /**
  35817. * 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)
  35818. * @param uniformName Name of the variable.
  35819. * @param array array to be set.
  35820. * @returns this effect.
  35821. */
  35822. setArray4(uniformName: string, array: number[]): Effect;
  35823. /**
  35824. * Sets matrices on a uniform variable.
  35825. * @param uniformName Name of the variable.
  35826. * @param matrices matrices to be set.
  35827. * @returns this effect.
  35828. */
  35829. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35830. /**
  35831. * Sets matrix on a uniform variable.
  35832. * @param uniformName Name of the variable.
  35833. * @param matrix matrix to be set.
  35834. * @returns this effect.
  35835. */
  35836. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35837. /**
  35838. * 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)
  35839. * @param uniformName Name of the variable.
  35840. * @param matrix matrix to be set.
  35841. * @returns this effect.
  35842. */
  35843. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35844. /**
  35845. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35846. * @param uniformName Name of the variable.
  35847. * @param matrix matrix to be set.
  35848. * @returns this effect.
  35849. */
  35850. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35851. /**
  35852. * Sets a float on a uniform variable.
  35853. * @param uniformName Name of the variable.
  35854. * @param value value to be set.
  35855. * @returns this effect.
  35856. */
  35857. setFloat(uniformName: string, value: number): Effect;
  35858. /**
  35859. * Sets a boolean on a uniform variable.
  35860. * @param uniformName Name of the variable.
  35861. * @param bool value to be set.
  35862. * @returns this effect.
  35863. */
  35864. setBool(uniformName: string, bool: boolean): Effect;
  35865. /**
  35866. * Sets a Vector2 on a uniform variable.
  35867. * @param uniformName Name of the variable.
  35868. * @param vector2 vector2 to be set.
  35869. * @returns this effect.
  35870. */
  35871. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35872. /**
  35873. * Sets a float2 on a uniform variable.
  35874. * @param uniformName Name of the variable.
  35875. * @param x First float in float2.
  35876. * @param y Second float in float2.
  35877. * @returns this effect.
  35878. */
  35879. setFloat2(uniformName: string, x: number, y: number): Effect;
  35880. /**
  35881. * Sets a Vector3 on a uniform variable.
  35882. * @param uniformName Name of the variable.
  35883. * @param vector3 Value to be set.
  35884. * @returns this effect.
  35885. */
  35886. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35887. /**
  35888. * Sets a float3 on a uniform variable.
  35889. * @param uniformName Name of the variable.
  35890. * @param x First float in float3.
  35891. * @param y Second float in float3.
  35892. * @param z Third float in float3.
  35893. * @returns this effect.
  35894. */
  35895. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35896. /**
  35897. * Sets a Vector4 on a uniform variable.
  35898. * @param uniformName Name of the variable.
  35899. * @param vector4 Value to be set.
  35900. * @returns this effect.
  35901. */
  35902. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35903. /**
  35904. * Sets a float4 on a uniform variable.
  35905. * @param uniformName Name of the variable.
  35906. * @param x First float in float4.
  35907. * @param y Second float in float4.
  35908. * @param z Third float in float4.
  35909. * @param w Fourth float in float4.
  35910. * @returns this effect.
  35911. */
  35912. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35913. /**
  35914. * Sets a Color3 on a uniform variable.
  35915. * @param uniformName Name of the variable.
  35916. * @param color3 Value to be set.
  35917. * @returns this effect.
  35918. */
  35919. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35920. /**
  35921. * Sets a Color4 on a uniform variable.
  35922. * @param uniformName Name of the variable.
  35923. * @param color3 Value to be set.
  35924. * @param alpha Alpha value to be set.
  35925. * @returns this effect.
  35926. */
  35927. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35928. /**
  35929. * Sets a Color4 on a uniform variable
  35930. * @param uniformName defines the name of the variable
  35931. * @param color4 defines the value to be set
  35932. * @returns this effect.
  35933. */
  35934. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35935. /** Release all associated resources */
  35936. dispose(): void;
  35937. /**
  35938. * This function will add a new shader to the shader store
  35939. * @param name the name of the shader
  35940. * @param pixelShader optional pixel shader content
  35941. * @param vertexShader optional vertex shader content
  35942. */
  35943. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35944. /**
  35945. * Store of each shader (The can be looked up using effect.key)
  35946. */
  35947. static ShadersStore: {
  35948. [key: string]: string;
  35949. };
  35950. /**
  35951. * Store of each included file for a shader (The can be looked up using effect.key)
  35952. */
  35953. static IncludesShadersStore: {
  35954. [key: string]: string;
  35955. };
  35956. /**
  35957. * Resets the cache of effects.
  35958. */
  35959. static ResetCache(): void;
  35960. }
  35961. }
  35962. declare module "babylonjs/Engines/engineCapabilities" {
  35963. /**
  35964. * Interface used to describe the capabilities of the engine relatively to the current browser
  35965. */
  35966. export interface EngineCapabilities {
  35967. /** Maximum textures units per fragment shader */
  35968. maxTexturesImageUnits: number;
  35969. /** Maximum texture units per vertex shader */
  35970. maxVertexTextureImageUnits: number;
  35971. /** Maximum textures units in the entire pipeline */
  35972. maxCombinedTexturesImageUnits: number;
  35973. /** Maximum texture size */
  35974. maxTextureSize: number;
  35975. /** Maximum texture samples */
  35976. maxSamples?: number;
  35977. /** Maximum cube texture size */
  35978. maxCubemapTextureSize: number;
  35979. /** Maximum render texture size */
  35980. maxRenderTextureSize: number;
  35981. /** Maximum number of vertex attributes */
  35982. maxVertexAttribs: number;
  35983. /** Maximum number of varyings */
  35984. maxVaryingVectors: number;
  35985. /** Maximum number of uniforms per vertex shader */
  35986. maxVertexUniformVectors: number;
  35987. /** Maximum number of uniforms per fragment shader */
  35988. maxFragmentUniformVectors: number;
  35989. /** Defines if standard derivates (dx/dy) are supported */
  35990. standardDerivatives: boolean;
  35991. /** Defines if s3tc texture compression is supported */
  35992. s3tc?: WEBGL_compressed_texture_s3tc;
  35993. /** Defines if pvrtc texture compression is supported */
  35994. pvrtc: any;
  35995. /** Defines if etc1 texture compression is supported */
  35996. etc1: any;
  35997. /** Defines if etc2 texture compression is supported */
  35998. etc2: any;
  35999. /** Defines if astc texture compression is supported */
  36000. astc: any;
  36001. /** Defines if float textures are supported */
  36002. textureFloat: boolean;
  36003. /** Defines if vertex array objects are supported */
  36004. vertexArrayObject: boolean;
  36005. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36006. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36007. /** Gets the maximum level of anisotropy supported */
  36008. maxAnisotropy: number;
  36009. /** Defines if instancing is supported */
  36010. instancedArrays: boolean;
  36011. /** Defines if 32 bits indices are supported */
  36012. uintIndices: boolean;
  36013. /** Defines if high precision shaders are supported */
  36014. highPrecisionShaderSupported: boolean;
  36015. /** Defines if depth reading in the fragment shader is supported */
  36016. fragmentDepthSupported: boolean;
  36017. /** Defines if float texture linear filtering is supported*/
  36018. textureFloatLinearFiltering: boolean;
  36019. /** Defines if rendering to float textures is supported */
  36020. textureFloatRender: boolean;
  36021. /** Defines if half float textures are supported*/
  36022. textureHalfFloat: boolean;
  36023. /** Defines if half float texture linear filtering is supported*/
  36024. textureHalfFloatLinearFiltering: boolean;
  36025. /** Defines if rendering to half float textures is supported */
  36026. textureHalfFloatRender: boolean;
  36027. /** Defines if textureLOD shader command is supported */
  36028. textureLOD: boolean;
  36029. /** Defines if draw buffers extension is supported */
  36030. drawBuffersExtension: boolean;
  36031. /** Defines if depth textures are supported */
  36032. depthTextureExtension: boolean;
  36033. /** Defines if float color buffer are supported */
  36034. colorBufferFloat: boolean;
  36035. /** Gets disjoint timer query extension (null if not supported) */
  36036. timerQuery?: EXT_disjoint_timer_query;
  36037. /** Defines if timestamp can be used with timer query */
  36038. canUseTimestampForTimerQuery: boolean;
  36039. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36040. multiview?: any;
  36041. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36042. oculusMultiview?: any;
  36043. /** Function used to let the system compiles shaders in background */
  36044. parallelShaderCompile?: {
  36045. COMPLETION_STATUS_KHR: number;
  36046. };
  36047. /** Max number of texture samples for MSAA */
  36048. maxMSAASamples: number;
  36049. /** Defines if the blend min max extension is supported */
  36050. blendMinMax: boolean;
  36051. }
  36052. }
  36053. declare module "babylonjs/States/depthCullingState" {
  36054. import { Nullable } from "babylonjs/types";
  36055. /**
  36056. * @hidden
  36057. **/
  36058. export class DepthCullingState {
  36059. private _isDepthTestDirty;
  36060. private _isDepthMaskDirty;
  36061. private _isDepthFuncDirty;
  36062. private _isCullFaceDirty;
  36063. private _isCullDirty;
  36064. private _isZOffsetDirty;
  36065. private _isFrontFaceDirty;
  36066. private _depthTest;
  36067. private _depthMask;
  36068. private _depthFunc;
  36069. private _cull;
  36070. private _cullFace;
  36071. private _zOffset;
  36072. private _frontFace;
  36073. /**
  36074. * Initializes the state.
  36075. */
  36076. constructor();
  36077. get isDirty(): boolean;
  36078. get zOffset(): number;
  36079. set zOffset(value: number);
  36080. get cullFace(): Nullable<number>;
  36081. set cullFace(value: Nullable<number>);
  36082. get cull(): Nullable<boolean>;
  36083. set cull(value: Nullable<boolean>);
  36084. get depthFunc(): Nullable<number>;
  36085. set depthFunc(value: Nullable<number>);
  36086. get depthMask(): boolean;
  36087. set depthMask(value: boolean);
  36088. get depthTest(): boolean;
  36089. set depthTest(value: boolean);
  36090. get frontFace(): Nullable<number>;
  36091. set frontFace(value: Nullable<number>);
  36092. reset(): void;
  36093. apply(gl: WebGLRenderingContext): void;
  36094. }
  36095. }
  36096. declare module "babylonjs/States/stencilState" {
  36097. /**
  36098. * @hidden
  36099. **/
  36100. export class StencilState {
  36101. /** 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 */
  36102. static readonly ALWAYS: number;
  36103. /** Passed to stencilOperation to specify that stencil value must be kept */
  36104. static readonly KEEP: number;
  36105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36106. static readonly REPLACE: number;
  36107. private _isStencilTestDirty;
  36108. private _isStencilMaskDirty;
  36109. private _isStencilFuncDirty;
  36110. private _isStencilOpDirty;
  36111. private _stencilTest;
  36112. private _stencilMask;
  36113. private _stencilFunc;
  36114. private _stencilFuncRef;
  36115. private _stencilFuncMask;
  36116. private _stencilOpStencilFail;
  36117. private _stencilOpDepthFail;
  36118. private _stencilOpStencilDepthPass;
  36119. get isDirty(): boolean;
  36120. get stencilFunc(): number;
  36121. set stencilFunc(value: number);
  36122. get stencilFuncRef(): number;
  36123. set stencilFuncRef(value: number);
  36124. get stencilFuncMask(): number;
  36125. set stencilFuncMask(value: number);
  36126. get stencilOpStencilFail(): number;
  36127. set stencilOpStencilFail(value: number);
  36128. get stencilOpDepthFail(): number;
  36129. set stencilOpDepthFail(value: number);
  36130. get stencilOpStencilDepthPass(): number;
  36131. set stencilOpStencilDepthPass(value: number);
  36132. get stencilMask(): number;
  36133. set stencilMask(value: number);
  36134. get stencilTest(): boolean;
  36135. set stencilTest(value: boolean);
  36136. constructor();
  36137. reset(): void;
  36138. apply(gl: WebGLRenderingContext): void;
  36139. }
  36140. }
  36141. declare module "babylonjs/States/alphaCullingState" {
  36142. /**
  36143. * @hidden
  36144. **/
  36145. export class AlphaState {
  36146. private _isAlphaBlendDirty;
  36147. private _isBlendFunctionParametersDirty;
  36148. private _isBlendEquationParametersDirty;
  36149. private _isBlendConstantsDirty;
  36150. private _alphaBlend;
  36151. private _blendFunctionParameters;
  36152. private _blendEquationParameters;
  36153. private _blendConstants;
  36154. /**
  36155. * Initializes the state.
  36156. */
  36157. constructor();
  36158. get isDirty(): boolean;
  36159. get alphaBlend(): boolean;
  36160. set alphaBlend(value: boolean);
  36161. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36162. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36163. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36164. reset(): void;
  36165. apply(gl: WebGLRenderingContext): void;
  36166. }
  36167. }
  36168. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36169. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36170. /** @hidden */
  36171. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36172. attributeProcessor(attribute: string): string;
  36173. varyingProcessor(varying: string, isFragment: boolean): string;
  36174. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36175. }
  36176. }
  36177. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36178. /**
  36179. * Interface for attribute information associated with buffer instanciation
  36180. */
  36181. export interface InstancingAttributeInfo {
  36182. /**
  36183. * Name of the GLSL attribute
  36184. * if attribute index is not specified, this is used to retrieve the index from the effect
  36185. */
  36186. attributeName: string;
  36187. /**
  36188. * Index/offset of the attribute in the vertex shader
  36189. * if not specified, this will be computes from the name.
  36190. */
  36191. index?: number;
  36192. /**
  36193. * size of the attribute, 1, 2, 3 or 4
  36194. */
  36195. attributeSize: number;
  36196. /**
  36197. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36198. */
  36199. offset: number;
  36200. /**
  36201. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36202. * default to 1
  36203. */
  36204. divisor?: number;
  36205. /**
  36206. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36207. * default is FLOAT
  36208. */
  36209. attributeType?: number;
  36210. /**
  36211. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36212. */
  36213. normalized?: boolean;
  36214. }
  36215. }
  36216. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36218. import { Nullable } from "babylonjs/types";
  36219. module "babylonjs/Engines/thinEngine" {
  36220. interface ThinEngine {
  36221. /**
  36222. * Update a video texture
  36223. * @param texture defines the texture to update
  36224. * @param video defines the video element to use
  36225. * @param invertY defines if data must be stored with Y axis inverted
  36226. */
  36227. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36228. }
  36229. }
  36230. }
  36231. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36232. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36233. import { Nullable } from "babylonjs/types";
  36234. module "babylonjs/Engines/thinEngine" {
  36235. interface ThinEngine {
  36236. /**
  36237. * Creates a dynamic texture
  36238. * @param width defines the width of the texture
  36239. * @param height defines the height of the texture
  36240. * @param generateMipMaps defines if the engine should generate the mip levels
  36241. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36242. * @returns the dynamic texture inside an InternalTexture
  36243. */
  36244. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36245. /**
  36246. * Update the content of a dynamic texture
  36247. * @param texture defines the texture to update
  36248. * @param canvas defines the canvas containing the source
  36249. * @param invertY defines if data must be stored with Y axis inverted
  36250. * @param premulAlpha defines if alpha is stored as premultiplied
  36251. * @param format defines the format of the data
  36252. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36253. */
  36254. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36255. }
  36256. }
  36257. }
  36258. declare module "babylonjs/Materials/Textures/videoTexture" {
  36259. import { Observable } from "babylonjs/Misc/observable";
  36260. import { Nullable } from "babylonjs/types";
  36261. import { Scene } from "babylonjs/scene";
  36262. import { Texture } from "babylonjs/Materials/Textures/texture";
  36263. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36264. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36265. /**
  36266. * Settings for finer control over video usage
  36267. */
  36268. export interface VideoTextureSettings {
  36269. /**
  36270. * Applies `autoplay` to video, if specified
  36271. */
  36272. autoPlay?: boolean;
  36273. /**
  36274. * Applies `loop` to video, if specified
  36275. */
  36276. loop?: boolean;
  36277. /**
  36278. * Automatically updates internal texture from video at every frame in the render loop
  36279. */
  36280. autoUpdateTexture: boolean;
  36281. /**
  36282. * Image src displayed during the video loading or until the user interacts with the video.
  36283. */
  36284. poster?: string;
  36285. }
  36286. /**
  36287. * If you want to display a video in your scene, this is the special texture for that.
  36288. * This special texture works similar to other textures, with the exception of a few parameters.
  36289. * @see https://doc.babylonjs.com/how_to/video_texture
  36290. */
  36291. export class VideoTexture extends Texture {
  36292. /**
  36293. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36294. */
  36295. readonly autoUpdateTexture: boolean;
  36296. /**
  36297. * The video instance used by the texture internally
  36298. */
  36299. readonly video: HTMLVideoElement;
  36300. private _onUserActionRequestedObservable;
  36301. /**
  36302. * Event triggerd when a dom action is required by the user to play the video.
  36303. * This happens due to recent changes in browser policies preventing video to auto start.
  36304. */
  36305. get onUserActionRequestedObservable(): Observable<Texture>;
  36306. private _generateMipMaps;
  36307. private _stillImageCaptured;
  36308. private _displayingPosterTexture;
  36309. private _settings;
  36310. private _createInternalTextureOnEvent;
  36311. private _frameId;
  36312. private _currentSrc;
  36313. /**
  36314. * Creates a video texture.
  36315. * If you want to display a video in your scene, this is the special texture for that.
  36316. * This special texture works similar to other textures, with the exception of a few parameters.
  36317. * @see https://doc.babylonjs.com/how_to/video_texture
  36318. * @param name optional name, will detect from video source, if not defined
  36319. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36320. * @param scene is obviously the current scene.
  36321. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36322. * @param invertY is false by default but can be used to invert video on Y axis
  36323. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36324. * @param settings allows finer control over video usage
  36325. */
  36326. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36327. private _getName;
  36328. private _getVideo;
  36329. private _createInternalTexture;
  36330. private reset;
  36331. /**
  36332. * @hidden Internal method to initiate `update`.
  36333. */
  36334. _rebuild(): void;
  36335. /**
  36336. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36337. */
  36338. update(): void;
  36339. /**
  36340. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36341. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36342. */
  36343. updateTexture(isVisible: boolean): void;
  36344. protected _updateInternalTexture: () => void;
  36345. /**
  36346. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36347. * @param url New url.
  36348. */
  36349. updateURL(url: string): void;
  36350. /**
  36351. * Clones the texture.
  36352. * @returns the cloned texture
  36353. */
  36354. clone(): VideoTexture;
  36355. /**
  36356. * Dispose the texture and release its associated resources.
  36357. */
  36358. dispose(): void;
  36359. /**
  36360. * Creates a video texture straight from a stream.
  36361. * @param scene Define the scene the texture should be created in
  36362. * @param stream Define the stream the texture should be created from
  36363. * @returns The created video texture as a promise
  36364. */
  36365. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36366. /**
  36367. * Creates a video texture straight from your WebCam video feed.
  36368. * @param scene Define the scene the texture should be created in
  36369. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36370. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36371. * @returns The created video texture as a promise
  36372. */
  36373. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36374. minWidth: number;
  36375. maxWidth: number;
  36376. minHeight: number;
  36377. maxHeight: number;
  36378. deviceId: string;
  36379. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36380. /**
  36381. * Creates a video texture straight from your WebCam video feed.
  36382. * @param scene Define the scene the texture should be created in
  36383. * @param onReady Define a callback to triggered once the texture will be ready
  36384. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36385. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36386. */
  36387. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36388. minWidth: number;
  36389. maxWidth: number;
  36390. minHeight: number;
  36391. maxHeight: number;
  36392. deviceId: string;
  36393. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36394. }
  36395. }
  36396. declare module "babylonjs/Engines/thinEngine" {
  36397. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36398. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36399. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36401. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36402. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36403. import { Observable } from "babylonjs/Misc/observable";
  36404. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36405. import { StencilState } from "babylonjs/States/stencilState";
  36406. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36408. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36409. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36410. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36411. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36412. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36413. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36414. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36416. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36417. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36418. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36419. import { WebRequest } from "babylonjs/Misc/webRequest";
  36420. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36421. /**
  36422. * Defines the interface used by objects working like Scene
  36423. * @hidden
  36424. */
  36425. export interface ISceneLike {
  36426. _addPendingData(data: any): void;
  36427. _removePendingData(data: any): void;
  36428. offlineProvider: IOfflineProvider;
  36429. }
  36430. /** Interface defining initialization parameters for Engine class */
  36431. export interface EngineOptions extends WebGLContextAttributes {
  36432. /**
  36433. * Defines if the engine should no exceed a specified device ratio
  36434. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36435. */
  36436. limitDeviceRatio?: number;
  36437. /**
  36438. * Defines if webvr should be enabled automatically
  36439. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36440. */
  36441. autoEnableWebVR?: boolean;
  36442. /**
  36443. * Defines if webgl2 should be turned off even if supported
  36444. * @see https://doc.babylonjs.com/features/webgl2
  36445. */
  36446. disableWebGL2Support?: boolean;
  36447. /**
  36448. * Defines if webaudio should be initialized as well
  36449. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36450. */
  36451. audioEngine?: boolean;
  36452. /**
  36453. * Defines if animations should run using a deterministic lock step
  36454. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36455. */
  36456. deterministicLockstep?: boolean;
  36457. /** Defines the maximum steps to use with deterministic lock step mode */
  36458. lockstepMaxSteps?: number;
  36459. /** Defines the seconds between each deterministic lock step */
  36460. timeStep?: number;
  36461. /**
  36462. * Defines that engine should ignore context lost events
  36463. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36464. */
  36465. doNotHandleContextLost?: boolean;
  36466. /**
  36467. * Defines that engine should ignore modifying touch action attribute and style
  36468. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36469. */
  36470. doNotHandleTouchAction?: boolean;
  36471. /**
  36472. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36473. */
  36474. useHighPrecisionFloats?: boolean;
  36475. /**
  36476. * Make the canvas XR Compatible for XR sessions
  36477. */
  36478. xrCompatible?: boolean;
  36479. /**
  36480. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36481. */
  36482. useHighPrecisionMatrix?: boolean;
  36483. }
  36484. /**
  36485. * The base engine class (root of all engines)
  36486. */
  36487. export class ThinEngine {
  36488. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36489. static ExceptionList: ({
  36490. key: string;
  36491. capture: string;
  36492. captureConstraint: number;
  36493. targets: string[];
  36494. } | {
  36495. key: string;
  36496. capture: null;
  36497. captureConstraint: null;
  36498. targets: string[];
  36499. })[];
  36500. /** @hidden */
  36501. static _TextureLoaders: IInternalTextureLoader[];
  36502. /**
  36503. * Returns the current npm package of the sdk
  36504. */
  36505. static get NpmPackage(): string;
  36506. /**
  36507. * Returns the current version of the framework
  36508. */
  36509. static get Version(): string;
  36510. /**
  36511. * Returns a string describing the current engine
  36512. */
  36513. get description(): string;
  36514. /**
  36515. * Gets or sets the epsilon value used by collision engine
  36516. */
  36517. static CollisionsEpsilon: number;
  36518. /**
  36519. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36520. */
  36521. static get ShadersRepository(): string;
  36522. static set ShadersRepository(value: string);
  36523. /** @hidden */
  36524. _shaderProcessor: IShaderProcessor;
  36525. /**
  36526. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36527. */
  36528. forcePOTTextures: boolean;
  36529. /**
  36530. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36531. */
  36532. isFullscreen: boolean;
  36533. /**
  36534. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36535. */
  36536. cullBackFaces: boolean;
  36537. /**
  36538. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36539. */
  36540. renderEvenInBackground: boolean;
  36541. /**
  36542. * Gets or sets a boolean indicating that cache can be kept between frames
  36543. */
  36544. preventCacheWipeBetweenFrames: boolean;
  36545. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36546. validateShaderPrograms: boolean;
  36547. /**
  36548. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36549. * This can provide greater z depth for distant objects.
  36550. */
  36551. useReverseDepthBuffer: boolean;
  36552. /**
  36553. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36554. */
  36555. disableUniformBuffers: boolean;
  36556. /** @hidden */
  36557. _uniformBuffers: UniformBuffer[];
  36558. /**
  36559. * Gets a boolean indicating that the engine supports uniform buffers
  36560. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36561. */
  36562. get supportsUniformBuffers(): boolean;
  36563. /** @hidden */
  36564. _gl: WebGLRenderingContext;
  36565. /** @hidden */
  36566. _webGLVersion: number;
  36567. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36568. protected _windowIsBackground: boolean;
  36569. protected _creationOptions: EngineOptions;
  36570. protected _highPrecisionShadersAllowed: boolean;
  36571. /** @hidden */
  36572. get _shouldUseHighPrecisionShader(): boolean;
  36573. /**
  36574. * Gets a boolean indicating that only power of 2 textures are supported
  36575. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36576. */
  36577. get needPOTTextures(): boolean;
  36578. /** @hidden */
  36579. _badOS: boolean;
  36580. /** @hidden */
  36581. _badDesktopOS: boolean;
  36582. private _hardwareScalingLevel;
  36583. /** @hidden */
  36584. _caps: EngineCapabilities;
  36585. private _isStencilEnable;
  36586. private _glVersion;
  36587. private _glRenderer;
  36588. private _glVendor;
  36589. /** @hidden */
  36590. _videoTextureSupported: boolean;
  36591. protected _renderingQueueLaunched: boolean;
  36592. protected _activeRenderLoops: (() => void)[];
  36593. /**
  36594. * Observable signaled when a context lost event is raised
  36595. */
  36596. onContextLostObservable: Observable<ThinEngine>;
  36597. /**
  36598. * Observable signaled when a context restored event is raised
  36599. */
  36600. onContextRestoredObservable: Observable<ThinEngine>;
  36601. private _onContextLost;
  36602. private _onContextRestored;
  36603. protected _contextWasLost: boolean;
  36604. /** @hidden */
  36605. _doNotHandleContextLost: boolean;
  36606. /**
  36607. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36608. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36609. */
  36610. get doNotHandleContextLost(): boolean;
  36611. set doNotHandleContextLost(value: boolean);
  36612. /**
  36613. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36614. */
  36615. disableVertexArrayObjects: boolean;
  36616. /** @hidden */
  36617. protected _colorWrite: boolean;
  36618. /** @hidden */
  36619. protected _colorWriteChanged: boolean;
  36620. /** @hidden */
  36621. protected _depthCullingState: DepthCullingState;
  36622. /** @hidden */
  36623. protected _stencilState: StencilState;
  36624. /** @hidden */
  36625. _alphaState: AlphaState;
  36626. /** @hidden */
  36627. _alphaMode: number;
  36628. /** @hidden */
  36629. _alphaEquation: number;
  36630. /** @hidden */
  36631. _internalTexturesCache: InternalTexture[];
  36632. /** @hidden */
  36633. protected _activeChannel: number;
  36634. private _currentTextureChannel;
  36635. /** @hidden */
  36636. protected _boundTexturesCache: {
  36637. [key: string]: Nullable<InternalTexture>;
  36638. };
  36639. /** @hidden */
  36640. protected _currentEffect: Nullable<Effect>;
  36641. /** @hidden */
  36642. protected _currentProgram: Nullable<WebGLProgram>;
  36643. private _compiledEffects;
  36644. private _vertexAttribArraysEnabled;
  36645. /** @hidden */
  36646. protected _cachedViewport: Nullable<IViewportLike>;
  36647. private _cachedVertexArrayObject;
  36648. /** @hidden */
  36649. protected _cachedVertexBuffers: any;
  36650. /** @hidden */
  36651. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36652. /** @hidden */
  36653. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36654. /** @hidden */
  36655. _currentRenderTarget: Nullable<InternalTexture>;
  36656. private _uintIndicesCurrentlySet;
  36657. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36658. /** @hidden */
  36659. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36660. /** @hidden */
  36661. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36662. private _currentBufferPointers;
  36663. private _currentInstanceLocations;
  36664. private _currentInstanceBuffers;
  36665. private _textureUnits;
  36666. /** @hidden */
  36667. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36668. /** @hidden */
  36669. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36670. /** @hidden */
  36671. _boundRenderFunction: any;
  36672. private _vaoRecordInProgress;
  36673. private _mustWipeVertexAttributes;
  36674. private _emptyTexture;
  36675. private _emptyCubeTexture;
  36676. private _emptyTexture3D;
  36677. private _emptyTexture2DArray;
  36678. /** @hidden */
  36679. _frameHandler: number;
  36680. private _nextFreeTextureSlots;
  36681. private _maxSimultaneousTextures;
  36682. private _activeRequests;
  36683. /** @hidden */
  36684. _transformTextureUrl: Nullable<(url: string) => string>;
  36685. protected get _supportsHardwareTextureRescaling(): boolean;
  36686. private _framebufferDimensionsObject;
  36687. /**
  36688. * sets the object from which width and height will be taken from when getting render width and height
  36689. * Will fallback to the gl object
  36690. * @param dimensions the framebuffer width and height that will be used.
  36691. */
  36692. set framebufferDimensionsObject(dimensions: Nullable<{
  36693. framebufferWidth: number;
  36694. framebufferHeight: number;
  36695. }>);
  36696. /**
  36697. * Gets the current viewport
  36698. */
  36699. get currentViewport(): Nullable<IViewportLike>;
  36700. /**
  36701. * Gets the default empty texture
  36702. */
  36703. get emptyTexture(): InternalTexture;
  36704. /**
  36705. * Gets the default empty 3D texture
  36706. */
  36707. get emptyTexture3D(): InternalTexture;
  36708. /**
  36709. * Gets the default empty 2D array texture
  36710. */
  36711. get emptyTexture2DArray(): InternalTexture;
  36712. /**
  36713. * Gets the default empty cube texture
  36714. */
  36715. get emptyCubeTexture(): InternalTexture;
  36716. /**
  36717. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36718. */
  36719. readonly premultipliedAlpha: boolean;
  36720. /**
  36721. * Observable event triggered before each texture is initialized
  36722. */
  36723. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36724. /**
  36725. * Creates a new engine
  36726. * @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
  36727. * @param antialias defines enable antialiasing (default: false)
  36728. * @param options defines further options to be sent to the getContext() function
  36729. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36730. */
  36731. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36732. private _rebuildInternalTextures;
  36733. private _rebuildEffects;
  36734. /**
  36735. * Gets a boolean indicating if all created effects are ready
  36736. * @returns true if all effects are ready
  36737. */
  36738. areAllEffectsReady(): boolean;
  36739. protected _rebuildBuffers(): void;
  36740. protected _initGLContext(): void;
  36741. /**
  36742. * Gets version of the current webGL context
  36743. */
  36744. get webGLVersion(): number;
  36745. /**
  36746. * Gets a string identifying the name of the class
  36747. * @returns "Engine" string
  36748. */
  36749. getClassName(): string;
  36750. /**
  36751. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36752. */
  36753. get isStencilEnable(): boolean;
  36754. /** @hidden */
  36755. _prepareWorkingCanvas(): void;
  36756. /**
  36757. * Reset the texture cache to empty state
  36758. */
  36759. resetTextureCache(): void;
  36760. /**
  36761. * Gets an object containing information about the current webGL context
  36762. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36763. */
  36764. getGlInfo(): {
  36765. vendor: string;
  36766. renderer: string;
  36767. version: string;
  36768. };
  36769. /**
  36770. * Defines the hardware scaling level.
  36771. * By default the hardware scaling level is computed from the window device ratio.
  36772. * 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.
  36773. * @param level defines the level to use
  36774. */
  36775. setHardwareScalingLevel(level: number): void;
  36776. /**
  36777. * Gets the current hardware scaling level.
  36778. * By default the hardware scaling level is computed from the window device ratio.
  36779. * 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.
  36780. * @returns a number indicating the current hardware scaling level
  36781. */
  36782. getHardwareScalingLevel(): number;
  36783. /**
  36784. * Gets the list of loaded textures
  36785. * @returns an array containing all loaded textures
  36786. */
  36787. getLoadedTexturesCache(): InternalTexture[];
  36788. /**
  36789. * Gets the object containing all engine capabilities
  36790. * @returns the EngineCapabilities object
  36791. */
  36792. getCaps(): EngineCapabilities;
  36793. /**
  36794. * stop executing a render loop function and remove it from the execution array
  36795. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36796. */
  36797. stopRenderLoop(renderFunction?: () => void): void;
  36798. /** @hidden */
  36799. _renderLoop(): void;
  36800. /**
  36801. * Gets the HTML canvas attached with the current webGL context
  36802. * @returns a HTML canvas
  36803. */
  36804. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36805. /**
  36806. * Gets host window
  36807. * @returns the host window object
  36808. */
  36809. getHostWindow(): Nullable<Window>;
  36810. /**
  36811. * Gets the current render width
  36812. * @param useScreen defines if screen size must be used (or the current render target if any)
  36813. * @returns a number defining the current render width
  36814. */
  36815. getRenderWidth(useScreen?: boolean): number;
  36816. /**
  36817. * Gets the current render height
  36818. * @param useScreen defines if screen size must be used (or the current render target if any)
  36819. * @returns a number defining the current render height
  36820. */
  36821. getRenderHeight(useScreen?: boolean): number;
  36822. /**
  36823. * Can be used to override the current requestAnimationFrame requester.
  36824. * @hidden
  36825. */
  36826. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36827. /**
  36828. * Register and execute a render loop. The engine can have more than one render function
  36829. * @param renderFunction defines the function to continuously execute
  36830. */
  36831. runRenderLoop(renderFunction: () => void): void;
  36832. /**
  36833. * Clear the current render buffer or the current render target (if any is set up)
  36834. * @param color defines the color to use
  36835. * @param backBuffer defines if the back buffer must be cleared
  36836. * @param depth defines if the depth buffer must be cleared
  36837. * @param stencil defines if the stencil buffer must be cleared
  36838. */
  36839. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36840. private _viewportCached;
  36841. /** @hidden */
  36842. _viewport(x: number, y: number, width: number, height: number): void;
  36843. /**
  36844. * Set the WebGL's viewport
  36845. * @param viewport defines the viewport element to be used
  36846. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36847. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36848. */
  36849. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36850. /**
  36851. * Begin a new frame
  36852. */
  36853. beginFrame(): void;
  36854. /**
  36855. * Enf the current frame
  36856. */
  36857. endFrame(): void;
  36858. /**
  36859. * Resize the view according to the canvas' size
  36860. */
  36861. resize(): void;
  36862. /**
  36863. * Force a specific size of the canvas
  36864. * @param width defines the new canvas' width
  36865. * @param height defines the new canvas' height
  36866. * @returns true if the size was changed
  36867. */
  36868. setSize(width: number, height: number): boolean;
  36869. /**
  36870. * Binds the frame buffer to the specified texture.
  36871. * @param texture The texture to render to or null for the default canvas
  36872. * @param faceIndex The face of the texture to render to in case of cube texture
  36873. * @param requiredWidth The width of the target to render to
  36874. * @param requiredHeight The height of the target to render to
  36875. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36876. * @param lodLevel defines the lod level to bind to the frame buffer
  36877. * @param layer defines the 2d array index to bind to frame buffer to
  36878. */
  36879. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36880. /** @hidden */
  36881. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36882. /**
  36883. * Unbind the current render target texture from the webGL context
  36884. * @param texture defines the render target texture to unbind
  36885. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36886. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36887. */
  36888. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36889. /**
  36890. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36891. */
  36892. flushFramebuffer(): void;
  36893. /**
  36894. * Unbind the current render target and bind the default framebuffer
  36895. */
  36896. restoreDefaultFramebuffer(): void;
  36897. /** @hidden */
  36898. protected _resetVertexBufferBinding(): void;
  36899. /**
  36900. * Creates a vertex buffer
  36901. * @param data the data for the vertex buffer
  36902. * @returns the new WebGL static buffer
  36903. */
  36904. createVertexBuffer(data: DataArray): DataBuffer;
  36905. private _createVertexBuffer;
  36906. /**
  36907. * Creates a dynamic vertex buffer
  36908. * @param data the data for the dynamic vertex buffer
  36909. * @returns the new WebGL dynamic buffer
  36910. */
  36911. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36912. protected _resetIndexBufferBinding(): void;
  36913. /**
  36914. * Creates a new index buffer
  36915. * @param indices defines the content of the index buffer
  36916. * @param updatable defines if the index buffer must be updatable
  36917. * @returns a new webGL buffer
  36918. */
  36919. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36920. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36921. /**
  36922. * Bind a webGL buffer to the webGL context
  36923. * @param buffer defines the buffer to bind
  36924. */
  36925. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36926. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36927. private bindBuffer;
  36928. /**
  36929. * update the bound buffer with the given data
  36930. * @param data defines the data to update
  36931. */
  36932. updateArrayBuffer(data: Float32Array): void;
  36933. private _vertexAttribPointer;
  36934. /** @hidden */
  36935. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36936. private _bindVertexBuffersAttributes;
  36937. /**
  36938. * Records a vertex array object
  36939. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36940. * @param vertexBuffers defines the list of vertex buffers to store
  36941. * @param indexBuffer defines the index buffer to store
  36942. * @param effect defines the effect to store
  36943. * @returns the new vertex array object
  36944. */
  36945. recordVertexArrayObject(vertexBuffers: {
  36946. [key: string]: VertexBuffer;
  36947. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36948. /**
  36949. * Bind a specific vertex array object
  36950. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36951. * @param vertexArrayObject defines the vertex array object to bind
  36952. * @param indexBuffer defines the index buffer to bind
  36953. */
  36954. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36955. /**
  36956. * Bind webGl buffers directly to the webGL context
  36957. * @param vertexBuffer defines the vertex buffer to bind
  36958. * @param indexBuffer defines the index buffer to bind
  36959. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36960. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36961. * @param effect defines the effect associated with the vertex buffer
  36962. */
  36963. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36964. private _unbindVertexArrayObject;
  36965. /**
  36966. * Bind a list of vertex buffers to the webGL context
  36967. * @param vertexBuffers defines the list of vertex buffers to bind
  36968. * @param indexBuffer defines the index buffer to bind
  36969. * @param effect defines the effect associated with the vertex buffers
  36970. */
  36971. bindBuffers(vertexBuffers: {
  36972. [key: string]: Nullable<VertexBuffer>;
  36973. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36974. /**
  36975. * Unbind all instance attributes
  36976. */
  36977. unbindInstanceAttributes(): void;
  36978. /**
  36979. * Release and free the memory of a vertex array object
  36980. * @param vao defines the vertex array object to delete
  36981. */
  36982. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36983. /** @hidden */
  36984. _releaseBuffer(buffer: DataBuffer): boolean;
  36985. protected _deleteBuffer(buffer: DataBuffer): void;
  36986. /**
  36987. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36988. * @param instancesBuffer defines the webGL buffer to update and bind
  36989. * @param data defines the data to store in the buffer
  36990. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36991. */
  36992. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36993. /**
  36994. * Bind the content of a webGL buffer used with instantiation
  36995. * @param instancesBuffer defines the webGL buffer to bind
  36996. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36997. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36998. */
  36999. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37000. /**
  37001. * Disable the instance attribute corresponding to the name in parameter
  37002. * @param name defines the name of the attribute to disable
  37003. */
  37004. disableInstanceAttributeByName(name: string): void;
  37005. /**
  37006. * Disable the instance attribute corresponding to the location in parameter
  37007. * @param attributeLocation defines the attribute location of the attribute to disable
  37008. */
  37009. disableInstanceAttribute(attributeLocation: number): void;
  37010. /**
  37011. * Disable the attribute corresponding to the location in parameter
  37012. * @param attributeLocation defines the attribute location of the attribute to disable
  37013. */
  37014. disableAttributeByIndex(attributeLocation: number): void;
  37015. /**
  37016. * Send a draw order
  37017. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37018. * @param indexStart defines the starting index
  37019. * @param indexCount defines the number of index to draw
  37020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37021. */
  37022. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37023. /**
  37024. * Draw a list of points
  37025. * @param verticesStart defines the index of first vertex to draw
  37026. * @param verticesCount defines the count of vertices to draw
  37027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37028. */
  37029. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37030. /**
  37031. * Draw a list of unindexed primitives
  37032. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37033. * @param verticesStart defines the index of first vertex to draw
  37034. * @param verticesCount defines the count of vertices to draw
  37035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37036. */
  37037. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37038. /**
  37039. * Draw a list of indexed primitives
  37040. * @param fillMode defines the primitive to use
  37041. * @param indexStart defines the starting index
  37042. * @param indexCount defines the number of index to draw
  37043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37044. */
  37045. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37046. /**
  37047. * Draw a list of unindexed primitives
  37048. * @param fillMode defines the primitive to use
  37049. * @param verticesStart defines the index of first vertex to draw
  37050. * @param verticesCount defines the count of vertices to draw
  37051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37052. */
  37053. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37054. private _drawMode;
  37055. /** @hidden */
  37056. protected _reportDrawCall(): void;
  37057. /** @hidden */
  37058. _releaseEffect(effect: Effect): void;
  37059. /** @hidden */
  37060. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37061. /**
  37062. * Create a new effect (used to store vertex/fragment shaders)
  37063. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37064. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37065. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37066. * @param samplers defines an array of string used to represent textures
  37067. * @param defines defines the string containing the defines to use to compile the shaders
  37068. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37069. * @param onCompiled defines a function to call when the effect creation is successful
  37070. * @param onError defines a function to call when the effect creation has failed
  37071. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37072. * @returns the new Effect
  37073. */
  37074. 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;
  37075. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37076. private _compileShader;
  37077. private _compileRawShader;
  37078. /** @hidden */
  37079. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37080. /**
  37081. * Directly creates a webGL program
  37082. * @param pipelineContext defines the pipeline context to attach to
  37083. * @param vertexCode defines the vertex shader code to use
  37084. * @param fragmentCode defines the fragment shader code to use
  37085. * @param context defines the webGL context to use (if not set, the current one will be used)
  37086. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37087. * @returns the new webGL program
  37088. */
  37089. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37090. /**
  37091. * Creates a webGL program
  37092. * @param pipelineContext defines the pipeline context to attach to
  37093. * @param vertexCode defines the vertex shader code to use
  37094. * @param fragmentCode defines the fragment shader code to use
  37095. * @param defines defines the string containing the defines to use to compile the shaders
  37096. * @param context defines the webGL context to use (if not set, the current one will be used)
  37097. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37098. * @returns the new webGL program
  37099. */
  37100. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37101. /**
  37102. * Creates a new pipeline context
  37103. * @returns the new pipeline
  37104. */
  37105. createPipelineContext(): IPipelineContext;
  37106. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37107. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37108. /** @hidden */
  37109. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37110. /** @hidden */
  37111. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37112. /** @hidden */
  37113. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37114. /**
  37115. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37116. * @param pipelineContext defines the pipeline context to use
  37117. * @param uniformsNames defines the list of uniform names
  37118. * @returns an array of webGL uniform locations
  37119. */
  37120. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37121. /**
  37122. * Gets the lsit of active attributes for a given webGL program
  37123. * @param pipelineContext defines the pipeline context to use
  37124. * @param attributesNames defines the list of attribute names to get
  37125. * @returns an array of indices indicating the offset of each attribute
  37126. */
  37127. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37128. /**
  37129. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37130. * @param effect defines the effect to activate
  37131. */
  37132. enableEffect(effect: Nullable<Effect>): void;
  37133. /**
  37134. * Set the value of an uniform to a number (int)
  37135. * @param uniform defines the webGL uniform location where to store the value
  37136. * @param value defines the int number to store
  37137. */
  37138. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37139. /**
  37140. * Set the value of an uniform to an array of int32
  37141. * @param uniform defines the webGL uniform location where to store the value
  37142. * @param array defines the array of int32 to store
  37143. */
  37144. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37145. /**
  37146. * Set the value of an uniform to an array of int32 (stored as vec2)
  37147. * @param uniform defines the webGL uniform location where to store the value
  37148. * @param array defines the array of int32 to store
  37149. */
  37150. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37151. /**
  37152. * Set the value of an uniform to an array of int32 (stored as vec3)
  37153. * @param uniform defines the webGL uniform location where to store the value
  37154. * @param array defines the array of int32 to store
  37155. */
  37156. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37157. /**
  37158. * Set the value of an uniform to an array of int32 (stored as vec4)
  37159. * @param uniform defines the webGL uniform location where to store the value
  37160. * @param array defines the array of int32 to store
  37161. */
  37162. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37163. /**
  37164. * Set the value of an uniform to an array of number
  37165. * @param uniform defines the webGL uniform location where to store the value
  37166. * @param array defines the array of number to store
  37167. */
  37168. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37169. /**
  37170. * Set the value of an uniform to an array of number (stored as vec2)
  37171. * @param uniform defines the webGL uniform location where to store the value
  37172. * @param array defines the array of number to store
  37173. */
  37174. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37175. /**
  37176. * Set the value of an uniform to an array of number (stored as vec3)
  37177. * @param uniform defines the webGL uniform location where to store the value
  37178. * @param array defines the array of number to store
  37179. */
  37180. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37181. /**
  37182. * Set the value of an uniform to an array of number (stored as vec4)
  37183. * @param uniform defines the webGL uniform location where to store the value
  37184. * @param array defines the array of number to store
  37185. */
  37186. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37187. /**
  37188. * Set the value of an uniform to an array of float32 (stored as matrices)
  37189. * @param uniform defines the webGL uniform location where to store the value
  37190. * @param matrices defines the array of float32 to store
  37191. */
  37192. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37193. /**
  37194. * Set the value of an uniform to a matrix (3x3)
  37195. * @param uniform defines the webGL uniform location where to store the value
  37196. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37197. */
  37198. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37199. /**
  37200. * Set the value of an uniform to a matrix (2x2)
  37201. * @param uniform defines the webGL uniform location where to store the value
  37202. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37203. */
  37204. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37205. /**
  37206. * Set the value of an uniform to a number (float)
  37207. * @param uniform defines the webGL uniform location where to store the value
  37208. * @param value defines the float number to store
  37209. */
  37210. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37211. /**
  37212. * Set the value of an uniform to a vec2
  37213. * @param uniform defines the webGL uniform location where to store the value
  37214. * @param x defines the 1st component of the value
  37215. * @param y defines the 2nd component of the value
  37216. */
  37217. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37218. /**
  37219. * Set the value of an uniform to a vec3
  37220. * @param uniform defines the webGL uniform location where to store the value
  37221. * @param x defines the 1st component of the value
  37222. * @param y defines the 2nd component of the value
  37223. * @param z defines the 3rd component of the value
  37224. */
  37225. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37226. /**
  37227. * Set the value of an uniform to a vec4
  37228. * @param uniform defines the webGL uniform location where to store the value
  37229. * @param x defines the 1st component of the value
  37230. * @param y defines the 2nd component of the value
  37231. * @param z defines the 3rd component of the value
  37232. * @param w defines the 4th component of the value
  37233. */
  37234. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37235. /**
  37236. * Apply all cached states (depth, culling, stencil and alpha)
  37237. */
  37238. applyStates(): void;
  37239. /**
  37240. * Enable or disable color writing
  37241. * @param enable defines the state to set
  37242. */
  37243. setColorWrite(enable: boolean): void;
  37244. /**
  37245. * Gets a boolean indicating if color writing is enabled
  37246. * @returns the current color writing state
  37247. */
  37248. getColorWrite(): boolean;
  37249. /**
  37250. * Gets the depth culling state manager
  37251. */
  37252. get depthCullingState(): DepthCullingState;
  37253. /**
  37254. * Gets the alpha state manager
  37255. */
  37256. get alphaState(): AlphaState;
  37257. /**
  37258. * Gets the stencil state manager
  37259. */
  37260. get stencilState(): StencilState;
  37261. /**
  37262. * Clears the list of texture accessible through engine.
  37263. * This can help preventing texture load conflict due to name collision.
  37264. */
  37265. clearInternalTexturesCache(): void;
  37266. /**
  37267. * Force the entire cache to be cleared
  37268. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37269. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37270. */
  37271. wipeCaches(bruteForce?: boolean): void;
  37272. /** @hidden */
  37273. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37274. min: number;
  37275. mag: number;
  37276. };
  37277. /** @hidden */
  37278. _createTexture(): WebGLTexture;
  37279. /**
  37280. * Usually called from Texture.ts.
  37281. * Passed information to create a WebGLTexture
  37282. * @param url defines a value which contains one of the following:
  37283. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37284. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37285. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37286. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37287. * @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)
  37288. * @param scene needed for loading to the correct scene
  37289. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37290. * @param onLoad optional callback to be called upon successful completion
  37291. * @param onError optional callback to be called upon failure
  37292. * @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
  37293. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37294. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37295. * @param forcedExtension defines the extension to use to pick the right loader
  37296. * @param mimeType defines an optional mime type
  37297. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37298. */
  37299. 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;
  37300. /**
  37301. * Loads an image as an HTMLImageElement.
  37302. * @param input url string, ArrayBuffer, or Blob to load
  37303. * @param onLoad callback called when the image successfully loads
  37304. * @param onError callback called when the image fails to load
  37305. * @param offlineProvider offline provider for caching
  37306. * @param mimeType optional mime type
  37307. * @returns the HTMLImageElement of the loaded image
  37308. * @hidden
  37309. */
  37310. 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>;
  37311. /**
  37312. * @hidden
  37313. */
  37314. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37315. private _unpackFlipYCached;
  37316. /**
  37317. * In case you are sharing the context with other applications, it might
  37318. * be interested to not cache the unpack flip y state to ensure a consistent
  37319. * value would be set.
  37320. */
  37321. enableUnpackFlipYCached: boolean;
  37322. /** @hidden */
  37323. _unpackFlipY(value: boolean): void;
  37324. /** @hidden */
  37325. _getUnpackAlignement(): number;
  37326. private _getTextureTarget;
  37327. /**
  37328. * Update the sampling mode of a given texture
  37329. * @param samplingMode defines the required sampling mode
  37330. * @param texture defines the texture to update
  37331. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37332. */
  37333. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37334. /**
  37335. * Update the sampling mode of a given texture
  37336. * @param texture defines the texture to update
  37337. * @param wrapU defines the texture wrap mode of the u coordinates
  37338. * @param wrapV defines the texture wrap mode of the v coordinates
  37339. * @param wrapR defines the texture wrap mode of the r coordinates
  37340. */
  37341. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37342. /** @hidden */
  37343. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37344. width: number;
  37345. height: number;
  37346. layers?: number;
  37347. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37348. /** @hidden */
  37349. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37350. /** @hidden */
  37351. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37352. /**
  37353. * Update a portion of an internal texture
  37354. * @param texture defines the texture to update
  37355. * @param imageData defines the data to store into the texture
  37356. * @param xOffset defines the x coordinates of the update rectangle
  37357. * @param yOffset defines the y coordinates of the update rectangle
  37358. * @param width defines the width of the update rectangle
  37359. * @param height defines the height of the update rectangle
  37360. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37361. * @param lod defines the lod level to update (0 by default)
  37362. */
  37363. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37364. /** @hidden */
  37365. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37366. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37367. private _prepareWebGLTexture;
  37368. /** @hidden */
  37369. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37370. private _getDepthStencilBuffer;
  37371. /** @hidden */
  37372. _releaseFramebufferObjects(texture: InternalTexture): void;
  37373. /** @hidden */
  37374. _releaseTexture(texture: InternalTexture): void;
  37375. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37376. protected _setProgram(program: WebGLProgram): void;
  37377. protected _boundUniforms: {
  37378. [key: number]: WebGLUniformLocation;
  37379. };
  37380. /**
  37381. * Binds an effect to the webGL context
  37382. * @param effect defines the effect to bind
  37383. */
  37384. bindSamplers(effect: Effect): void;
  37385. private _activateCurrentTexture;
  37386. /** @hidden */
  37387. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37388. /** @hidden */
  37389. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37390. /**
  37391. * Unbind all textures from the webGL context
  37392. */
  37393. unbindAllTextures(): void;
  37394. /**
  37395. * Sets a texture to the according uniform.
  37396. * @param channel The texture channel
  37397. * @param uniform The uniform to set
  37398. * @param texture The texture to apply
  37399. */
  37400. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37401. private _bindSamplerUniformToChannel;
  37402. private _getTextureWrapMode;
  37403. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37404. /**
  37405. * Sets an array of texture to the webGL context
  37406. * @param channel defines the channel where the texture array must be set
  37407. * @param uniform defines the associated uniform location
  37408. * @param textures defines the array of textures to bind
  37409. */
  37410. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37411. /** @hidden */
  37412. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37413. private _setTextureParameterFloat;
  37414. private _setTextureParameterInteger;
  37415. /**
  37416. * Unbind all vertex attributes from the webGL context
  37417. */
  37418. unbindAllAttributes(): void;
  37419. /**
  37420. * 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
  37421. */
  37422. releaseEffects(): void;
  37423. /**
  37424. * Dispose and release all associated resources
  37425. */
  37426. dispose(): void;
  37427. /**
  37428. * Attach a new callback raised when context lost event is fired
  37429. * @param callback defines the callback to call
  37430. */
  37431. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37432. /**
  37433. * Attach a new callback raised when context restored event is fired
  37434. * @param callback defines the callback to call
  37435. */
  37436. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37437. /**
  37438. * Get the current error code of the webGL context
  37439. * @returns the error code
  37440. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37441. */
  37442. getError(): number;
  37443. private _canRenderToFloatFramebuffer;
  37444. private _canRenderToHalfFloatFramebuffer;
  37445. private _canRenderToFramebuffer;
  37446. /** @hidden */
  37447. _getWebGLTextureType(type: number): number;
  37448. /** @hidden */
  37449. _getInternalFormat(format: number): number;
  37450. /** @hidden */
  37451. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37452. /** @hidden */
  37453. _getRGBAMultiSampleBufferFormat(type: number): number;
  37454. /** @hidden */
  37455. _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;
  37456. /**
  37457. * Loads a file from a url
  37458. * @param url url to load
  37459. * @param onSuccess callback called when the file successfully loads
  37460. * @param onProgress callback called while file is loading (if the server supports this mode)
  37461. * @param offlineProvider defines the offline provider for caching
  37462. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37463. * @param onError callback called when the file fails to load
  37464. * @returns a file request object
  37465. * @hidden
  37466. */
  37467. 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;
  37468. /**
  37469. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37470. * @param x defines the x coordinate of the rectangle where pixels must be read
  37471. * @param y defines the y coordinate of the rectangle where pixels must be read
  37472. * @param width defines the width of the rectangle where pixels must be read
  37473. * @param height defines the height of the rectangle where pixels must be read
  37474. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37475. * @returns a Uint8Array containing RGBA colors
  37476. */
  37477. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37478. private static _isSupported;
  37479. /**
  37480. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37481. * @returns true if the engine can be created
  37482. * @ignorenaming
  37483. */
  37484. static isSupported(): boolean;
  37485. /**
  37486. * Find the next highest power of two.
  37487. * @param x Number to start search from.
  37488. * @return Next highest power of two.
  37489. */
  37490. static CeilingPOT(x: number): number;
  37491. /**
  37492. * Find the next lowest power of two.
  37493. * @param x Number to start search from.
  37494. * @return Next lowest power of two.
  37495. */
  37496. static FloorPOT(x: number): number;
  37497. /**
  37498. * Find the nearest power of two.
  37499. * @param x Number to start search from.
  37500. * @return Next nearest power of two.
  37501. */
  37502. static NearestPOT(x: number): number;
  37503. /**
  37504. * Get the closest exponent of two
  37505. * @param value defines the value to approximate
  37506. * @param max defines the maximum value to return
  37507. * @param mode defines how to define the closest value
  37508. * @returns closest exponent of two of the given value
  37509. */
  37510. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37511. /**
  37512. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37513. * @param func - the function to be called
  37514. * @param requester - the object that will request the next frame. Falls back to window.
  37515. * @returns frame number
  37516. */
  37517. static QueueNewFrame(func: () => void, requester?: any): number;
  37518. /**
  37519. * Gets host document
  37520. * @returns the host document object
  37521. */
  37522. getHostDocument(): Nullable<Document>;
  37523. }
  37524. }
  37525. declare module "babylonjs/Maths/sphericalPolynomial" {
  37526. import { Vector3 } from "babylonjs/Maths/math.vector";
  37527. import { Color3 } from "babylonjs/Maths/math.color";
  37528. /**
  37529. * Class representing spherical harmonics coefficients to the 3rd degree
  37530. */
  37531. export class SphericalHarmonics {
  37532. /**
  37533. * Defines whether or not the harmonics have been prescaled for rendering.
  37534. */
  37535. preScaled: boolean;
  37536. /**
  37537. * The l0,0 coefficients of the spherical harmonics
  37538. */
  37539. l00: Vector3;
  37540. /**
  37541. * The l1,-1 coefficients of the spherical harmonics
  37542. */
  37543. l1_1: Vector3;
  37544. /**
  37545. * The l1,0 coefficients of the spherical harmonics
  37546. */
  37547. l10: Vector3;
  37548. /**
  37549. * The l1,1 coefficients of the spherical harmonics
  37550. */
  37551. l11: Vector3;
  37552. /**
  37553. * The l2,-2 coefficients of the spherical harmonics
  37554. */
  37555. l2_2: Vector3;
  37556. /**
  37557. * The l2,-1 coefficients of the spherical harmonics
  37558. */
  37559. l2_1: Vector3;
  37560. /**
  37561. * The l2,0 coefficients of the spherical harmonics
  37562. */
  37563. l20: Vector3;
  37564. /**
  37565. * The l2,1 coefficients of the spherical harmonics
  37566. */
  37567. l21: Vector3;
  37568. /**
  37569. * The l2,2 coefficients of the spherical harmonics
  37570. */
  37571. l22: Vector3;
  37572. /**
  37573. * Adds a light to the spherical harmonics
  37574. * @param direction the direction of the light
  37575. * @param color the color of the light
  37576. * @param deltaSolidAngle the delta solid angle of the light
  37577. */
  37578. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37579. /**
  37580. * Scales the spherical harmonics by the given amount
  37581. * @param scale the amount to scale
  37582. */
  37583. scaleInPlace(scale: number): void;
  37584. /**
  37585. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37586. *
  37587. * ```
  37588. * E_lm = A_l * L_lm
  37589. * ```
  37590. *
  37591. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37592. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37593. * the scaling factors are given in equation 9.
  37594. */
  37595. convertIncidentRadianceToIrradiance(): void;
  37596. /**
  37597. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37598. *
  37599. * ```
  37600. * L = (1/pi) * E * rho
  37601. * ```
  37602. *
  37603. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37604. */
  37605. convertIrradianceToLambertianRadiance(): void;
  37606. /**
  37607. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37608. * required operations at run time.
  37609. *
  37610. * This is simply done by scaling back the SH with Ylm constants parameter.
  37611. * The trigonometric part being applied by the shader at run time.
  37612. */
  37613. preScaleForRendering(): void;
  37614. /**
  37615. * Constructs a spherical harmonics from an array.
  37616. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37617. * @returns the spherical harmonics
  37618. */
  37619. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37620. /**
  37621. * Gets the spherical harmonics from polynomial
  37622. * @param polynomial the spherical polynomial
  37623. * @returns the spherical harmonics
  37624. */
  37625. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37626. }
  37627. /**
  37628. * Class representing spherical polynomial coefficients to the 3rd degree
  37629. */
  37630. export class SphericalPolynomial {
  37631. private _harmonics;
  37632. /**
  37633. * The spherical harmonics used to create the polynomials.
  37634. */
  37635. get preScaledHarmonics(): SphericalHarmonics;
  37636. /**
  37637. * The x coefficients of the spherical polynomial
  37638. */
  37639. x: Vector3;
  37640. /**
  37641. * The y coefficients of the spherical polynomial
  37642. */
  37643. y: Vector3;
  37644. /**
  37645. * The z coefficients of the spherical polynomial
  37646. */
  37647. z: Vector3;
  37648. /**
  37649. * The xx coefficients of the spherical polynomial
  37650. */
  37651. xx: Vector3;
  37652. /**
  37653. * The yy coefficients of the spherical polynomial
  37654. */
  37655. yy: Vector3;
  37656. /**
  37657. * The zz coefficients of the spherical polynomial
  37658. */
  37659. zz: Vector3;
  37660. /**
  37661. * The xy coefficients of the spherical polynomial
  37662. */
  37663. xy: Vector3;
  37664. /**
  37665. * The yz coefficients of the spherical polynomial
  37666. */
  37667. yz: Vector3;
  37668. /**
  37669. * The zx coefficients of the spherical polynomial
  37670. */
  37671. zx: Vector3;
  37672. /**
  37673. * Adds an ambient color to the spherical polynomial
  37674. * @param color the color to add
  37675. */
  37676. addAmbient(color: Color3): void;
  37677. /**
  37678. * Scales the spherical polynomial by the given amount
  37679. * @param scale the amount to scale
  37680. */
  37681. scaleInPlace(scale: number): void;
  37682. /**
  37683. * Gets the spherical polynomial from harmonics
  37684. * @param harmonics the spherical harmonics
  37685. * @returns the spherical polynomial
  37686. */
  37687. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37688. /**
  37689. * Constructs a spherical polynomial from an array.
  37690. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37691. * @returns the spherical polynomial
  37692. */
  37693. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37694. }
  37695. }
  37696. declare module "babylonjs/Materials/Textures/internalTexture" {
  37697. import { Observable } from "babylonjs/Misc/observable";
  37698. import { Nullable, int } from "babylonjs/types";
  37699. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37700. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37701. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37702. /**
  37703. * Defines the source of the internal texture
  37704. */
  37705. export enum InternalTextureSource {
  37706. /**
  37707. * The source of the texture data is unknown
  37708. */
  37709. Unknown = 0,
  37710. /**
  37711. * Texture data comes from an URL
  37712. */
  37713. Url = 1,
  37714. /**
  37715. * Texture data is only used for temporary storage
  37716. */
  37717. Temp = 2,
  37718. /**
  37719. * Texture data comes from raw data (ArrayBuffer)
  37720. */
  37721. Raw = 3,
  37722. /**
  37723. * Texture content is dynamic (video or dynamic texture)
  37724. */
  37725. Dynamic = 4,
  37726. /**
  37727. * Texture content is generated by rendering to it
  37728. */
  37729. RenderTarget = 5,
  37730. /**
  37731. * Texture content is part of a multi render target process
  37732. */
  37733. MultiRenderTarget = 6,
  37734. /**
  37735. * Texture data comes from a cube data file
  37736. */
  37737. Cube = 7,
  37738. /**
  37739. * Texture data comes from a raw cube data
  37740. */
  37741. CubeRaw = 8,
  37742. /**
  37743. * Texture data come from a prefiltered cube data file
  37744. */
  37745. CubePrefiltered = 9,
  37746. /**
  37747. * Texture content is raw 3D data
  37748. */
  37749. Raw3D = 10,
  37750. /**
  37751. * Texture content is raw 2D array data
  37752. */
  37753. Raw2DArray = 11,
  37754. /**
  37755. * Texture content is a depth texture
  37756. */
  37757. Depth = 12,
  37758. /**
  37759. * Texture data comes from a raw cube data encoded with RGBD
  37760. */
  37761. CubeRawRGBD = 13
  37762. }
  37763. /**
  37764. * Class used to store data associated with WebGL texture data for the engine
  37765. * This class should not be used directly
  37766. */
  37767. export class InternalTexture {
  37768. /** @hidden */
  37769. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37770. /**
  37771. * Defines if the texture is ready
  37772. */
  37773. isReady: boolean;
  37774. /**
  37775. * Defines if the texture is a cube texture
  37776. */
  37777. isCube: boolean;
  37778. /**
  37779. * Defines if the texture contains 3D data
  37780. */
  37781. is3D: boolean;
  37782. /**
  37783. * Defines if the texture contains 2D array data
  37784. */
  37785. is2DArray: boolean;
  37786. /**
  37787. * Defines if the texture contains multiview data
  37788. */
  37789. isMultiview: boolean;
  37790. /**
  37791. * Gets the URL used to load this texture
  37792. */
  37793. url: string;
  37794. /**
  37795. * Gets the sampling mode of the texture
  37796. */
  37797. samplingMode: number;
  37798. /**
  37799. * Gets a boolean indicating if the texture needs mipmaps generation
  37800. */
  37801. generateMipMaps: boolean;
  37802. /**
  37803. * Gets the number of samples used by the texture (WebGL2+ only)
  37804. */
  37805. samples: number;
  37806. /**
  37807. * Gets the type of the texture (int, float...)
  37808. */
  37809. type: number;
  37810. /**
  37811. * Gets the format of the texture (RGB, RGBA...)
  37812. */
  37813. format: number;
  37814. /**
  37815. * Observable called when the texture is loaded
  37816. */
  37817. onLoadedObservable: Observable<InternalTexture>;
  37818. /**
  37819. * Gets the width of the texture
  37820. */
  37821. width: number;
  37822. /**
  37823. * Gets the height of the texture
  37824. */
  37825. height: number;
  37826. /**
  37827. * Gets the depth of the texture
  37828. */
  37829. depth: number;
  37830. /**
  37831. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37832. */
  37833. baseWidth: number;
  37834. /**
  37835. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37836. */
  37837. baseHeight: number;
  37838. /**
  37839. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37840. */
  37841. baseDepth: number;
  37842. /**
  37843. * Gets a boolean indicating if the texture is inverted on Y axis
  37844. */
  37845. invertY: boolean;
  37846. /** @hidden */
  37847. _invertVScale: boolean;
  37848. /** @hidden */
  37849. _associatedChannel: number;
  37850. /** @hidden */
  37851. _source: InternalTextureSource;
  37852. /** @hidden */
  37853. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37854. /** @hidden */
  37855. _bufferView: Nullable<ArrayBufferView>;
  37856. /** @hidden */
  37857. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37858. /** @hidden */
  37859. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37860. /** @hidden */
  37861. _size: number;
  37862. /** @hidden */
  37863. _extension: string;
  37864. /** @hidden */
  37865. _files: Nullable<string[]>;
  37866. /** @hidden */
  37867. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37868. /** @hidden */
  37869. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37870. /** @hidden */
  37871. _framebuffer: Nullable<WebGLFramebuffer>;
  37872. /** @hidden */
  37873. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37874. /** @hidden */
  37875. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37876. /** @hidden */
  37877. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37878. /** @hidden */
  37879. _attachments: Nullable<number[]>;
  37880. /** @hidden */
  37881. _textureArray: Nullable<InternalTexture[]>;
  37882. /** @hidden */
  37883. _cachedCoordinatesMode: Nullable<number>;
  37884. /** @hidden */
  37885. _cachedWrapU: Nullable<number>;
  37886. /** @hidden */
  37887. _cachedWrapV: Nullable<number>;
  37888. /** @hidden */
  37889. _cachedWrapR: Nullable<number>;
  37890. /** @hidden */
  37891. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37892. /** @hidden */
  37893. _isDisabled: boolean;
  37894. /** @hidden */
  37895. _compression: Nullable<string>;
  37896. /** @hidden */
  37897. _generateStencilBuffer: boolean;
  37898. /** @hidden */
  37899. _generateDepthBuffer: boolean;
  37900. /** @hidden */
  37901. _comparisonFunction: number;
  37902. /** @hidden */
  37903. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37904. /** @hidden */
  37905. _lodGenerationScale: number;
  37906. /** @hidden */
  37907. _lodGenerationOffset: number;
  37908. /** @hidden */
  37909. _depthStencilTexture: Nullable<InternalTexture>;
  37910. /** @hidden */
  37911. _colorTextureArray: Nullable<WebGLTexture>;
  37912. /** @hidden */
  37913. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37914. /** @hidden */
  37915. _lodTextureHigh: Nullable<BaseTexture>;
  37916. /** @hidden */
  37917. _lodTextureMid: Nullable<BaseTexture>;
  37918. /** @hidden */
  37919. _lodTextureLow: Nullable<BaseTexture>;
  37920. /** @hidden */
  37921. _isRGBD: boolean;
  37922. /** @hidden */
  37923. _linearSpecularLOD: boolean;
  37924. /** @hidden */
  37925. _irradianceTexture: Nullable<BaseTexture>;
  37926. /** @hidden */
  37927. _webGLTexture: Nullable<WebGLTexture>;
  37928. /** @hidden */
  37929. _references: number;
  37930. private _engine;
  37931. /**
  37932. * Gets the Engine the texture belongs to.
  37933. * @returns The babylon engine
  37934. */
  37935. getEngine(): ThinEngine;
  37936. /**
  37937. * Gets the data source type of the texture
  37938. */
  37939. get source(): InternalTextureSource;
  37940. /**
  37941. * Creates a new InternalTexture
  37942. * @param engine defines the engine to use
  37943. * @param source defines the type of data that will be used
  37944. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37945. */
  37946. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37947. /**
  37948. * Increments the number of references (ie. the number of Texture that point to it)
  37949. */
  37950. incrementReferences(): void;
  37951. /**
  37952. * Change the size of the texture (not the size of the content)
  37953. * @param width defines the new width
  37954. * @param height defines the new height
  37955. * @param depth defines the new depth (1 by default)
  37956. */
  37957. updateSize(width: int, height: int, depth?: int): void;
  37958. /** @hidden */
  37959. _rebuild(): void;
  37960. /** @hidden */
  37961. _swapAndDie(target: InternalTexture): void;
  37962. /**
  37963. * Dispose the current allocated resources
  37964. */
  37965. dispose(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Audio/analyser" {
  37969. import { Scene } from "babylonjs/scene";
  37970. /**
  37971. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37973. */
  37974. export class Analyser {
  37975. /**
  37976. * Gets or sets the smoothing
  37977. * @ignorenaming
  37978. */
  37979. SMOOTHING: number;
  37980. /**
  37981. * Gets or sets the FFT table size
  37982. * @ignorenaming
  37983. */
  37984. FFT_SIZE: number;
  37985. /**
  37986. * Gets or sets the bar graph amplitude
  37987. * @ignorenaming
  37988. */
  37989. BARGRAPHAMPLITUDE: number;
  37990. /**
  37991. * Gets or sets the position of the debug canvas
  37992. * @ignorenaming
  37993. */
  37994. DEBUGCANVASPOS: {
  37995. x: number;
  37996. y: number;
  37997. };
  37998. /**
  37999. * Gets or sets the debug canvas size
  38000. * @ignorenaming
  38001. */
  38002. DEBUGCANVASSIZE: {
  38003. width: number;
  38004. height: number;
  38005. };
  38006. private _byteFreqs;
  38007. private _byteTime;
  38008. private _floatFreqs;
  38009. private _webAudioAnalyser;
  38010. private _debugCanvas;
  38011. private _debugCanvasContext;
  38012. private _scene;
  38013. private _registerFunc;
  38014. private _audioEngine;
  38015. /**
  38016. * Creates a new analyser
  38017. * @param scene defines hosting scene
  38018. */
  38019. constructor(scene: Scene);
  38020. /**
  38021. * Get the number of data values you will have to play with for the visualization
  38022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38023. * @returns a number
  38024. */
  38025. getFrequencyBinCount(): number;
  38026. /**
  38027. * Gets the current frequency data as a byte array
  38028. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38029. * @returns a Uint8Array
  38030. */
  38031. getByteFrequencyData(): Uint8Array;
  38032. /**
  38033. * Gets the current waveform as a byte array
  38034. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38035. * @returns a Uint8Array
  38036. */
  38037. getByteTimeDomainData(): Uint8Array;
  38038. /**
  38039. * Gets the current frequency data as a float array
  38040. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38041. * @returns a Float32Array
  38042. */
  38043. getFloatFrequencyData(): Float32Array;
  38044. /**
  38045. * Renders the debug canvas
  38046. */
  38047. drawDebugCanvas(): void;
  38048. /**
  38049. * Stops rendering the debug canvas and removes it
  38050. */
  38051. stopDebugCanvas(): void;
  38052. /**
  38053. * Connects two audio nodes
  38054. * @param inputAudioNode defines first node to connect
  38055. * @param outputAudioNode defines second node to connect
  38056. */
  38057. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38058. /**
  38059. * Releases all associated resources
  38060. */
  38061. dispose(): void;
  38062. }
  38063. }
  38064. declare module "babylonjs/Audio/audioEngine" {
  38065. import { IDisposable } from "babylonjs/scene";
  38066. import { Analyser } from "babylonjs/Audio/analyser";
  38067. import { Nullable } from "babylonjs/types";
  38068. import { Observable } from "babylonjs/Misc/observable";
  38069. /**
  38070. * This represents an audio engine and it is responsible
  38071. * to play, synchronize and analyse sounds throughout the application.
  38072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38073. */
  38074. export interface IAudioEngine extends IDisposable {
  38075. /**
  38076. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38077. */
  38078. readonly canUseWebAudio: boolean;
  38079. /**
  38080. * Gets the current AudioContext if available.
  38081. */
  38082. readonly audioContext: Nullable<AudioContext>;
  38083. /**
  38084. * The master gain node defines the global audio volume of your audio engine.
  38085. */
  38086. readonly masterGain: GainNode;
  38087. /**
  38088. * Gets whether or not mp3 are supported by your browser.
  38089. */
  38090. readonly isMP3supported: boolean;
  38091. /**
  38092. * Gets whether or not ogg are supported by your browser.
  38093. */
  38094. readonly isOGGsupported: boolean;
  38095. /**
  38096. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38097. * @ignoreNaming
  38098. */
  38099. WarnedWebAudioUnsupported: boolean;
  38100. /**
  38101. * Defines if the audio engine relies on a custom unlocked button.
  38102. * In this case, the embedded button will not be displayed.
  38103. */
  38104. useCustomUnlockedButton: boolean;
  38105. /**
  38106. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38107. */
  38108. readonly unlocked: boolean;
  38109. /**
  38110. * Event raised when audio has been unlocked on the browser.
  38111. */
  38112. onAudioUnlockedObservable: Observable<AudioEngine>;
  38113. /**
  38114. * Event raised when audio has been locked on the browser.
  38115. */
  38116. onAudioLockedObservable: Observable<AudioEngine>;
  38117. /**
  38118. * Flags the audio engine in Locked state.
  38119. * This happens due to new browser policies preventing audio to autoplay.
  38120. */
  38121. lock(): void;
  38122. /**
  38123. * Unlocks the audio engine once a user action has been done on the dom.
  38124. * This is helpful to resume play once browser policies have been satisfied.
  38125. */
  38126. unlock(): void;
  38127. /**
  38128. * Gets the global volume sets on the master gain.
  38129. * @returns the global volume if set or -1 otherwise
  38130. */
  38131. getGlobalVolume(): number;
  38132. /**
  38133. * Sets the global volume of your experience (sets on the master gain).
  38134. * @param newVolume Defines the new global volume of the application
  38135. */
  38136. setGlobalVolume(newVolume: number): void;
  38137. /**
  38138. * Connect the audio engine to an audio analyser allowing some amazing
  38139. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38141. * @param analyser The analyser to connect to the engine
  38142. */
  38143. connectToAnalyser(analyser: Analyser): void;
  38144. }
  38145. /**
  38146. * This represents the default audio engine used in babylon.
  38147. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38149. */
  38150. export class AudioEngine implements IAudioEngine {
  38151. private _audioContext;
  38152. private _audioContextInitialized;
  38153. private _muteButton;
  38154. private _hostElement;
  38155. /**
  38156. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38157. */
  38158. canUseWebAudio: boolean;
  38159. /**
  38160. * The master gain node defines the global audio volume of your audio engine.
  38161. */
  38162. masterGain: GainNode;
  38163. /**
  38164. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38165. * @ignoreNaming
  38166. */
  38167. WarnedWebAudioUnsupported: boolean;
  38168. /**
  38169. * Gets whether or not mp3 are supported by your browser.
  38170. */
  38171. isMP3supported: boolean;
  38172. /**
  38173. * Gets whether or not ogg are supported by your browser.
  38174. */
  38175. isOGGsupported: boolean;
  38176. /**
  38177. * Gets whether audio has been unlocked on the device.
  38178. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38179. * a user interaction has happened.
  38180. */
  38181. unlocked: boolean;
  38182. /**
  38183. * Defines if the audio engine relies on a custom unlocked button.
  38184. * In this case, the embedded button will not be displayed.
  38185. */
  38186. useCustomUnlockedButton: boolean;
  38187. /**
  38188. * Event raised when audio has been unlocked on the browser.
  38189. */
  38190. onAudioUnlockedObservable: Observable<AudioEngine>;
  38191. /**
  38192. * Event raised when audio has been locked on the browser.
  38193. */
  38194. onAudioLockedObservable: Observable<AudioEngine>;
  38195. /**
  38196. * Gets the current AudioContext if available.
  38197. */
  38198. get audioContext(): Nullable<AudioContext>;
  38199. private _connectedAnalyser;
  38200. /**
  38201. * Instantiates a new audio engine.
  38202. *
  38203. * There should be only one per page as some browsers restrict the number
  38204. * of audio contexts you can create.
  38205. * @param hostElement defines the host element where to display the mute icon if necessary
  38206. */
  38207. constructor(hostElement?: Nullable<HTMLElement>);
  38208. /**
  38209. * Flags the audio engine in Locked state.
  38210. * This happens due to new browser policies preventing audio to autoplay.
  38211. */
  38212. lock(): void;
  38213. /**
  38214. * Unlocks the audio engine once a user action has been done on the dom.
  38215. * This is helpful to resume play once browser policies have been satisfied.
  38216. */
  38217. unlock(): void;
  38218. private _resumeAudioContext;
  38219. private _initializeAudioContext;
  38220. private _tryToRun;
  38221. private _triggerRunningState;
  38222. private _triggerSuspendedState;
  38223. private _displayMuteButton;
  38224. private _moveButtonToTopLeft;
  38225. private _onResize;
  38226. private _hideMuteButton;
  38227. /**
  38228. * Destroy and release the resources associated with the audio ccontext.
  38229. */
  38230. dispose(): void;
  38231. /**
  38232. * Gets the global volume sets on the master gain.
  38233. * @returns the global volume if set or -1 otherwise
  38234. */
  38235. getGlobalVolume(): number;
  38236. /**
  38237. * Sets the global volume of your experience (sets on the master gain).
  38238. * @param newVolume Defines the new global volume of the application
  38239. */
  38240. setGlobalVolume(newVolume: number): void;
  38241. /**
  38242. * Connect the audio engine to an audio analyser allowing some amazing
  38243. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38245. * @param analyser The analyser to connect to the engine
  38246. */
  38247. connectToAnalyser(analyser: Analyser): void;
  38248. }
  38249. }
  38250. declare module "babylonjs/Loading/loadingScreen" {
  38251. /**
  38252. * Interface used to present a loading screen while loading a scene
  38253. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38254. */
  38255. export interface ILoadingScreen {
  38256. /**
  38257. * Function called to display the loading screen
  38258. */
  38259. displayLoadingUI: () => void;
  38260. /**
  38261. * Function called to hide the loading screen
  38262. */
  38263. hideLoadingUI: () => void;
  38264. /**
  38265. * Gets or sets the color to use for the background
  38266. */
  38267. loadingUIBackgroundColor: string;
  38268. /**
  38269. * Gets or sets the text to display while loading
  38270. */
  38271. loadingUIText: string;
  38272. }
  38273. /**
  38274. * Class used for the default loading screen
  38275. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38276. */
  38277. export class DefaultLoadingScreen implements ILoadingScreen {
  38278. private _renderingCanvas;
  38279. private _loadingText;
  38280. private _loadingDivBackgroundColor;
  38281. private _loadingDiv;
  38282. private _loadingTextDiv;
  38283. /** Gets or sets the logo url to use for the default loading screen */
  38284. static DefaultLogoUrl: string;
  38285. /** Gets or sets the spinner url to use for the default loading screen */
  38286. static DefaultSpinnerUrl: string;
  38287. /**
  38288. * Creates a new default loading screen
  38289. * @param _renderingCanvas defines the canvas used to render the scene
  38290. * @param _loadingText defines the default text to display
  38291. * @param _loadingDivBackgroundColor defines the default background color
  38292. */
  38293. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38294. /**
  38295. * Function called to display the loading screen
  38296. */
  38297. displayLoadingUI(): void;
  38298. /**
  38299. * Function called to hide the loading screen
  38300. */
  38301. hideLoadingUI(): void;
  38302. /**
  38303. * Gets or sets the text to display while loading
  38304. */
  38305. set loadingUIText(text: string);
  38306. get loadingUIText(): string;
  38307. /**
  38308. * Gets or sets the color to use for the background
  38309. */
  38310. get loadingUIBackgroundColor(): string;
  38311. set loadingUIBackgroundColor(color: string);
  38312. private _resizeLoadingUI;
  38313. }
  38314. }
  38315. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38316. /**
  38317. * Interface for any object that can request an animation frame
  38318. */
  38319. export interface ICustomAnimationFrameRequester {
  38320. /**
  38321. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38322. */
  38323. renderFunction?: Function;
  38324. /**
  38325. * Called to request the next frame to render to
  38326. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38327. */
  38328. requestAnimationFrame: Function;
  38329. /**
  38330. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38331. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38332. */
  38333. requestID?: number;
  38334. }
  38335. }
  38336. declare module "babylonjs/Misc/performanceMonitor" {
  38337. /**
  38338. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38339. */
  38340. export class PerformanceMonitor {
  38341. private _enabled;
  38342. private _rollingFrameTime;
  38343. private _lastFrameTimeMs;
  38344. /**
  38345. * constructor
  38346. * @param frameSampleSize The number of samples required to saturate the sliding window
  38347. */
  38348. constructor(frameSampleSize?: number);
  38349. /**
  38350. * Samples current frame
  38351. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38352. */
  38353. sampleFrame(timeMs?: number): void;
  38354. /**
  38355. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38356. */
  38357. get averageFrameTime(): number;
  38358. /**
  38359. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38360. */
  38361. get averageFrameTimeVariance(): number;
  38362. /**
  38363. * Returns the frame time of the most recent frame
  38364. */
  38365. get instantaneousFrameTime(): number;
  38366. /**
  38367. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38368. */
  38369. get averageFPS(): number;
  38370. /**
  38371. * Returns the average framerate in frames per second using the most recent frame time
  38372. */
  38373. get instantaneousFPS(): number;
  38374. /**
  38375. * Returns true if enough samples have been taken to completely fill the sliding window
  38376. */
  38377. get isSaturated(): boolean;
  38378. /**
  38379. * Enables contributions to the sliding window sample set
  38380. */
  38381. enable(): void;
  38382. /**
  38383. * Disables contributions to the sliding window sample set
  38384. * Samples will not be interpolated over the disabled period
  38385. */
  38386. disable(): void;
  38387. /**
  38388. * Returns true if sampling is enabled
  38389. */
  38390. get isEnabled(): boolean;
  38391. /**
  38392. * Resets performance monitor
  38393. */
  38394. reset(): void;
  38395. }
  38396. /**
  38397. * RollingAverage
  38398. *
  38399. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38400. */
  38401. export class RollingAverage {
  38402. /**
  38403. * Current average
  38404. */
  38405. average: number;
  38406. /**
  38407. * Current variance
  38408. */
  38409. variance: number;
  38410. protected _samples: Array<number>;
  38411. protected _sampleCount: number;
  38412. protected _pos: number;
  38413. protected _m2: number;
  38414. /**
  38415. * constructor
  38416. * @param length The number of samples required to saturate the sliding window
  38417. */
  38418. constructor(length: number);
  38419. /**
  38420. * Adds a sample to the sample set
  38421. * @param v The sample value
  38422. */
  38423. add(v: number): void;
  38424. /**
  38425. * Returns previously added values or null if outside of history or outside the sliding window domain
  38426. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38427. * @return Value previously recorded with add() or null if outside of range
  38428. */
  38429. history(i: number): number;
  38430. /**
  38431. * Returns true if enough samples have been taken to completely fill the sliding window
  38432. * @return true if sample-set saturated
  38433. */
  38434. isSaturated(): boolean;
  38435. /**
  38436. * Resets the rolling average (equivalent to 0 samples taken so far)
  38437. */
  38438. reset(): void;
  38439. /**
  38440. * Wraps a value around the sample range boundaries
  38441. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38442. * @return Wrapped position in sample range
  38443. */
  38444. protected _wrapPosition(i: number): number;
  38445. }
  38446. }
  38447. declare module "babylonjs/Misc/perfCounter" {
  38448. /**
  38449. * This class is used to track a performance counter which is number based.
  38450. * The user has access to many properties which give statistics of different nature.
  38451. *
  38452. * The implementer can track two kinds of Performance Counter: time and count.
  38453. * 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.
  38454. * 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.
  38455. */
  38456. export class PerfCounter {
  38457. /**
  38458. * Gets or sets a global boolean to turn on and off all the counters
  38459. */
  38460. static Enabled: boolean;
  38461. /**
  38462. * Returns the smallest value ever
  38463. */
  38464. get min(): number;
  38465. /**
  38466. * Returns the biggest value ever
  38467. */
  38468. get max(): number;
  38469. /**
  38470. * Returns the average value since the performance counter is running
  38471. */
  38472. get average(): number;
  38473. /**
  38474. * Returns the average value of the last second the counter was monitored
  38475. */
  38476. get lastSecAverage(): number;
  38477. /**
  38478. * Returns the current value
  38479. */
  38480. get current(): number;
  38481. /**
  38482. * Gets the accumulated total
  38483. */
  38484. get total(): number;
  38485. /**
  38486. * Gets the total value count
  38487. */
  38488. get count(): number;
  38489. /**
  38490. * Creates a new counter
  38491. */
  38492. constructor();
  38493. /**
  38494. * Call this method to start monitoring a new frame.
  38495. * 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.
  38496. */
  38497. fetchNewFrame(): void;
  38498. /**
  38499. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38500. * @param newCount the count value to add to the monitored count
  38501. * @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.
  38502. */
  38503. addCount(newCount: number, fetchResult: boolean): void;
  38504. /**
  38505. * Start monitoring this performance counter
  38506. */
  38507. beginMonitoring(): void;
  38508. /**
  38509. * Compute the time lapsed since the previous beginMonitoring() call.
  38510. * @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
  38511. */
  38512. endMonitoring(newFrame?: boolean): void;
  38513. private _fetchResult;
  38514. private _startMonitoringTime;
  38515. private _min;
  38516. private _max;
  38517. private _average;
  38518. private _current;
  38519. private _totalValueCount;
  38520. private _totalAccumulated;
  38521. private _lastSecAverage;
  38522. private _lastSecAccumulated;
  38523. private _lastSecTime;
  38524. private _lastSecValueCount;
  38525. }
  38526. }
  38527. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38529. import { Nullable } from "babylonjs/types";
  38530. module "babylonjs/Engines/thinEngine" {
  38531. interface ThinEngine {
  38532. /** @hidden */
  38533. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38534. }
  38535. }
  38536. }
  38537. declare module "babylonjs/Engines/engine" {
  38538. import { Observable } from "babylonjs/Misc/observable";
  38539. import { Nullable } from "babylonjs/types";
  38540. import { Scene } from "babylonjs/scene";
  38541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38542. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38543. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38544. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38545. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38546. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38547. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38548. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38549. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38551. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38553. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38554. import "babylonjs/Engines/Extensions/engine.alpha";
  38555. import "babylonjs/Engines/Extensions/engine.readTexture";
  38556. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38557. import { Material } from "babylonjs/Materials/material";
  38558. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38559. /**
  38560. * Defines the interface used by display changed events
  38561. */
  38562. export interface IDisplayChangedEventArgs {
  38563. /** Gets the vrDisplay object (if any) */
  38564. vrDisplay: Nullable<any>;
  38565. /** Gets a boolean indicating if webVR is supported */
  38566. vrSupported: boolean;
  38567. }
  38568. /**
  38569. * Defines the interface used by objects containing a viewport (like a camera)
  38570. */
  38571. interface IViewportOwnerLike {
  38572. /**
  38573. * Gets or sets the viewport
  38574. */
  38575. viewport: IViewportLike;
  38576. }
  38577. /**
  38578. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38579. */
  38580. export class Engine extends ThinEngine {
  38581. /** Defines that alpha blending is disabled */
  38582. static readonly ALPHA_DISABLE: number;
  38583. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38584. static readonly ALPHA_ADD: number;
  38585. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38586. static readonly ALPHA_COMBINE: number;
  38587. /** Defines that alpha blending to DEST - SRC * DEST */
  38588. static readonly ALPHA_SUBTRACT: number;
  38589. /** Defines that alpha blending to SRC * DEST */
  38590. static readonly ALPHA_MULTIPLY: number;
  38591. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38592. static readonly ALPHA_MAXIMIZED: number;
  38593. /** Defines that alpha blending to SRC + DEST */
  38594. static readonly ALPHA_ONEONE: number;
  38595. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38596. static readonly ALPHA_PREMULTIPLIED: number;
  38597. /**
  38598. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38599. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38600. */
  38601. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38602. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38603. static readonly ALPHA_INTERPOLATE: number;
  38604. /**
  38605. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38606. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38607. */
  38608. static readonly ALPHA_SCREENMODE: number;
  38609. /** Defines that the ressource is not delayed*/
  38610. static readonly DELAYLOADSTATE_NONE: number;
  38611. /** Defines that the ressource was successfully delay loaded */
  38612. static readonly DELAYLOADSTATE_LOADED: number;
  38613. /** Defines that the ressource is currently delay loading */
  38614. static readonly DELAYLOADSTATE_LOADING: number;
  38615. /** Defines that the ressource is delayed and has not started loading */
  38616. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38617. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38618. static readonly NEVER: number;
  38619. /** 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 */
  38620. static readonly ALWAYS: number;
  38621. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38622. static readonly LESS: number;
  38623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38624. static readonly EQUAL: number;
  38625. /** 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 */
  38626. static readonly LEQUAL: number;
  38627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38628. static readonly GREATER: number;
  38629. /** 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 */
  38630. static readonly GEQUAL: number;
  38631. /** 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 */
  38632. static readonly NOTEQUAL: number;
  38633. /** Passed to stencilOperation to specify that stencil value must be kept */
  38634. static readonly KEEP: number;
  38635. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38636. static readonly REPLACE: number;
  38637. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38638. static readonly INCR: number;
  38639. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38640. static readonly DECR: number;
  38641. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38642. static readonly INVERT: number;
  38643. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38644. static readonly INCR_WRAP: number;
  38645. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38646. static readonly DECR_WRAP: number;
  38647. /** Texture is not repeating outside of 0..1 UVs */
  38648. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38649. /** Texture is repeating outside of 0..1 UVs */
  38650. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38651. /** Texture is repeating and mirrored */
  38652. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38653. /** ALPHA */
  38654. static readonly TEXTUREFORMAT_ALPHA: number;
  38655. /** LUMINANCE */
  38656. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38657. /** LUMINANCE_ALPHA */
  38658. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38659. /** RGB */
  38660. static readonly TEXTUREFORMAT_RGB: number;
  38661. /** RGBA */
  38662. static readonly TEXTUREFORMAT_RGBA: number;
  38663. /** RED */
  38664. static readonly TEXTUREFORMAT_RED: number;
  38665. /** RED (2nd reference) */
  38666. static readonly TEXTUREFORMAT_R: number;
  38667. /** RG */
  38668. static readonly TEXTUREFORMAT_RG: number;
  38669. /** RED_INTEGER */
  38670. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38671. /** RED_INTEGER (2nd reference) */
  38672. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38673. /** RG_INTEGER */
  38674. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38675. /** RGB_INTEGER */
  38676. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38677. /** RGBA_INTEGER */
  38678. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38679. /** UNSIGNED_BYTE */
  38680. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38681. /** UNSIGNED_BYTE (2nd reference) */
  38682. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38683. /** FLOAT */
  38684. static readonly TEXTURETYPE_FLOAT: number;
  38685. /** HALF_FLOAT */
  38686. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38687. /** BYTE */
  38688. static readonly TEXTURETYPE_BYTE: number;
  38689. /** SHORT */
  38690. static readonly TEXTURETYPE_SHORT: number;
  38691. /** UNSIGNED_SHORT */
  38692. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38693. /** INT */
  38694. static readonly TEXTURETYPE_INT: number;
  38695. /** UNSIGNED_INT */
  38696. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38697. /** UNSIGNED_SHORT_4_4_4_4 */
  38698. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38699. /** UNSIGNED_SHORT_5_5_5_1 */
  38700. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38701. /** UNSIGNED_SHORT_5_6_5 */
  38702. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38703. /** UNSIGNED_INT_2_10_10_10_REV */
  38704. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38705. /** UNSIGNED_INT_24_8 */
  38706. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38707. /** UNSIGNED_INT_10F_11F_11F_REV */
  38708. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38709. /** UNSIGNED_INT_5_9_9_9_REV */
  38710. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38711. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38712. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38713. /** nearest is mag = nearest and min = nearest and mip = linear */
  38714. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38715. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38716. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38717. /** Trilinear is mag = linear and min = linear and mip = linear */
  38718. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38719. /** nearest is mag = nearest and min = nearest and mip = linear */
  38720. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38722. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38723. /** Trilinear is mag = linear and min = linear and mip = linear */
  38724. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38725. /** mag = nearest and min = nearest and mip = nearest */
  38726. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38727. /** mag = nearest and min = linear and mip = nearest */
  38728. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38729. /** mag = nearest and min = linear and mip = linear */
  38730. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38731. /** mag = nearest and min = linear and mip = none */
  38732. static readonly TEXTURE_NEAREST_LINEAR: number;
  38733. /** mag = nearest and min = nearest and mip = none */
  38734. static readonly TEXTURE_NEAREST_NEAREST: number;
  38735. /** mag = linear and min = nearest and mip = nearest */
  38736. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38737. /** mag = linear and min = nearest and mip = linear */
  38738. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38739. /** mag = linear and min = linear and mip = none */
  38740. static readonly TEXTURE_LINEAR_LINEAR: number;
  38741. /** mag = linear and min = nearest and mip = none */
  38742. static readonly TEXTURE_LINEAR_NEAREST: number;
  38743. /** Explicit coordinates mode */
  38744. static readonly TEXTURE_EXPLICIT_MODE: number;
  38745. /** Spherical coordinates mode */
  38746. static readonly TEXTURE_SPHERICAL_MODE: number;
  38747. /** Planar coordinates mode */
  38748. static readonly TEXTURE_PLANAR_MODE: number;
  38749. /** Cubic coordinates mode */
  38750. static readonly TEXTURE_CUBIC_MODE: number;
  38751. /** Projection coordinates mode */
  38752. static readonly TEXTURE_PROJECTION_MODE: number;
  38753. /** Skybox coordinates mode */
  38754. static readonly TEXTURE_SKYBOX_MODE: number;
  38755. /** Inverse Cubic coordinates mode */
  38756. static readonly TEXTURE_INVCUBIC_MODE: number;
  38757. /** Equirectangular coordinates mode */
  38758. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38759. /** Equirectangular Fixed coordinates mode */
  38760. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38761. /** Equirectangular Fixed Mirrored coordinates mode */
  38762. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38763. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38764. static readonly SCALEMODE_FLOOR: number;
  38765. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38766. static readonly SCALEMODE_NEAREST: number;
  38767. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38768. static readonly SCALEMODE_CEILING: number;
  38769. /**
  38770. * Returns the current npm package of the sdk
  38771. */
  38772. static get NpmPackage(): string;
  38773. /**
  38774. * Returns the current version of the framework
  38775. */
  38776. static get Version(): string;
  38777. /** Gets the list of created engines */
  38778. static get Instances(): Engine[];
  38779. /**
  38780. * Gets the latest created engine
  38781. */
  38782. static get LastCreatedEngine(): Nullable<Engine>;
  38783. /**
  38784. * Gets the latest created scene
  38785. */
  38786. static get LastCreatedScene(): Nullable<Scene>;
  38787. /**
  38788. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38789. * @param flag defines which part of the materials must be marked as dirty
  38790. * @param predicate defines a predicate used to filter which materials should be affected
  38791. */
  38792. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38793. /**
  38794. * Method called to create the default loading screen.
  38795. * This can be overriden in your own app.
  38796. * @param canvas The rendering canvas element
  38797. * @returns The loading screen
  38798. */
  38799. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38800. /**
  38801. * Method called to create the default rescale post process on each engine.
  38802. */
  38803. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38804. /**
  38805. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38806. **/
  38807. enableOfflineSupport: boolean;
  38808. /**
  38809. * 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)
  38810. **/
  38811. disableManifestCheck: boolean;
  38812. /**
  38813. * Gets the list of created scenes
  38814. */
  38815. scenes: Scene[];
  38816. /**
  38817. * Event raised when a new scene is created
  38818. */
  38819. onNewSceneAddedObservable: Observable<Scene>;
  38820. /**
  38821. * Gets the list of created postprocesses
  38822. */
  38823. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38824. /**
  38825. * Gets a boolean indicating if the pointer is currently locked
  38826. */
  38827. isPointerLock: boolean;
  38828. /**
  38829. * Observable event triggered each time the rendering canvas is resized
  38830. */
  38831. onResizeObservable: Observable<Engine>;
  38832. /**
  38833. * Observable event triggered each time the canvas loses focus
  38834. */
  38835. onCanvasBlurObservable: Observable<Engine>;
  38836. /**
  38837. * Observable event triggered each time the canvas gains focus
  38838. */
  38839. onCanvasFocusObservable: Observable<Engine>;
  38840. /**
  38841. * Observable event triggered each time the canvas receives pointerout event
  38842. */
  38843. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38844. /**
  38845. * Observable raised when the engine begins a new frame
  38846. */
  38847. onBeginFrameObservable: Observable<Engine>;
  38848. /**
  38849. * If set, will be used to request the next animation frame for the render loop
  38850. */
  38851. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38852. /**
  38853. * Observable raised when the engine ends the current frame
  38854. */
  38855. onEndFrameObservable: Observable<Engine>;
  38856. /**
  38857. * Observable raised when the engine is about to compile a shader
  38858. */
  38859. onBeforeShaderCompilationObservable: Observable<Engine>;
  38860. /**
  38861. * Observable raised when the engine has jsut compiled a shader
  38862. */
  38863. onAfterShaderCompilationObservable: Observable<Engine>;
  38864. /**
  38865. * Gets the audio engine
  38866. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38867. * @ignorenaming
  38868. */
  38869. static audioEngine: IAudioEngine;
  38870. /**
  38871. * Default AudioEngine factory responsible of creating the Audio Engine.
  38872. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38873. */
  38874. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38875. /**
  38876. * Default offline support factory responsible of creating a tool used to store data locally.
  38877. * By default, this will create a Database object if the workload has been embedded.
  38878. */
  38879. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38880. private _loadingScreen;
  38881. private _pointerLockRequested;
  38882. private _rescalePostProcess;
  38883. private _deterministicLockstep;
  38884. private _lockstepMaxSteps;
  38885. private _timeStep;
  38886. protected get _supportsHardwareTextureRescaling(): boolean;
  38887. private _fps;
  38888. private _deltaTime;
  38889. /** @hidden */
  38890. _drawCalls: PerfCounter;
  38891. /** 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 */
  38892. canvasTabIndex: number;
  38893. /**
  38894. * Turn this value on if you want to pause FPS computation when in background
  38895. */
  38896. disablePerformanceMonitorInBackground: boolean;
  38897. private _performanceMonitor;
  38898. /**
  38899. * Gets the performance monitor attached to this engine
  38900. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38901. */
  38902. get performanceMonitor(): PerformanceMonitor;
  38903. private _onFocus;
  38904. private _onBlur;
  38905. private _onCanvasPointerOut;
  38906. private _onCanvasBlur;
  38907. private _onCanvasFocus;
  38908. private _onFullscreenChange;
  38909. private _onPointerLockChange;
  38910. /**
  38911. * Gets the HTML element used to attach event listeners
  38912. * @returns a HTML element
  38913. */
  38914. getInputElement(): Nullable<HTMLElement>;
  38915. /**
  38916. * Creates a new engine
  38917. * @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
  38918. * @param antialias defines enable antialiasing (default: false)
  38919. * @param options defines further options to be sent to the getContext() function
  38920. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38921. */
  38922. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38923. /**
  38924. * Gets current aspect ratio
  38925. * @param viewportOwner defines the camera to use to get the aspect ratio
  38926. * @param useScreen defines if screen size must be used (or the current render target if any)
  38927. * @returns a number defining the aspect ratio
  38928. */
  38929. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38930. /**
  38931. * Gets current screen aspect ratio
  38932. * @returns a number defining the aspect ratio
  38933. */
  38934. getScreenAspectRatio(): number;
  38935. /**
  38936. * Gets the client rect of the HTML canvas attached with the current webGL context
  38937. * @returns a client rectanglee
  38938. */
  38939. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38940. /**
  38941. * Gets the client rect of the HTML element used for events
  38942. * @returns a client rectanglee
  38943. */
  38944. getInputElementClientRect(): Nullable<ClientRect>;
  38945. /**
  38946. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38947. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38948. * @returns true if engine is in deterministic lock step mode
  38949. */
  38950. isDeterministicLockStep(): boolean;
  38951. /**
  38952. * Gets the max steps when engine is running in deterministic lock step
  38953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38954. * @returns the max steps
  38955. */
  38956. getLockstepMaxSteps(): number;
  38957. /**
  38958. * Returns the time in ms between steps when using deterministic lock step.
  38959. * @returns time step in (ms)
  38960. */
  38961. getTimeStep(): number;
  38962. /**
  38963. * Force the mipmap generation for the given render target texture
  38964. * @param texture defines the render target texture to use
  38965. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38966. */
  38967. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38968. /** States */
  38969. /**
  38970. * Set various states to the webGL context
  38971. * @param culling defines backface culling state
  38972. * @param zOffset defines the value to apply to zOffset (0 by default)
  38973. * @param force defines if states must be applied even if cache is up to date
  38974. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38975. */
  38976. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38977. /**
  38978. * Set the z offset to apply to current rendering
  38979. * @param value defines the offset to apply
  38980. */
  38981. setZOffset(value: number): void;
  38982. /**
  38983. * Gets the current value of the zOffset
  38984. * @returns the current zOffset state
  38985. */
  38986. getZOffset(): number;
  38987. /**
  38988. * Enable or disable depth buffering
  38989. * @param enable defines the state to set
  38990. */
  38991. setDepthBuffer(enable: boolean): void;
  38992. /**
  38993. * Gets a boolean indicating if depth writing is enabled
  38994. * @returns the current depth writing state
  38995. */
  38996. getDepthWrite(): boolean;
  38997. /**
  38998. * Enable or disable depth writing
  38999. * @param enable defines the state to set
  39000. */
  39001. setDepthWrite(enable: boolean): void;
  39002. /**
  39003. * Gets a boolean indicating if stencil buffer is enabled
  39004. * @returns the current stencil buffer state
  39005. */
  39006. getStencilBuffer(): boolean;
  39007. /**
  39008. * Enable or disable the stencil buffer
  39009. * @param enable defines if the stencil buffer must be enabled or disabled
  39010. */
  39011. setStencilBuffer(enable: boolean): void;
  39012. /**
  39013. * Gets the current stencil mask
  39014. * @returns a number defining the new stencil mask to use
  39015. */
  39016. getStencilMask(): number;
  39017. /**
  39018. * Sets the current stencil mask
  39019. * @param mask defines the new stencil mask to use
  39020. */
  39021. setStencilMask(mask: number): void;
  39022. /**
  39023. * Gets the current stencil function
  39024. * @returns a number defining the stencil function to use
  39025. */
  39026. getStencilFunction(): number;
  39027. /**
  39028. * Gets the current stencil reference value
  39029. * @returns a number defining the stencil reference value to use
  39030. */
  39031. getStencilFunctionReference(): number;
  39032. /**
  39033. * Gets the current stencil mask
  39034. * @returns a number defining the stencil mask to use
  39035. */
  39036. getStencilFunctionMask(): number;
  39037. /**
  39038. * Sets the current stencil function
  39039. * @param stencilFunc defines the new stencil function to use
  39040. */
  39041. setStencilFunction(stencilFunc: number): void;
  39042. /**
  39043. * Sets the current stencil reference
  39044. * @param reference defines the new stencil reference to use
  39045. */
  39046. setStencilFunctionReference(reference: number): void;
  39047. /**
  39048. * Sets the current stencil mask
  39049. * @param mask defines the new stencil mask to use
  39050. */
  39051. setStencilFunctionMask(mask: number): void;
  39052. /**
  39053. * Gets the current stencil operation when stencil fails
  39054. * @returns a number defining stencil operation to use when stencil fails
  39055. */
  39056. getStencilOperationFail(): number;
  39057. /**
  39058. * Gets the current stencil operation when depth fails
  39059. * @returns a number defining stencil operation to use when depth fails
  39060. */
  39061. getStencilOperationDepthFail(): number;
  39062. /**
  39063. * Gets the current stencil operation when stencil passes
  39064. * @returns a number defining stencil operation to use when stencil passes
  39065. */
  39066. getStencilOperationPass(): number;
  39067. /**
  39068. * Sets the stencil operation to use when stencil fails
  39069. * @param operation defines the stencil operation to use when stencil fails
  39070. */
  39071. setStencilOperationFail(operation: number): void;
  39072. /**
  39073. * Sets the stencil operation to use when depth fails
  39074. * @param operation defines the stencil operation to use when depth fails
  39075. */
  39076. setStencilOperationDepthFail(operation: number): void;
  39077. /**
  39078. * Sets the stencil operation to use when stencil passes
  39079. * @param operation defines the stencil operation to use when stencil passes
  39080. */
  39081. setStencilOperationPass(operation: number): void;
  39082. /**
  39083. * Sets a boolean indicating if the dithering state is enabled or disabled
  39084. * @param value defines the dithering state
  39085. */
  39086. setDitheringState(value: boolean): void;
  39087. /**
  39088. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39089. * @param value defines the rasterizer state
  39090. */
  39091. setRasterizerState(value: boolean): void;
  39092. /**
  39093. * Gets the current depth function
  39094. * @returns a number defining the depth function
  39095. */
  39096. getDepthFunction(): Nullable<number>;
  39097. /**
  39098. * Sets the current depth function
  39099. * @param depthFunc defines the function to use
  39100. */
  39101. setDepthFunction(depthFunc: number): void;
  39102. /**
  39103. * Sets the current depth function to GREATER
  39104. */
  39105. setDepthFunctionToGreater(): void;
  39106. /**
  39107. * Sets the current depth function to GEQUAL
  39108. */
  39109. setDepthFunctionToGreaterOrEqual(): void;
  39110. /**
  39111. * Sets the current depth function to LESS
  39112. */
  39113. setDepthFunctionToLess(): void;
  39114. /**
  39115. * Sets the current depth function to LEQUAL
  39116. */
  39117. setDepthFunctionToLessOrEqual(): void;
  39118. private _cachedStencilBuffer;
  39119. private _cachedStencilFunction;
  39120. private _cachedStencilMask;
  39121. private _cachedStencilOperationPass;
  39122. private _cachedStencilOperationFail;
  39123. private _cachedStencilOperationDepthFail;
  39124. private _cachedStencilReference;
  39125. /**
  39126. * Caches the the state of the stencil buffer
  39127. */
  39128. cacheStencilState(): void;
  39129. /**
  39130. * Restores the state of the stencil buffer
  39131. */
  39132. restoreStencilState(): void;
  39133. /**
  39134. * Directly set the WebGL Viewport
  39135. * @param x defines the x coordinate of the viewport (in screen space)
  39136. * @param y defines the y coordinate of the viewport (in screen space)
  39137. * @param width defines the width of the viewport (in screen space)
  39138. * @param height defines the height of the viewport (in screen space)
  39139. * @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
  39140. */
  39141. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39142. /**
  39143. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39144. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39145. * @param y defines the y-coordinate of the corner of the clear rectangle
  39146. * @param width defines the width of the clear rectangle
  39147. * @param height defines the height of the clear rectangle
  39148. * @param clearColor defines the clear color
  39149. */
  39150. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39151. /**
  39152. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39153. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39154. * @param y defines the y-coordinate of the corner of the clear rectangle
  39155. * @param width defines the width of the clear rectangle
  39156. * @param height defines the height of the clear rectangle
  39157. */
  39158. enableScissor(x: number, y: number, width: number, height: number): void;
  39159. /**
  39160. * Disable previously set scissor test rectangle
  39161. */
  39162. disableScissor(): void;
  39163. protected _reportDrawCall(): void;
  39164. /**
  39165. * Initializes a webVR display and starts listening to display change events
  39166. * The onVRDisplayChangedObservable will be notified upon these changes
  39167. * @returns The onVRDisplayChangedObservable
  39168. */
  39169. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39170. /** @hidden */
  39171. _prepareVRComponent(): void;
  39172. /** @hidden */
  39173. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39174. /** @hidden */
  39175. _submitVRFrame(): void;
  39176. /**
  39177. * Call this function to leave webVR mode
  39178. * Will do nothing if webVR is not supported or if there is no webVR device
  39179. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39180. */
  39181. disableVR(): void;
  39182. /**
  39183. * Gets a boolean indicating that the system is in VR mode and is presenting
  39184. * @returns true if VR mode is engaged
  39185. */
  39186. isVRPresenting(): boolean;
  39187. /** @hidden */
  39188. _requestVRFrame(): void;
  39189. /** @hidden */
  39190. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39191. /**
  39192. * Gets the source code of the vertex shader associated with a specific webGL program
  39193. * @param program defines the program to use
  39194. * @returns a string containing the source code of the vertex shader associated with the program
  39195. */
  39196. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39197. /**
  39198. * Gets the source code of the fragment shader associated with a specific webGL program
  39199. * @param program defines the program to use
  39200. * @returns a string containing the source code of the fragment shader associated with the program
  39201. */
  39202. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39203. /**
  39204. * Sets a depth stencil texture from a render target to the according uniform.
  39205. * @param channel The texture channel
  39206. * @param uniform The uniform to set
  39207. * @param texture The render target texture containing the depth stencil texture to apply
  39208. */
  39209. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39210. /**
  39211. * Sets a texture to the webGL context from a postprocess
  39212. * @param channel defines the channel to use
  39213. * @param postProcess defines the source postprocess
  39214. */
  39215. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39216. /**
  39217. * Binds the output of the passed in post process to the texture channel specified
  39218. * @param channel The channel the texture should be bound to
  39219. * @param postProcess The post process which's output should be bound
  39220. */
  39221. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39222. protected _rebuildBuffers(): void;
  39223. /** @hidden */
  39224. _renderFrame(): void;
  39225. _renderLoop(): void;
  39226. /** @hidden */
  39227. _renderViews(): boolean;
  39228. /**
  39229. * Toggle full screen mode
  39230. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39231. */
  39232. switchFullscreen(requestPointerLock: boolean): void;
  39233. /**
  39234. * Enters full screen mode
  39235. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39236. */
  39237. enterFullscreen(requestPointerLock: boolean): void;
  39238. /**
  39239. * Exits full screen mode
  39240. */
  39241. exitFullscreen(): void;
  39242. /**
  39243. * Enters Pointerlock mode
  39244. */
  39245. enterPointerlock(): void;
  39246. /**
  39247. * Exits Pointerlock mode
  39248. */
  39249. exitPointerlock(): void;
  39250. /**
  39251. * Begin a new frame
  39252. */
  39253. beginFrame(): void;
  39254. /**
  39255. * Enf the current frame
  39256. */
  39257. endFrame(): void;
  39258. resize(): void;
  39259. /**
  39260. * Force a specific size of the canvas
  39261. * @param width defines the new canvas' width
  39262. * @param height defines the new canvas' height
  39263. * @returns true if the size was changed
  39264. */
  39265. setSize(width: number, height: number): boolean;
  39266. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39267. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39268. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39269. _releaseTexture(texture: InternalTexture): void;
  39270. /**
  39271. * @hidden
  39272. * Rescales a texture
  39273. * @param source input texutre
  39274. * @param destination destination texture
  39275. * @param scene scene to use to render the resize
  39276. * @param internalFormat format to use when resizing
  39277. * @param onComplete callback to be called when resize has completed
  39278. */
  39279. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39280. /**
  39281. * Gets the current framerate
  39282. * @returns a number representing the framerate
  39283. */
  39284. getFps(): number;
  39285. /**
  39286. * Gets the time spent between current and previous frame
  39287. * @returns a number representing the delta time in ms
  39288. */
  39289. getDeltaTime(): number;
  39290. private _measureFps;
  39291. /** @hidden */
  39292. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39293. /**
  39294. * Updates the sample count of a render target texture
  39295. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39296. * @param texture defines the texture to update
  39297. * @param samples defines the sample count to set
  39298. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39299. */
  39300. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39301. /**
  39302. * Updates a depth texture Comparison Mode and Function.
  39303. * If the comparison Function is equal to 0, the mode will be set to none.
  39304. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39305. * @param texture The texture to set the comparison function for
  39306. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39307. */
  39308. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39309. /**
  39310. * Creates a webGL buffer to use with instanciation
  39311. * @param capacity defines the size of the buffer
  39312. * @returns the webGL buffer
  39313. */
  39314. createInstancesBuffer(capacity: number): DataBuffer;
  39315. /**
  39316. * Delete a webGL buffer used with instanciation
  39317. * @param buffer defines the webGL buffer to delete
  39318. */
  39319. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39320. private _clientWaitAsync;
  39321. /** @hidden */
  39322. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39323. dispose(): void;
  39324. private _disableTouchAction;
  39325. /**
  39326. * Display the loading screen
  39327. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39328. */
  39329. displayLoadingUI(): void;
  39330. /**
  39331. * Hide the loading screen
  39332. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39333. */
  39334. hideLoadingUI(): void;
  39335. /**
  39336. * Gets the current loading screen object
  39337. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39338. */
  39339. get loadingScreen(): ILoadingScreen;
  39340. /**
  39341. * Sets the current loading screen object
  39342. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39343. */
  39344. set loadingScreen(loadingScreen: ILoadingScreen);
  39345. /**
  39346. * Sets the current loading screen text
  39347. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39348. */
  39349. set loadingUIText(text: string);
  39350. /**
  39351. * Sets the current loading screen background color
  39352. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39353. */
  39354. set loadingUIBackgroundColor(color: string);
  39355. /** Pointerlock and fullscreen */
  39356. /**
  39357. * Ask the browser to promote the current element to pointerlock mode
  39358. * @param element defines the DOM element to promote
  39359. */
  39360. static _RequestPointerlock(element: HTMLElement): void;
  39361. /**
  39362. * Asks the browser to exit pointerlock mode
  39363. */
  39364. static _ExitPointerlock(): void;
  39365. /**
  39366. * Ask the browser to promote the current element to fullscreen rendering mode
  39367. * @param element defines the DOM element to promote
  39368. */
  39369. static _RequestFullscreen(element: HTMLElement): void;
  39370. /**
  39371. * Asks the browser to exit fullscreen mode
  39372. */
  39373. static _ExitFullscreen(): void;
  39374. }
  39375. }
  39376. declare module "babylonjs/Engines/engineStore" {
  39377. import { Nullable } from "babylonjs/types";
  39378. import { Engine } from "babylonjs/Engines/engine";
  39379. import { Scene } from "babylonjs/scene";
  39380. /**
  39381. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39382. * during the life time of the application.
  39383. */
  39384. export class EngineStore {
  39385. /** Gets the list of created engines */
  39386. static Instances: import("babylonjs/Engines/engine").Engine[];
  39387. /** @hidden */
  39388. static _LastCreatedScene: Nullable<Scene>;
  39389. /**
  39390. * Gets the latest created engine
  39391. */
  39392. static get LastCreatedEngine(): Nullable<Engine>;
  39393. /**
  39394. * Gets the latest created scene
  39395. */
  39396. static get LastCreatedScene(): Nullable<Scene>;
  39397. /**
  39398. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39399. * @ignorenaming
  39400. */
  39401. static UseFallbackTexture: boolean;
  39402. /**
  39403. * Texture content used if a texture cannot loaded
  39404. * @ignorenaming
  39405. */
  39406. static FallbackTexture: string;
  39407. }
  39408. }
  39409. declare module "babylonjs/Misc/promise" {
  39410. /**
  39411. * Helper class that provides a small promise polyfill
  39412. */
  39413. export class PromisePolyfill {
  39414. /**
  39415. * Static function used to check if the polyfill is required
  39416. * If this is the case then the function will inject the polyfill to window.Promise
  39417. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39418. */
  39419. static Apply(force?: boolean): void;
  39420. }
  39421. }
  39422. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39423. /**
  39424. * Interface for screenshot methods with describe argument called `size` as object with options
  39425. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39426. */
  39427. export interface IScreenshotSize {
  39428. /**
  39429. * number in pixels for canvas height
  39430. */
  39431. height?: number;
  39432. /**
  39433. * multiplier allowing render at a higher or lower resolution
  39434. * If value is defined then height and width will be ignored and taken from camera
  39435. */
  39436. precision?: number;
  39437. /**
  39438. * number in pixels for canvas width
  39439. */
  39440. width?: number;
  39441. }
  39442. }
  39443. declare module "babylonjs/Misc/tools" {
  39444. import { Nullable, float } from "babylonjs/types";
  39445. import { DomManagement } from "babylonjs/Misc/domManagement";
  39446. import { WebRequest } from "babylonjs/Misc/webRequest";
  39447. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39448. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39449. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39450. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39451. import { Camera } from "babylonjs/Cameras/camera";
  39452. import { Engine } from "babylonjs/Engines/engine";
  39453. interface IColor4Like {
  39454. r: float;
  39455. g: float;
  39456. b: float;
  39457. a: float;
  39458. }
  39459. /**
  39460. * Class containing a set of static utilities functions
  39461. */
  39462. export class Tools {
  39463. /**
  39464. * Gets or sets the base URL to use to load assets
  39465. */
  39466. static get BaseUrl(): string;
  39467. static set BaseUrl(value: string);
  39468. /**
  39469. * Enable/Disable Custom HTTP Request Headers globally.
  39470. * default = false
  39471. * @see CustomRequestHeaders
  39472. */
  39473. static UseCustomRequestHeaders: boolean;
  39474. /**
  39475. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39476. * i.e. when loading files, where the server/service expects an Authorization header
  39477. */
  39478. static CustomRequestHeaders: {
  39479. [key: string]: string;
  39480. };
  39481. /**
  39482. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39483. */
  39484. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39485. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39486. /**
  39487. * Default behaviour for cors in the application.
  39488. * It can be a string if the expected behavior is identical in the entire app.
  39489. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39490. */
  39491. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39492. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39493. /**
  39494. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39495. * @ignorenaming
  39496. */
  39497. static get UseFallbackTexture(): boolean;
  39498. static set UseFallbackTexture(value: boolean);
  39499. /**
  39500. * Use this object to register external classes like custom textures or material
  39501. * to allow the laoders to instantiate them
  39502. */
  39503. static get RegisteredExternalClasses(): {
  39504. [key: string]: Object;
  39505. };
  39506. static set RegisteredExternalClasses(classes: {
  39507. [key: string]: Object;
  39508. });
  39509. /**
  39510. * Texture content used if a texture cannot loaded
  39511. * @ignorenaming
  39512. */
  39513. static get fallbackTexture(): string;
  39514. static set fallbackTexture(value: string);
  39515. /**
  39516. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39517. * @param u defines the coordinate on X axis
  39518. * @param v defines the coordinate on Y axis
  39519. * @param width defines the width of the source data
  39520. * @param height defines the height of the source data
  39521. * @param pixels defines the source byte array
  39522. * @param color defines the output color
  39523. */
  39524. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39525. /**
  39526. * Interpolates between a and b via alpha
  39527. * @param a The lower value (returned when alpha = 0)
  39528. * @param b The upper value (returned when alpha = 1)
  39529. * @param alpha The interpolation-factor
  39530. * @return The mixed value
  39531. */
  39532. static Mix(a: number, b: number, alpha: number): number;
  39533. /**
  39534. * Tries to instantiate a new object from a given class name
  39535. * @param className defines the class name to instantiate
  39536. * @returns the new object or null if the system was not able to do the instantiation
  39537. */
  39538. static Instantiate(className: string): any;
  39539. /**
  39540. * Provides a slice function that will work even on IE
  39541. * @param data defines the array to slice
  39542. * @param start defines the start of the data (optional)
  39543. * @param end defines the end of the data (optional)
  39544. * @returns the new sliced array
  39545. */
  39546. static Slice<T>(data: T, start?: number, end?: number): T;
  39547. /**
  39548. * Polyfill for setImmediate
  39549. * @param action defines the action to execute after the current execution block
  39550. */
  39551. static SetImmediate(action: () => void): void;
  39552. /**
  39553. * Function indicating if a number is an exponent of 2
  39554. * @param value defines the value to test
  39555. * @returns true if the value is an exponent of 2
  39556. */
  39557. static IsExponentOfTwo(value: number): boolean;
  39558. private static _tmpFloatArray;
  39559. /**
  39560. * Returns the nearest 32-bit single precision float representation of a Number
  39561. * @param value A Number. If the parameter is of a different type, it will get converted
  39562. * to a number or to NaN if it cannot be converted
  39563. * @returns number
  39564. */
  39565. static FloatRound(value: number): number;
  39566. /**
  39567. * Extracts the filename from a path
  39568. * @param path defines the path to use
  39569. * @returns the filename
  39570. */
  39571. static GetFilename(path: string): string;
  39572. /**
  39573. * Extracts the "folder" part of a path (everything before the filename).
  39574. * @param uri The URI to extract the info from
  39575. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39576. * @returns The "folder" part of the path
  39577. */
  39578. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39579. /**
  39580. * Extracts text content from a DOM element hierarchy
  39581. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39582. */
  39583. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39584. /**
  39585. * Convert an angle in radians to degrees
  39586. * @param angle defines the angle to convert
  39587. * @returns the angle in degrees
  39588. */
  39589. static ToDegrees(angle: number): number;
  39590. /**
  39591. * Convert an angle in degrees to radians
  39592. * @param angle defines the angle to convert
  39593. * @returns the angle in radians
  39594. */
  39595. static ToRadians(angle: number): number;
  39596. /**
  39597. * Returns an array if obj is not an array
  39598. * @param obj defines the object to evaluate as an array
  39599. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39600. * @returns either obj directly if obj is an array or a new array containing obj
  39601. */
  39602. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39603. /**
  39604. * Gets the pointer prefix to use
  39605. * @param engine defines the engine we are finding the prefix for
  39606. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39607. */
  39608. static GetPointerPrefix(engine: Engine): string;
  39609. /**
  39610. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39611. * @param url define the url we are trying
  39612. * @param element define the dom element where to configure the cors policy
  39613. */
  39614. static SetCorsBehavior(url: string | string[], element: {
  39615. crossOrigin: string | null;
  39616. }): void;
  39617. /**
  39618. * Removes unwanted characters from an url
  39619. * @param url defines the url to clean
  39620. * @returns the cleaned url
  39621. */
  39622. static CleanUrl(url: string): string;
  39623. /**
  39624. * Gets or sets a function used to pre-process url before using them to load assets
  39625. */
  39626. static get PreprocessUrl(): (url: string) => string;
  39627. static set PreprocessUrl(processor: (url: string) => string);
  39628. /**
  39629. * Loads an image as an HTMLImageElement.
  39630. * @param input url string, ArrayBuffer, or Blob to load
  39631. * @param onLoad callback called when the image successfully loads
  39632. * @param onError callback called when the image fails to load
  39633. * @param offlineProvider offline provider for caching
  39634. * @param mimeType optional mime type
  39635. * @returns the HTMLImageElement of the loaded image
  39636. */
  39637. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39638. /**
  39639. * Loads a file from a url
  39640. * @param url url string, ArrayBuffer, or Blob to load
  39641. * @param onSuccess callback called when the file successfully loads
  39642. * @param onProgress callback called while file is loading (if the server supports this mode)
  39643. * @param offlineProvider defines the offline provider for caching
  39644. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39645. * @param onError callback called when the file fails to load
  39646. * @returns a file request object
  39647. */
  39648. 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;
  39649. /**
  39650. * Loads a file from a url
  39651. * @param url the file url to load
  39652. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39653. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39654. */
  39655. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39656. /**
  39657. * Load a script (identified by an url). When the url returns, the
  39658. * content of this file is added into a new script element, attached to the DOM (body element)
  39659. * @param scriptUrl defines the url of the script to laod
  39660. * @param onSuccess defines the callback called when the script is loaded
  39661. * @param onError defines the callback to call if an error occurs
  39662. * @param scriptId defines the id of the script element
  39663. */
  39664. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39665. /**
  39666. * Load an asynchronous script (identified by an url). When the url returns, the
  39667. * content of this file is added into a new script element, attached to the DOM (body element)
  39668. * @param scriptUrl defines the url of the script to laod
  39669. * @param scriptId defines the id of the script element
  39670. * @returns a promise request object
  39671. */
  39672. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39673. /**
  39674. * Loads a file from a blob
  39675. * @param fileToLoad defines the blob to use
  39676. * @param callback defines the callback to call when data is loaded
  39677. * @param progressCallback defines the callback to call during loading process
  39678. * @returns a file request object
  39679. */
  39680. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39681. /**
  39682. * Reads a file from a File object
  39683. * @param file defines the file to load
  39684. * @param onSuccess defines the callback to call when data is loaded
  39685. * @param onProgress defines the callback to call during loading process
  39686. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39687. * @param onError defines the callback to call when an error occurs
  39688. * @returns a file request object
  39689. */
  39690. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39691. /**
  39692. * Creates a data url from a given string content
  39693. * @param content defines the content to convert
  39694. * @returns the new data url link
  39695. */
  39696. static FileAsURL(content: string): string;
  39697. /**
  39698. * Format the given number to a specific decimal format
  39699. * @param value defines the number to format
  39700. * @param decimals defines the number of decimals to use
  39701. * @returns the formatted string
  39702. */
  39703. static Format(value: number, decimals?: number): string;
  39704. /**
  39705. * Tries to copy an object by duplicating every property
  39706. * @param source defines the source object
  39707. * @param destination defines the target object
  39708. * @param doNotCopyList defines a list of properties to avoid
  39709. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39710. */
  39711. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39712. /**
  39713. * Gets a boolean indicating if the given object has no own property
  39714. * @param obj defines the object to test
  39715. * @returns true if object has no own property
  39716. */
  39717. static IsEmpty(obj: any): boolean;
  39718. /**
  39719. * Function used to register events at window level
  39720. * @param windowElement defines the Window object to use
  39721. * @param events defines the events to register
  39722. */
  39723. static RegisterTopRootEvents(windowElement: Window, events: {
  39724. name: string;
  39725. handler: Nullable<(e: FocusEvent) => any>;
  39726. }[]): void;
  39727. /**
  39728. * Function used to unregister events from window level
  39729. * @param windowElement defines the Window object to use
  39730. * @param events defines the events to unregister
  39731. */
  39732. static UnregisterTopRootEvents(windowElement: Window, events: {
  39733. name: string;
  39734. handler: Nullable<(e: FocusEvent) => any>;
  39735. }[]): void;
  39736. /**
  39737. * @ignore
  39738. */
  39739. static _ScreenshotCanvas: HTMLCanvasElement;
  39740. /**
  39741. * Dumps the current bound framebuffer
  39742. * @param width defines the rendering width
  39743. * @param height defines the rendering height
  39744. * @param engine defines the hosting engine
  39745. * @param successCallback defines the callback triggered once the data are available
  39746. * @param mimeType defines the mime type of the result
  39747. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39748. */
  39749. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39750. /**
  39751. * Converts the canvas data to blob.
  39752. * This acts as a polyfill for browsers not supporting the to blob function.
  39753. * @param canvas Defines the canvas to extract the data from
  39754. * @param successCallback Defines the callback triggered once the data are available
  39755. * @param mimeType Defines the mime type of the result
  39756. */
  39757. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39758. /**
  39759. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39760. * @param successCallback defines the callback triggered once the data are available
  39761. * @param mimeType defines the mime type of the result
  39762. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39763. */
  39764. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39765. /**
  39766. * Downloads a blob in the browser
  39767. * @param blob defines the blob to download
  39768. * @param fileName defines the name of the downloaded file
  39769. */
  39770. static Download(blob: Blob, fileName: string): void;
  39771. /**
  39772. * Captures a screenshot of the current rendering
  39773. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39774. * @param engine defines the rendering engine
  39775. * @param camera defines the source camera
  39776. * @param size This parameter can be set to a single number or to an object with the
  39777. * following (optional) properties: precision, width, height. If a single number is passed,
  39778. * it will be used for both width and height. If an object is passed, the screenshot size
  39779. * will be derived from the parameters. The precision property is a multiplier allowing
  39780. * rendering at a higher or lower resolution
  39781. * @param successCallback defines the callback receives a single parameter which contains the
  39782. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39783. * src parameter of an <img> to display it
  39784. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39785. * Check your browser for supported MIME types
  39786. */
  39787. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39788. /**
  39789. * Captures a screenshot of the current rendering
  39790. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39791. * @param engine defines the rendering engine
  39792. * @param camera defines the source camera
  39793. * @param size This parameter can be set to a single number or to an object with the
  39794. * following (optional) properties: precision, width, height. If a single number is passed,
  39795. * it will be used for both width and height. If an object is passed, the screenshot size
  39796. * will be derived from the parameters. The precision property is a multiplier allowing
  39797. * rendering at a higher or lower resolution
  39798. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39799. * Check your browser for supported MIME types
  39800. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39801. * to the src parameter of an <img> to display it
  39802. */
  39803. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39804. /**
  39805. * Generates an image screenshot from the specified camera.
  39806. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39807. * @param engine The engine to use for rendering
  39808. * @param camera The camera to use for rendering
  39809. * @param size This parameter can be set to a single number or to an object with the
  39810. * following (optional) properties: precision, width, height. If a single number is passed,
  39811. * it will be used for both width and height. If an object is passed, the screenshot size
  39812. * will be derived from the parameters. The precision property is a multiplier allowing
  39813. * rendering at a higher or lower resolution
  39814. * @param successCallback The callback receives a single parameter which contains the
  39815. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39816. * src parameter of an <img> to display it
  39817. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39818. * Check your browser for supported MIME types
  39819. * @param samples Texture samples (default: 1)
  39820. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39821. * @param fileName A name for for the downloaded file.
  39822. */
  39823. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39824. /**
  39825. * Generates an image screenshot from the specified camera.
  39826. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39827. * @param engine The engine to use for rendering
  39828. * @param camera The camera to use for rendering
  39829. * @param size This parameter can be set to a single number or to an object with the
  39830. * following (optional) properties: precision, width, height. If a single number is passed,
  39831. * it will be used for both width and height. If an object is passed, the screenshot size
  39832. * will be derived from the parameters. The precision property is a multiplier allowing
  39833. * rendering at a higher or lower resolution
  39834. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39835. * Check your browser for supported MIME types
  39836. * @param samples Texture samples (default: 1)
  39837. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39838. * @param fileName A name for for the downloaded file.
  39839. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39840. * to the src parameter of an <img> to display it
  39841. */
  39842. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39843. /**
  39844. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39845. * Be aware Math.random() could cause collisions, but:
  39846. * "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"
  39847. * @returns a pseudo random id
  39848. */
  39849. static RandomId(): string;
  39850. /**
  39851. * Test if the given uri is a base64 string
  39852. * @param uri The uri to test
  39853. * @return True if the uri is a base64 string or false otherwise
  39854. */
  39855. static IsBase64(uri: string): boolean;
  39856. /**
  39857. * Decode the given base64 uri.
  39858. * @param uri The uri to decode
  39859. * @return The decoded base64 data.
  39860. */
  39861. static DecodeBase64(uri: string): ArrayBuffer;
  39862. /**
  39863. * Gets the absolute url.
  39864. * @param url the input url
  39865. * @return the absolute url
  39866. */
  39867. static GetAbsoluteUrl(url: string): string;
  39868. /**
  39869. * No log
  39870. */
  39871. static readonly NoneLogLevel: number;
  39872. /**
  39873. * Only message logs
  39874. */
  39875. static readonly MessageLogLevel: number;
  39876. /**
  39877. * Only warning logs
  39878. */
  39879. static readonly WarningLogLevel: number;
  39880. /**
  39881. * Only error logs
  39882. */
  39883. static readonly ErrorLogLevel: number;
  39884. /**
  39885. * All logs
  39886. */
  39887. static readonly AllLogLevel: number;
  39888. /**
  39889. * Gets a value indicating the number of loading errors
  39890. * @ignorenaming
  39891. */
  39892. static get errorsCount(): number;
  39893. /**
  39894. * Callback called when a new log is added
  39895. */
  39896. static OnNewCacheEntry: (entry: string) => void;
  39897. /**
  39898. * Log a message to the console
  39899. * @param message defines the message to log
  39900. */
  39901. static Log(message: string): void;
  39902. /**
  39903. * Write a warning message to the console
  39904. * @param message defines the message to log
  39905. */
  39906. static Warn(message: string): void;
  39907. /**
  39908. * Write an error message to the console
  39909. * @param message defines the message to log
  39910. */
  39911. static Error(message: string): void;
  39912. /**
  39913. * Gets current log cache (list of logs)
  39914. */
  39915. static get LogCache(): string;
  39916. /**
  39917. * Clears the log cache
  39918. */
  39919. static ClearLogCache(): void;
  39920. /**
  39921. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39922. */
  39923. static set LogLevels(level: number);
  39924. /**
  39925. * Checks if the window object exists
  39926. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39927. */
  39928. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39929. /**
  39930. * No performance log
  39931. */
  39932. static readonly PerformanceNoneLogLevel: number;
  39933. /**
  39934. * Use user marks to log performance
  39935. */
  39936. static readonly PerformanceUserMarkLogLevel: number;
  39937. /**
  39938. * Log performance to the console
  39939. */
  39940. static readonly PerformanceConsoleLogLevel: number;
  39941. private static _performance;
  39942. /**
  39943. * Sets the current performance log level
  39944. */
  39945. static set PerformanceLogLevel(level: number);
  39946. private static _StartPerformanceCounterDisabled;
  39947. private static _EndPerformanceCounterDisabled;
  39948. private static _StartUserMark;
  39949. private static _EndUserMark;
  39950. private static _StartPerformanceConsole;
  39951. private static _EndPerformanceConsole;
  39952. /**
  39953. * Starts a performance counter
  39954. */
  39955. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39956. /**
  39957. * Ends a specific performance coutner
  39958. */
  39959. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39960. /**
  39961. * Gets either window.performance.now() if supported or Date.now() else
  39962. */
  39963. static get Now(): number;
  39964. /**
  39965. * This method will return the name of the class used to create the instance of the given object.
  39966. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39967. * @param object the object to get the class name from
  39968. * @param isType defines if the object is actually a type
  39969. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39970. */
  39971. static GetClassName(object: any, isType?: boolean): string;
  39972. /**
  39973. * Gets the first element of an array satisfying a given predicate
  39974. * @param array defines the array to browse
  39975. * @param predicate defines the predicate to use
  39976. * @returns null if not found or the element
  39977. */
  39978. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39979. /**
  39980. * This method will return the name of the full name of the class, including its owning module (if any).
  39981. * 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).
  39982. * @param object the object to get the class name from
  39983. * @param isType defines if the object is actually a type
  39984. * @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.
  39985. * @ignorenaming
  39986. */
  39987. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39988. /**
  39989. * Returns a promise that resolves after the given amount of time.
  39990. * @param delay Number of milliseconds to delay
  39991. * @returns Promise that resolves after the given amount of time
  39992. */
  39993. static DelayAsync(delay: number): Promise<void>;
  39994. /**
  39995. * Utility function to detect if the current user agent is Safari
  39996. * @returns whether or not the current user agent is safari
  39997. */
  39998. static IsSafari(): boolean;
  39999. }
  40000. /**
  40001. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40002. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40003. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40004. * @param name The name of the class, case should be preserved
  40005. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40006. */
  40007. export function className(name: string, module?: string): (target: Object) => void;
  40008. /**
  40009. * An implementation of a loop for asynchronous functions.
  40010. */
  40011. export class AsyncLoop {
  40012. /**
  40013. * Defines the number of iterations for the loop
  40014. */
  40015. iterations: number;
  40016. /**
  40017. * Defines the current index of the loop.
  40018. */
  40019. index: number;
  40020. private _done;
  40021. private _fn;
  40022. private _successCallback;
  40023. /**
  40024. * Constructor.
  40025. * @param iterations the number of iterations.
  40026. * @param func the function to run each iteration
  40027. * @param successCallback the callback that will be called upon succesful execution
  40028. * @param offset starting offset.
  40029. */
  40030. constructor(
  40031. /**
  40032. * Defines the number of iterations for the loop
  40033. */
  40034. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40035. /**
  40036. * Execute the next iteration. Must be called after the last iteration was finished.
  40037. */
  40038. executeNext(): void;
  40039. /**
  40040. * Break the loop and run the success callback.
  40041. */
  40042. breakLoop(): void;
  40043. /**
  40044. * Create and run an async loop.
  40045. * @param iterations the number of iterations.
  40046. * @param fn the function to run each iteration
  40047. * @param successCallback the callback that will be called upon succesful execution
  40048. * @param offset starting offset.
  40049. * @returns the created async loop object
  40050. */
  40051. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40052. /**
  40053. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40054. * @param iterations total number of iterations
  40055. * @param syncedIterations number of synchronous iterations in each async iteration.
  40056. * @param fn the function to call each iteration.
  40057. * @param callback a success call back that will be called when iterating stops.
  40058. * @param breakFunction a break condition (optional)
  40059. * @param timeout timeout settings for the setTimeout function. default - 0.
  40060. * @returns the created async loop object
  40061. */
  40062. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40063. }
  40064. }
  40065. declare module "babylonjs/Misc/stringDictionary" {
  40066. import { Nullable } from "babylonjs/types";
  40067. /**
  40068. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40069. * The underlying implementation relies on an associative array to ensure the best performances.
  40070. * The value can be anything including 'null' but except 'undefined'
  40071. */
  40072. export class StringDictionary<T> {
  40073. /**
  40074. * This will clear this dictionary and copy the content from the 'source' one.
  40075. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40076. * @param source the dictionary to take the content from and copy to this dictionary
  40077. */
  40078. copyFrom(source: StringDictionary<T>): void;
  40079. /**
  40080. * Get a value based from its key
  40081. * @param key the given key to get the matching value from
  40082. * @return the value if found, otherwise undefined is returned
  40083. */
  40084. get(key: string): T | undefined;
  40085. /**
  40086. * Get a value from its key or add it if it doesn't exist.
  40087. * This method will ensure you that a given key/data will be present in the dictionary.
  40088. * @param key the given key to get the matching value from
  40089. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40090. * The factory will only be invoked if there's no data for the given key.
  40091. * @return the value corresponding to the key.
  40092. */
  40093. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40094. /**
  40095. * Get a value from its key if present in the dictionary otherwise add it
  40096. * @param key the key to get the value from
  40097. * @param val if there's no such key/value pair in the dictionary add it with this value
  40098. * @return the value corresponding to the key
  40099. */
  40100. getOrAdd(key: string, val: T): T;
  40101. /**
  40102. * Check if there's a given key in the dictionary
  40103. * @param key the key to check for
  40104. * @return true if the key is present, false otherwise
  40105. */
  40106. contains(key: string): boolean;
  40107. /**
  40108. * Add a new key and its corresponding value
  40109. * @param key the key to add
  40110. * @param value the value corresponding to the key
  40111. * @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
  40112. */
  40113. add(key: string, value: T): boolean;
  40114. /**
  40115. * Update a specific value associated to a key
  40116. * @param key defines the key to use
  40117. * @param value defines the value to store
  40118. * @returns true if the value was updated (or false if the key was not found)
  40119. */
  40120. set(key: string, value: T): boolean;
  40121. /**
  40122. * Get the element of the given key and remove it from the dictionary
  40123. * @param key defines the key to search
  40124. * @returns the value associated with the key or null if not found
  40125. */
  40126. getAndRemove(key: string): Nullable<T>;
  40127. /**
  40128. * Remove a key/value from the dictionary.
  40129. * @param key the key to remove
  40130. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40131. */
  40132. remove(key: string): boolean;
  40133. /**
  40134. * Clear the whole content of the dictionary
  40135. */
  40136. clear(): void;
  40137. /**
  40138. * Gets the current count
  40139. */
  40140. get count(): number;
  40141. /**
  40142. * Execute a callback on each key/val of the dictionary.
  40143. * Note that you can remove any element in this dictionary in the callback implementation
  40144. * @param callback the callback to execute on a given key/value pair
  40145. */
  40146. forEach(callback: (key: string, val: T) => void): void;
  40147. /**
  40148. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40149. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40150. * Note that you can remove any element in this dictionary in the callback implementation
  40151. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40152. * @returns the first item
  40153. */
  40154. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40155. private _count;
  40156. private _data;
  40157. }
  40158. }
  40159. declare module "babylonjs/Collisions/collisionCoordinator" {
  40160. import { Nullable } from "babylonjs/types";
  40161. import { Scene } from "babylonjs/scene";
  40162. import { Vector3 } from "babylonjs/Maths/math.vector";
  40163. import { Collider } from "babylonjs/Collisions/collider";
  40164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40165. /** @hidden */
  40166. export interface ICollisionCoordinator {
  40167. createCollider(): Collider;
  40168. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40169. init(scene: Scene): void;
  40170. }
  40171. /** @hidden */
  40172. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40173. private _scene;
  40174. private _scaledPosition;
  40175. private _scaledVelocity;
  40176. private _finalPosition;
  40177. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40178. createCollider(): Collider;
  40179. init(scene: Scene): void;
  40180. private _collideWithWorld;
  40181. }
  40182. }
  40183. declare module "babylonjs/Inputs/scene.inputManager" {
  40184. import { Nullable } from "babylonjs/types";
  40185. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40186. import { Vector2 } from "babylonjs/Maths/math.vector";
  40187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40188. import { Scene } from "babylonjs/scene";
  40189. /**
  40190. * Class used to manage all inputs for the scene.
  40191. */
  40192. export class InputManager {
  40193. /** The distance in pixel that you have to move to prevent some events */
  40194. static DragMovementThreshold: number;
  40195. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40196. static LongPressDelay: number;
  40197. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40198. static DoubleClickDelay: number;
  40199. /** If you need to check double click without raising a single click at first click, enable this flag */
  40200. static ExclusiveDoubleClickMode: boolean;
  40201. /** 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. */
  40202. private _alreadyAttached;
  40203. private _wheelEventName;
  40204. private _onPointerMove;
  40205. private _onPointerDown;
  40206. private _onPointerUp;
  40207. private _initClickEvent;
  40208. private _initActionManager;
  40209. private _delayedSimpleClick;
  40210. private _delayedSimpleClickTimeout;
  40211. private _previousDelayedSimpleClickTimeout;
  40212. private _meshPickProceed;
  40213. private _previousButtonPressed;
  40214. private _currentPickResult;
  40215. private _previousPickResult;
  40216. private _totalPointersPressed;
  40217. private _doubleClickOccured;
  40218. private _pointerOverMesh;
  40219. private _pickedDownMesh;
  40220. private _pickedUpMesh;
  40221. private _pointerX;
  40222. private _pointerY;
  40223. private _unTranslatedPointerX;
  40224. private _unTranslatedPointerY;
  40225. private _startingPointerPosition;
  40226. private _previousStartingPointerPosition;
  40227. private _startingPointerTime;
  40228. private _previousStartingPointerTime;
  40229. private _pointerCaptures;
  40230. private _onKeyDown;
  40231. private _onKeyUp;
  40232. private _onCanvasFocusObserver;
  40233. private _onCanvasBlurObserver;
  40234. private _scene;
  40235. /**
  40236. * Creates a new InputManager
  40237. * @param scene defines the hosting scene
  40238. */
  40239. constructor(scene: Scene);
  40240. /**
  40241. * Gets the mesh that is currently under the pointer
  40242. */
  40243. get meshUnderPointer(): Nullable<AbstractMesh>;
  40244. /**
  40245. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40246. */
  40247. get unTranslatedPointer(): Vector2;
  40248. /**
  40249. * Gets or sets the current on-screen X position of the pointer
  40250. */
  40251. get pointerX(): number;
  40252. set pointerX(value: number);
  40253. /**
  40254. * Gets or sets the current on-screen Y position of the pointer
  40255. */
  40256. get pointerY(): number;
  40257. set pointerY(value: number);
  40258. private _updatePointerPosition;
  40259. private _processPointerMove;
  40260. private _setRayOnPointerInfo;
  40261. private _checkPrePointerObservable;
  40262. /**
  40263. * Use this method to simulate a pointer move on a mesh
  40264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40267. */
  40268. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40269. /**
  40270. * Use this method to simulate a pointer down on a mesh
  40271. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40272. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40273. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40274. */
  40275. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40276. private _processPointerDown;
  40277. /** @hidden */
  40278. _isPointerSwiping(): boolean;
  40279. /**
  40280. * Use this method to simulate a pointer up on a mesh
  40281. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40282. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40283. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40284. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40285. */
  40286. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40287. private _processPointerUp;
  40288. /**
  40289. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40290. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40291. * @returns true if the pointer was captured
  40292. */
  40293. isPointerCaptured(pointerId?: number): boolean;
  40294. /**
  40295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40296. * @param attachUp defines if you want to attach events to pointerup
  40297. * @param attachDown defines if you want to attach events to pointerdown
  40298. * @param attachMove defines if you want to attach events to pointermove
  40299. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40300. */
  40301. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40302. /**
  40303. * Detaches all event handlers
  40304. */
  40305. detachControl(): void;
  40306. /**
  40307. * Force the value of meshUnderPointer
  40308. * @param mesh defines the mesh to use
  40309. */
  40310. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40311. /**
  40312. * Gets the mesh under the pointer
  40313. * @returns a Mesh or null if no mesh is under the pointer
  40314. */
  40315. getPointerOverMesh(): Nullable<AbstractMesh>;
  40316. }
  40317. }
  40318. declare module "babylonjs/Animations/animationGroup" {
  40319. import { Animatable } from "babylonjs/Animations/animatable";
  40320. import { Animation } from "babylonjs/Animations/animation";
  40321. import { Scene, IDisposable } from "babylonjs/scene";
  40322. import { Observable } from "babylonjs/Misc/observable";
  40323. import { Nullable } from "babylonjs/types";
  40324. import "babylonjs/Animations/animatable";
  40325. /**
  40326. * This class defines the direct association between an animation and a target
  40327. */
  40328. export class TargetedAnimation {
  40329. /**
  40330. * Animation to perform
  40331. */
  40332. animation: Animation;
  40333. /**
  40334. * Target to animate
  40335. */
  40336. target: any;
  40337. /**
  40338. * Returns the string "TargetedAnimation"
  40339. * @returns "TargetedAnimation"
  40340. */
  40341. getClassName(): string;
  40342. /**
  40343. * Serialize the object
  40344. * @returns the JSON object representing the current entity
  40345. */
  40346. serialize(): any;
  40347. }
  40348. /**
  40349. * Use this class to create coordinated animations on multiple targets
  40350. */
  40351. export class AnimationGroup implements IDisposable {
  40352. /** The name of the animation group */
  40353. name: string;
  40354. private _scene;
  40355. private _targetedAnimations;
  40356. private _animatables;
  40357. private _from;
  40358. private _to;
  40359. private _isStarted;
  40360. private _isPaused;
  40361. private _speedRatio;
  40362. private _loopAnimation;
  40363. private _isAdditive;
  40364. /**
  40365. * Gets or sets the unique id of the node
  40366. */
  40367. uniqueId: number;
  40368. /**
  40369. * This observable will notify when one animation have ended
  40370. */
  40371. onAnimationEndObservable: Observable<TargetedAnimation>;
  40372. /**
  40373. * Observer raised when one animation loops
  40374. */
  40375. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40376. /**
  40377. * Observer raised when all animations have looped
  40378. */
  40379. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40380. /**
  40381. * This observable will notify when all animations have ended.
  40382. */
  40383. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40384. /**
  40385. * This observable will notify when all animations have paused.
  40386. */
  40387. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40388. /**
  40389. * This observable will notify when all animations are playing.
  40390. */
  40391. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40392. /**
  40393. * Gets the first frame
  40394. */
  40395. get from(): number;
  40396. /**
  40397. * Gets the last frame
  40398. */
  40399. get to(): number;
  40400. /**
  40401. * Define if the animations are started
  40402. */
  40403. get isStarted(): boolean;
  40404. /**
  40405. * Gets a value indicating that the current group is playing
  40406. */
  40407. get isPlaying(): boolean;
  40408. /**
  40409. * Gets or sets the speed ratio to use for all animations
  40410. */
  40411. get speedRatio(): number;
  40412. /**
  40413. * Gets or sets the speed ratio to use for all animations
  40414. */
  40415. set speedRatio(value: number);
  40416. /**
  40417. * Gets or sets if all animations should loop or not
  40418. */
  40419. get loopAnimation(): boolean;
  40420. set loopAnimation(value: boolean);
  40421. /**
  40422. * Gets or sets if all animations should be evaluated additively
  40423. */
  40424. get isAdditive(): boolean;
  40425. set isAdditive(value: boolean);
  40426. /**
  40427. * Gets the targeted animations for this animation group
  40428. */
  40429. get targetedAnimations(): Array<TargetedAnimation>;
  40430. /**
  40431. * returning the list of animatables controlled by this animation group.
  40432. */
  40433. get animatables(): Array<Animatable>;
  40434. /**
  40435. * Gets the list of target animations
  40436. */
  40437. get children(): TargetedAnimation[];
  40438. /**
  40439. * Instantiates a new Animation Group.
  40440. * This helps managing several animations at once.
  40441. * @see https://doc.babylonjs.com/how_to/group
  40442. * @param name Defines the name of the group
  40443. * @param scene Defines the scene the group belongs to
  40444. */
  40445. constructor(
  40446. /** The name of the animation group */
  40447. name: string, scene?: Nullable<Scene>);
  40448. /**
  40449. * Add an animation (with its target) in the group
  40450. * @param animation defines the animation we want to add
  40451. * @param target defines the target of the animation
  40452. * @returns the TargetedAnimation object
  40453. */
  40454. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40455. /**
  40456. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40457. * It can add constant keys at begin or end
  40458. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40459. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40460. * @returns the animation group
  40461. */
  40462. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40463. private _animationLoopCount;
  40464. private _animationLoopFlags;
  40465. private _processLoop;
  40466. /**
  40467. * Start all animations on given targets
  40468. * @param loop defines if animations must loop
  40469. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40470. * @param from defines the from key (optional)
  40471. * @param to defines the to key (optional)
  40472. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40473. * @returns the current animation group
  40474. */
  40475. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40476. /**
  40477. * Pause all animations
  40478. * @returns the animation group
  40479. */
  40480. pause(): AnimationGroup;
  40481. /**
  40482. * Play all animations to initial state
  40483. * This function will start() the animations if they were not started or will restart() them if they were paused
  40484. * @param loop defines if animations must loop
  40485. * @returns the animation group
  40486. */
  40487. play(loop?: boolean): AnimationGroup;
  40488. /**
  40489. * Reset all animations to initial state
  40490. * @returns the animation group
  40491. */
  40492. reset(): AnimationGroup;
  40493. /**
  40494. * Restart animations from key 0
  40495. * @returns the animation group
  40496. */
  40497. restart(): AnimationGroup;
  40498. /**
  40499. * Stop all animations
  40500. * @returns the animation group
  40501. */
  40502. stop(): AnimationGroup;
  40503. /**
  40504. * Set animation weight for all animatables
  40505. * @param weight defines the weight to use
  40506. * @return the animationGroup
  40507. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40508. */
  40509. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40510. /**
  40511. * Synchronize and normalize all animatables with a source animatable
  40512. * @param root defines the root animatable to synchronize with
  40513. * @return the animationGroup
  40514. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40515. */
  40516. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40517. /**
  40518. * Goes to a specific frame in this animation group
  40519. * @param frame the frame number to go to
  40520. * @return the animationGroup
  40521. */
  40522. goToFrame(frame: number): AnimationGroup;
  40523. /**
  40524. * Dispose all associated resources
  40525. */
  40526. dispose(): void;
  40527. private _checkAnimationGroupEnded;
  40528. /**
  40529. * Clone the current animation group and returns a copy
  40530. * @param newName defines the name of the new group
  40531. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40532. * @returns the new aniamtion group
  40533. */
  40534. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40535. /**
  40536. * Serializes the animationGroup to an object
  40537. * @returns Serialized object
  40538. */
  40539. serialize(): any;
  40540. /**
  40541. * Returns a new AnimationGroup object parsed from the source provided.
  40542. * @param parsedAnimationGroup defines the source
  40543. * @param scene defines the scene that will receive the animationGroup
  40544. * @returns a new AnimationGroup
  40545. */
  40546. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40547. /**
  40548. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40549. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40550. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40551. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40552. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40553. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40554. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40555. */
  40556. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40557. /**
  40558. * Returns the string "AnimationGroup"
  40559. * @returns "AnimationGroup"
  40560. */
  40561. getClassName(): string;
  40562. /**
  40563. * Creates a detailled string about the object
  40564. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40565. * @returns a string representing the object
  40566. */
  40567. toString(fullDetails?: boolean): string;
  40568. }
  40569. }
  40570. declare module "babylonjs/scene" {
  40571. import { Nullable } from "babylonjs/types";
  40572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40573. import { Observable } from "babylonjs/Misc/observable";
  40574. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40575. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40576. import { Geometry } from "babylonjs/Meshes/geometry";
  40577. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40580. import { Mesh } from "babylonjs/Meshes/mesh";
  40581. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40582. import { Bone } from "babylonjs/Bones/bone";
  40583. import { Skeleton } from "babylonjs/Bones/skeleton";
  40584. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40585. import { Camera } from "babylonjs/Cameras/camera";
  40586. import { AbstractScene } from "babylonjs/abstractScene";
  40587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40589. import { Material } from "babylonjs/Materials/material";
  40590. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40591. import { Effect } from "babylonjs/Materials/effect";
  40592. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40593. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40594. import { Light } from "babylonjs/Lights/light";
  40595. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40596. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40597. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40598. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40599. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40600. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40601. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40602. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40603. import { Engine } from "babylonjs/Engines/engine";
  40604. import { Node } from "babylonjs/node";
  40605. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40606. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40607. import { WebRequest } from "babylonjs/Misc/webRequest";
  40608. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40609. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40610. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40611. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40612. import { Plane } from "babylonjs/Maths/math.plane";
  40613. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40614. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40615. import { Ray } from "babylonjs/Culling/ray";
  40616. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40617. import { Animation } from "babylonjs/Animations/animation";
  40618. import { Animatable } from "babylonjs/Animations/animatable";
  40619. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40620. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40621. import { Collider } from "babylonjs/Collisions/collider";
  40622. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40623. /**
  40624. * Define an interface for all classes that will hold resources
  40625. */
  40626. export interface IDisposable {
  40627. /**
  40628. * Releases all held resources
  40629. */
  40630. dispose(): void;
  40631. }
  40632. /** Interface defining initialization parameters for Scene class */
  40633. export interface SceneOptions {
  40634. /**
  40635. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40636. * It will improve performance when the number of geometries becomes important.
  40637. */
  40638. useGeometryUniqueIdsMap?: boolean;
  40639. /**
  40640. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40641. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40642. */
  40643. useMaterialMeshMap?: boolean;
  40644. /**
  40645. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40646. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40647. */
  40648. useClonedMeshMap?: boolean;
  40649. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40650. virtual?: boolean;
  40651. }
  40652. /**
  40653. * Represents a scene to be rendered by the engine.
  40654. * @see https://doc.babylonjs.com/features/scene
  40655. */
  40656. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40657. /** The fog is deactivated */
  40658. static readonly FOGMODE_NONE: number;
  40659. /** The fog density is following an exponential function */
  40660. static readonly FOGMODE_EXP: number;
  40661. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40662. static readonly FOGMODE_EXP2: number;
  40663. /** The fog density is following a linear function. */
  40664. static readonly FOGMODE_LINEAR: number;
  40665. /**
  40666. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40667. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40668. */
  40669. static MinDeltaTime: number;
  40670. /**
  40671. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40672. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40673. */
  40674. static MaxDeltaTime: number;
  40675. /**
  40676. * Factory used to create the default material.
  40677. * @param name The name of the material to create
  40678. * @param scene The scene to create the material for
  40679. * @returns The default material
  40680. */
  40681. static DefaultMaterialFactory(scene: Scene): Material;
  40682. /**
  40683. * Factory used to create the a collision coordinator.
  40684. * @returns The collision coordinator
  40685. */
  40686. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40687. /** @hidden */
  40688. _inputManager: InputManager;
  40689. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40690. cameraToUseForPointers: Nullable<Camera>;
  40691. /** @hidden */
  40692. readonly _isScene: boolean;
  40693. /** @hidden */
  40694. _blockEntityCollection: boolean;
  40695. /**
  40696. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40697. */
  40698. autoClear: boolean;
  40699. /**
  40700. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40701. */
  40702. autoClearDepthAndStencil: boolean;
  40703. /**
  40704. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40705. */
  40706. clearColor: Color4;
  40707. /**
  40708. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40709. */
  40710. ambientColor: Color3;
  40711. /**
  40712. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40713. * It should only be one of the following (if not the default embedded one):
  40714. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40715. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40716. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40717. * The material properties need to be setup according to the type of texture in use.
  40718. */
  40719. environmentBRDFTexture: BaseTexture;
  40720. /** @hidden */
  40721. protected _environmentTexture: Nullable<BaseTexture>;
  40722. /**
  40723. * Texture used in all pbr material as the reflection texture.
  40724. * As in the majority of the scene they are the same (exception for multi room and so on),
  40725. * this is easier to reference from here than from all the materials.
  40726. */
  40727. get environmentTexture(): Nullable<BaseTexture>;
  40728. /**
  40729. * Texture used in all pbr material as the reflection texture.
  40730. * As in the majority of the scene they are the same (exception for multi room and so on),
  40731. * this is easier to set here than in all the materials.
  40732. */
  40733. set environmentTexture(value: Nullable<BaseTexture>);
  40734. /** @hidden */
  40735. protected _environmentIntensity: number;
  40736. /**
  40737. * Intensity of the environment in all pbr material.
  40738. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40739. * As in the majority of the scene they are the same (exception for multi room and so on),
  40740. * this is easier to reference from here than from all the materials.
  40741. */
  40742. get environmentIntensity(): number;
  40743. /**
  40744. * Intensity of the environment in all pbr material.
  40745. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40746. * As in the majority of the scene they are the same (exception for multi room and so on),
  40747. * this is easier to set here than in all the materials.
  40748. */
  40749. set environmentIntensity(value: number);
  40750. /** @hidden */
  40751. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40752. /**
  40753. * Default image processing configuration used either in the rendering
  40754. * Forward main pass or through the imageProcessingPostProcess if present.
  40755. * As in the majority of the scene they are the same (exception for multi camera),
  40756. * this is easier to reference from here than from all the materials and post process.
  40757. *
  40758. * No setter as we it is a shared configuration, you can set the values instead.
  40759. */
  40760. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40761. private _forceWireframe;
  40762. /**
  40763. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40764. */
  40765. set forceWireframe(value: boolean);
  40766. get forceWireframe(): boolean;
  40767. private _skipFrustumClipping;
  40768. /**
  40769. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40770. */
  40771. set skipFrustumClipping(value: boolean);
  40772. get skipFrustumClipping(): boolean;
  40773. private _forcePointsCloud;
  40774. /**
  40775. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40776. */
  40777. set forcePointsCloud(value: boolean);
  40778. get forcePointsCloud(): boolean;
  40779. /**
  40780. * Gets or sets the active clipplane 1
  40781. */
  40782. clipPlane: Nullable<Plane>;
  40783. /**
  40784. * Gets or sets the active clipplane 2
  40785. */
  40786. clipPlane2: Nullable<Plane>;
  40787. /**
  40788. * Gets or sets the active clipplane 3
  40789. */
  40790. clipPlane3: Nullable<Plane>;
  40791. /**
  40792. * Gets or sets the active clipplane 4
  40793. */
  40794. clipPlane4: Nullable<Plane>;
  40795. /**
  40796. * Gets or sets the active clipplane 5
  40797. */
  40798. clipPlane5: Nullable<Plane>;
  40799. /**
  40800. * Gets or sets the active clipplane 6
  40801. */
  40802. clipPlane6: Nullable<Plane>;
  40803. /**
  40804. * Gets or sets a boolean indicating if animations are enabled
  40805. */
  40806. animationsEnabled: boolean;
  40807. private _animationPropertiesOverride;
  40808. /**
  40809. * Gets or sets the animation properties override
  40810. */
  40811. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40812. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40813. /**
  40814. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40815. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40816. */
  40817. useConstantAnimationDeltaTime: boolean;
  40818. /**
  40819. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40820. * Please note that it requires to run a ray cast through the scene on every frame
  40821. */
  40822. constantlyUpdateMeshUnderPointer: boolean;
  40823. /**
  40824. * Defines the HTML cursor to use when hovering over interactive elements
  40825. */
  40826. hoverCursor: string;
  40827. /**
  40828. * Defines the HTML default cursor to use (empty by default)
  40829. */
  40830. defaultCursor: string;
  40831. /**
  40832. * Defines whether cursors are handled by the scene.
  40833. */
  40834. doNotHandleCursors: boolean;
  40835. /**
  40836. * This is used to call preventDefault() on pointer down
  40837. * in order to block unwanted artifacts like system double clicks
  40838. */
  40839. preventDefaultOnPointerDown: boolean;
  40840. /**
  40841. * This is used to call preventDefault() on pointer up
  40842. * in order to block unwanted artifacts like system double clicks
  40843. */
  40844. preventDefaultOnPointerUp: boolean;
  40845. /**
  40846. * Gets or sets user defined metadata
  40847. */
  40848. metadata: any;
  40849. /**
  40850. * For internal use only. Please do not use.
  40851. */
  40852. reservedDataStore: any;
  40853. /**
  40854. * Gets the name of the plugin used to load this scene (null by default)
  40855. */
  40856. loadingPluginName: string;
  40857. /**
  40858. * Use this array to add regular expressions used to disable offline support for specific urls
  40859. */
  40860. disableOfflineSupportExceptionRules: RegExp[];
  40861. /**
  40862. * An event triggered when the scene is disposed.
  40863. */
  40864. onDisposeObservable: Observable<Scene>;
  40865. private _onDisposeObserver;
  40866. /** Sets a function to be executed when this scene is disposed. */
  40867. set onDispose(callback: () => void);
  40868. /**
  40869. * An event triggered before rendering the scene (right after animations and physics)
  40870. */
  40871. onBeforeRenderObservable: Observable<Scene>;
  40872. private _onBeforeRenderObserver;
  40873. /** Sets a function to be executed before rendering this scene */
  40874. set beforeRender(callback: Nullable<() => void>);
  40875. /**
  40876. * An event triggered after rendering the scene
  40877. */
  40878. onAfterRenderObservable: Observable<Scene>;
  40879. /**
  40880. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40881. */
  40882. onAfterRenderCameraObservable: Observable<Camera>;
  40883. private _onAfterRenderObserver;
  40884. /** Sets a function to be executed after rendering this scene */
  40885. set afterRender(callback: Nullable<() => void>);
  40886. /**
  40887. * An event triggered before animating the scene
  40888. */
  40889. onBeforeAnimationsObservable: Observable<Scene>;
  40890. /**
  40891. * An event triggered after animations processing
  40892. */
  40893. onAfterAnimationsObservable: Observable<Scene>;
  40894. /**
  40895. * An event triggered before draw calls are ready to be sent
  40896. */
  40897. onBeforeDrawPhaseObservable: Observable<Scene>;
  40898. /**
  40899. * An event triggered after draw calls have been sent
  40900. */
  40901. onAfterDrawPhaseObservable: Observable<Scene>;
  40902. /**
  40903. * An event triggered when the scene is ready
  40904. */
  40905. onReadyObservable: Observable<Scene>;
  40906. /**
  40907. * An event triggered before rendering a camera
  40908. */
  40909. onBeforeCameraRenderObservable: Observable<Camera>;
  40910. private _onBeforeCameraRenderObserver;
  40911. /** Sets a function to be executed before rendering a camera*/
  40912. set beforeCameraRender(callback: () => void);
  40913. /**
  40914. * An event triggered after rendering a camera
  40915. */
  40916. onAfterCameraRenderObservable: Observable<Camera>;
  40917. private _onAfterCameraRenderObserver;
  40918. /** Sets a function to be executed after rendering a camera*/
  40919. set afterCameraRender(callback: () => void);
  40920. /**
  40921. * An event triggered when active meshes evaluation is about to start
  40922. */
  40923. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40924. /**
  40925. * An event triggered when active meshes evaluation is done
  40926. */
  40927. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40928. /**
  40929. * An event triggered when particles rendering is about to start
  40930. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40931. */
  40932. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40933. /**
  40934. * An event triggered when particles rendering is done
  40935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40936. */
  40937. onAfterParticlesRenderingObservable: Observable<Scene>;
  40938. /**
  40939. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40940. */
  40941. onDataLoadedObservable: Observable<Scene>;
  40942. /**
  40943. * An event triggered when a camera is created
  40944. */
  40945. onNewCameraAddedObservable: Observable<Camera>;
  40946. /**
  40947. * An event triggered when a camera is removed
  40948. */
  40949. onCameraRemovedObservable: Observable<Camera>;
  40950. /**
  40951. * An event triggered when a light is created
  40952. */
  40953. onNewLightAddedObservable: Observable<Light>;
  40954. /**
  40955. * An event triggered when a light is removed
  40956. */
  40957. onLightRemovedObservable: Observable<Light>;
  40958. /**
  40959. * An event triggered when a geometry is created
  40960. */
  40961. onNewGeometryAddedObservable: Observable<Geometry>;
  40962. /**
  40963. * An event triggered when a geometry is removed
  40964. */
  40965. onGeometryRemovedObservable: Observable<Geometry>;
  40966. /**
  40967. * An event triggered when a transform node is created
  40968. */
  40969. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40970. /**
  40971. * An event triggered when a transform node is removed
  40972. */
  40973. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40974. /**
  40975. * An event triggered when a mesh is created
  40976. */
  40977. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40978. /**
  40979. * An event triggered when a mesh is removed
  40980. */
  40981. onMeshRemovedObservable: Observable<AbstractMesh>;
  40982. /**
  40983. * An event triggered when a skeleton is created
  40984. */
  40985. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40986. /**
  40987. * An event triggered when a skeleton is removed
  40988. */
  40989. onSkeletonRemovedObservable: Observable<Skeleton>;
  40990. /**
  40991. * An event triggered when a material is created
  40992. */
  40993. onNewMaterialAddedObservable: Observable<Material>;
  40994. /**
  40995. * An event triggered when a material is removed
  40996. */
  40997. onMaterialRemovedObservable: Observable<Material>;
  40998. /**
  40999. * An event triggered when a texture is created
  41000. */
  41001. onNewTextureAddedObservable: Observable<BaseTexture>;
  41002. /**
  41003. * An event triggered when a texture is removed
  41004. */
  41005. onTextureRemovedObservable: Observable<BaseTexture>;
  41006. /**
  41007. * An event triggered when render targets are about to be rendered
  41008. * Can happen multiple times per frame.
  41009. */
  41010. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41011. /**
  41012. * An event triggered when render targets were rendered.
  41013. * Can happen multiple times per frame.
  41014. */
  41015. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41016. /**
  41017. * An event triggered before calculating deterministic simulation step
  41018. */
  41019. onBeforeStepObservable: Observable<Scene>;
  41020. /**
  41021. * An event triggered after calculating deterministic simulation step
  41022. */
  41023. onAfterStepObservable: Observable<Scene>;
  41024. /**
  41025. * An event triggered when the activeCamera property is updated
  41026. */
  41027. onActiveCameraChanged: Observable<Scene>;
  41028. /**
  41029. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41030. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41031. * 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)
  41032. */
  41033. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41034. /**
  41035. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41036. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41037. * 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)
  41038. */
  41039. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41040. /**
  41041. * This Observable will when a mesh has been imported into the scene.
  41042. */
  41043. onMeshImportedObservable: Observable<AbstractMesh>;
  41044. /**
  41045. * This Observable will when an animation file has been imported into the scene.
  41046. */
  41047. onAnimationFileImportedObservable: Observable<Scene>;
  41048. /**
  41049. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41050. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41051. */
  41052. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41053. /** @hidden */
  41054. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41055. /**
  41056. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41057. */
  41058. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41059. /**
  41060. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41061. */
  41062. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41063. /**
  41064. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41065. */
  41066. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41067. /** Callback called when a pointer move is detected */
  41068. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41069. /** Callback called when a pointer down is detected */
  41070. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41071. /** Callback called when a pointer up is detected */
  41072. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41073. /** Callback called when a pointer pick is detected */
  41074. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41075. /**
  41076. * 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).
  41077. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41078. */
  41079. onPrePointerObservable: Observable<PointerInfoPre>;
  41080. /**
  41081. * Observable event triggered each time an input event is received from the rendering canvas
  41082. */
  41083. onPointerObservable: Observable<PointerInfo>;
  41084. /**
  41085. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41086. */
  41087. get unTranslatedPointer(): Vector2;
  41088. /**
  41089. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41090. */
  41091. static get DragMovementThreshold(): number;
  41092. static set DragMovementThreshold(value: number);
  41093. /**
  41094. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41095. */
  41096. static get LongPressDelay(): number;
  41097. static set LongPressDelay(value: number);
  41098. /**
  41099. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41100. */
  41101. static get DoubleClickDelay(): number;
  41102. static set DoubleClickDelay(value: number);
  41103. /** If you need to check double click without raising a single click at first click, enable this flag */
  41104. static get ExclusiveDoubleClickMode(): boolean;
  41105. static set ExclusiveDoubleClickMode(value: boolean);
  41106. /** @hidden */
  41107. _mirroredCameraPosition: Nullable<Vector3>;
  41108. /**
  41109. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41110. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41111. */
  41112. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41113. /**
  41114. * Observable event triggered each time an keyboard event is received from the hosting window
  41115. */
  41116. onKeyboardObservable: Observable<KeyboardInfo>;
  41117. private _useRightHandedSystem;
  41118. /**
  41119. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41120. */
  41121. set useRightHandedSystem(value: boolean);
  41122. get useRightHandedSystem(): boolean;
  41123. private _timeAccumulator;
  41124. private _currentStepId;
  41125. private _currentInternalStep;
  41126. /**
  41127. * Sets the step Id used by deterministic lock step
  41128. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41129. * @param newStepId defines the step Id
  41130. */
  41131. setStepId(newStepId: number): void;
  41132. /**
  41133. * Gets the step Id used by deterministic lock step
  41134. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41135. * @returns the step Id
  41136. */
  41137. getStepId(): number;
  41138. /**
  41139. * Gets the internal step used by deterministic lock step
  41140. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41141. * @returns the internal step
  41142. */
  41143. getInternalStep(): number;
  41144. private _fogEnabled;
  41145. /**
  41146. * Gets or sets a boolean indicating if fog is enabled on this scene
  41147. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41148. * (Default is true)
  41149. */
  41150. set fogEnabled(value: boolean);
  41151. get fogEnabled(): boolean;
  41152. private _fogMode;
  41153. /**
  41154. * Gets or sets the fog mode to use
  41155. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41156. * | mode | value |
  41157. * | --- | --- |
  41158. * | FOGMODE_NONE | 0 |
  41159. * | FOGMODE_EXP | 1 |
  41160. * | FOGMODE_EXP2 | 2 |
  41161. * | FOGMODE_LINEAR | 3 |
  41162. */
  41163. set fogMode(value: number);
  41164. get fogMode(): number;
  41165. /**
  41166. * Gets or sets the fog color to use
  41167. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41168. * (Default is Color3(0.2, 0.2, 0.3))
  41169. */
  41170. fogColor: Color3;
  41171. /**
  41172. * Gets or sets the fog density to use
  41173. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41174. * (Default is 0.1)
  41175. */
  41176. fogDensity: number;
  41177. /**
  41178. * Gets or sets the fog start distance to use
  41179. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41180. * (Default is 0)
  41181. */
  41182. fogStart: number;
  41183. /**
  41184. * Gets or sets the fog end distance to use
  41185. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41186. * (Default is 1000)
  41187. */
  41188. fogEnd: number;
  41189. /**
  41190. * Flag indicating that the frame buffer binding is handled by another component
  41191. */
  41192. prePass: boolean;
  41193. private _shadowsEnabled;
  41194. /**
  41195. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41196. */
  41197. set shadowsEnabled(value: boolean);
  41198. get shadowsEnabled(): boolean;
  41199. private _lightsEnabled;
  41200. /**
  41201. * Gets or sets a boolean indicating if lights are enabled on this scene
  41202. */
  41203. set lightsEnabled(value: boolean);
  41204. get lightsEnabled(): boolean;
  41205. /** All of the active cameras added to this scene. */
  41206. activeCameras: Camera[];
  41207. /** @hidden */
  41208. _activeCamera: Nullable<Camera>;
  41209. /** Gets or sets the current active camera */
  41210. get activeCamera(): Nullable<Camera>;
  41211. set activeCamera(value: Nullable<Camera>);
  41212. private _defaultMaterial;
  41213. /** The default material used on meshes when no material is affected */
  41214. get defaultMaterial(): Material;
  41215. /** The default material used on meshes when no material is affected */
  41216. set defaultMaterial(value: Material);
  41217. private _texturesEnabled;
  41218. /**
  41219. * Gets or sets a boolean indicating if textures are enabled on this scene
  41220. */
  41221. set texturesEnabled(value: boolean);
  41222. get texturesEnabled(): boolean;
  41223. /**
  41224. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41225. */
  41226. physicsEnabled: boolean;
  41227. /**
  41228. * Gets or sets a boolean indicating if particles are enabled on this scene
  41229. */
  41230. particlesEnabled: boolean;
  41231. /**
  41232. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41233. */
  41234. spritesEnabled: boolean;
  41235. private _skeletonsEnabled;
  41236. /**
  41237. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41238. */
  41239. set skeletonsEnabled(value: boolean);
  41240. get skeletonsEnabled(): boolean;
  41241. /**
  41242. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41243. */
  41244. lensFlaresEnabled: boolean;
  41245. /**
  41246. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41247. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41248. */
  41249. collisionsEnabled: boolean;
  41250. private _collisionCoordinator;
  41251. /** @hidden */
  41252. get collisionCoordinator(): ICollisionCoordinator;
  41253. /**
  41254. * Defines the gravity applied to this scene (used only for collisions)
  41255. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41256. */
  41257. gravity: Vector3;
  41258. /**
  41259. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41260. */
  41261. postProcessesEnabled: boolean;
  41262. /**
  41263. * Gets the current postprocess manager
  41264. */
  41265. postProcessManager: PostProcessManager;
  41266. /**
  41267. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41268. */
  41269. renderTargetsEnabled: boolean;
  41270. /**
  41271. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41272. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41273. */
  41274. dumpNextRenderTargets: boolean;
  41275. /**
  41276. * The list of user defined render targets added to the scene
  41277. */
  41278. customRenderTargets: RenderTargetTexture[];
  41279. /**
  41280. * Defines if texture loading must be delayed
  41281. * If true, textures will only be loaded when they need to be rendered
  41282. */
  41283. useDelayedTextureLoading: boolean;
  41284. /**
  41285. * Gets the list of meshes imported to the scene through SceneLoader
  41286. */
  41287. importedMeshesFiles: String[];
  41288. /**
  41289. * Gets or sets a boolean indicating if probes are enabled on this scene
  41290. */
  41291. probesEnabled: boolean;
  41292. /**
  41293. * Gets or sets the current offline provider to use to store scene data
  41294. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41295. */
  41296. offlineProvider: IOfflineProvider;
  41297. /**
  41298. * Gets or sets the action manager associated with the scene
  41299. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41300. */
  41301. actionManager: AbstractActionManager;
  41302. private _meshesForIntersections;
  41303. /**
  41304. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41305. */
  41306. proceduralTexturesEnabled: boolean;
  41307. private _engine;
  41308. private _totalVertices;
  41309. /** @hidden */
  41310. _activeIndices: PerfCounter;
  41311. /** @hidden */
  41312. _activeParticles: PerfCounter;
  41313. /** @hidden */
  41314. _activeBones: PerfCounter;
  41315. private _animationRatio;
  41316. /** @hidden */
  41317. _animationTimeLast: number;
  41318. /** @hidden */
  41319. _animationTime: number;
  41320. /**
  41321. * Gets or sets a general scale for animation speed
  41322. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41323. */
  41324. animationTimeScale: number;
  41325. /** @hidden */
  41326. _cachedMaterial: Nullable<Material>;
  41327. /** @hidden */
  41328. _cachedEffect: Nullable<Effect>;
  41329. /** @hidden */
  41330. _cachedVisibility: Nullable<number>;
  41331. private _renderId;
  41332. private _frameId;
  41333. private _executeWhenReadyTimeoutId;
  41334. private _intermediateRendering;
  41335. private _viewUpdateFlag;
  41336. private _projectionUpdateFlag;
  41337. /** @hidden */
  41338. _toBeDisposed: Nullable<IDisposable>[];
  41339. private _activeRequests;
  41340. /** @hidden */
  41341. _pendingData: any[];
  41342. private _isDisposed;
  41343. /**
  41344. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41345. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41346. */
  41347. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41348. private _activeMeshes;
  41349. private _processedMaterials;
  41350. private _renderTargets;
  41351. /** @hidden */
  41352. _activeParticleSystems: SmartArray<IParticleSystem>;
  41353. private _activeSkeletons;
  41354. private _softwareSkinnedMeshes;
  41355. private _renderingManager;
  41356. /** @hidden */
  41357. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41358. private _transformMatrix;
  41359. private _sceneUbo;
  41360. /** @hidden */
  41361. _viewMatrix: Matrix;
  41362. private _projectionMatrix;
  41363. /** @hidden */
  41364. _forcedViewPosition: Nullable<Vector3>;
  41365. /** @hidden */
  41366. _frustumPlanes: Plane[];
  41367. /**
  41368. * Gets the list of frustum planes (built from the active camera)
  41369. */
  41370. get frustumPlanes(): Plane[];
  41371. /**
  41372. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41373. * This is useful if there are more lights that the maximum simulteanous authorized
  41374. */
  41375. requireLightSorting: boolean;
  41376. /** @hidden */
  41377. readonly useMaterialMeshMap: boolean;
  41378. /** @hidden */
  41379. readonly useClonedMeshMap: boolean;
  41380. private _externalData;
  41381. private _uid;
  41382. /**
  41383. * @hidden
  41384. * Backing store of defined scene components.
  41385. */
  41386. _components: ISceneComponent[];
  41387. /**
  41388. * @hidden
  41389. * Backing store of defined scene components.
  41390. */
  41391. _serializableComponents: ISceneSerializableComponent[];
  41392. /**
  41393. * List of components to register on the next registration step.
  41394. */
  41395. private _transientComponents;
  41396. /**
  41397. * Registers the transient components if needed.
  41398. */
  41399. private _registerTransientComponents;
  41400. /**
  41401. * @hidden
  41402. * Add a component to the scene.
  41403. * Note that the ccomponent could be registered on th next frame if this is called after
  41404. * the register component stage.
  41405. * @param component Defines the component to add to the scene
  41406. */
  41407. _addComponent(component: ISceneComponent): void;
  41408. /**
  41409. * @hidden
  41410. * Gets a component from the scene.
  41411. * @param name defines the name of the component to retrieve
  41412. * @returns the component or null if not present
  41413. */
  41414. _getComponent(name: string): Nullable<ISceneComponent>;
  41415. /**
  41416. * @hidden
  41417. * Defines the actions happening before camera updates.
  41418. */
  41419. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41420. /**
  41421. * @hidden
  41422. * Defines the actions happening before clear the canvas.
  41423. */
  41424. _beforeClearStage: Stage<SimpleStageAction>;
  41425. /**
  41426. * @hidden
  41427. * Defines the actions when collecting render targets for the frame.
  41428. */
  41429. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41430. /**
  41431. * @hidden
  41432. * Defines the actions happening for one camera in the frame.
  41433. */
  41434. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41435. /**
  41436. * @hidden
  41437. * Defines the actions happening during the per mesh ready checks.
  41438. */
  41439. _isReadyForMeshStage: Stage<MeshStageAction>;
  41440. /**
  41441. * @hidden
  41442. * Defines the actions happening before evaluate active mesh checks.
  41443. */
  41444. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41445. /**
  41446. * @hidden
  41447. * Defines the actions happening during the evaluate sub mesh checks.
  41448. */
  41449. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41450. /**
  41451. * @hidden
  41452. * Defines the actions happening during the active mesh stage.
  41453. */
  41454. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41455. /**
  41456. * @hidden
  41457. * Defines the actions happening during the per camera render target step.
  41458. */
  41459. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41460. /**
  41461. * @hidden
  41462. * Defines the actions happening just before the active camera is drawing.
  41463. */
  41464. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41465. /**
  41466. * @hidden
  41467. * Defines the actions happening just before a render target is drawing.
  41468. */
  41469. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41470. /**
  41471. * @hidden
  41472. * Defines the actions happening just before a rendering group is drawing.
  41473. */
  41474. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41475. /**
  41476. * @hidden
  41477. * Defines the actions happening just before a mesh is drawing.
  41478. */
  41479. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41480. /**
  41481. * @hidden
  41482. * Defines the actions happening just after a mesh has been drawn.
  41483. */
  41484. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41485. /**
  41486. * @hidden
  41487. * Defines the actions happening just after a rendering group has been drawn.
  41488. */
  41489. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41490. /**
  41491. * @hidden
  41492. * Defines the actions happening just after the active camera has been drawn.
  41493. */
  41494. _afterCameraDrawStage: Stage<CameraStageAction>;
  41495. /**
  41496. * @hidden
  41497. * Defines the actions happening just after a render target has been drawn.
  41498. */
  41499. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41500. /**
  41501. * @hidden
  41502. * Defines the actions happening just after rendering all cameras and computing intersections.
  41503. */
  41504. _afterRenderStage: Stage<SimpleStageAction>;
  41505. /**
  41506. * @hidden
  41507. * Defines the actions happening when a pointer move event happens.
  41508. */
  41509. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41510. /**
  41511. * @hidden
  41512. * Defines the actions happening when a pointer down event happens.
  41513. */
  41514. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41515. /**
  41516. * @hidden
  41517. * Defines the actions happening when a pointer up event happens.
  41518. */
  41519. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41520. /**
  41521. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41522. */
  41523. private geometriesByUniqueId;
  41524. /**
  41525. * Creates a new Scene
  41526. * @param engine defines the engine to use to render this scene
  41527. * @param options defines the scene options
  41528. */
  41529. constructor(engine: Engine, options?: SceneOptions);
  41530. /**
  41531. * Gets a string identifying the name of the class
  41532. * @returns "Scene" string
  41533. */
  41534. getClassName(): string;
  41535. private _defaultMeshCandidates;
  41536. /**
  41537. * @hidden
  41538. */
  41539. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41540. private _defaultSubMeshCandidates;
  41541. /**
  41542. * @hidden
  41543. */
  41544. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41545. /**
  41546. * Sets the default candidate providers for the scene.
  41547. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41548. * and getCollidingSubMeshCandidates to their default function
  41549. */
  41550. setDefaultCandidateProviders(): void;
  41551. /**
  41552. * Gets the mesh that is currently under the pointer
  41553. */
  41554. get meshUnderPointer(): Nullable<AbstractMesh>;
  41555. /**
  41556. * Gets or sets the current on-screen X position of the pointer
  41557. */
  41558. get pointerX(): number;
  41559. set pointerX(value: number);
  41560. /**
  41561. * Gets or sets the current on-screen Y position of the pointer
  41562. */
  41563. get pointerY(): number;
  41564. set pointerY(value: number);
  41565. /**
  41566. * Gets the cached material (ie. the latest rendered one)
  41567. * @returns the cached material
  41568. */
  41569. getCachedMaterial(): Nullable<Material>;
  41570. /**
  41571. * Gets the cached effect (ie. the latest rendered one)
  41572. * @returns the cached effect
  41573. */
  41574. getCachedEffect(): Nullable<Effect>;
  41575. /**
  41576. * Gets the cached visibility state (ie. the latest rendered one)
  41577. * @returns the cached visibility state
  41578. */
  41579. getCachedVisibility(): Nullable<number>;
  41580. /**
  41581. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41582. * @param material defines the current material
  41583. * @param effect defines the current effect
  41584. * @param visibility defines the current visibility state
  41585. * @returns true if one parameter is not cached
  41586. */
  41587. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41588. /**
  41589. * Gets the engine associated with the scene
  41590. * @returns an Engine
  41591. */
  41592. getEngine(): Engine;
  41593. /**
  41594. * Gets the total number of vertices rendered per frame
  41595. * @returns the total number of vertices rendered per frame
  41596. */
  41597. getTotalVertices(): number;
  41598. /**
  41599. * Gets the performance counter for total vertices
  41600. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41601. */
  41602. get totalVerticesPerfCounter(): PerfCounter;
  41603. /**
  41604. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41605. * @returns the total number of active indices rendered per frame
  41606. */
  41607. getActiveIndices(): number;
  41608. /**
  41609. * Gets the performance counter for active indices
  41610. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41611. */
  41612. get totalActiveIndicesPerfCounter(): PerfCounter;
  41613. /**
  41614. * Gets the total number of active particles rendered per frame
  41615. * @returns the total number of active particles rendered per frame
  41616. */
  41617. getActiveParticles(): number;
  41618. /**
  41619. * Gets the performance counter for active particles
  41620. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41621. */
  41622. get activeParticlesPerfCounter(): PerfCounter;
  41623. /**
  41624. * Gets the total number of active bones rendered per frame
  41625. * @returns the total number of active bones rendered per frame
  41626. */
  41627. getActiveBones(): number;
  41628. /**
  41629. * Gets the performance counter for active bones
  41630. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41631. */
  41632. get activeBonesPerfCounter(): PerfCounter;
  41633. /**
  41634. * Gets the array of active meshes
  41635. * @returns an array of AbstractMesh
  41636. */
  41637. getActiveMeshes(): SmartArray<AbstractMesh>;
  41638. /**
  41639. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41640. * @returns a number
  41641. */
  41642. getAnimationRatio(): number;
  41643. /**
  41644. * Gets an unique Id for the current render phase
  41645. * @returns a number
  41646. */
  41647. getRenderId(): number;
  41648. /**
  41649. * Gets an unique Id for the current frame
  41650. * @returns a number
  41651. */
  41652. getFrameId(): number;
  41653. /** Call this function if you want to manually increment the render Id*/
  41654. incrementRenderId(): void;
  41655. private _createUbo;
  41656. /**
  41657. * Use this method to simulate a pointer move on a mesh
  41658. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41659. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41660. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41661. * @returns the current scene
  41662. */
  41663. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41664. /**
  41665. * Use this method to simulate a pointer down on a mesh
  41666. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41667. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41668. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41669. * @returns the current scene
  41670. */
  41671. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41672. /**
  41673. * Use this method to simulate a pointer up on a mesh
  41674. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41675. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41676. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41677. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41678. * @returns the current scene
  41679. */
  41680. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41681. /**
  41682. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41683. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41684. * @returns true if the pointer was captured
  41685. */
  41686. isPointerCaptured(pointerId?: number): boolean;
  41687. /**
  41688. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41689. * @param attachUp defines if you want to attach events to pointerup
  41690. * @param attachDown defines if you want to attach events to pointerdown
  41691. * @param attachMove defines if you want to attach events to pointermove
  41692. */
  41693. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41694. /** Detaches all event handlers*/
  41695. detachControl(): void;
  41696. /**
  41697. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41698. * Delay loaded resources are not taking in account
  41699. * @return true if all required resources are ready
  41700. */
  41701. isReady(): boolean;
  41702. /** Resets all cached information relative to material (including effect and visibility) */
  41703. resetCachedMaterial(): void;
  41704. /**
  41705. * Registers a function to be called before every frame render
  41706. * @param func defines the function to register
  41707. */
  41708. registerBeforeRender(func: () => void): void;
  41709. /**
  41710. * Unregisters a function called before every frame render
  41711. * @param func defines the function to unregister
  41712. */
  41713. unregisterBeforeRender(func: () => void): void;
  41714. /**
  41715. * Registers a function to be called after every frame render
  41716. * @param func defines the function to register
  41717. */
  41718. registerAfterRender(func: () => void): void;
  41719. /**
  41720. * Unregisters a function called after every frame render
  41721. * @param func defines the function to unregister
  41722. */
  41723. unregisterAfterRender(func: () => void): void;
  41724. private _executeOnceBeforeRender;
  41725. /**
  41726. * The provided function will run before render once and will be disposed afterwards.
  41727. * A timeout delay can be provided so that the function will be executed in N ms.
  41728. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41729. * @param func The function to be executed.
  41730. * @param timeout optional delay in ms
  41731. */
  41732. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41733. /** @hidden */
  41734. _addPendingData(data: any): void;
  41735. /** @hidden */
  41736. _removePendingData(data: any): void;
  41737. /**
  41738. * Returns the number of items waiting to be loaded
  41739. * @returns the number of items waiting to be loaded
  41740. */
  41741. getWaitingItemsCount(): number;
  41742. /**
  41743. * Returns a boolean indicating if the scene is still loading data
  41744. */
  41745. get isLoading(): boolean;
  41746. /**
  41747. * Registers a function to be executed when the scene is ready
  41748. * @param {Function} func - the function to be executed
  41749. */
  41750. executeWhenReady(func: () => void): void;
  41751. /**
  41752. * Returns a promise that resolves when the scene is ready
  41753. * @returns A promise that resolves when the scene is ready
  41754. */
  41755. whenReadyAsync(): Promise<void>;
  41756. /** @hidden */
  41757. _checkIsReady(): void;
  41758. /**
  41759. * Gets all animatable attached to the scene
  41760. */
  41761. get animatables(): Animatable[];
  41762. /**
  41763. * Resets the last animation time frame.
  41764. * Useful to override when animations start running when loading a scene for the first time.
  41765. */
  41766. resetLastAnimationTimeFrame(): void;
  41767. /**
  41768. * Gets the current view matrix
  41769. * @returns a Matrix
  41770. */
  41771. getViewMatrix(): Matrix;
  41772. /**
  41773. * Gets the current projection matrix
  41774. * @returns a Matrix
  41775. */
  41776. getProjectionMatrix(): Matrix;
  41777. /**
  41778. * Gets the current transform matrix
  41779. * @returns a Matrix made of View * Projection
  41780. */
  41781. getTransformMatrix(): Matrix;
  41782. /**
  41783. * Sets the current transform matrix
  41784. * @param viewL defines the View matrix to use
  41785. * @param projectionL defines the Projection matrix to use
  41786. * @param viewR defines the right View matrix to use (if provided)
  41787. * @param projectionR defines the right Projection matrix to use (if provided)
  41788. */
  41789. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41790. /**
  41791. * Gets the uniform buffer used to store scene data
  41792. * @returns a UniformBuffer
  41793. */
  41794. getSceneUniformBuffer(): UniformBuffer;
  41795. /**
  41796. * Gets an unique (relatively to the current scene) Id
  41797. * @returns an unique number for the scene
  41798. */
  41799. getUniqueId(): number;
  41800. /**
  41801. * Add a mesh to the list of scene's meshes
  41802. * @param newMesh defines the mesh to add
  41803. * @param recursive if all child meshes should also be added to the scene
  41804. */
  41805. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41806. /**
  41807. * Remove a mesh for the list of scene's meshes
  41808. * @param toRemove defines the mesh to remove
  41809. * @param recursive if all child meshes should also be removed from the scene
  41810. * @returns the index where the mesh was in the mesh list
  41811. */
  41812. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41813. /**
  41814. * Add a transform node to the list of scene's transform nodes
  41815. * @param newTransformNode defines the transform node to add
  41816. */
  41817. addTransformNode(newTransformNode: TransformNode): void;
  41818. /**
  41819. * Remove a transform node for the list of scene's transform nodes
  41820. * @param toRemove defines the transform node to remove
  41821. * @returns the index where the transform node was in the transform node list
  41822. */
  41823. removeTransformNode(toRemove: TransformNode): number;
  41824. /**
  41825. * Remove a skeleton for the list of scene's skeletons
  41826. * @param toRemove defines the skeleton to remove
  41827. * @returns the index where the skeleton was in the skeleton list
  41828. */
  41829. removeSkeleton(toRemove: Skeleton): number;
  41830. /**
  41831. * Remove a morph target for the list of scene's morph targets
  41832. * @param toRemove defines the morph target to remove
  41833. * @returns the index where the morph target was in the morph target list
  41834. */
  41835. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41836. /**
  41837. * Remove a light for the list of scene's lights
  41838. * @param toRemove defines the light to remove
  41839. * @returns the index where the light was in the light list
  41840. */
  41841. removeLight(toRemove: Light): number;
  41842. /**
  41843. * Remove a camera for the list of scene's cameras
  41844. * @param toRemove defines the camera to remove
  41845. * @returns the index where the camera was in the camera list
  41846. */
  41847. removeCamera(toRemove: Camera): number;
  41848. /**
  41849. * Remove a particle system for the list of scene's particle systems
  41850. * @param toRemove defines the particle system to remove
  41851. * @returns the index where the particle system was in the particle system list
  41852. */
  41853. removeParticleSystem(toRemove: IParticleSystem): number;
  41854. /**
  41855. * Remove a animation for the list of scene's animations
  41856. * @param toRemove defines the animation to remove
  41857. * @returns the index where the animation was in the animation list
  41858. */
  41859. removeAnimation(toRemove: Animation): number;
  41860. /**
  41861. * Will stop the animation of the given target
  41862. * @param target - the target
  41863. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41864. * @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)
  41865. */
  41866. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41867. /**
  41868. * Removes the given animation group from this scene.
  41869. * @param toRemove The animation group to remove
  41870. * @returns The index of the removed animation group
  41871. */
  41872. removeAnimationGroup(toRemove: AnimationGroup): number;
  41873. /**
  41874. * Removes the given multi-material from this scene.
  41875. * @param toRemove The multi-material to remove
  41876. * @returns The index of the removed multi-material
  41877. */
  41878. removeMultiMaterial(toRemove: MultiMaterial): number;
  41879. /**
  41880. * Removes the given material from this scene.
  41881. * @param toRemove The material to remove
  41882. * @returns The index of the removed material
  41883. */
  41884. removeMaterial(toRemove: Material): number;
  41885. /**
  41886. * Removes the given action manager from this scene.
  41887. * @param toRemove The action manager to remove
  41888. * @returns The index of the removed action manager
  41889. */
  41890. removeActionManager(toRemove: AbstractActionManager): number;
  41891. /**
  41892. * Removes the given texture from this scene.
  41893. * @param toRemove The texture to remove
  41894. * @returns The index of the removed texture
  41895. */
  41896. removeTexture(toRemove: BaseTexture): number;
  41897. /**
  41898. * Adds the given light to this scene
  41899. * @param newLight The light to add
  41900. */
  41901. addLight(newLight: Light): void;
  41902. /**
  41903. * Sorts the list list based on light priorities
  41904. */
  41905. sortLightsByPriority(): void;
  41906. /**
  41907. * Adds the given camera to this scene
  41908. * @param newCamera The camera to add
  41909. */
  41910. addCamera(newCamera: Camera): void;
  41911. /**
  41912. * Adds the given skeleton to this scene
  41913. * @param newSkeleton The skeleton to add
  41914. */
  41915. addSkeleton(newSkeleton: Skeleton): void;
  41916. /**
  41917. * Adds the given particle system to this scene
  41918. * @param newParticleSystem The particle system to add
  41919. */
  41920. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41921. /**
  41922. * Adds the given animation to this scene
  41923. * @param newAnimation The animation to add
  41924. */
  41925. addAnimation(newAnimation: Animation): void;
  41926. /**
  41927. * Adds the given animation group to this scene.
  41928. * @param newAnimationGroup The animation group to add
  41929. */
  41930. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41931. /**
  41932. * Adds the given multi-material to this scene
  41933. * @param newMultiMaterial The multi-material to add
  41934. */
  41935. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41936. /**
  41937. * Adds the given material to this scene
  41938. * @param newMaterial The material to add
  41939. */
  41940. addMaterial(newMaterial: Material): void;
  41941. /**
  41942. * Adds the given morph target to this scene
  41943. * @param newMorphTargetManager The morph target to add
  41944. */
  41945. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41946. /**
  41947. * Adds the given geometry to this scene
  41948. * @param newGeometry The geometry to add
  41949. */
  41950. addGeometry(newGeometry: Geometry): void;
  41951. /**
  41952. * Adds the given action manager to this scene
  41953. * @param newActionManager The action manager to add
  41954. */
  41955. addActionManager(newActionManager: AbstractActionManager): void;
  41956. /**
  41957. * Adds the given texture to this scene.
  41958. * @param newTexture The texture to add
  41959. */
  41960. addTexture(newTexture: BaseTexture): void;
  41961. /**
  41962. * Switch active camera
  41963. * @param newCamera defines the new active camera
  41964. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41965. */
  41966. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41967. /**
  41968. * sets the active camera of the scene using its ID
  41969. * @param id defines the camera's ID
  41970. * @return the new active camera or null if none found.
  41971. */
  41972. setActiveCameraByID(id: string): Nullable<Camera>;
  41973. /**
  41974. * sets the active camera of the scene using its name
  41975. * @param name defines the camera's name
  41976. * @returns the new active camera or null if none found.
  41977. */
  41978. setActiveCameraByName(name: string): Nullable<Camera>;
  41979. /**
  41980. * get an animation group using its name
  41981. * @param name defines the material's name
  41982. * @return the animation group or null if none found.
  41983. */
  41984. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41985. /**
  41986. * Get a material using its unique id
  41987. * @param uniqueId defines the material's unique id
  41988. * @return the material or null if none found.
  41989. */
  41990. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41991. /**
  41992. * get a material using its id
  41993. * @param id defines the material's ID
  41994. * @return the material or null if none found.
  41995. */
  41996. getMaterialByID(id: string): Nullable<Material>;
  41997. /**
  41998. * Gets a the last added material using a given id
  41999. * @param id defines the material's ID
  42000. * @return the last material with the given id or null if none found.
  42001. */
  42002. getLastMaterialByID(id: string): Nullable<Material>;
  42003. /**
  42004. * Gets a material using its name
  42005. * @param name defines the material's name
  42006. * @return the material or null if none found.
  42007. */
  42008. getMaterialByName(name: string): Nullable<Material>;
  42009. /**
  42010. * Get a texture using its unique id
  42011. * @param uniqueId defines the texture's unique id
  42012. * @return the texture or null if none found.
  42013. */
  42014. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42015. /**
  42016. * Gets a camera using its id
  42017. * @param id defines the id to look for
  42018. * @returns the camera or null if not found
  42019. */
  42020. getCameraByID(id: string): Nullable<Camera>;
  42021. /**
  42022. * Gets a camera using its unique id
  42023. * @param uniqueId defines the unique id to look for
  42024. * @returns the camera or null if not found
  42025. */
  42026. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42027. /**
  42028. * Gets a camera using its name
  42029. * @param name defines the camera's name
  42030. * @return the camera or null if none found.
  42031. */
  42032. getCameraByName(name: string): Nullable<Camera>;
  42033. /**
  42034. * Gets a bone using its id
  42035. * @param id defines the bone's id
  42036. * @return the bone or null if not found
  42037. */
  42038. getBoneByID(id: string): Nullable<Bone>;
  42039. /**
  42040. * Gets a bone using its id
  42041. * @param name defines the bone's name
  42042. * @return the bone or null if not found
  42043. */
  42044. getBoneByName(name: string): Nullable<Bone>;
  42045. /**
  42046. * Gets a light node using its name
  42047. * @param name defines the the light's name
  42048. * @return the light or null if none found.
  42049. */
  42050. getLightByName(name: string): Nullable<Light>;
  42051. /**
  42052. * Gets a light node using its id
  42053. * @param id defines the light's id
  42054. * @return the light or null if none found.
  42055. */
  42056. getLightByID(id: string): Nullable<Light>;
  42057. /**
  42058. * Gets a light node using its scene-generated unique ID
  42059. * @param uniqueId defines the light's unique id
  42060. * @return the light or null if none found.
  42061. */
  42062. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42063. /**
  42064. * Gets a particle system by id
  42065. * @param id defines the particle system id
  42066. * @return the corresponding system or null if none found
  42067. */
  42068. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42069. /**
  42070. * Gets a geometry using its ID
  42071. * @param id defines the geometry's id
  42072. * @return the geometry or null if none found.
  42073. */
  42074. getGeometryByID(id: string): Nullable<Geometry>;
  42075. private _getGeometryByUniqueID;
  42076. /**
  42077. * Add a new geometry to this scene
  42078. * @param geometry defines the geometry to be added to the scene.
  42079. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42080. * @return a boolean defining if the geometry was added or not
  42081. */
  42082. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42083. /**
  42084. * Removes an existing geometry
  42085. * @param geometry defines the geometry to be removed from the scene
  42086. * @return a boolean defining if the geometry was removed or not
  42087. */
  42088. removeGeometry(geometry: Geometry): boolean;
  42089. /**
  42090. * Gets the list of geometries attached to the scene
  42091. * @returns an array of Geometry
  42092. */
  42093. getGeometries(): Geometry[];
  42094. /**
  42095. * Gets the first added mesh found of a given ID
  42096. * @param id defines the id to search for
  42097. * @return the mesh found or null if not found at all
  42098. */
  42099. getMeshByID(id: string): Nullable<AbstractMesh>;
  42100. /**
  42101. * Gets a list of meshes using their id
  42102. * @param id defines the id to search for
  42103. * @returns a list of meshes
  42104. */
  42105. getMeshesByID(id: string): Array<AbstractMesh>;
  42106. /**
  42107. * Gets the first added transform node found of a given ID
  42108. * @param id defines the id to search for
  42109. * @return the found transform node or null if not found at all.
  42110. */
  42111. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42112. /**
  42113. * Gets a transform node with its auto-generated unique id
  42114. * @param uniqueId efines the unique id to search for
  42115. * @return the found transform node or null if not found at all.
  42116. */
  42117. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42118. /**
  42119. * Gets a list of transform nodes using their id
  42120. * @param id defines the id to search for
  42121. * @returns a list of transform nodes
  42122. */
  42123. getTransformNodesByID(id: string): Array<TransformNode>;
  42124. /**
  42125. * Gets a mesh with its auto-generated unique id
  42126. * @param uniqueId defines the unique id to search for
  42127. * @return the found mesh or null if not found at all.
  42128. */
  42129. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42130. /**
  42131. * Gets a the last added mesh using a given id
  42132. * @param id defines the id to search for
  42133. * @return the found mesh or null if not found at all.
  42134. */
  42135. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42136. /**
  42137. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42138. * @param id defines the id to search for
  42139. * @return the found node or null if not found at all
  42140. */
  42141. getLastEntryByID(id: string): Nullable<Node>;
  42142. /**
  42143. * Gets a node (Mesh, Camera, Light) using a given id
  42144. * @param id defines the id to search for
  42145. * @return the found node or null if not found at all
  42146. */
  42147. getNodeByID(id: string): Nullable<Node>;
  42148. /**
  42149. * Gets a node (Mesh, Camera, Light) using a given name
  42150. * @param name defines the name to search for
  42151. * @return the found node or null if not found at all.
  42152. */
  42153. getNodeByName(name: string): Nullable<Node>;
  42154. /**
  42155. * Gets a mesh using a given name
  42156. * @param name defines the name to search for
  42157. * @return the found mesh or null if not found at all.
  42158. */
  42159. getMeshByName(name: string): Nullable<AbstractMesh>;
  42160. /**
  42161. * Gets a transform node using a given name
  42162. * @param name defines the name to search for
  42163. * @return the found transform node or null if not found at all.
  42164. */
  42165. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42166. /**
  42167. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42168. * @param id defines the id to search for
  42169. * @return the found skeleton or null if not found at all.
  42170. */
  42171. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42172. /**
  42173. * Gets a skeleton using a given auto generated unique id
  42174. * @param uniqueId defines the unique id to search for
  42175. * @return the found skeleton or null if not found at all.
  42176. */
  42177. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42178. /**
  42179. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42180. * @param id defines the id to search for
  42181. * @return the found skeleton or null if not found at all.
  42182. */
  42183. getSkeletonById(id: string): Nullable<Skeleton>;
  42184. /**
  42185. * Gets a skeleton using a given name
  42186. * @param name defines the name to search for
  42187. * @return the found skeleton or null if not found at all.
  42188. */
  42189. getSkeletonByName(name: string): Nullable<Skeleton>;
  42190. /**
  42191. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42192. * @param id defines the id to search for
  42193. * @return the found morph target manager or null if not found at all.
  42194. */
  42195. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42196. /**
  42197. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42198. * @param id defines the id to search for
  42199. * @return the found morph target or null if not found at all.
  42200. */
  42201. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42202. /**
  42203. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42204. * @param name defines the name to search for
  42205. * @return the found morph target or null if not found at all.
  42206. */
  42207. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42208. /**
  42209. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42210. * @param name defines the name to search for
  42211. * @return the found post process or null if not found at all.
  42212. */
  42213. getPostProcessByName(name: string): Nullable<PostProcess>;
  42214. /**
  42215. * Gets a boolean indicating if the given mesh is active
  42216. * @param mesh defines the mesh to look for
  42217. * @returns true if the mesh is in the active list
  42218. */
  42219. isActiveMesh(mesh: AbstractMesh): boolean;
  42220. /**
  42221. * Return a unique id as a string which can serve as an identifier for the scene
  42222. */
  42223. get uid(): string;
  42224. /**
  42225. * Add an externaly attached data from its key.
  42226. * This method call will fail and return false, if such key already exists.
  42227. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42228. * @param key the unique key that identifies the data
  42229. * @param data the data object to associate to the key for this Engine instance
  42230. * @return true if no such key were already present and the data was added successfully, false otherwise
  42231. */
  42232. addExternalData<T>(key: string, data: T): boolean;
  42233. /**
  42234. * Get an externaly attached data from its key
  42235. * @param key the unique key that identifies the data
  42236. * @return the associated data, if present (can be null), or undefined if not present
  42237. */
  42238. getExternalData<T>(key: string): Nullable<T>;
  42239. /**
  42240. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42241. * @param key the unique key that identifies the data
  42242. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42243. * @return the associated data, can be null if the factory returned null.
  42244. */
  42245. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42246. /**
  42247. * Remove an externaly attached data from the Engine instance
  42248. * @param key the unique key that identifies the data
  42249. * @return true if the data was successfully removed, false if it doesn't exist
  42250. */
  42251. removeExternalData(key: string): boolean;
  42252. private _evaluateSubMesh;
  42253. /**
  42254. * Clear the processed materials smart array preventing retention point in material dispose.
  42255. */
  42256. freeProcessedMaterials(): void;
  42257. private _preventFreeActiveMeshesAndRenderingGroups;
  42258. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42259. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42260. * when disposing several meshes in a row or a hierarchy of meshes.
  42261. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42262. */
  42263. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42264. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42265. /**
  42266. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42267. */
  42268. freeActiveMeshes(): void;
  42269. /**
  42270. * Clear the info related to rendering groups preventing retention points during dispose.
  42271. */
  42272. freeRenderingGroups(): void;
  42273. /** @hidden */
  42274. _isInIntermediateRendering(): boolean;
  42275. /**
  42276. * Lambda returning the list of potentially active meshes.
  42277. */
  42278. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42279. /**
  42280. * Lambda returning the list of potentially active sub meshes.
  42281. */
  42282. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42283. /**
  42284. * Lambda returning the list of potentially intersecting sub meshes.
  42285. */
  42286. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42287. /**
  42288. * Lambda returning the list of potentially colliding sub meshes.
  42289. */
  42290. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42291. private _activeMeshesFrozen;
  42292. private _skipEvaluateActiveMeshesCompletely;
  42293. /**
  42294. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42295. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42296. * @returns the current scene
  42297. */
  42298. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42299. /**
  42300. * Use this function to restart evaluating active meshes on every frame
  42301. * @returns the current scene
  42302. */
  42303. unfreezeActiveMeshes(): Scene;
  42304. private _evaluateActiveMeshes;
  42305. private _activeMesh;
  42306. /**
  42307. * Update the transform matrix to update from the current active camera
  42308. * @param force defines a boolean used to force the update even if cache is up to date
  42309. */
  42310. updateTransformMatrix(force?: boolean): void;
  42311. private _bindFrameBuffer;
  42312. /** @hidden */
  42313. _allowPostProcessClearColor: boolean;
  42314. /** @hidden */
  42315. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42316. private _processSubCameras;
  42317. private _checkIntersections;
  42318. /** @hidden */
  42319. _advancePhysicsEngineStep(step: number): void;
  42320. /**
  42321. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42322. */
  42323. getDeterministicFrameTime: () => number;
  42324. /** @hidden */
  42325. _animate(): void;
  42326. /** Execute all animations (for a frame) */
  42327. animate(): void;
  42328. /**
  42329. * Render the scene
  42330. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42331. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42332. */
  42333. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42334. /**
  42335. * Freeze all materials
  42336. * A frozen material will not be updatable but should be faster to render
  42337. */
  42338. freezeMaterials(): void;
  42339. /**
  42340. * Unfreeze all materials
  42341. * A frozen material will not be updatable but should be faster to render
  42342. */
  42343. unfreezeMaterials(): void;
  42344. /**
  42345. * Releases all held ressources
  42346. */
  42347. dispose(): void;
  42348. /**
  42349. * Gets if the scene is already disposed
  42350. */
  42351. get isDisposed(): boolean;
  42352. /**
  42353. * Call this function to reduce memory footprint of the scene.
  42354. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42355. */
  42356. clearCachedVertexData(): void;
  42357. /**
  42358. * This function will remove the local cached buffer data from texture.
  42359. * It will save memory but will prevent the texture from being rebuilt
  42360. */
  42361. cleanCachedTextureBuffer(): void;
  42362. /**
  42363. * Get the world extend vectors with an optional filter
  42364. *
  42365. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42366. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42367. */
  42368. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42369. min: Vector3;
  42370. max: Vector3;
  42371. };
  42372. /**
  42373. * Creates a ray that can be used to pick in the scene
  42374. * @param x defines the x coordinate of the origin (on-screen)
  42375. * @param y defines the y coordinate of the origin (on-screen)
  42376. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42377. * @param camera defines the camera to use for the picking
  42378. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42379. * @returns a Ray
  42380. */
  42381. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42382. /**
  42383. * Creates a ray that can be used to pick in the scene
  42384. * @param x defines the x coordinate of the origin (on-screen)
  42385. * @param y defines the y coordinate of the origin (on-screen)
  42386. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42387. * @param result defines the ray where to store the picking ray
  42388. * @param camera defines the camera to use for the picking
  42389. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42390. * @returns the current scene
  42391. */
  42392. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42393. /**
  42394. * Creates a ray that can be used to pick in the scene
  42395. * @param x defines the x coordinate of the origin (on-screen)
  42396. * @param y defines the y coordinate of the origin (on-screen)
  42397. * @param camera defines the camera to use for the picking
  42398. * @returns a Ray
  42399. */
  42400. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42401. /**
  42402. * Creates a ray that can be used to pick in the scene
  42403. * @param x defines the x coordinate of the origin (on-screen)
  42404. * @param y defines the y coordinate of the origin (on-screen)
  42405. * @param result defines the ray where to store the picking ray
  42406. * @param camera defines the camera to use for the picking
  42407. * @returns the current scene
  42408. */
  42409. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42410. /** Launch a ray to try to pick a mesh in the scene
  42411. * @param x position on screen
  42412. * @param y position on screen
  42413. * @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
  42414. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42415. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42416. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42417. * @returns a PickingInfo
  42418. */
  42419. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42420. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42421. * @param x position on screen
  42422. * @param y position on screen
  42423. * @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
  42424. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42425. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42426. * @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)
  42427. */
  42428. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42429. /** Use the given ray to pick a mesh in the scene
  42430. * @param ray The ray to use to pick meshes
  42431. * @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
  42432. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42434. * @returns a PickingInfo
  42435. */
  42436. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42437. /**
  42438. * Launch a ray to try to pick a mesh in the scene
  42439. * @param x X position on screen
  42440. * @param y Y position on screen
  42441. * @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
  42442. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42443. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42444. * @returns an array of PickingInfo
  42445. */
  42446. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42447. /**
  42448. * Launch a ray to try to pick a mesh in the scene
  42449. * @param ray Ray to use
  42450. * @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
  42451. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42452. * @returns an array of PickingInfo
  42453. */
  42454. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42455. /**
  42456. * Force the value of meshUnderPointer
  42457. * @param mesh defines the mesh to use
  42458. */
  42459. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42460. /**
  42461. * Gets the mesh under the pointer
  42462. * @returns a Mesh or null if no mesh is under the pointer
  42463. */
  42464. getPointerOverMesh(): Nullable<AbstractMesh>;
  42465. /** @hidden */
  42466. _rebuildGeometries(): void;
  42467. /** @hidden */
  42468. _rebuildTextures(): void;
  42469. private _getByTags;
  42470. /**
  42471. * Get a list of meshes by tags
  42472. * @param tagsQuery defines the tags query to use
  42473. * @param forEach defines a predicate used to filter results
  42474. * @returns an array of Mesh
  42475. */
  42476. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42477. /**
  42478. * Get a list of cameras by tags
  42479. * @param tagsQuery defines the tags query to use
  42480. * @param forEach defines a predicate used to filter results
  42481. * @returns an array of Camera
  42482. */
  42483. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42484. /**
  42485. * Get a list of lights by tags
  42486. * @param tagsQuery defines the tags query to use
  42487. * @param forEach defines a predicate used to filter results
  42488. * @returns an array of Light
  42489. */
  42490. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42491. /**
  42492. * Get a list of materials by tags
  42493. * @param tagsQuery defines the tags query to use
  42494. * @param forEach defines a predicate used to filter results
  42495. * @returns an array of Material
  42496. */
  42497. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42498. /**
  42499. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42500. * This allowed control for front to back rendering or reversly depending of the special needs.
  42501. *
  42502. * @param renderingGroupId The rendering group id corresponding to its index
  42503. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42504. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42505. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42506. */
  42507. 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;
  42508. /**
  42509. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42510. *
  42511. * @param renderingGroupId The rendering group id corresponding to its index
  42512. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42513. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42514. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42515. */
  42516. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42517. /**
  42518. * Gets the current auto clear configuration for one rendering group of the rendering
  42519. * manager.
  42520. * @param index the rendering group index to get the information for
  42521. * @returns The auto clear setup for the requested rendering group
  42522. */
  42523. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42524. private _blockMaterialDirtyMechanism;
  42525. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42526. get blockMaterialDirtyMechanism(): boolean;
  42527. set blockMaterialDirtyMechanism(value: boolean);
  42528. /**
  42529. * Will flag all materials as dirty to trigger new shader compilation
  42530. * @param flag defines the flag used to specify which material part must be marked as dirty
  42531. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42532. */
  42533. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42534. /** @hidden */
  42535. _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;
  42536. /** @hidden */
  42537. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42538. /** @hidden */
  42539. _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;
  42540. /** @hidden */
  42541. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42542. /** @hidden */
  42543. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42544. /** @hidden */
  42545. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42546. }
  42547. }
  42548. declare module "babylonjs/assetContainer" {
  42549. import { AbstractScene } from "babylonjs/abstractScene";
  42550. import { Scene } from "babylonjs/scene";
  42551. import { Mesh } from "babylonjs/Meshes/mesh";
  42552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42553. import { Skeleton } from "babylonjs/Bones/skeleton";
  42554. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42555. import { Animatable } from "babylonjs/Animations/animatable";
  42556. import { Nullable } from "babylonjs/types";
  42557. import { Node } from "babylonjs/node";
  42558. /**
  42559. * Set of assets to keep when moving a scene into an asset container.
  42560. */
  42561. export class KeepAssets extends AbstractScene {
  42562. }
  42563. /**
  42564. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42565. */
  42566. export class InstantiatedEntries {
  42567. /**
  42568. * List of new root nodes (eg. nodes with no parent)
  42569. */
  42570. rootNodes: TransformNode[];
  42571. /**
  42572. * List of new skeletons
  42573. */
  42574. skeletons: Skeleton[];
  42575. /**
  42576. * List of new animation groups
  42577. */
  42578. animationGroups: AnimationGroup[];
  42579. }
  42580. /**
  42581. * Container with a set of assets that can be added or removed from a scene.
  42582. */
  42583. export class AssetContainer extends AbstractScene {
  42584. private _wasAddedToScene;
  42585. /**
  42586. * The scene the AssetContainer belongs to.
  42587. */
  42588. scene: Scene;
  42589. /**
  42590. * Instantiates an AssetContainer.
  42591. * @param scene The scene the AssetContainer belongs to.
  42592. */
  42593. constructor(scene: Scene);
  42594. /**
  42595. * Instantiate or clone all meshes and add the new ones to the scene.
  42596. * Skeletons and animation groups will all be cloned
  42597. * @param nameFunction defines an optional function used to get new names for clones
  42598. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42599. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42600. */
  42601. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42602. /**
  42603. * Adds all the assets from the container to the scene.
  42604. */
  42605. addAllToScene(): void;
  42606. /**
  42607. * Removes all the assets in the container from the scene
  42608. */
  42609. removeAllFromScene(): void;
  42610. /**
  42611. * Disposes all the assets in the container
  42612. */
  42613. dispose(): void;
  42614. private _moveAssets;
  42615. /**
  42616. * Removes all the assets contained in the scene and adds them to the container.
  42617. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42618. */
  42619. moveAllFromScene(keepAssets?: KeepAssets): void;
  42620. /**
  42621. * 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.
  42622. * @returns the root mesh
  42623. */
  42624. createRootMesh(): Mesh;
  42625. /**
  42626. * Merge animations (direct and animation groups) from this asset container into a scene
  42627. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42628. * @param animatables set of animatables to retarget to a node from the scene
  42629. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42630. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42631. */
  42632. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42633. }
  42634. }
  42635. declare module "babylonjs/abstractScene" {
  42636. import { Scene } from "babylonjs/scene";
  42637. import { Nullable } from "babylonjs/types";
  42638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42639. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42640. import { Geometry } from "babylonjs/Meshes/geometry";
  42641. import { Skeleton } from "babylonjs/Bones/skeleton";
  42642. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42643. import { AssetContainer } from "babylonjs/assetContainer";
  42644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42645. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42646. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42647. import { Material } from "babylonjs/Materials/material";
  42648. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42649. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42650. import { Camera } from "babylonjs/Cameras/camera";
  42651. import { Light } from "babylonjs/Lights/light";
  42652. import { Node } from "babylonjs/node";
  42653. import { Animation } from "babylonjs/Animations/animation";
  42654. /**
  42655. * Defines how the parser contract is defined.
  42656. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42657. */
  42658. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42659. /**
  42660. * Defines how the individual parser contract is defined.
  42661. * These parser can parse an individual asset
  42662. */
  42663. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42664. /**
  42665. * Base class of the scene acting as a container for the different elements composing a scene.
  42666. * This class is dynamically extended by the different components of the scene increasing
  42667. * flexibility and reducing coupling
  42668. */
  42669. export abstract class AbstractScene {
  42670. /**
  42671. * Stores the list of available parsers in the application.
  42672. */
  42673. private static _BabylonFileParsers;
  42674. /**
  42675. * Stores the list of available individual parsers in the application.
  42676. */
  42677. private static _IndividualBabylonFileParsers;
  42678. /**
  42679. * Adds a parser in the list of available ones
  42680. * @param name Defines the name of the parser
  42681. * @param parser Defines the parser to add
  42682. */
  42683. static AddParser(name: string, parser: BabylonFileParser): void;
  42684. /**
  42685. * Gets a general parser from the list of avaialble ones
  42686. * @param name Defines the name of the parser
  42687. * @returns the requested parser or null
  42688. */
  42689. static GetParser(name: string): Nullable<BabylonFileParser>;
  42690. /**
  42691. * Adds n individual parser in the list of available ones
  42692. * @param name Defines the name of the parser
  42693. * @param parser Defines the parser to add
  42694. */
  42695. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42696. /**
  42697. * Gets an individual parser from the list of avaialble ones
  42698. * @param name Defines the name of the parser
  42699. * @returns the requested parser or null
  42700. */
  42701. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42702. /**
  42703. * Parser json data and populate both a scene and its associated container object
  42704. * @param jsonData Defines the data to parse
  42705. * @param scene Defines the scene to parse the data for
  42706. * @param container Defines the container attached to the parsing sequence
  42707. * @param rootUrl Defines the root url of the data
  42708. */
  42709. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42710. /**
  42711. * Gets the list of root nodes (ie. nodes with no parent)
  42712. */
  42713. rootNodes: Node[];
  42714. /** All of the cameras added to this scene
  42715. * @see https://doc.babylonjs.com/babylon101/cameras
  42716. */
  42717. cameras: Camera[];
  42718. /**
  42719. * All of the lights added to this scene
  42720. * @see https://doc.babylonjs.com/babylon101/lights
  42721. */
  42722. lights: Light[];
  42723. /**
  42724. * All of the (abstract) meshes added to this scene
  42725. */
  42726. meshes: AbstractMesh[];
  42727. /**
  42728. * The list of skeletons added to the scene
  42729. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42730. */
  42731. skeletons: Skeleton[];
  42732. /**
  42733. * All of the particle systems added to this scene
  42734. * @see https://doc.babylonjs.com/babylon101/particles
  42735. */
  42736. particleSystems: IParticleSystem[];
  42737. /**
  42738. * Gets a list of Animations associated with the scene
  42739. */
  42740. animations: Animation[];
  42741. /**
  42742. * All of the animation groups added to this scene
  42743. * @see https://doc.babylonjs.com/how_to/group
  42744. */
  42745. animationGroups: AnimationGroup[];
  42746. /**
  42747. * All of the multi-materials added to this scene
  42748. * @see https://doc.babylonjs.com/how_to/multi_materials
  42749. */
  42750. multiMaterials: MultiMaterial[];
  42751. /**
  42752. * All of the materials added to this scene
  42753. * In the context of a Scene, it is not supposed to be modified manually.
  42754. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42755. * Note also that the order of the Material within the array is not significant and might change.
  42756. * @see https://doc.babylonjs.com/babylon101/materials
  42757. */
  42758. materials: Material[];
  42759. /**
  42760. * The list of morph target managers added to the scene
  42761. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42762. */
  42763. morphTargetManagers: MorphTargetManager[];
  42764. /**
  42765. * The list of geometries used in the scene.
  42766. */
  42767. geometries: Geometry[];
  42768. /**
  42769. * All of the tranform nodes added to this scene
  42770. * In the context of a Scene, it is not supposed to be modified manually.
  42771. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42772. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42773. * @see https://doc.babylonjs.com/how_to/transformnode
  42774. */
  42775. transformNodes: TransformNode[];
  42776. /**
  42777. * ActionManagers available on the scene.
  42778. */
  42779. actionManagers: AbstractActionManager[];
  42780. /**
  42781. * Textures to keep.
  42782. */
  42783. textures: BaseTexture[];
  42784. /**
  42785. * Environment texture for the scene
  42786. */
  42787. environmentTexture: Nullable<BaseTexture>;
  42788. /**
  42789. * The list of postprocesses added to the scene
  42790. */
  42791. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42792. /**
  42793. * @returns all meshes, lights, cameras, transformNodes and bones
  42794. */
  42795. getNodes(): Array<Node>;
  42796. }
  42797. }
  42798. declare module "babylonjs/Audio/sound" {
  42799. import { Observable } from "babylonjs/Misc/observable";
  42800. import { Vector3 } from "babylonjs/Maths/math.vector";
  42801. import { Nullable } from "babylonjs/types";
  42802. import { Scene } from "babylonjs/scene";
  42803. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42804. /**
  42805. * Interface used to define options for Sound class
  42806. */
  42807. export interface ISoundOptions {
  42808. /**
  42809. * Does the sound autoplay once loaded.
  42810. */
  42811. autoplay?: boolean;
  42812. /**
  42813. * Does the sound loop after it finishes playing once.
  42814. */
  42815. loop?: boolean;
  42816. /**
  42817. * Sound's volume
  42818. */
  42819. volume?: number;
  42820. /**
  42821. * Is it a spatial sound?
  42822. */
  42823. spatialSound?: boolean;
  42824. /**
  42825. * Maximum distance to hear that sound
  42826. */
  42827. maxDistance?: number;
  42828. /**
  42829. * Uses user defined attenuation function
  42830. */
  42831. useCustomAttenuation?: boolean;
  42832. /**
  42833. * Define the roll off factor of spatial sounds.
  42834. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42835. */
  42836. rolloffFactor?: number;
  42837. /**
  42838. * Define the reference distance the sound should be heard perfectly.
  42839. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42840. */
  42841. refDistance?: number;
  42842. /**
  42843. * Define the distance attenuation model the sound will follow.
  42844. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42845. */
  42846. distanceModel?: string;
  42847. /**
  42848. * Defines the playback speed (1 by default)
  42849. */
  42850. playbackRate?: number;
  42851. /**
  42852. * Defines if the sound is from a streaming source
  42853. */
  42854. streaming?: boolean;
  42855. /**
  42856. * Defines an optional length (in seconds) inside the sound file
  42857. */
  42858. length?: number;
  42859. /**
  42860. * Defines an optional offset (in seconds) inside the sound file
  42861. */
  42862. offset?: number;
  42863. /**
  42864. * If true, URLs will not be required to state the audio file codec to use.
  42865. */
  42866. skipCodecCheck?: boolean;
  42867. }
  42868. /**
  42869. * Defines a sound that can be played in the application.
  42870. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42871. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42872. */
  42873. export class Sound {
  42874. /**
  42875. * The name of the sound in the scene.
  42876. */
  42877. name: string;
  42878. /**
  42879. * Does the sound autoplay once loaded.
  42880. */
  42881. autoplay: boolean;
  42882. /**
  42883. * Does the sound loop after it finishes playing once.
  42884. */
  42885. loop: boolean;
  42886. /**
  42887. * Does the sound use a custom attenuation curve to simulate the falloff
  42888. * happening when the source gets further away from the camera.
  42889. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42890. */
  42891. useCustomAttenuation: boolean;
  42892. /**
  42893. * The sound track id this sound belongs to.
  42894. */
  42895. soundTrackId: number;
  42896. /**
  42897. * Is this sound currently played.
  42898. */
  42899. isPlaying: boolean;
  42900. /**
  42901. * Is this sound currently paused.
  42902. */
  42903. isPaused: boolean;
  42904. /**
  42905. * Does this sound enables spatial sound.
  42906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42907. */
  42908. spatialSound: boolean;
  42909. /**
  42910. * Define the reference distance the sound should be heard perfectly.
  42911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42912. */
  42913. refDistance: number;
  42914. /**
  42915. * Define the roll off factor of spatial sounds.
  42916. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42917. */
  42918. rolloffFactor: number;
  42919. /**
  42920. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42921. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42922. */
  42923. maxDistance: number;
  42924. /**
  42925. * Define the distance attenuation model the sound will follow.
  42926. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42927. */
  42928. distanceModel: string;
  42929. /**
  42930. * @hidden
  42931. * Back Compat
  42932. **/
  42933. onended: () => any;
  42934. /**
  42935. * Gets or sets an object used to store user defined information for the sound.
  42936. */
  42937. metadata: any;
  42938. /**
  42939. * Observable event when the current playing sound finishes.
  42940. */
  42941. onEndedObservable: Observable<Sound>;
  42942. private _panningModel;
  42943. private _playbackRate;
  42944. private _streaming;
  42945. private _startTime;
  42946. private _startOffset;
  42947. private _position;
  42948. /** @hidden */
  42949. _positionInEmitterSpace: boolean;
  42950. private _localDirection;
  42951. private _volume;
  42952. private _isReadyToPlay;
  42953. private _isDirectional;
  42954. private _readyToPlayCallback;
  42955. private _audioBuffer;
  42956. private _soundSource;
  42957. private _streamingSource;
  42958. private _soundPanner;
  42959. private _soundGain;
  42960. private _inputAudioNode;
  42961. private _outputAudioNode;
  42962. private _coneInnerAngle;
  42963. private _coneOuterAngle;
  42964. private _coneOuterGain;
  42965. private _scene;
  42966. private _connectedTransformNode;
  42967. private _customAttenuationFunction;
  42968. private _registerFunc;
  42969. private _isOutputConnected;
  42970. private _htmlAudioElement;
  42971. private _urlType;
  42972. private _length?;
  42973. private _offset?;
  42974. /** @hidden */
  42975. static _SceneComponentInitialization: (scene: Scene) => void;
  42976. /**
  42977. * Create a sound and attach it to a scene
  42978. * @param name Name of your sound
  42979. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42980. * @param scene defines the scene the sound belongs to
  42981. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42982. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42983. */
  42984. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42985. /**
  42986. * Release the sound and its associated resources
  42987. */
  42988. dispose(): void;
  42989. /**
  42990. * Gets if the sounds is ready to be played or not.
  42991. * @returns true if ready, otherwise false
  42992. */
  42993. isReady(): boolean;
  42994. private _soundLoaded;
  42995. /**
  42996. * Sets the data of the sound from an audiobuffer
  42997. * @param audioBuffer The audioBuffer containing the data
  42998. */
  42999. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43000. /**
  43001. * Updates the current sounds options such as maxdistance, loop...
  43002. * @param options A JSON object containing values named as the object properties
  43003. */
  43004. updateOptions(options: ISoundOptions): void;
  43005. private _createSpatialParameters;
  43006. private _updateSpatialParameters;
  43007. /**
  43008. * Switch the panning model to HRTF:
  43009. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43011. */
  43012. switchPanningModelToHRTF(): void;
  43013. /**
  43014. * Switch the panning model to Equal Power:
  43015. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43017. */
  43018. switchPanningModelToEqualPower(): void;
  43019. private _switchPanningModel;
  43020. /**
  43021. * Connect this sound to a sound track audio node like gain...
  43022. * @param soundTrackAudioNode the sound track audio node to connect to
  43023. */
  43024. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43025. /**
  43026. * Transform this sound into a directional source
  43027. * @param coneInnerAngle Size of the inner cone in degree
  43028. * @param coneOuterAngle Size of the outer cone in degree
  43029. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43030. */
  43031. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43032. /**
  43033. * Gets or sets the inner angle for the directional cone.
  43034. */
  43035. get directionalConeInnerAngle(): number;
  43036. /**
  43037. * Gets or sets the inner angle for the directional cone.
  43038. */
  43039. set directionalConeInnerAngle(value: number);
  43040. /**
  43041. * Gets or sets the outer angle for the directional cone.
  43042. */
  43043. get directionalConeOuterAngle(): number;
  43044. /**
  43045. * Gets or sets the outer angle for the directional cone.
  43046. */
  43047. set directionalConeOuterAngle(value: number);
  43048. /**
  43049. * Sets the position of the emitter if spatial sound is enabled
  43050. * @param newPosition Defines the new posisiton
  43051. */
  43052. setPosition(newPosition: Vector3): void;
  43053. /**
  43054. * Sets the local direction of the emitter if spatial sound is enabled
  43055. * @param newLocalDirection Defines the new local direction
  43056. */
  43057. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43058. private _updateDirection;
  43059. /** @hidden */
  43060. updateDistanceFromListener(): void;
  43061. /**
  43062. * Sets a new custom attenuation function for the sound.
  43063. * @param callback Defines the function used for the attenuation
  43064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43065. */
  43066. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43067. /**
  43068. * Play the sound
  43069. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43070. * @param offset (optional) Start the sound at a specific time in seconds
  43071. * @param length (optional) Sound duration (in seconds)
  43072. */
  43073. play(time?: number, offset?: number, length?: number): void;
  43074. private _onended;
  43075. /**
  43076. * Stop the sound
  43077. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43078. */
  43079. stop(time?: number): void;
  43080. /**
  43081. * Put the sound in pause
  43082. */
  43083. pause(): void;
  43084. /**
  43085. * Sets a dedicated volume for this sounds
  43086. * @param newVolume Define the new volume of the sound
  43087. * @param time Define time for gradual change to new volume
  43088. */
  43089. setVolume(newVolume: number, time?: number): void;
  43090. /**
  43091. * Set the sound play back rate
  43092. * @param newPlaybackRate Define the playback rate the sound should be played at
  43093. */
  43094. setPlaybackRate(newPlaybackRate: number): void;
  43095. /**
  43096. * Gets the volume of the sound.
  43097. * @returns the volume of the sound
  43098. */
  43099. getVolume(): number;
  43100. /**
  43101. * Attach the sound to a dedicated mesh
  43102. * @param transformNode The transform node to connect the sound with
  43103. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43104. */
  43105. attachToMesh(transformNode: TransformNode): void;
  43106. /**
  43107. * Detach the sound from the previously attached mesh
  43108. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43109. */
  43110. detachFromMesh(): void;
  43111. private _onRegisterAfterWorldMatrixUpdate;
  43112. /**
  43113. * Clone the current sound in the scene.
  43114. * @returns the new sound clone
  43115. */
  43116. clone(): Nullable<Sound>;
  43117. /**
  43118. * Gets the current underlying audio buffer containing the data
  43119. * @returns the audio buffer
  43120. */
  43121. getAudioBuffer(): Nullable<AudioBuffer>;
  43122. /**
  43123. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43124. * @returns the source node
  43125. */
  43126. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43127. /**
  43128. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43129. * @returns the gain node
  43130. */
  43131. getSoundGain(): Nullable<GainNode>;
  43132. /**
  43133. * Serializes the Sound in a JSON representation
  43134. * @returns the JSON representation of the sound
  43135. */
  43136. serialize(): any;
  43137. /**
  43138. * Parse a JSON representation of a sound to innstantiate in a given scene
  43139. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43140. * @param scene Define the scene the new parsed sound should be created in
  43141. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43142. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43143. * @returns the newly parsed sound
  43144. */
  43145. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43146. }
  43147. }
  43148. declare module "babylonjs/Actions/directAudioActions" {
  43149. import { Action } from "babylonjs/Actions/action";
  43150. import { Condition } from "babylonjs/Actions/condition";
  43151. import { Sound } from "babylonjs/Audio/sound";
  43152. /**
  43153. * This defines an action helpful to play a defined sound on a triggered action.
  43154. */
  43155. export class PlaySoundAction extends Action {
  43156. private _sound;
  43157. /**
  43158. * Instantiate the action
  43159. * @param triggerOptions defines the trigger options
  43160. * @param sound defines the sound to play
  43161. * @param condition defines the trigger related conditions
  43162. */
  43163. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43164. /** @hidden */
  43165. _prepare(): void;
  43166. /**
  43167. * Execute the action and play the sound.
  43168. */
  43169. execute(): void;
  43170. /**
  43171. * Serializes the actions and its related information.
  43172. * @param parent defines the object to serialize in
  43173. * @returns the serialized object
  43174. */
  43175. serialize(parent: any): any;
  43176. }
  43177. /**
  43178. * This defines an action helpful to stop a defined sound on a triggered action.
  43179. */
  43180. export class StopSoundAction extends Action {
  43181. private _sound;
  43182. /**
  43183. * Instantiate the action
  43184. * @param triggerOptions defines the trigger options
  43185. * @param sound defines the sound to stop
  43186. * @param condition defines the trigger related conditions
  43187. */
  43188. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43189. /** @hidden */
  43190. _prepare(): void;
  43191. /**
  43192. * Execute the action and stop the sound.
  43193. */
  43194. execute(): void;
  43195. /**
  43196. * Serializes the actions and its related information.
  43197. * @param parent defines the object to serialize in
  43198. * @returns the serialized object
  43199. */
  43200. serialize(parent: any): any;
  43201. }
  43202. }
  43203. declare module "babylonjs/Actions/interpolateValueAction" {
  43204. import { Action } from "babylonjs/Actions/action";
  43205. import { Condition } from "babylonjs/Actions/condition";
  43206. import { Observable } from "babylonjs/Misc/observable";
  43207. /**
  43208. * This defines an action responsible to change the value of a property
  43209. * by interpolating between its current value and the newly set one once triggered.
  43210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43211. */
  43212. export class InterpolateValueAction extends Action {
  43213. /**
  43214. * Defines the path of the property where the value should be interpolated
  43215. */
  43216. propertyPath: string;
  43217. /**
  43218. * Defines the target value at the end of the interpolation.
  43219. */
  43220. value: any;
  43221. /**
  43222. * Defines the time it will take for the property to interpolate to the value.
  43223. */
  43224. duration: number;
  43225. /**
  43226. * Defines if the other scene animations should be stopped when the action has been triggered
  43227. */
  43228. stopOtherAnimations?: boolean;
  43229. /**
  43230. * Defines a callback raised once the interpolation animation has been done.
  43231. */
  43232. onInterpolationDone?: () => void;
  43233. /**
  43234. * Observable triggered once the interpolation animation has been done.
  43235. */
  43236. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43237. private _target;
  43238. private _effectiveTarget;
  43239. private _property;
  43240. /**
  43241. * Instantiate the action
  43242. * @param triggerOptions defines the trigger options
  43243. * @param target defines the object containing the value to interpolate
  43244. * @param propertyPath defines the path to the property in the target object
  43245. * @param value defines the target value at the end of the interpolation
  43246. * @param duration deines the time it will take for the property to interpolate to the value.
  43247. * @param condition defines the trigger related conditions
  43248. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43249. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43250. */
  43251. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43252. /** @hidden */
  43253. _prepare(): void;
  43254. /**
  43255. * Execute the action starts the value interpolation.
  43256. */
  43257. execute(): void;
  43258. /**
  43259. * Serializes the actions and its related information.
  43260. * @param parent defines the object to serialize in
  43261. * @returns the serialized object
  43262. */
  43263. serialize(parent: any): any;
  43264. }
  43265. }
  43266. declare module "babylonjs/Actions/index" {
  43267. export * from "babylonjs/Actions/abstractActionManager";
  43268. export * from "babylonjs/Actions/action";
  43269. export * from "babylonjs/Actions/actionEvent";
  43270. export * from "babylonjs/Actions/actionManager";
  43271. export * from "babylonjs/Actions/condition";
  43272. export * from "babylonjs/Actions/directActions";
  43273. export * from "babylonjs/Actions/directAudioActions";
  43274. export * from "babylonjs/Actions/interpolateValueAction";
  43275. }
  43276. declare module "babylonjs/Animations/index" {
  43277. export * from "babylonjs/Animations/animatable";
  43278. export * from "babylonjs/Animations/animation";
  43279. export * from "babylonjs/Animations/animationGroup";
  43280. export * from "babylonjs/Animations/animationPropertiesOverride";
  43281. export * from "babylonjs/Animations/easing";
  43282. export * from "babylonjs/Animations/runtimeAnimation";
  43283. export * from "babylonjs/Animations/animationEvent";
  43284. export * from "babylonjs/Animations/animationGroup";
  43285. export * from "babylonjs/Animations/animationKey";
  43286. export * from "babylonjs/Animations/animationRange";
  43287. export * from "babylonjs/Animations/animatable.interface";
  43288. }
  43289. declare module "babylonjs/Audio/soundTrack" {
  43290. import { Sound } from "babylonjs/Audio/sound";
  43291. import { Analyser } from "babylonjs/Audio/analyser";
  43292. import { Scene } from "babylonjs/scene";
  43293. /**
  43294. * Options allowed during the creation of a sound track.
  43295. */
  43296. export interface ISoundTrackOptions {
  43297. /**
  43298. * The volume the sound track should take during creation
  43299. */
  43300. volume?: number;
  43301. /**
  43302. * Define if the sound track is the main sound track of the scene
  43303. */
  43304. mainTrack?: boolean;
  43305. }
  43306. /**
  43307. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43308. * It will be also used in a future release to apply effects on a specific track.
  43309. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43310. */
  43311. export class SoundTrack {
  43312. /**
  43313. * The unique identifier of the sound track in the scene.
  43314. */
  43315. id: number;
  43316. /**
  43317. * The list of sounds included in the sound track.
  43318. */
  43319. soundCollection: Array<Sound>;
  43320. private _outputAudioNode;
  43321. private _scene;
  43322. private _connectedAnalyser;
  43323. private _options;
  43324. private _isInitialized;
  43325. /**
  43326. * Creates a new sound track.
  43327. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43328. * @param scene Define the scene the sound track belongs to
  43329. * @param options
  43330. */
  43331. constructor(scene: Scene, options?: ISoundTrackOptions);
  43332. private _initializeSoundTrackAudioGraph;
  43333. /**
  43334. * Release the sound track and its associated resources
  43335. */
  43336. dispose(): void;
  43337. /**
  43338. * Adds a sound to this sound track
  43339. * @param sound define the cound to add
  43340. * @ignoreNaming
  43341. */
  43342. AddSound(sound: Sound): void;
  43343. /**
  43344. * Removes a sound to this sound track
  43345. * @param sound define the cound to remove
  43346. * @ignoreNaming
  43347. */
  43348. RemoveSound(sound: Sound): void;
  43349. /**
  43350. * Set a global volume for the full sound track.
  43351. * @param newVolume Define the new volume of the sound track
  43352. */
  43353. setVolume(newVolume: number): void;
  43354. /**
  43355. * Switch the panning model to HRTF:
  43356. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43357. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43358. */
  43359. switchPanningModelToHRTF(): void;
  43360. /**
  43361. * Switch the panning model to Equal Power:
  43362. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43364. */
  43365. switchPanningModelToEqualPower(): void;
  43366. /**
  43367. * Connect the sound track to an audio analyser allowing some amazing
  43368. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43369. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43370. * @param analyser The analyser to connect to the engine
  43371. */
  43372. connectToAnalyser(analyser: Analyser): void;
  43373. }
  43374. }
  43375. declare module "babylonjs/Audio/audioSceneComponent" {
  43376. import { Sound } from "babylonjs/Audio/sound";
  43377. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43378. import { Nullable } from "babylonjs/types";
  43379. import { Vector3 } from "babylonjs/Maths/math.vector";
  43380. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43381. import { Scene } from "babylonjs/scene";
  43382. import { AbstractScene } from "babylonjs/abstractScene";
  43383. import "babylonjs/Audio/audioEngine";
  43384. module "babylonjs/abstractScene" {
  43385. interface AbstractScene {
  43386. /**
  43387. * The list of sounds used in the scene.
  43388. */
  43389. sounds: Nullable<Array<Sound>>;
  43390. }
  43391. }
  43392. module "babylonjs/scene" {
  43393. interface Scene {
  43394. /**
  43395. * @hidden
  43396. * Backing field
  43397. */
  43398. _mainSoundTrack: SoundTrack;
  43399. /**
  43400. * The main sound track played by the scene.
  43401. * It cotains your primary collection of sounds.
  43402. */
  43403. mainSoundTrack: SoundTrack;
  43404. /**
  43405. * The list of sound tracks added to the scene
  43406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43407. */
  43408. soundTracks: Nullable<Array<SoundTrack>>;
  43409. /**
  43410. * Gets a sound using a given name
  43411. * @param name defines the name to search for
  43412. * @return the found sound or null if not found at all.
  43413. */
  43414. getSoundByName(name: string): Nullable<Sound>;
  43415. /**
  43416. * Gets or sets if audio support is enabled
  43417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43418. */
  43419. audioEnabled: boolean;
  43420. /**
  43421. * Gets or sets if audio will be output to headphones
  43422. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43423. */
  43424. headphone: boolean;
  43425. /**
  43426. * Gets or sets custom audio listener position provider
  43427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43428. */
  43429. audioListenerPositionProvider: Nullable<() => Vector3>;
  43430. /**
  43431. * Gets or sets a refresh rate when using 3D audio positioning
  43432. */
  43433. audioPositioningRefreshRate: number;
  43434. }
  43435. }
  43436. /**
  43437. * Defines the sound scene component responsible to manage any sounds
  43438. * in a given scene.
  43439. */
  43440. export class AudioSceneComponent implements ISceneSerializableComponent {
  43441. /**
  43442. * The component name helpfull to identify the component in the list of scene components.
  43443. */
  43444. readonly name: string;
  43445. /**
  43446. * The scene the component belongs to.
  43447. */
  43448. scene: Scene;
  43449. private _audioEnabled;
  43450. /**
  43451. * Gets whether audio is enabled or not.
  43452. * Please use related enable/disable method to switch state.
  43453. */
  43454. get audioEnabled(): boolean;
  43455. private _headphone;
  43456. /**
  43457. * Gets whether audio is outputing to headphone or not.
  43458. * Please use the according Switch methods to change output.
  43459. */
  43460. get headphone(): boolean;
  43461. /**
  43462. * Gets or sets a refresh rate when using 3D audio positioning
  43463. */
  43464. audioPositioningRefreshRate: number;
  43465. private _audioListenerPositionProvider;
  43466. /**
  43467. * Gets the current audio listener position provider
  43468. */
  43469. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43470. /**
  43471. * Sets a custom listener position for all sounds in the scene
  43472. * By default, this is the position of the first active camera
  43473. */
  43474. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43475. /**
  43476. * Creates a new instance of the component for the given scene
  43477. * @param scene Defines the scene to register the component in
  43478. */
  43479. constructor(scene: Scene);
  43480. /**
  43481. * Registers the component in a given scene
  43482. */
  43483. register(): void;
  43484. /**
  43485. * Rebuilds the elements related to this component in case of
  43486. * context lost for instance.
  43487. */
  43488. rebuild(): void;
  43489. /**
  43490. * Serializes the component data to the specified json object
  43491. * @param serializationObject The object to serialize to
  43492. */
  43493. serialize(serializationObject: any): void;
  43494. /**
  43495. * Adds all the elements from the container to the scene
  43496. * @param container the container holding the elements
  43497. */
  43498. addFromContainer(container: AbstractScene): void;
  43499. /**
  43500. * Removes all the elements in the container from the scene
  43501. * @param container contains the elements to remove
  43502. * @param dispose if the removed element should be disposed (default: false)
  43503. */
  43504. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43505. /**
  43506. * Disposes the component and the associated ressources.
  43507. */
  43508. dispose(): void;
  43509. /**
  43510. * Disables audio in the associated scene.
  43511. */
  43512. disableAudio(): void;
  43513. /**
  43514. * Enables audio in the associated scene.
  43515. */
  43516. enableAudio(): void;
  43517. /**
  43518. * Switch audio to headphone output.
  43519. */
  43520. switchAudioModeForHeadphones(): void;
  43521. /**
  43522. * Switch audio to normal speakers.
  43523. */
  43524. switchAudioModeForNormalSpeakers(): void;
  43525. private _cachedCameraDirection;
  43526. private _cachedCameraPosition;
  43527. private _lastCheck;
  43528. private _afterRender;
  43529. }
  43530. }
  43531. declare module "babylonjs/Audio/weightedsound" {
  43532. import { Sound } from "babylonjs/Audio/sound";
  43533. /**
  43534. * Wraps one or more Sound objects and selects one with random weight for playback.
  43535. */
  43536. export class WeightedSound {
  43537. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43538. loop: boolean;
  43539. private _coneInnerAngle;
  43540. private _coneOuterAngle;
  43541. private _volume;
  43542. /** A Sound is currently playing. */
  43543. isPlaying: boolean;
  43544. /** A Sound is currently paused. */
  43545. isPaused: boolean;
  43546. private _sounds;
  43547. private _weights;
  43548. private _currentIndex?;
  43549. /**
  43550. * Creates a new WeightedSound from the list of sounds given.
  43551. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43552. * @param sounds Array of Sounds that will be selected from.
  43553. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43554. */
  43555. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43556. /**
  43557. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43558. */
  43559. get directionalConeInnerAngle(): number;
  43560. /**
  43561. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43562. */
  43563. set directionalConeInnerAngle(value: number);
  43564. /**
  43565. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43566. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43567. */
  43568. get directionalConeOuterAngle(): number;
  43569. /**
  43570. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43571. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43572. */
  43573. set directionalConeOuterAngle(value: number);
  43574. /**
  43575. * Playback volume.
  43576. */
  43577. get volume(): number;
  43578. /**
  43579. * Playback volume.
  43580. */
  43581. set volume(value: number);
  43582. private _onended;
  43583. /**
  43584. * Suspend playback
  43585. */
  43586. pause(): void;
  43587. /**
  43588. * Stop playback
  43589. */
  43590. stop(): void;
  43591. /**
  43592. * Start playback.
  43593. * @param startOffset Position the clip head at a specific time in seconds.
  43594. */
  43595. play(startOffset?: number): void;
  43596. }
  43597. }
  43598. declare module "babylonjs/Audio/index" {
  43599. export * from "babylonjs/Audio/analyser";
  43600. export * from "babylonjs/Audio/audioEngine";
  43601. export * from "babylonjs/Audio/audioSceneComponent";
  43602. export * from "babylonjs/Audio/sound";
  43603. export * from "babylonjs/Audio/soundTrack";
  43604. export * from "babylonjs/Audio/weightedsound";
  43605. }
  43606. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43607. import { Behavior } from "babylonjs/Behaviors/behavior";
  43608. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43609. import { BackEase } from "babylonjs/Animations/easing";
  43610. /**
  43611. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43612. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43613. */
  43614. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43615. /**
  43616. * Gets the name of the behavior.
  43617. */
  43618. get name(): string;
  43619. /**
  43620. * The easing function used by animations
  43621. */
  43622. static EasingFunction: BackEase;
  43623. /**
  43624. * The easing mode used by animations
  43625. */
  43626. static EasingMode: number;
  43627. /**
  43628. * The duration of the animation, in milliseconds
  43629. */
  43630. transitionDuration: number;
  43631. /**
  43632. * Length of the distance animated by the transition when lower radius is reached
  43633. */
  43634. lowerRadiusTransitionRange: number;
  43635. /**
  43636. * Length of the distance animated by the transition when upper radius is reached
  43637. */
  43638. upperRadiusTransitionRange: number;
  43639. private _autoTransitionRange;
  43640. /**
  43641. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43642. */
  43643. get autoTransitionRange(): boolean;
  43644. /**
  43645. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43646. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43647. */
  43648. set autoTransitionRange(value: boolean);
  43649. private _attachedCamera;
  43650. private _onAfterCheckInputsObserver;
  43651. private _onMeshTargetChangedObserver;
  43652. /**
  43653. * Initializes the behavior.
  43654. */
  43655. init(): void;
  43656. /**
  43657. * Attaches the behavior to its arc rotate camera.
  43658. * @param camera Defines the camera to attach the behavior to
  43659. */
  43660. attach(camera: ArcRotateCamera): void;
  43661. /**
  43662. * Detaches the behavior from its current arc rotate camera.
  43663. */
  43664. detach(): void;
  43665. private _radiusIsAnimating;
  43666. private _radiusBounceTransition;
  43667. private _animatables;
  43668. private _cachedWheelPrecision;
  43669. /**
  43670. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43671. * @param radiusLimit The limit to check against.
  43672. * @return Bool to indicate if at limit.
  43673. */
  43674. private _isRadiusAtLimit;
  43675. /**
  43676. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43677. * @param radiusDelta The delta by which to animate to. Can be negative.
  43678. */
  43679. private _applyBoundRadiusAnimation;
  43680. /**
  43681. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43682. */
  43683. protected _clearAnimationLocks(): void;
  43684. /**
  43685. * Stops and removes all animations that have been applied to the camera
  43686. */
  43687. stopAllAnimations(): void;
  43688. }
  43689. }
  43690. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43691. import { Behavior } from "babylonjs/Behaviors/behavior";
  43692. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43693. import { ExponentialEase } from "babylonjs/Animations/easing";
  43694. import { Nullable } from "babylonjs/types";
  43695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43696. import { Vector3 } from "babylonjs/Maths/math.vector";
  43697. /**
  43698. * 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.
  43699. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43700. */
  43701. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43702. /**
  43703. * Gets the name of the behavior.
  43704. */
  43705. get name(): string;
  43706. private _mode;
  43707. private _radiusScale;
  43708. private _positionScale;
  43709. private _defaultElevation;
  43710. private _elevationReturnTime;
  43711. private _elevationReturnWaitTime;
  43712. private _zoomStopsAnimation;
  43713. private _framingTime;
  43714. /**
  43715. * The easing function used by animations
  43716. */
  43717. static EasingFunction: ExponentialEase;
  43718. /**
  43719. * The easing mode used by animations
  43720. */
  43721. static EasingMode: number;
  43722. /**
  43723. * Sets the current mode used by the behavior
  43724. */
  43725. set mode(mode: number);
  43726. /**
  43727. * Gets current mode used by the behavior.
  43728. */
  43729. get mode(): number;
  43730. /**
  43731. * Sets the scale applied to the radius (1 by default)
  43732. */
  43733. set radiusScale(radius: number);
  43734. /**
  43735. * Gets the scale applied to the radius
  43736. */
  43737. get radiusScale(): number;
  43738. /**
  43739. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43740. */
  43741. set positionScale(scale: number);
  43742. /**
  43743. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43744. */
  43745. get positionScale(): number;
  43746. /**
  43747. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43748. * behaviour is triggered, in radians.
  43749. */
  43750. set defaultElevation(elevation: number);
  43751. /**
  43752. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43753. * behaviour is triggered, in radians.
  43754. */
  43755. get defaultElevation(): number;
  43756. /**
  43757. * Sets the time (in milliseconds) taken to return to the default beta position.
  43758. * Negative value indicates camera should not return to default.
  43759. */
  43760. set elevationReturnTime(speed: number);
  43761. /**
  43762. * Gets the time (in milliseconds) taken to return to the default beta position.
  43763. * Negative value indicates camera should not return to default.
  43764. */
  43765. get elevationReturnTime(): number;
  43766. /**
  43767. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43768. */
  43769. set elevationReturnWaitTime(time: number);
  43770. /**
  43771. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43772. */
  43773. get elevationReturnWaitTime(): number;
  43774. /**
  43775. * Sets the flag that indicates if user zooming should stop animation.
  43776. */
  43777. set zoomStopsAnimation(flag: boolean);
  43778. /**
  43779. * Gets the flag that indicates if user zooming should stop animation.
  43780. */
  43781. get zoomStopsAnimation(): boolean;
  43782. /**
  43783. * Sets the transition time when framing the mesh, in milliseconds
  43784. */
  43785. set framingTime(time: number);
  43786. /**
  43787. * Gets the transition time when framing the mesh, in milliseconds
  43788. */
  43789. get framingTime(): number;
  43790. /**
  43791. * Define if the behavior should automatically change the configured
  43792. * camera limits and sensibilities.
  43793. */
  43794. autoCorrectCameraLimitsAndSensibility: boolean;
  43795. private _onPrePointerObservableObserver;
  43796. private _onAfterCheckInputsObserver;
  43797. private _onMeshTargetChangedObserver;
  43798. private _attachedCamera;
  43799. private _isPointerDown;
  43800. private _lastInteractionTime;
  43801. /**
  43802. * Initializes the behavior.
  43803. */
  43804. init(): void;
  43805. /**
  43806. * Attaches the behavior to its arc rotate camera.
  43807. * @param camera Defines the camera to attach the behavior to
  43808. */
  43809. attach(camera: ArcRotateCamera): void;
  43810. /**
  43811. * Detaches the behavior from its current arc rotate camera.
  43812. */
  43813. detach(): void;
  43814. private _animatables;
  43815. private _betaIsAnimating;
  43816. private _betaTransition;
  43817. private _radiusTransition;
  43818. private _vectorTransition;
  43819. /**
  43820. * Targets the given mesh and updates zoom level accordingly.
  43821. * @param mesh The mesh to target.
  43822. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43823. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43824. */
  43825. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43826. /**
  43827. * Targets the given mesh with its children and updates zoom level accordingly.
  43828. * @param mesh The mesh to target.
  43829. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43830. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43831. */
  43832. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43833. /**
  43834. * Targets the given meshes with their children and updates zoom level accordingly.
  43835. * @param meshes The mesh to target.
  43836. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43837. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43838. */
  43839. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43840. /**
  43841. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43842. * @param minimumWorld Determines the smaller position of the bounding box extend
  43843. * @param maximumWorld Determines the bigger position of the bounding box extend
  43844. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43845. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43846. */
  43847. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43848. /**
  43849. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43850. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43851. * frustum width.
  43852. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43853. * to fully enclose the mesh in the viewing frustum.
  43854. */
  43855. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43856. /**
  43857. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43858. * is automatically returned to its default position (expected to be above ground plane).
  43859. */
  43860. private _maintainCameraAboveGround;
  43861. /**
  43862. * Returns the frustum slope based on the canvas ratio and camera FOV
  43863. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43864. */
  43865. private _getFrustumSlope;
  43866. /**
  43867. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43868. */
  43869. private _clearAnimationLocks;
  43870. /**
  43871. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43872. */
  43873. private _applyUserInteraction;
  43874. /**
  43875. * Stops and removes all animations that have been applied to the camera
  43876. */
  43877. stopAllAnimations(): void;
  43878. /**
  43879. * Gets a value indicating if the user is moving the camera
  43880. */
  43881. get isUserIsMoving(): boolean;
  43882. /**
  43883. * The camera can move all the way towards the mesh.
  43884. */
  43885. static IgnoreBoundsSizeMode: number;
  43886. /**
  43887. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43888. */
  43889. static FitFrustumSidesMode: number;
  43890. }
  43891. }
  43892. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43893. import { Nullable } from "babylonjs/types";
  43894. import { Camera } from "babylonjs/Cameras/camera";
  43895. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43896. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43897. /**
  43898. * Base class for Camera Pointer Inputs.
  43899. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43900. * for example usage.
  43901. */
  43902. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43903. /**
  43904. * Defines the camera the input is attached to.
  43905. */
  43906. abstract camera: Camera;
  43907. /**
  43908. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43909. */
  43910. protected _altKey: boolean;
  43911. protected _ctrlKey: boolean;
  43912. protected _metaKey: boolean;
  43913. protected _shiftKey: boolean;
  43914. /**
  43915. * Which mouse buttons were pressed at time of last mouse event.
  43916. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43917. */
  43918. protected _buttonsPressed: number;
  43919. /**
  43920. * Defines the buttons associated with the input to handle camera move.
  43921. */
  43922. buttons: number[];
  43923. /**
  43924. * Attach the input controls to a specific dom element to get the input from.
  43925. * @param element Defines the element the controls should be listened from
  43926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43927. */
  43928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43929. /**
  43930. * Detach the current controls from the specified dom element.
  43931. * @param element Defines the element to stop listening the inputs from
  43932. */
  43933. detachControl(element: Nullable<HTMLElement>): void;
  43934. /**
  43935. * Gets the class name of the current input.
  43936. * @returns the class name
  43937. */
  43938. getClassName(): string;
  43939. /**
  43940. * Get the friendly name associated with the input class.
  43941. * @returns the input friendly name
  43942. */
  43943. getSimpleName(): string;
  43944. /**
  43945. * Called on pointer POINTERDOUBLETAP event.
  43946. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43947. */
  43948. protected onDoubleTap(type: string): void;
  43949. /**
  43950. * Called on pointer POINTERMOVE event if only a single touch is active.
  43951. * Override this method to provide functionality.
  43952. */
  43953. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43954. /**
  43955. * Called on pointer POINTERMOVE event if multiple touches are active.
  43956. * Override this method to provide functionality.
  43957. */
  43958. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43959. /**
  43960. * Called on JS contextmenu event.
  43961. * Override this method to provide functionality.
  43962. */
  43963. protected onContextMenu(evt: PointerEvent): void;
  43964. /**
  43965. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43966. * press.
  43967. * Override this method to provide functionality.
  43968. */
  43969. protected onButtonDown(evt: PointerEvent): void;
  43970. /**
  43971. * Called each time a new POINTERUP event occurs. Ie, for each button
  43972. * release.
  43973. * Override this method to provide functionality.
  43974. */
  43975. protected onButtonUp(evt: PointerEvent): void;
  43976. /**
  43977. * Called when window becomes inactive.
  43978. * Override this method to provide functionality.
  43979. */
  43980. protected onLostFocus(): void;
  43981. private _pointerInput;
  43982. private _observer;
  43983. private _onLostFocus;
  43984. private pointA;
  43985. private pointB;
  43986. }
  43987. }
  43988. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43989. import { Nullable } from "babylonjs/types";
  43990. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43991. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43992. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43993. /**
  43994. * Manage the pointers inputs to control an arc rotate camera.
  43995. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43996. */
  43997. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43998. /**
  43999. * Defines the camera the input is attached to.
  44000. */
  44001. camera: ArcRotateCamera;
  44002. /**
  44003. * Gets the class name of the current input.
  44004. * @returns the class name
  44005. */
  44006. getClassName(): string;
  44007. /**
  44008. * Defines the buttons associated with the input to handle camera move.
  44009. */
  44010. buttons: number[];
  44011. /**
  44012. * Defines the pointer angular sensibility along the X axis or how fast is
  44013. * the camera rotating.
  44014. */
  44015. angularSensibilityX: number;
  44016. /**
  44017. * Defines the pointer angular sensibility along the Y axis or how fast is
  44018. * the camera rotating.
  44019. */
  44020. angularSensibilityY: number;
  44021. /**
  44022. * Defines the pointer pinch precision or how fast is the camera zooming.
  44023. */
  44024. pinchPrecision: number;
  44025. /**
  44026. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44027. * from 0.
  44028. * It defines the percentage of current camera.radius to use as delta when
  44029. * pinch zoom is used.
  44030. */
  44031. pinchDeltaPercentage: number;
  44032. /**
  44033. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44034. * that any object in the plane at the camera's target point will scale
  44035. * perfectly with finger motion.
  44036. * Overrides pinchDeltaPercentage and pinchPrecision.
  44037. */
  44038. useNaturalPinchZoom: boolean;
  44039. /**
  44040. * Defines the pointer panning sensibility or how fast is the camera moving.
  44041. */
  44042. panningSensibility: number;
  44043. /**
  44044. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44045. */
  44046. multiTouchPanning: boolean;
  44047. /**
  44048. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44049. * zoom (pinch) through multitouch.
  44050. */
  44051. multiTouchPanAndZoom: boolean;
  44052. /**
  44053. * Revers pinch action direction.
  44054. */
  44055. pinchInwards: boolean;
  44056. private _isPanClick;
  44057. private _twoFingerActivityCount;
  44058. private _isPinching;
  44059. /**
  44060. * Called on pointer POINTERMOVE event if only a single touch is active.
  44061. */
  44062. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44063. /**
  44064. * Called on pointer POINTERDOUBLETAP event.
  44065. */
  44066. protected onDoubleTap(type: string): void;
  44067. /**
  44068. * Called on pointer POINTERMOVE event if multiple touches are active.
  44069. */
  44070. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44071. /**
  44072. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44073. * press.
  44074. */
  44075. protected onButtonDown(evt: PointerEvent): void;
  44076. /**
  44077. * Called each time a new POINTERUP event occurs. Ie, for each button
  44078. * release.
  44079. */
  44080. protected onButtonUp(evt: PointerEvent): void;
  44081. /**
  44082. * Called when window becomes inactive.
  44083. */
  44084. protected onLostFocus(): void;
  44085. }
  44086. }
  44087. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44088. import { Nullable } from "babylonjs/types";
  44089. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44090. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44091. /**
  44092. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44093. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44094. */
  44095. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44096. /**
  44097. * Defines the camera the input is attached to.
  44098. */
  44099. camera: ArcRotateCamera;
  44100. /**
  44101. * Defines the list of key codes associated with the up action (increase alpha)
  44102. */
  44103. keysUp: number[];
  44104. /**
  44105. * Defines the list of key codes associated with the down action (decrease alpha)
  44106. */
  44107. keysDown: number[];
  44108. /**
  44109. * Defines the list of key codes associated with the left action (increase beta)
  44110. */
  44111. keysLeft: number[];
  44112. /**
  44113. * Defines the list of key codes associated with the right action (decrease beta)
  44114. */
  44115. keysRight: number[];
  44116. /**
  44117. * Defines the list of key codes associated with the reset action.
  44118. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44119. */
  44120. keysReset: number[];
  44121. /**
  44122. * Defines the panning sensibility of the inputs.
  44123. * (How fast is the camera panning)
  44124. */
  44125. panningSensibility: number;
  44126. /**
  44127. * Defines the zooming sensibility of the inputs.
  44128. * (How fast is the camera zooming)
  44129. */
  44130. zoomingSensibility: number;
  44131. /**
  44132. * Defines whether maintaining the alt key down switch the movement mode from
  44133. * orientation to zoom.
  44134. */
  44135. useAltToZoom: boolean;
  44136. /**
  44137. * Rotation speed of the camera
  44138. */
  44139. angularSpeed: number;
  44140. private _keys;
  44141. private _ctrlPressed;
  44142. private _altPressed;
  44143. private _onCanvasBlurObserver;
  44144. private _onKeyboardObserver;
  44145. private _engine;
  44146. private _scene;
  44147. /**
  44148. * Attach the input controls to a specific dom element to get the input from.
  44149. * @param element Defines the element the controls should be listened from
  44150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44151. */
  44152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44153. /**
  44154. * Detach the current controls from the specified dom element.
  44155. * @param element Defines the element to stop listening the inputs from
  44156. */
  44157. detachControl(element: Nullable<HTMLElement>): void;
  44158. /**
  44159. * Update the current camera state depending on the inputs that have been used this frame.
  44160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44161. */
  44162. checkInputs(): void;
  44163. /**
  44164. * Gets the class name of the current intput.
  44165. * @returns the class name
  44166. */
  44167. getClassName(): string;
  44168. /**
  44169. * Get the friendly name associated with the input class.
  44170. * @returns the input friendly name
  44171. */
  44172. getSimpleName(): string;
  44173. }
  44174. }
  44175. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44176. import { Nullable } from "babylonjs/types";
  44177. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44179. /**
  44180. * Manage the mouse wheel inputs to control an arc rotate camera.
  44181. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44182. */
  44183. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44184. /**
  44185. * Defines the camera the input is attached to.
  44186. */
  44187. camera: ArcRotateCamera;
  44188. /**
  44189. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44190. */
  44191. wheelPrecision: number;
  44192. /**
  44193. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44194. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44195. */
  44196. wheelDeltaPercentage: number;
  44197. private _wheel;
  44198. private _observer;
  44199. private computeDeltaFromMouseWheelLegacyEvent;
  44200. /**
  44201. * Attach the input controls to a specific dom element to get the input from.
  44202. * @param element Defines the element the controls should be listened from
  44203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44204. */
  44205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44206. /**
  44207. * Detach the current controls from the specified dom element.
  44208. * @param element Defines the element to stop listening the inputs from
  44209. */
  44210. detachControl(element: Nullable<HTMLElement>): void;
  44211. /**
  44212. * Gets the class name of the current intput.
  44213. * @returns the class name
  44214. */
  44215. getClassName(): string;
  44216. /**
  44217. * Get the friendly name associated with the input class.
  44218. * @returns the input friendly name
  44219. */
  44220. getSimpleName(): string;
  44221. }
  44222. }
  44223. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44224. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44225. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44226. /**
  44227. * Default Inputs manager for the ArcRotateCamera.
  44228. * It groups all the default supported inputs for ease of use.
  44229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44230. */
  44231. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44232. /**
  44233. * Instantiates a new ArcRotateCameraInputsManager.
  44234. * @param camera Defines the camera the inputs belong to
  44235. */
  44236. constructor(camera: ArcRotateCamera);
  44237. /**
  44238. * Add mouse wheel input support to the input manager.
  44239. * @returns the current input manager
  44240. */
  44241. addMouseWheel(): ArcRotateCameraInputsManager;
  44242. /**
  44243. * Add pointers input support to the input manager.
  44244. * @returns the current input manager
  44245. */
  44246. addPointers(): ArcRotateCameraInputsManager;
  44247. /**
  44248. * Add keyboard input support to the input manager.
  44249. * @returns the current input manager
  44250. */
  44251. addKeyboard(): ArcRotateCameraInputsManager;
  44252. }
  44253. }
  44254. declare module "babylonjs/Cameras/arcRotateCamera" {
  44255. import { Observable } from "babylonjs/Misc/observable";
  44256. import { Nullable } from "babylonjs/types";
  44257. import { Scene } from "babylonjs/scene";
  44258. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44260. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44261. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44262. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44263. import { Camera } from "babylonjs/Cameras/camera";
  44264. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44265. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44266. import { Collider } from "babylonjs/Collisions/collider";
  44267. /**
  44268. * This represents an orbital type of camera.
  44269. *
  44270. * 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.
  44271. * 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.
  44272. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44273. */
  44274. export class ArcRotateCamera extends TargetCamera {
  44275. /**
  44276. * Defines the rotation angle of the camera along the longitudinal axis.
  44277. */
  44278. alpha: number;
  44279. /**
  44280. * Defines the rotation angle of the camera along the latitudinal axis.
  44281. */
  44282. beta: number;
  44283. /**
  44284. * Defines the radius of the camera from it s target point.
  44285. */
  44286. radius: number;
  44287. protected _target: Vector3;
  44288. protected _targetHost: Nullable<AbstractMesh>;
  44289. /**
  44290. * Defines the target point of the camera.
  44291. * The camera looks towards it form the radius distance.
  44292. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44293. */
  44294. get target(): Vector3;
  44295. set target(value: Vector3);
  44296. /**
  44297. * Define the current local position of the camera in the scene
  44298. */
  44299. get position(): Vector3;
  44300. set position(newPosition: Vector3);
  44301. protected _upVector: Vector3;
  44302. protected _upToYMatrix: Matrix;
  44303. protected _YToUpMatrix: Matrix;
  44304. /**
  44305. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44306. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44307. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44308. */
  44309. set upVector(vec: Vector3);
  44310. get upVector(): Vector3;
  44311. /**
  44312. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44313. */
  44314. setMatUp(): void;
  44315. /**
  44316. * Current inertia value on the longitudinal axis.
  44317. * The bigger this number the longer it will take for the camera to stop.
  44318. */
  44319. inertialAlphaOffset: number;
  44320. /**
  44321. * Current inertia value on the latitudinal axis.
  44322. * The bigger this number the longer it will take for the camera to stop.
  44323. */
  44324. inertialBetaOffset: number;
  44325. /**
  44326. * Current inertia value on the radius axis.
  44327. * The bigger this number the longer it will take for the camera to stop.
  44328. */
  44329. inertialRadiusOffset: number;
  44330. /**
  44331. * Minimum allowed angle on the longitudinal axis.
  44332. * This can help limiting how the Camera is able to move in the scene.
  44333. */
  44334. lowerAlphaLimit: Nullable<number>;
  44335. /**
  44336. * Maximum allowed angle on the longitudinal axis.
  44337. * This can help limiting how the Camera is able to move in the scene.
  44338. */
  44339. upperAlphaLimit: Nullable<number>;
  44340. /**
  44341. * Minimum allowed angle on the latitudinal axis.
  44342. * This can help limiting how the Camera is able to move in the scene.
  44343. */
  44344. lowerBetaLimit: number;
  44345. /**
  44346. * Maximum allowed angle on the latitudinal axis.
  44347. * This can help limiting how the Camera is able to move in the scene.
  44348. */
  44349. upperBetaLimit: number;
  44350. /**
  44351. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44352. * This can help limiting how the Camera is able to move in the scene.
  44353. */
  44354. lowerRadiusLimit: Nullable<number>;
  44355. /**
  44356. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44357. * This can help limiting how the Camera is able to move in the scene.
  44358. */
  44359. upperRadiusLimit: Nullable<number>;
  44360. /**
  44361. * Defines the current inertia value used during panning of the camera along the X axis.
  44362. */
  44363. inertialPanningX: number;
  44364. /**
  44365. * Defines the current inertia value used during panning of the camera along the Y axis.
  44366. */
  44367. inertialPanningY: number;
  44368. /**
  44369. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44370. * Basically if your fingers moves away from more than this distance you will be considered
  44371. * in pinch mode.
  44372. */
  44373. pinchToPanMaxDistance: number;
  44374. /**
  44375. * Defines the maximum distance the camera can pan.
  44376. * This could help keeping the cammera always in your scene.
  44377. */
  44378. panningDistanceLimit: Nullable<number>;
  44379. /**
  44380. * Defines the target of the camera before paning.
  44381. */
  44382. panningOriginTarget: Vector3;
  44383. /**
  44384. * Defines the value of the inertia used during panning.
  44385. * 0 would mean stop inertia and one would mean no decelleration at all.
  44386. */
  44387. panningInertia: number;
  44388. /**
  44389. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44390. */
  44391. get angularSensibilityX(): number;
  44392. set angularSensibilityX(value: number);
  44393. /**
  44394. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44395. */
  44396. get angularSensibilityY(): number;
  44397. set angularSensibilityY(value: number);
  44398. /**
  44399. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44400. */
  44401. get pinchPrecision(): number;
  44402. set pinchPrecision(value: number);
  44403. /**
  44404. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44405. * It will be used instead of pinchDeltaPrecision if different from 0.
  44406. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44407. */
  44408. get pinchDeltaPercentage(): number;
  44409. set pinchDeltaPercentage(value: number);
  44410. /**
  44411. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44412. * and pinch delta percentage.
  44413. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44414. * that any object in the plane at the camera's target point will scale
  44415. * perfectly with finger motion.
  44416. */
  44417. get useNaturalPinchZoom(): boolean;
  44418. set useNaturalPinchZoom(value: boolean);
  44419. /**
  44420. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44421. */
  44422. get panningSensibility(): number;
  44423. set panningSensibility(value: number);
  44424. /**
  44425. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44426. */
  44427. get keysUp(): number[];
  44428. set keysUp(value: number[]);
  44429. /**
  44430. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44431. */
  44432. get keysDown(): number[];
  44433. set keysDown(value: number[]);
  44434. /**
  44435. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44436. */
  44437. get keysLeft(): number[];
  44438. set keysLeft(value: number[]);
  44439. /**
  44440. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44441. */
  44442. get keysRight(): number[];
  44443. set keysRight(value: number[]);
  44444. /**
  44445. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44446. */
  44447. get wheelPrecision(): number;
  44448. set wheelPrecision(value: number);
  44449. /**
  44450. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44451. * It will be used instead of pinchDeltaPrecision if different from 0.
  44452. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44453. */
  44454. get wheelDeltaPercentage(): number;
  44455. set wheelDeltaPercentage(value: number);
  44456. /**
  44457. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44458. */
  44459. zoomOnFactor: number;
  44460. /**
  44461. * Defines a screen offset for the camera position.
  44462. */
  44463. targetScreenOffset: Vector2;
  44464. /**
  44465. * Allows the camera to be completely reversed.
  44466. * If false the camera can not arrive upside down.
  44467. */
  44468. allowUpsideDown: boolean;
  44469. /**
  44470. * Define if double tap/click is used to restore the previously saved state of the camera.
  44471. */
  44472. useInputToRestoreState: boolean;
  44473. /** @hidden */
  44474. _viewMatrix: Matrix;
  44475. /** @hidden */
  44476. _useCtrlForPanning: boolean;
  44477. /** @hidden */
  44478. _panningMouseButton: number;
  44479. /**
  44480. * Defines the input associated to the camera.
  44481. */
  44482. inputs: ArcRotateCameraInputsManager;
  44483. /** @hidden */
  44484. _reset: () => void;
  44485. /**
  44486. * Defines the allowed panning axis.
  44487. */
  44488. panningAxis: Vector3;
  44489. protected _localDirection: Vector3;
  44490. protected _transformedDirection: Vector3;
  44491. private _bouncingBehavior;
  44492. /**
  44493. * Gets the bouncing behavior of the camera if it has been enabled.
  44494. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44495. */
  44496. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44497. /**
  44498. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44499. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44500. */
  44501. get useBouncingBehavior(): boolean;
  44502. set useBouncingBehavior(value: boolean);
  44503. private _framingBehavior;
  44504. /**
  44505. * Gets the framing behavior of the camera if it has been enabled.
  44506. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44507. */
  44508. get framingBehavior(): Nullable<FramingBehavior>;
  44509. /**
  44510. * Defines if the framing behavior of the camera is enabled on the camera.
  44511. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44512. */
  44513. get useFramingBehavior(): boolean;
  44514. set useFramingBehavior(value: boolean);
  44515. private _autoRotationBehavior;
  44516. /**
  44517. * Gets the auto rotation behavior of the camera if it has been enabled.
  44518. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44519. */
  44520. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44521. /**
  44522. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44523. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44524. */
  44525. get useAutoRotationBehavior(): boolean;
  44526. set useAutoRotationBehavior(value: boolean);
  44527. /**
  44528. * Observable triggered when the mesh target has been changed on the camera.
  44529. */
  44530. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44531. /**
  44532. * Event raised when the camera is colliding with a mesh.
  44533. */
  44534. onCollide: (collidedMesh: AbstractMesh) => void;
  44535. /**
  44536. * Defines whether the camera should check collision with the objects oh the scene.
  44537. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44538. */
  44539. checkCollisions: boolean;
  44540. /**
  44541. * Defines the collision radius of the camera.
  44542. * This simulates a sphere around the camera.
  44543. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44544. */
  44545. collisionRadius: Vector3;
  44546. protected _collider: Collider;
  44547. protected _previousPosition: Vector3;
  44548. protected _collisionVelocity: Vector3;
  44549. protected _newPosition: Vector3;
  44550. protected _previousAlpha: number;
  44551. protected _previousBeta: number;
  44552. protected _previousRadius: number;
  44553. protected _collisionTriggered: boolean;
  44554. protected _targetBoundingCenter: Nullable<Vector3>;
  44555. private _computationVector;
  44556. /**
  44557. * Instantiates a new ArcRotateCamera in a given scene
  44558. * @param name Defines the name of the camera
  44559. * @param alpha Defines the camera rotation along the logitudinal axis
  44560. * @param beta Defines the camera rotation along the latitudinal axis
  44561. * @param radius Defines the camera distance from its target
  44562. * @param target Defines the camera target
  44563. * @param scene Defines the scene the camera belongs to
  44564. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44565. */
  44566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44567. /** @hidden */
  44568. _initCache(): void;
  44569. /** @hidden */
  44570. _updateCache(ignoreParentClass?: boolean): void;
  44571. protected _getTargetPosition(): Vector3;
  44572. private _storedAlpha;
  44573. private _storedBeta;
  44574. private _storedRadius;
  44575. private _storedTarget;
  44576. private _storedTargetScreenOffset;
  44577. /**
  44578. * Stores the current state of the camera (alpha, beta, radius and target)
  44579. * @returns the camera itself
  44580. */
  44581. storeState(): Camera;
  44582. /**
  44583. * @hidden
  44584. * Restored camera state. You must call storeState() first
  44585. */
  44586. _restoreStateValues(): boolean;
  44587. /** @hidden */
  44588. _isSynchronizedViewMatrix(): boolean;
  44589. /**
  44590. * Attached controls to the current camera.
  44591. * @param element Defines the element the controls should be listened from
  44592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44593. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44594. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44595. */
  44596. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44597. /**
  44598. * Detach the current controls from the camera.
  44599. * The camera will stop reacting to inputs.
  44600. * @param element Defines the element to stop listening the inputs from
  44601. */
  44602. detachControl(element: HTMLElement): void;
  44603. /** @hidden */
  44604. _checkInputs(): void;
  44605. protected _checkLimits(): void;
  44606. /**
  44607. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44608. */
  44609. rebuildAnglesAndRadius(): void;
  44610. /**
  44611. * Use a position to define the current camera related information like alpha, beta and radius
  44612. * @param position Defines the position to set the camera at
  44613. */
  44614. setPosition(position: Vector3): void;
  44615. /**
  44616. * Defines the target the camera should look at.
  44617. * This will automatically adapt alpha beta and radius to fit within the new target.
  44618. * @param target Defines the new target as a Vector or a mesh
  44619. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44620. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44621. */
  44622. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44623. /** @hidden */
  44624. _getViewMatrix(): Matrix;
  44625. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44626. /**
  44627. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44628. * @param meshes Defines the mesh to zoom on
  44629. * @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)
  44630. */
  44631. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44632. /**
  44633. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44634. * The target will be changed but the radius
  44635. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44636. * @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)
  44637. */
  44638. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44639. min: Vector3;
  44640. max: Vector3;
  44641. distance: number;
  44642. }, doNotUpdateMaxZ?: boolean): void;
  44643. /**
  44644. * @override
  44645. * Override Camera.createRigCamera
  44646. */
  44647. createRigCamera(name: string, cameraIndex: number): Camera;
  44648. /**
  44649. * @hidden
  44650. * @override
  44651. * Override Camera._updateRigCameras
  44652. */
  44653. _updateRigCameras(): void;
  44654. /**
  44655. * Destroy the camera and release the current resources hold by it.
  44656. */
  44657. dispose(): void;
  44658. /**
  44659. * Gets the current object class name.
  44660. * @return the class name
  44661. */
  44662. getClassName(): string;
  44663. }
  44664. }
  44665. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44666. import { Behavior } from "babylonjs/Behaviors/behavior";
  44667. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44668. /**
  44669. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44670. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44671. */
  44672. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44673. /**
  44674. * Gets the name of the behavior.
  44675. */
  44676. get name(): string;
  44677. private _zoomStopsAnimation;
  44678. private _idleRotationSpeed;
  44679. private _idleRotationWaitTime;
  44680. private _idleRotationSpinupTime;
  44681. /**
  44682. * Sets the flag that indicates if user zooming should stop animation.
  44683. */
  44684. set zoomStopsAnimation(flag: boolean);
  44685. /**
  44686. * Gets the flag that indicates if user zooming should stop animation.
  44687. */
  44688. get zoomStopsAnimation(): boolean;
  44689. /**
  44690. * Sets the default speed at which the camera rotates around the model.
  44691. */
  44692. set idleRotationSpeed(speed: number);
  44693. /**
  44694. * Gets the default speed at which the camera rotates around the model.
  44695. */
  44696. get idleRotationSpeed(): number;
  44697. /**
  44698. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44699. */
  44700. set idleRotationWaitTime(time: number);
  44701. /**
  44702. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44703. */
  44704. get idleRotationWaitTime(): number;
  44705. /**
  44706. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44707. */
  44708. set idleRotationSpinupTime(time: number);
  44709. /**
  44710. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44711. */
  44712. get idleRotationSpinupTime(): number;
  44713. /**
  44714. * Gets a value indicating if the camera is currently rotating because of this behavior
  44715. */
  44716. get rotationInProgress(): boolean;
  44717. private _onPrePointerObservableObserver;
  44718. private _onAfterCheckInputsObserver;
  44719. private _attachedCamera;
  44720. private _isPointerDown;
  44721. private _lastFrameTime;
  44722. private _lastInteractionTime;
  44723. private _cameraRotationSpeed;
  44724. /**
  44725. * Initializes the behavior.
  44726. */
  44727. init(): void;
  44728. /**
  44729. * Attaches the behavior to its arc rotate camera.
  44730. * @param camera Defines the camera to attach the behavior to
  44731. */
  44732. attach(camera: ArcRotateCamera): void;
  44733. /**
  44734. * Detaches the behavior from its current arc rotate camera.
  44735. */
  44736. detach(): void;
  44737. /**
  44738. * Returns true if user is scrolling.
  44739. * @return true if user is scrolling.
  44740. */
  44741. private _userIsZooming;
  44742. private _lastFrameRadius;
  44743. private _shouldAnimationStopForInteraction;
  44744. /**
  44745. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44746. */
  44747. private _applyUserInteraction;
  44748. private _userIsMoving;
  44749. }
  44750. }
  44751. declare module "babylonjs/Behaviors/Cameras/index" {
  44752. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44753. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44754. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44755. }
  44756. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44757. import { Mesh } from "babylonjs/Meshes/mesh";
  44758. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44759. import { Behavior } from "babylonjs/Behaviors/behavior";
  44760. /**
  44761. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44762. */
  44763. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44764. private ui;
  44765. /**
  44766. * The name of the behavior
  44767. */
  44768. name: string;
  44769. /**
  44770. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44771. */
  44772. distanceAwayFromFace: number;
  44773. /**
  44774. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44775. */
  44776. distanceAwayFromBottomOfFace: number;
  44777. private _faceVectors;
  44778. private _target;
  44779. private _scene;
  44780. private _onRenderObserver;
  44781. private _tmpMatrix;
  44782. private _tmpVector;
  44783. /**
  44784. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44785. * @param ui The transform node that should be attched to the mesh
  44786. */
  44787. constructor(ui: TransformNode);
  44788. /**
  44789. * Initializes the behavior
  44790. */
  44791. init(): void;
  44792. private _closestFace;
  44793. private _zeroVector;
  44794. private _lookAtTmpMatrix;
  44795. private _lookAtToRef;
  44796. /**
  44797. * Attaches the AttachToBoxBehavior to the passed in mesh
  44798. * @param target The mesh that the specified node will be attached to
  44799. */
  44800. attach(target: Mesh): void;
  44801. /**
  44802. * Detaches the behavior from the mesh
  44803. */
  44804. detach(): void;
  44805. }
  44806. }
  44807. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44808. import { Behavior } from "babylonjs/Behaviors/behavior";
  44809. import { Mesh } from "babylonjs/Meshes/mesh";
  44810. /**
  44811. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44812. */
  44813. export class FadeInOutBehavior implements Behavior<Mesh> {
  44814. /**
  44815. * Time in milliseconds to delay before fading in (Default: 0)
  44816. */
  44817. delay: number;
  44818. /**
  44819. * Time in milliseconds for the mesh to fade in (Default: 300)
  44820. */
  44821. fadeInTime: number;
  44822. private _millisecondsPerFrame;
  44823. private _hovered;
  44824. private _hoverValue;
  44825. private _ownerNode;
  44826. /**
  44827. * Instatiates the FadeInOutBehavior
  44828. */
  44829. constructor();
  44830. /**
  44831. * The name of the behavior
  44832. */
  44833. get name(): string;
  44834. /**
  44835. * Initializes the behavior
  44836. */
  44837. init(): void;
  44838. /**
  44839. * Attaches the fade behavior on the passed in mesh
  44840. * @param ownerNode The mesh that will be faded in/out once attached
  44841. */
  44842. attach(ownerNode: Mesh): void;
  44843. /**
  44844. * Detaches the behavior from the mesh
  44845. */
  44846. detach(): void;
  44847. /**
  44848. * Triggers the mesh to begin fading in or out
  44849. * @param value if the object should fade in or out (true to fade in)
  44850. */
  44851. fadeIn(value: boolean): void;
  44852. private _update;
  44853. private _setAllVisibility;
  44854. }
  44855. }
  44856. declare module "babylonjs/Misc/pivotTools" {
  44857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44858. /**
  44859. * Class containing a set of static utilities functions for managing Pivots
  44860. * @hidden
  44861. */
  44862. export class PivotTools {
  44863. private static _PivotCached;
  44864. private static _OldPivotPoint;
  44865. private static _PivotTranslation;
  44866. private static _PivotTmpVector;
  44867. /** @hidden */
  44868. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44869. /** @hidden */
  44870. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44871. }
  44872. }
  44873. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44874. import { Scene } from "babylonjs/scene";
  44875. import { Vector4 } from "babylonjs/Maths/math.vector";
  44876. import { Mesh } from "babylonjs/Meshes/mesh";
  44877. import { Nullable } from "babylonjs/types";
  44878. import { Plane } from "babylonjs/Maths/math.plane";
  44879. /**
  44880. * Class containing static functions to help procedurally build meshes
  44881. */
  44882. export class PlaneBuilder {
  44883. /**
  44884. * Creates a plane mesh
  44885. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44886. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44887. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44891. * @param name defines the name of the mesh
  44892. * @param options defines the options used to create the mesh
  44893. * @param scene defines the hosting scene
  44894. * @returns the plane mesh
  44895. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44896. */
  44897. static CreatePlane(name: string, options: {
  44898. size?: number;
  44899. width?: number;
  44900. height?: number;
  44901. sideOrientation?: number;
  44902. frontUVs?: Vector4;
  44903. backUVs?: Vector4;
  44904. updatable?: boolean;
  44905. sourcePlane?: Plane;
  44906. }, scene?: Nullable<Scene>): Mesh;
  44907. }
  44908. }
  44909. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44910. import { Behavior } from "babylonjs/Behaviors/behavior";
  44911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44912. import { Observable } from "babylonjs/Misc/observable";
  44913. import { Vector3 } from "babylonjs/Maths/math.vector";
  44914. import { Ray } from "babylonjs/Culling/ray";
  44915. import "babylonjs/Meshes/Builders/planeBuilder";
  44916. /**
  44917. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44918. */
  44919. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44920. private static _AnyMouseID;
  44921. /**
  44922. * Abstract mesh the behavior is set on
  44923. */
  44924. attachedNode: AbstractMesh;
  44925. private _dragPlane;
  44926. private _scene;
  44927. private _pointerObserver;
  44928. private _beforeRenderObserver;
  44929. private static _planeScene;
  44930. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44931. /**
  44932. * 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)
  44933. */
  44934. maxDragAngle: number;
  44935. /**
  44936. * @hidden
  44937. */
  44938. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44939. /**
  44940. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44941. */
  44942. currentDraggingPointerID: number;
  44943. /**
  44944. * The last position where the pointer hit the drag plane in world space
  44945. */
  44946. lastDragPosition: Vector3;
  44947. /**
  44948. * If the behavior is currently in a dragging state
  44949. */
  44950. dragging: boolean;
  44951. /**
  44952. * 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)
  44953. */
  44954. dragDeltaRatio: number;
  44955. /**
  44956. * If the drag plane orientation should be updated during the dragging (Default: true)
  44957. */
  44958. updateDragPlane: boolean;
  44959. private _debugMode;
  44960. private _moving;
  44961. /**
  44962. * Fires each time the attached mesh is dragged with the pointer
  44963. * * delta between last drag position and current drag position in world space
  44964. * * dragDistance along the drag axis
  44965. * * dragPlaneNormal normal of the current drag plane used during the drag
  44966. * * dragPlanePoint in world space where the drag intersects the drag plane
  44967. */
  44968. onDragObservable: Observable<{
  44969. delta: Vector3;
  44970. dragPlanePoint: Vector3;
  44971. dragPlaneNormal: Vector3;
  44972. dragDistance: number;
  44973. pointerId: number;
  44974. }>;
  44975. /**
  44976. * Fires each time a drag begins (eg. mouse down on mesh)
  44977. */
  44978. onDragStartObservable: Observable<{
  44979. dragPlanePoint: Vector3;
  44980. pointerId: number;
  44981. }>;
  44982. /**
  44983. * Fires each time a drag ends (eg. mouse release after drag)
  44984. */
  44985. onDragEndObservable: Observable<{
  44986. dragPlanePoint: Vector3;
  44987. pointerId: number;
  44988. }>;
  44989. /**
  44990. * If the attached mesh should be moved when dragged
  44991. */
  44992. moveAttached: boolean;
  44993. /**
  44994. * If the drag behavior will react to drag events (Default: true)
  44995. */
  44996. enabled: boolean;
  44997. /**
  44998. * If pointer events should start and release the drag (Default: true)
  44999. */
  45000. startAndReleaseDragOnPointerEvents: boolean;
  45001. /**
  45002. * If camera controls should be detached during the drag
  45003. */
  45004. detachCameraControls: boolean;
  45005. /**
  45006. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45007. */
  45008. useObjectOrientationForDragging: boolean;
  45009. private _options;
  45010. /**
  45011. * Gets the options used by the behavior
  45012. */
  45013. get options(): {
  45014. dragAxis?: Vector3;
  45015. dragPlaneNormal?: Vector3;
  45016. };
  45017. /**
  45018. * Sets the options used by the behavior
  45019. */
  45020. set options(options: {
  45021. dragAxis?: Vector3;
  45022. dragPlaneNormal?: Vector3;
  45023. });
  45024. /**
  45025. * Creates a pointer drag behavior that can be attached to a mesh
  45026. * @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)
  45027. */
  45028. constructor(options?: {
  45029. dragAxis?: Vector3;
  45030. dragPlaneNormal?: Vector3;
  45031. });
  45032. /**
  45033. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45034. */
  45035. validateDrag: (targetPosition: Vector3) => boolean;
  45036. /**
  45037. * The name of the behavior
  45038. */
  45039. get name(): string;
  45040. /**
  45041. * Initializes the behavior
  45042. */
  45043. init(): void;
  45044. private _tmpVector;
  45045. private _alternatePickedPoint;
  45046. private _worldDragAxis;
  45047. private _targetPosition;
  45048. private _attachedElement;
  45049. /**
  45050. * Attaches the drag behavior the passed in mesh
  45051. * @param ownerNode The mesh that will be dragged around once attached
  45052. * @param predicate Predicate to use for pick filtering
  45053. */
  45054. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45055. /**
  45056. * Force relase the drag action by code.
  45057. */
  45058. releaseDrag(): void;
  45059. private _startDragRay;
  45060. private _lastPointerRay;
  45061. /**
  45062. * Simulates the start of a pointer drag event on the behavior
  45063. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45064. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45065. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45066. */
  45067. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45068. private _startDrag;
  45069. private _dragDelta;
  45070. private _moveDrag;
  45071. private _pickWithRayOnDragPlane;
  45072. private _pointA;
  45073. private _pointC;
  45074. private _localAxis;
  45075. private _lookAt;
  45076. private _updateDragPlanePosition;
  45077. /**
  45078. * Detaches the behavior from the mesh
  45079. */
  45080. detach(): void;
  45081. }
  45082. }
  45083. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45084. import { Mesh } from "babylonjs/Meshes/mesh";
  45085. import { Behavior } from "babylonjs/Behaviors/behavior";
  45086. /**
  45087. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45088. */
  45089. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45090. private _dragBehaviorA;
  45091. private _dragBehaviorB;
  45092. private _startDistance;
  45093. private _initialScale;
  45094. private _targetScale;
  45095. private _ownerNode;
  45096. private _sceneRenderObserver;
  45097. /**
  45098. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45099. */
  45100. constructor();
  45101. /**
  45102. * The name of the behavior
  45103. */
  45104. get name(): string;
  45105. /**
  45106. * Initializes the behavior
  45107. */
  45108. init(): void;
  45109. private _getCurrentDistance;
  45110. /**
  45111. * Attaches the scale behavior the passed in mesh
  45112. * @param ownerNode The mesh that will be scaled around once attached
  45113. */
  45114. attach(ownerNode: Mesh): void;
  45115. /**
  45116. * Detaches the behavior from the mesh
  45117. */
  45118. detach(): void;
  45119. }
  45120. }
  45121. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45122. import { Behavior } from "babylonjs/Behaviors/behavior";
  45123. import { Mesh } from "babylonjs/Meshes/mesh";
  45124. import { Observable } from "babylonjs/Misc/observable";
  45125. /**
  45126. * 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
  45127. */
  45128. export class SixDofDragBehavior implements Behavior<Mesh> {
  45129. private static _virtualScene;
  45130. private _ownerNode;
  45131. private _sceneRenderObserver;
  45132. private _scene;
  45133. private _targetPosition;
  45134. private _virtualOriginMesh;
  45135. private _virtualDragMesh;
  45136. private _pointerObserver;
  45137. private _moving;
  45138. private _startingOrientation;
  45139. private _attachedElement;
  45140. /**
  45141. * 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)
  45142. */
  45143. private zDragFactor;
  45144. /**
  45145. * If the object should rotate to face the drag origin
  45146. */
  45147. rotateDraggedObject: boolean;
  45148. /**
  45149. * If the behavior is currently in a dragging state
  45150. */
  45151. dragging: boolean;
  45152. /**
  45153. * 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)
  45154. */
  45155. dragDeltaRatio: number;
  45156. /**
  45157. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45158. */
  45159. currentDraggingPointerID: number;
  45160. /**
  45161. * If camera controls should be detached during the drag
  45162. */
  45163. detachCameraControls: boolean;
  45164. /**
  45165. * Fires each time a drag starts
  45166. */
  45167. onDragStartObservable: Observable<{}>;
  45168. /**
  45169. * Fires each time a drag ends (eg. mouse release after drag)
  45170. */
  45171. onDragEndObservable: Observable<{}>;
  45172. /**
  45173. * 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
  45174. */
  45175. constructor();
  45176. /**
  45177. * The name of the behavior
  45178. */
  45179. get name(): string;
  45180. /**
  45181. * Initializes the behavior
  45182. */
  45183. init(): void;
  45184. /**
  45185. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45186. */
  45187. private get _pointerCamera();
  45188. /**
  45189. * Attaches the scale behavior the passed in mesh
  45190. * @param ownerNode The mesh that will be scaled around once attached
  45191. */
  45192. attach(ownerNode: Mesh): void;
  45193. /**
  45194. * Detaches the behavior from the mesh
  45195. */
  45196. detach(): void;
  45197. }
  45198. }
  45199. declare module "babylonjs/Behaviors/Meshes/index" {
  45200. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45201. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45202. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45203. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45204. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45205. }
  45206. declare module "babylonjs/Behaviors/index" {
  45207. export * from "babylonjs/Behaviors/behavior";
  45208. export * from "babylonjs/Behaviors/Cameras/index";
  45209. export * from "babylonjs/Behaviors/Meshes/index";
  45210. }
  45211. declare module "babylonjs/Bones/boneIKController" {
  45212. import { Bone } from "babylonjs/Bones/bone";
  45213. import { Vector3 } from "babylonjs/Maths/math.vector";
  45214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45215. import { Nullable } from "babylonjs/types";
  45216. /**
  45217. * Class used to apply inverse kinematics to bones
  45218. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45219. */
  45220. export class BoneIKController {
  45221. private static _tmpVecs;
  45222. private static _tmpQuat;
  45223. private static _tmpMats;
  45224. /**
  45225. * Gets or sets the target mesh
  45226. */
  45227. targetMesh: AbstractMesh;
  45228. /** Gets or sets the mesh used as pole */
  45229. poleTargetMesh: AbstractMesh;
  45230. /**
  45231. * Gets or sets the bone used as pole
  45232. */
  45233. poleTargetBone: Nullable<Bone>;
  45234. /**
  45235. * Gets or sets the target position
  45236. */
  45237. targetPosition: Vector3;
  45238. /**
  45239. * Gets or sets the pole target position
  45240. */
  45241. poleTargetPosition: Vector3;
  45242. /**
  45243. * Gets or sets the pole target local offset
  45244. */
  45245. poleTargetLocalOffset: Vector3;
  45246. /**
  45247. * Gets or sets the pole angle
  45248. */
  45249. poleAngle: number;
  45250. /**
  45251. * Gets or sets the mesh associated with the controller
  45252. */
  45253. mesh: AbstractMesh;
  45254. /**
  45255. * 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)
  45256. */
  45257. slerpAmount: number;
  45258. private _bone1Quat;
  45259. private _bone1Mat;
  45260. private _bone2Ang;
  45261. private _bone1;
  45262. private _bone2;
  45263. private _bone1Length;
  45264. private _bone2Length;
  45265. private _maxAngle;
  45266. private _maxReach;
  45267. private _rightHandedSystem;
  45268. private _bendAxis;
  45269. private _slerping;
  45270. private _adjustRoll;
  45271. /**
  45272. * Gets or sets maximum allowed angle
  45273. */
  45274. get maxAngle(): number;
  45275. set maxAngle(value: number);
  45276. /**
  45277. * Creates a new BoneIKController
  45278. * @param mesh defines the mesh to control
  45279. * @param bone defines the bone to control
  45280. * @param options defines options to set up the controller
  45281. */
  45282. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45283. targetMesh?: AbstractMesh;
  45284. poleTargetMesh?: AbstractMesh;
  45285. poleTargetBone?: Bone;
  45286. poleTargetLocalOffset?: Vector3;
  45287. poleAngle?: number;
  45288. bendAxis?: Vector3;
  45289. maxAngle?: number;
  45290. slerpAmount?: number;
  45291. });
  45292. private _setMaxAngle;
  45293. /**
  45294. * Force the controller to update the bones
  45295. */
  45296. update(): void;
  45297. }
  45298. }
  45299. declare module "babylonjs/Bones/boneLookController" {
  45300. import { Vector3 } from "babylonjs/Maths/math.vector";
  45301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45302. import { Bone } from "babylonjs/Bones/bone";
  45303. import { Space } from "babylonjs/Maths/math.axis";
  45304. /**
  45305. * Class used to make a bone look toward a point in space
  45306. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45307. */
  45308. export class BoneLookController {
  45309. private static _tmpVecs;
  45310. private static _tmpQuat;
  45311. private static _tmpMats;
  45312. /**
  45313. * The target Vector3 that the bone will look at
  45314. */
  45315. target: Vector3;
  45316. /**
  45317. * The mesh that the bone is attached to
  45318. */
  45319. mesh: AbstractMesh;
  45320. /**
  45321. * The bone that will be looking to the target
  45322. */
  45323. bone: Bone;
  45324. /**
  45325. * The up axis of the coordinate system that is used when the bone is rotated
  45326. */
  45327. upAxis: Vector3;
  45328. /**
  45329. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45330. */
  45331. upAxisSpace: Space;
  45332. /**
  45333. * Used to make an adjustment to the yaw of the bone
  45334. */
  45335. adjustYaw: number;
  45336. /**
  45337. * Used to make an adjustment to the pitch of the bone
  45338. */
  45339. adjustPitch: number;
  45340. /**
  45341. * Used to make an adjustment to the roll of the bone
  45342. */
  45343. adjustRoll: number;
  45344. /**
  45345. * 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)
  45346. */
  45347. slerpAmount: number;
  45348. private _minYaw;
  45349. private _maxYaw;
  45350. private _minPitch;
  45351. private _maxPitch;
  45352. private _minYawSin;
  45353. private _minYawCos;
  45354. private _maxYawSin;
  45355. private _maxYawCos;
  45356. private _midYawConstraint;
  45357. private _minPitchTan;
  45358. private _maxPitchTan;
  45359. private _boneQuat;
  45360. private _slerping;
  45361. private _transformYawPitch;
  45362. private _transformYawPitchInv;
  45363. private _firstFrameSkipped;
  45364. private _yawRange;
  45365. private _fowardAxis;
  45366. /**
  45367. * Gets or sets the minimum yaw angle that the bone can look to
  45368. */
  45369. get minYaw(): number;
  45370. set minYaw(value: number);
  45371. /**
  45372. * Gets or sets the maximum yaw angle that the bone can look to
  45373. */
  45374. get maxYaw(): number;
  45375. set maxYaw(value: number);
  45376. /**
  45377. * Gets or sets the minimum pitch angle that the bone can look to
  45378. */
  45379. get minPitch(): number;
  45380. set minPitch(value: number);
  45381. /**
  45382. * Gets or sets the maximum pitch angle that the bone can look to
  45383. */
  45384. get maxPitch(): number;
  45385. set maxPitch(value: number);
  45386. /**
  45387. * Create a BoneLookController
  45388. * @param mesh the mesh that the bone belongs to
  45389. * @param bone the bone that will be looking to the target
  45390. * @param target the target Vector3 to look at
  45391. * @param options optional settings:
  45392. * * maxYaw: the maximum angle the bone will yaw to
  45393. * * minYaw: the minimum angle the bone will yaw to
  45394. * * maxPitch: the maximum angle the bone will pitch to
  45395. * * minPitch: the minimum angle the bone will yaw to
  45396. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45397. * * upAxis: the up axis of the coordinate system
  45398. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45399. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45400. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45401. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45402. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45403. * * adjustRoll: used to make an adjustment to the roll of the bone
  45404. **/
  45405. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45406. maxYaw?: number;
  45407. minYaw?: number;
  45408. maxPitch?: number;
  45409. minPitch?: number;
  45410. slerpAmount?: number;
  45411. upAxis?: Vector3;
  45412. upAxisSpace?: Space;
  45413. yawAxis?: Vector3;
  45414. pitchAxis?: Vector3;
  45415. adjustYaw?: number;
  45416. adjustPitch?: number;
  45417. adjustRoll?: number;
  45418. });
  45419. /**
  45420. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45421. */
  45422. update(): void;
  45423. private _getAngleDiff;
  45424. private _getAngleBetween;
  45425. private _isAngleBetween;
  45426. }
  45427. }
  45428. declare module "babylonjs/Bones/index" {
  45429. export * from "babylonjs/Bones/bone";
  45430. export * from "babylonjs/Bones/boneIKController";
  45431. export * from "babylonjs/Bones/boneLookController";
  45432. export * from "babylonjs/Bones/skeleton";
  45433. }
  45434. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45435. import { Nullable } from "babylonjs/types";
  45436. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45437. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45438. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45439. /**
  45440. * Manage the gamepad inputs to control an arc rotate camera.
  45441. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45442. */
  45443. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45444. /**
  45445. * Defines the camera the input is attached to.
  45446. */
  45447. camera: ArcRotateCamera;
  45448. /**
  45449. * Defines the gamepad the input is gathering event from.
  45450. */
  45451. gamepad: Nullable<Gamepad>;
  45452. /**
  45453. * Defines the gamepad rotation sensiblity.
  45454. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45455. */
  45456. gamepadRotationSensibility: number;
  45457. /**
  45458. * Defines the gamepad move sensiblity.
  45459. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45460. */
  45461. gamepadMoveSensibility: number;
  45462. private _yAxisScale;
  45463. /**
  45464. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45465. */
  45466. get invertYAxis(): boolean;
  45467. set invertYAxis(value: boolean);
  45468. private _onGamepadConnectedObserver;
  45469. private _onGamepadDisconnectedObserver;
  45470. /**
  45471. * Attach the input controls to a specific dom element to get the input from.
  45472. * @param element Defines the element the controls should be listened from
  45473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45474. */
  45475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45476. /**
  45477. * Detach the current controls from the specified dom element.
  45478. * @param element Defines the element to stop listening the inputs from
  45479. */
  45480. detachControl(element: Nullable<HTMLElement>): void;
  45481. /**
  45482. * Update the current camera state depending on the inputs that have been used this frame.
  45483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45484. */
  45485. checkInputs(): void;
  45486. /**
  45487. * Gets the class name of the current intput.
  45488. * @returns the class name
  45489. */
  45490. getClassName(): string;
  45491. /**
  45492. * Get the friendly name associated with the input class.
  45493. * @returns the input friendly name
  45494. */
  45495. getSimpleName(): string;
  45496. }
  45497. }
  45498. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45499. import { Nullable } from "babylonjs/types";
  45500. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45501. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45502. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45503. interface ArcRotateCameraInputsManager {
  45504. /**
  45505. * Add orientation input support to the input manager.
  45506. * @returns the current input manager
  45507. */
  45508. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45509. }
  45510. }
  45511. /**
  45512. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45513. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45514. */
  45515. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45516. /**
  45517. * Defines the camera the input is attached to.
  45518. */
  45519. camera: ArcRotateCamera;
  45520. /**
  45521. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45522. */
  45523. alphaCorrection: number;
  45524. /**
  45525. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45526. */
  45527. gammaCorrection: number;
  45528. private _alpha;
  45529. private _gamma;
  45530. private _dirty;
  45531. private _deviceOrientationHandler;
  45532. /**
  45533. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45534. */
  45535. constructor();
  45536. /**
  45537. * Attach the input controls to a specific dom element to get the input from.
  45538. * @param element Defines the element the controls should be listened from
  45539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45540. */
  45541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45542. /** @hidden */
  45543. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45544. /**
  45545. * Update the current camera state depending on the inputs that have been used this frame.
  45546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45547. */
  45548. checkInputs(): void;
  45549. /**
  45550. * Detach the current controls from the specified dom element.
  45551. * @param element Defines the element to stop listening the inputs from
  45552. */
  45553. detachControl(element: Nullable<HTMLElement>): void;
  45554. /**
  45555. * Gets the class name of the current intput.
  45556. * @returns the class name
  45557. */
  45558. getClassName(): string;
  45559. /**
  45560. * Get the friendly name associated with the input class.
  45561. * @returns the input friendly name
  45562. */
  45563. getSimpleName(): string;
  45564. }
  45565. }
  45566. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45567. import { Nullable } from "babylonjs/types";
  45568. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45569. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45570. /**
  45571. * Listen to mouse events to control the camera.
  45572. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45573. */
  45574. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45575. /**
  45576. * Defines the camera the input is attached to.
  45577. */
  45578. camera: FlyCamera;
  45579. /**
  45580. * Defines if touch is enabled. (Default is true.)
  45581. */
  45582. touchEnabled: boolean;
  45583. /**
  45584. * Defines the buttons associated with the input to handle camera rotation.
  45585. */
  45586. buttons: number[];
  45587. /**
  45588. * Assign buttons for Yaw control.
  45589. */
  45590. buttonsYaw: number[];
  45591. /**
  45592. * Assign buttons for Pitch control.
  45593. */
  45594. buttonsPitch: number[];
  45595. /**
  45596. * Assign buttons for Roll control.
  45597. */
  45598. buttonsRoll: number[];
  45599. /**
  45600. * Detect if any button is being pressed while mouse is moved.
  45601. * -1 = Mouse locked.
  45602. * 0 = Left button.
  45603. * 1 = Middle Button.
  45604. * 2 = Right Button.
  45605. */
  45606. activeButton: number;
  45607. /**
  45608. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45609. * Higher values reduce its sensitivity.
  45610. */
  45611. angularSensibility: number;
  45612. private _mousemoveCallback;
  45613. private _observer;
  45614. private _rollObserver;
  45615. private previousPosition;
  45616. private noPreventDefault;
  45617. private element;
  45618. /**
  45619. * Listen to mouse events to control the camera.
  45620. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45621. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45622. */
  45623. constructor(touchEnabled?: boolean);
  45624. /**
  45625. * Attach the mouse control to the HTML DOM element.
  45626. * @param element Defines the element that listens to the input events.
  45627. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45628. */
  45629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45630. /**
  45631. * Detach the current controls from the specified dom element.
  45632. * @param element Defines the element to stop listening the inputs from
  45633. */
  45634. detachControl(element: Nullable<HTMLElement>): void;
  45635. /**
  45636. * Gets the class name of the current input.
  45637. * @returns the class name.
  45638. */
  45639. getClassName(): string;
  45640. /**
  45641. * Get the friendly name associated with the input class.
  45642. * @returns the input's friendly name.
  45643. */
  45644. getSimpleName(): string;
  45645. private _pointerInput;
  45646. private _onMouseMove;
  45647. /**
  45648. * Rotate camera by mouse offset.
  45649. */
  45650. private rotateCamera;
  45651. }
  45652. }
  45653. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45654. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45655. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45656. /**
  45657. * Default Inputs manager for the FlyCamera.
  45658. * It groups all the default supported inputs for ease of use.
  45659. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45660. */
  45661. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45662. /**
  45663. * Instantiates a new FlyCameraInputsManager.
  45664. * @param camera Defines the camera the inputs belong to.
  45665. */
  45666. constructor(camera: FlyCamera);
  45667. /**
  45668. * Add keyboard input support to the input manager.
  45669. * @returns the new FlyCameraKeyboardMoveInput().
  45670. */
  45671. addKeyboard(): FlyCameraInputsManager;
  45672. /**
  45673. * Add mouse input support to the input manager.
  45674. * @param touchEnabled Enable touch screen support.
  45675. * @returns the new FlyCameraMouseInput().
  45676. */
  45677. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45678. }
  45679. }
  45680. declare module "babylonjs/Cameras/flyCamera" {
  45681. import { Scene } from "babylonjs/scene";
  45682. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45684. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45685. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45686. /**
  45687. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45688. * such as in a 3D Space Shooter or a Flight Simulator.
  45689. */
  45690. export class FlyCamera extends TargetCamera {
  45691. /**
  45692. * Define the collision ellipsoid of the camera.
  45693. * This is helpful for simulating a camera body, like a player's body.
  45694. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45695. */
  45696. ellipsoid: Vector3;
  45697. /**
  45698. * Define an offset for the position of the ellipsoid around the camera.
  45699. * This can be helpful if the camera is attached away from the player's body center,
  45700. * such as at its head.
  45701. */
  45702. ellipsoidOffset: Vector3;
  45703. /**
  45704. * Enable or disable collisions of the camera with the rest of the scene objects.
  45705. */
  45706. checkCollisions: boolean;
  45707. /**
  45708. * Enable or disable gravity on the camera.
  45709. */
  45710. applyGravity: boolean;
  45711. /**
  45712. * Define the current direction the camera is moving to.
  45713. */
  45714. cameraDirection: Vector3;
  45715. /**
  45716. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45717. * This overrides and empties cameraRotation.
  45718. */
  45719. rotationQuaternion: Quaternion;
  45720. /**
  45721. * Track Roll to maintain the wanted Rolling when looking around.
  45722. */
  45723. _trackRoll: number;
  45724. /**
  45725. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45726. */
  45727. rollCorrect: number;
  45728. /**
  45729. * Mimic a banked turn, Rolling the camera when Yawing.
  45730. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45731. */
  45732. bankedTurn: boolean;
  45733. /**
  45734. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45735. */
  45736. bankedTurnLimit: number;
  45737. /**
  45738. * Value of 0 disables the banked Roll.
  45739. * Value of 1 is equal to the Yaw angle in radians.
  45740. */
  45741. bankedTurnMultiplier: number;
  45742. /**
  45743. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45744. */
  45745. inputs: FlyCameraInputsManager;
  45746. /**
  45747. * Gets the input sensibility for mouse input.
  45748. * Higher values reduce sensitivity.
  45749. */
  45750. get angularSensibility(): number;
  45751. /**
  45752. * Sets the input sensibility for a mouse input.
  45753. * Higher values reduce sensitivity.
  45754. */
  45755. set angularSensibility(value: number);
  45756. /**
  45757. * Get the keys for camera movement forward.
  45758. */
  45759. get keysForward(): number[];
  45760. /**
  45761. * Set the keys for camera movement forward.
  45762. */
  45763. set keysForward(value: number[]);
  45764. /**
  45765. * Get the keys for camera movement backward.
  45766. */
  45767. get keysBackward(): number[];
  45768. set keysBackward(value: number[]);
  45769. /**
  45770. * Get the keys for camera movement up.
  45771. */
  45772. get keysUp(): number[];
  45773. /**
  45774. * Set the keys for camera movement up.
  45775. */
  45776. set keysUp(value: number[]);
  45777. /**
  45778. * Get the keys for camera movement down.
  45779. */
  45780. get keysDown(): number[];
  45781. /**
  45782. * Set the keys for camera movement down.
  45783. */
  45784. set keysDown(value: number[]);
  45785. /**
  45786. * Get the keys for camera movement left.
  45787. */
  45788. get keysLeft(): number[];
  45789. /**
  45790. * Set the keys for camera movement left.
  45791. */
  45792. set keysLeft(value: number[]);
  45793. /**
  45794. * Set the keys for camera movement right.
  45795. */
  45796. get keysRight(): number[];
  45797. /**
  45798. * Set the keys for camera movement right.
  45799. */
  45800. set keysRight(value: number[]);
  45801. /**
  45802. * Event raised when the camera collides with a mesh in the scene.
  45803. */
  45804. onCollide: (collidedMesh: AbstractMesh) => void;
  45805. private _collider;
  45806. private _needMoveForGravity;
  45807. private _oldPosition;
  45808. private _diffPosition;
  45809. private _newPosition;
  45810. /** @hidden */
  45811. _localDirection: Vector3;
  45812. /** @hidden */
  45813. _transformedDirection: Vector3;
  45814. /**
  45815. * Instantiates a FlyCamera.
  45816. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45817. * such as in a 3D Space Shooter or a Flight Simulator.
  45818. * @param name Define the name of the camera in the scene.
  45819. * @param position Define the starting position of the camera in the scene.
  45820. * @param scene Define the scene the camera belongs to.
  45821. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45822. */
  45823. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45824. /**
  45825. * Attach a control to the HTML DOM element.
  45826. * @param element Defines the element that listens to the input events.
  45827. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45828. */
  45829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45830. /**
  45831. * Detach a control from the HTML DOM element.
  45832. * The camera will stop reacting to that input.
  45833. * @param element Defines the element that listens to the input events.
  45834. */
  45835. detachControl(element: HTMLElement): void;
  45836. private _collisionMask;
  45837. /**
  45838. * Get the mask that the camera ignores in collision events.
  45839. */
  45840. get collisionMask(): number;
  45841. /**
  45842. * Set the mask that the camera ignores in collision events.
  45843. */
  45844. set collisionMask(mask: number);
  45845. /** @hidden */
  45846. _collideWithWorld(displacement: Vector3): void;
  45847. /** @hidden */
  45848. private _onCollisionPositionChange;
  45849. /** @hidden */
  45850. _checkInputs(): void;
  45851. /** @hidden */
  45852. _decideIfNeedsToMove(): boolean;
  45853. /** @hidden */
  45854. _updatePosition(): void;
  45855. /**
  45856. * Restore the Roll to its target value at the rate specified.
  45857. * @param rate - Higher means slower restoring.
  45858. * @hidden
  45859. */
  45860. restoreRoll(rate: number): void;
  45861. /**
  45862. * Destroy the camera and release the current resources held by it.
  45863. */
  45864. dispose(): void;
  45865. /**
  45866. * Get the current object class name.
  45867. * @returns the class name.
  45868. */
  45869. getClassName(): string;
  45870. }
  45871. }
  45872. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45873. import { Nullable } from "babylonjs/types";
  45874. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45875. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45876. /**
  45877. * Listen to keyboard events to control the camera.
  45878. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45879. */
  45880. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45881. /**
  45882. * Defines the camera the input is attached to.
  45883. */
  45884. camera: FlyCamera;
  45885. /**
  45886. * The list of keyboard keys used to control the forward move of the camera.
  45887. */
  45888. keysForward: number[];
  45889. /**
  45890. * The list of keyboard keys used to control the backward move of the camera.
  45891. */
  45892. keysBackward: number[];
  45893. /**
  45894. * The list of keyboard keys used to control the forward move of the camera.
  45895. */
  45896. keysUp: number[];
  45897. /**
  45898. * The list of keyboard keys used to control the backward move of the camera.
  45899. */
  45900. keysDown: number[];
  45901. /**
  45902. * The list of keyboard keys used to control the right strafe move of the camera.
  45903. */
  45904. keysRight: number[];
  45905. /**
  45906. * The list of keyboard keys used to control the left strafe move of the camera.
  45907. */
  45908. keysLeft: number[];
  45909. private _keys;
  45910. private _onCanvasBlurObserver;
  45911. private _onKeyboardObserver;
  45912. private _engine;
  45913. private _scene;
  45914. /**
  45915. * Attach the input controls to a specific dom element to get the input from.
  45916. * @param element Defines the element the controls should be listened from
  45917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45918. */
  45919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45920. /**
  45921. * Detach the current controls from the specified dom element.
  45922. * @param element Defines the element to stop listening the inputs from
  45923. */
  45924. detachControl(element: Nullable<HTMLElement>): void;
  45925. /**
  45926. * Gets the class name of the current intput.
  45927. * @returns the class name
  45928. */
  45929. getClassName(): string;
  45930. /** @hidden */
  45931. _onLostFocus(e: FocusEvent): void;
  45932. /**
  45933. * Get the friendly name associated with the input class.
  45934. * @returns the input friendly name
  45935. */
  45936. getSimpleName(): string;
  45937. /**
  45938. * Update the current camera state depending on the inputs that have been used this frame.
  45939. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45940. */
  45941. checkInputs(): void;
  45942. }
  45943. }
  45944. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45945. import { Nullable } from "babylonjs/types";
  45946. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45947. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45948. /**
  45949. * Manage the mouse wheel inputs to control a follow camera.
  45950. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45951. */
  45952. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45953. /**
  45954. * Defines the camera the input is attached to.
  45955. */
  45956. camera: FollowCamera;
  45957. /**
  45958. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45959. */
  45960. axisControlRadius: boolean;
  45961. /**
  45962. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45963. */
  45964. axisControlHeight: boolean;
  45965. /**
  45966. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45967. */
  45968. axisControlRotation: boolean;
  45969. /**
  45970. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45971. * relation to mouseWheel events.
  45972. */
  45973. wheelPrecision: number;
  45974. /**
  45975. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45976. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45977. */
  45978. wheelDeltaPercentage: number;
  45979. private _wheel;
  45980. private _observer;
  45981. /**
  45982. * Attach the input controls to a specific dom element to get the input from.
  45983. * @param element Defines the element the controls should be listened from
  45984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45985. */
  45986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45987. /**
  45988. * Detach the current controls from the specified dom element.
  45989. * @param element Defines the element to stop listening the inputs from
  45990. */
  45991. detachControl(element: Nullable<HTMLElement>): void;
  45992. /**
  45993. * Gets the class name of the current intput.
  45994. * @returns the class name
  45995. */
  45996. getClassName(): string;
  45997. /**
  45998. * Get the friendly name associated with the input class.
  45999. * @returns the input friendly name
  46000. */
  46001. getSimpleName(): string;
  46002. }
  46003. }
  46004. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46005. import { Nullable } from "babylonjs/types";
  46006. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46007. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46008. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46009. /**
  46010. * Manage the pointers inputs to control an follow camera.
  46011. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46012. */
  46013. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46014. /**
  46015. * Defines the camera the input is attached to.
  46016. */
  46017. camera: FollowCamera;
  46018. /**
  46019. * Gets the class name of the current input.
  46020. * @returns the class name
  46021. */
  46022. getClassName(): string;
  46023. /**
  46024. * Defines the pointer angular sensibility along the X axis or how fast is
  46025. * the camera rotating.
  46026. * A negative number will reverse the axis direction.
  46027. */
  46028. angularSensibilityX: number;
  46029. /**
  46030. * Defines the pointer angular sensibility along the Y axis or how fast is
  46031. * the camera rotating.
  46032. * A negative number will reverse the axis direction.
  46033. */
  46034. angularSensibilityY: number;
  46035. /**
  46036. * Defines the pointer pinch precision or how fast is the camera zooming.
  46037. * A negative number will reverse the axis direction.
  46038. */
  46039. pinchPrecision: number;
  46040. /**
  46041. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46042. * from 0.
  46043. * It defines the percentage of current camera.radius to use as delta when
  46044. * pinch zoom is used.
  46045. */
  46046. pinchDeltaPercentage: number;
  46047. /**
  46048. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46049. */
  46050. axisXControlRadius: boolean;
  46051. /**
  46052. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46053. */
  46054. axisXControlHeight: boolean;
  46055. /**
  46056. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46057. */
  46058. axisXControlRotation: boolean;
  46059. /**
  46060. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46061. */
  46062. axisYControlRadius: boolean;
  46063. /**
  46064. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46065. */
  46066. axisYControlHeight: boolean;
  46067. /**
  46068. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46069. */
  46070. axisYControlRotation: boolean;
  46071. /**
  46072. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46073. */
  46074. axisPinchControlRadius: boolean;
  46075. /**
  46076. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46077. */
  46078. axisPinchControlHeight: boolean;
  46079. /**
  46080. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46081. */
  46082. axisPinchControlRotation: boolean;
  46083. /**
  46084. * Log error messages if basic misconfiguration has occurred.
  46085. */
  46086. warningEnable: boolean;
  46087. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46088. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46089. private _warningCounter;
  46090. private _warning;
  46091. }
  46092. }
  46093. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46094. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46095. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46096. /**
  46097. * Default Inputs manager for the FollowCamera.
  46098. * It groups all the default supported inputs for ease of use.
  46099. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46100. */
  46101. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46102. /**
  46103. * Instantiates a new FollowCameraInputsManager.
  46104. * @param camera Defines the camera the inputs belong to
  46105. */
  46106. constructor(camera: FollowCamera);
  46107. /**
  46108. * Add keyboard input support to the input manager.
  46109. * @returns the current input manager
  46110. */
  46111. addKeyboard(): FollowCameraInputsManager;
  46112. /**
  46113. * Add mouse wheel input support to the input manager.
  46114. * @returns the current input manager
  46115. */
  46116. addMouseWheel(): FollowCameraInputsManager;
  46117. /**
  46118. * Add pointers input support to the input manager.
  46119. * @returns the current input manager
  46120. */
  46121. addPointers(): FollowCameraInputsManager;
  46122. /**
  46123. * Add orientation input support to the input manager.
  46124. * @returns the current input manager
  46125. */
  46126. addVRDeviceOrientation(): FollowCameraInputsManager;
  46127. }
  46128. }
  46129. declare module "babylonjs/Cameras/followCamera" {
  46130. import { Nullable } from "babylonjs/types";
  46131. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46132. import { Scene } from "babylonjs/scene";
  46133. import { Vector3 } from "babylonjs/Maths/math.vector";
  46134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46135. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46136. /**
  46137. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46138. * an arc rotate version arcFollowCamera are available.
  46139. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46140. */
  46141. export class FollowCamera extends TargetCamera {
  46142. /**
  46143. * Distance the follow camera should follow an object at
  46144. */
  46145. radius: number;
  46146. /**
  46147. * Minimum allowed distance of the camera to the axis of rotation
  46148. * (The camera can not get closer).
  46149. * This can help limiting how the Camera is able to move in the scene.
  46150. */
  46151. lowerRadiusLimit: Nullable<number>;
  46152. /**
  46153. * Maximum allowed distance of the camera to the axis of rotation
  46154. * (The camera can not get further).
  46155. * This can help limiting how the Camera is able to move in the scene.
  46156. */
  46157. upperRadiusLimit: Nullable<number>;
  46158. /**
  46159. * Define a rotation offset between the camera and the object it follows
  46160. */
  46161. rotationOffset: number;
  46162. /**
  46163. * Minimum allowed angle to camera position relative to target object.
  46164. * This can help limiting how the Camera is able to move in the scene.
  46165. */
  46166. lowerRotationOffsetLimit: Nullable<number>;
  46167. /**
  46168. * Maximum allowed angle to camera position relative to target object.
  46169. * This can help limiting how the Camera is able to move in the scene.
  46170. */
  46171. upperRotationOffsetLimit: Nullable<number>;
  46172. /**
  46173. * Define a height offset between the camera and the object it follows.
  46174. * It can help following an object from the top (like a car chaing a plane)
  46175. */
  46176. heightOffset: number;
  46177. /**
  46178. * Minimum allowed height of camera position relative to target object.
  46179. * This can help limiting how the Camera is able to move in the scene.
  46180. */
  46181. lowerHeightOffsetLimit: Nullable<number>;
  46182. /**
  46183. * Maximum allowed height of camera position relative to target object.
  46184. * This can help limiting how the Camera is able to move in the scene.
  46185. */
  46186. upperHeightOffsetLimit: Nullable<number>;
  46187. /**
  46188. * Define how fast the camera can accelerate to follow it s target.
  46189. */
  46190. cameraAcceleration: number;
  46191. /**
  46192. * Define the speed limit of the camera following an object.
  46193. */
  46194. maxCameraSpeed: number;
  46195. /**
  46196. * Define the target of the camera.
  46197. */
  46198. lockedTarget: Nullable<AbstractMesh>;
  46199. /**
  46200. * Defines the input associated with the camera.
  46201. */
  46202. inputs: FollowCameraInputsManager;
  46203. /**
  46204. * Instantiates the follow camera.
  46205. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46206. * @param name Define the name of the camera in the scene
  46207. * @param position Define the position of the camera
  46208. * @param scene Define the scene the camera belong to
  46209. * @param lockedTarget Define the target of the camera
  46210. */
  46211. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46212. private _follow;
  46213. /**
  46214. * Attached controls to the current camera.
  46215. * @param element Defines the element the controls should be listened from
  46216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46217. */
  46218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46219. /**
  46220. * Detach the current controls from the camera.
  46221. * The camera will stop reacting to inputs.
  46222. * @param element Defines the element to stop listening the inputs from
  46223. */
  46224. detachControl(element: HTMLElement): void;
  46225. /** @hidden */
  46226. _checkInputs(): void;
  46227. private _checkLimits;
  46228. /**
  46229. * Gets the camera class name.
  46230. * @returns the class name
  46231. */
  46232. getClassName(): string;
  46233. }
  46234. /**
  46235. * Arc Rotate version of the follow camera.
  46236. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46237. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46238. */
  46239. export class ArcFollowCamera extends TargetCamera {
  46240. /** The longitudinal angle of the camera */
  46241. alpha: number;
  46242. /** The latitudinal angle of the camera */
  46243. beta: number;
  46244. /** The radius of the camera from its target */
  46245. radius: number;
  46246. private _cartesianCoordinates;
  46247. /** Define the camera target (the mesh it should follow) */
  46248. private _meshTarget;
  46249. /**
  46250. * Instantiates a new ArcFollowCamera
  46251. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46252. * @param name Define the name of the camera
  46253. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46254. * @param beta Define the rotation angle of the camera around the elevation axis
  46255. * @param radius Define the radius of the camera from its target point
  46256. * @param target Define the target of the camera
  46257. * @param scene Define the scene the camera belongs to
  46258. */
  46259. constructor(name: string,
  46260. /** The longitudinal angle of the camera */
  46261. alpha: number,
  46262. /** The latitudinal angle of the camera */
  46263. beta: number,
  46264. /** The radius of the camera from its target */
  46265. radius: number,
  46266. /** Define the camera target (the mesh it should follow) */
  46267. target: Nullable<AbstractMesh>, scene: Scene);
  46268. private _follow;
  46269. /** @hidden */
  46270. _checkInputs(): void;
  46271. /**
  46272. * Returns the class name of the object.
  46273. * It is mostly used internally for serialization purposes.
  46274. */
  46275. getClassName(): string;
  46276. }
  46277. }
  46278. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46279. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46280. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46281. import { Nullable } from "babylonjs/types";
  46282. /**
  46283. * Manage the keyboard inputs to control the movement of a follow camera.
  46284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46285. */
  46286. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46287. /**
  46288. * Defines the camera the input is attached to.
  46289. */
  46290. camera: FollowCamera;
  46291. /**
  46292. * Defines the list of key codes associated with the up action (increase heightOffset)
  46293. */
  46294. keysHeightOffsetIncr: number[];
  46295. /**
  46296. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46297. */
  46298. keysHeightOffsetDecr: number[];
  46299. /**
  46300. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46301. */
  46302. keysHeightOffsetModifierAlt: boolean;
  46303. /**
  46304. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46305. */
  46306. keysHeightOffsetModifierCtrl: boolean;
  46307. /**
  46308. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46309. */
  46310. keysHeightOffsetModifierShift: boolean;
  46311. /**
  46312. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46313. */
  46314. keysRotationOffsetIncr: number[];
  46315. /**
  46316. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46317. */
  46318. keysRotationOffsetDecr: number[];
  46319. /**
  46320. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46321. */
  46322. keysRotationOffsetModifierAlt: boolean;
  46323. /**
  46324. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46325. */
  46326. keysRotationOffsetModifierCtrl: boolean;
  46327. /**
  46328. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46329. */
  46330. keysRotationOffsetModifierShift: boolean;
  46331. /**
  46332. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46333. */
  46334. keysRadiusIncr: number[];
  46335. /**
  46336. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46337. */
  46338. keysRadiusDecr: number[];
  46339. /**
  46340. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46341. */
  46342. keysRadiusModifierAlt: boolean;
  46343. /**
  46344. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46345. */
  46346. keysRadiusModifierCtrl: boolean;
  46347. /**
  46348. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46349. */
  46350. keysRadiusModifierShift: boolean;
  46351. /**
  46352. * Defines the rate of change of heightOffset.
  46353. */
  46354. heightSensibility: number;
  46355. /**
  46356. * Defines the rate of change of rotationOffset.
  46357. */
  46358. rotationSensibility: number;
  46359. /**
  46360. * Defines the rate of change of radius.
  46361. */
  46362. radiusSensibility: number;
  46363. private _keys;
  46364. private _ctrlPressed;
  46365. private _altPressed;
  46366. private _shiftPressed;
  46367. private _onCanvasBlurObserver;
  46368. private _onKeyboardObserver;
  46369. private _engine;
  46370. private _scene;
  46371. /**
  46372. * Attach the input controls to a specific dom element to get the input from.
  46373. * @param element Defines the element the controls should be listened from
  46374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46375. */
  46376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46377. /**
  46378. * Detach the current controls from the specified dom element.
  46379. * @param element Defines the element to stop listening the inputs from
  46380. */
  46381. detachControl(element: Nullable<HTMLElement>): void;
  46382. /**
  46383. * Update the current camera state depending on the inputs that have been used this frame.
  46384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46385. */
  46386. checkInputs(): void;
  46387. /**
  46388. * Gets the class name of the current input.
  46389. * @returns the class name
  46390. */
  46391. getClassName(): string;
  46392. /**
  46393. * Get the friendly name associated with the input class.
  46394. * @returns the input friendly name
  46395. */
  46396. getSimpleName(): string;
  46397. /**
  46398. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46399. * allow modification of the heightOffset value.
  46400. */
  46401. private _modifierHeightOffset;
  46402. /**
  46403. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46404. * allow modification of the rotationOffset value.
  46405. */
  46406. private _modifierRotationOffset;
  46407. /**
  46408. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46409. * allow modification of the radius value.
  46410. */
  46411. private _modifierRadius;
  46412. }
  46413. }
  46414. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46415. import { Nullable } from "babylonjs/types";
  46416. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46417. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46418. import { Observable } from "babylonjs/Misc/observable";
  46419. module "babylonjs/Cameras/freeCameraInputsManager" {
  46420. interface FreeCameraInputsManager {
  46421. /**
  46422. * @hidden
  46423. */
  46424. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46425. /**
  46426. * Add orientation input support to the input manager.
  46427. * @returns the current input manager
  46428. */
  46429. addDeviceOrientation(): FreeCameraInputsManager;
  46430. }
  46431. }
  46432. /**
  46433. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46434. * Screen rotation is taken into account.
  46435. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46436. */
  46437. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46438. private _camera;
  46439. private _screenOrientationAngle;
  46440. private _constantTranform;
  46441. private _screenQuaternion;
  46442. private _alpha;
  46443. private _beta;
  46444. private _gamma;
  46445. /**
  46446. * Can be used to detect if a device orientation sensor is available on a device
  46447. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46448. * @returns a promise that will resolve on orientation change
  46449. */
  46450. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46451. /**
  46452. * @hidden
  46453. */
  46454. _onDeviceOrientationChangedObservable: Observable<void>;
  46455. /**
  46456. * Instantiates a new input
  46457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46458. */
  46459. constructor();
  46460. /**
  46461. * Define the camera controlled by the input.
  46462. */
  46463. get camera(): FreeCamera;
  46464. set camera(camera: FreeCamera);
  46465. /**
  46466. * Attach the input controls to a specific dom element to get the input from.
  46467. * @param element Defines the element the controls should be listened from
  46468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46469. */
  46470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46471. private _orientationChanged;
  46472. private _deviceOrientation;
  46473. /**
  46474. * Detach the current controls from the specified dom element.
  46475. * @param element Defines the element to stop listening the inputs from
  46476. */
  46477. detachControl(element: Nullable<HTMLElement>): void;
  46478. /**
  46479. * Update the current camera state depending on the inputs that have been used this frame.
  46480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46481. */
  46482. checkInputs(): void;
  46483. /**
  46484. * Gets the class name of the current intput.
  46485. * @returns the class name
  46486. */
  46487. getClassName(): string;
  46488. /**
  46489. * Get the friendly name associated with the input class.
  46490. * @returns the input friendly name
  46491. */
  46492. getSimpleName(): string;
  46493. }
  46494. }
  46495. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46496. import { Nullable } from "babylonjs/types";
  46497. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46498. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46499. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46500. /**
  46501. * Manage the gamepad inputs to control a free camera.
  46502. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46503. */
  46504. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46505. /**
  46506. * Define the camera the input is attached to.
  46507. */
  46508. camera: FreeCamera;
  46509. /**
  46510. * Define the Gamepad controlling the input
  46511. */
  46512. gamepad: Nullable<Gamepad>;
  46513. /**
  46514. * Defines the gamepad rotation sensiblity.
  46515. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46516. */
  46517. gamepadAngularSensibility: number;
  46518. /**
  46519. * Defines the gamepad move sensiblity.
  46520. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46521. */
  46522. gamepadMoveSensibility: number;
  46523. private _yAxisScale;
  46524. /**
  46525. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46526. */
  46527. get invertYAxis(): boolean;
  46528. set invertYAxis(value: boolean);
  46529. private _onGamepadConnectedObserver;
  46530. private _onGamepadDisconnectedObserver;
  46531. private _cameraTransform;
  46532. private _deltaTransform;
  46533. private _vector3;
  46534. private _vector2;
  46535. /**
  46536. * Attach the input controls to a specific dom element to get the input from.
  46537. * @param element Defines the element the controls should be listened from
  46538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46539. */
  46540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46541. /**
  46542. * Detach the current controls from the specified dom element.
  46543. * @param element Defines the element to stop listening the inputs from
  46544. */
  46545. detachControl(element: Nullable<HTMLElement>): void;
  46546. /**
  46547. * Update the current camera state depending on the inputs that have been used this frame.
  46548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46549. */
  46550. checkInputs(): void;
  46551. /**
  46552. * Gets the class name of the current intput.
  46553. * @returns the class name
  46554. */
  46555. getClassName(): string;
  46556. /**
  46557. * Get the friendly name associated with the input class.
  46558. * @returns the input friendly name
  46559. */
  46560. getSimpleName(): string;
  46561. }
  46562. }
  46563. declare module "babylonjs/Misc/virtualJoystick" {
  46564. import { Nullable } from "babylonjs/types";
  46565. import { Vector3 } from "babylonjs/Maths/math.vector";
  46566. /**
  46567. * Defines the potential axis of a Joystick
  46568. */
  46569. export enum JoystickAxis {
  46570. /** X axis */
  46571. X = 0,
  46572. /** Y axis */
  46573. Y = 1,
  46574. /** Z axis */
  46575. Z = 2
  46576. }
  46577. /**
  46578. * Represents the different customization options available
  46579. * for VirtualJoystick
  46580. */
  46581. interface VirtualJoystickCustomizations {
  46582. /**
  46583. * Size of the joystick's puck
  46584. */
  46585. puckSize: number;
  46586. /**
  46587. * Size of the joystick's container
  46588. */
  46589. containerSize: number;
  46590. /**
  46591. * Color of the joystick && puck
  46592. */
  46593. color: string;
  46594. /**
  46595. * Image URL for the joystick's puck
  46596. */
  46597. puckImage?: string;
  46598. /**
  46599. * Image URL for the joystick's container
  46600. */
  46601. containerImage?: string;
  46602. /**
  46603. * Defines the unmoving position of the joystick container
  46604. */
  46605. position?: {
  46606. x: number;
  46607. y: number;
  46608. };
  46609. /**
  46610. * Defines whether or not the joystick container is always visible
  46611. */
  46612. alwaysVisible: boolean;
  46613. /**
  46614. * Defines whether or not to limit the movement of the puck to the joystick's container
  46615. */
  46616. limitToContainer: boolean;
  46617. }
  46618. /**
  46619. * Class used to define virtual joystick (used in touch mode)
  46620. */
  46621. export class VirtualJoystick {
  46622. /**
  46623. * Gets or sets a boolean indicating that left and right values must be inverted
  46624. */
  46625. reverseLeftRight: boolean;
  46626. /**
  46627. * Gets or sets a boolean indicating that up and down values must be inverted
  46628. */
  46629. reverseUpDown: boolean;
  46630. /**
  46631. * Gets the offset value for the position (ie. the change of the position value)
  46632. */
  46633. deltaPosition: Vector3;
  46634. /**
  46635. * Gets a boolean indicating if the virtual joystick was pressed
  46636. */
  46637. pressed: boolean;
  46638. /**
  46639. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46640. */
  46641. static Canvas: Nullable<HTMLCanvasElement>;
  46642. /**
  46643. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46644. */
  46645. limitToContainer: boolean;
  46646. private static _globalJoystickIndex;
  46647. private static _alwaysVisibleSticks;
  46648. private static vjCanvasContext;
  46649. private static vjCanvasWidth;
  46650. private static vjCanvasHeight;
  46651. private static halfWidth;
  46652. private static _GetDefaultOptions;
  46653. private _action;
  46654. private _axisTargetedByLeftAndRight;
  46655. private _axisTargetedByUpAndDown;
  46656. private _joystickSensibility;
  46657. private _inversedSensibility;
  46658. private _joystickPointerID;
  46659. private _joystickColor;
  46660. private _joystickPointerPos;
  46661. private _joystickPreviousPointerPos;
  46662. private _joystickPointerStartPos;
  46663. private _deltaJoystickVector;
  46664. private _leftJoystick;
  46665. private _touches;
  46666. private _joystickPosition;
  46667. private _alwaysVisible;
  46668. private _puckImage;
  46669. private _containerImage;
  46670. private _joystickPuckSize;
  46671. private _joystickContainerSize;
  46672. private _clearPuckSize;
  46673. private _clearContainerSize;
  46674. private _clearPuckSizeOffset;
  46675. private _clearContainerSizeOffset;
  46676. private _onPointerDownHandlerRef;
  46677. private _onPointerMoveHandlerRef;
  46678. private _onPointerUpHandlerRef;
  46679. private _onResize;
  46680. /**
  46681. * Creates a new virtual joystick
  46682. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46683. * @param customizations Defines the options we want to customize the VirtualJoystick
  46684. */
  46685. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46686. /**
  46687. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46688. * @param newJoystickSensibility defines the new sensibility
  46689. */
  46690. setJoystickSensibility(newJoystickSensibility: number): void;
  46691. private _onPointerDown;
  46692. private _onPointerMove;
  46693. private _onPointerUp;
  46694. /**
  46695. * Change the color of the virtual joystick
  46696. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46697. */
  46698. setJoystickColor(newColor: string): void;
  46699. /**
  46700. * Size of the joystick's container
  46701. */
  46702. set containerSize(newSize: number);
  46703. get containerSize(): number;
  46704. /**
  46705. * Size of the joystick's puck
  46706. */
  46707. set puckSize(newSize: number);
  46708. get puckSize(): number;
  46709. /**
  46710. * Clears the set position of the joystick
  46711. */
  46712. clearPosition(): void;
  46713. /**
  46714. * Defines whether or not the joystick container is always visible
  46715. */
  46716. set alwaysVisible(value: boolean);
  46717. get alwaysVisible(): boolean;
  46718. /**
  46719. * Sets the constant position of the Joystick container
  46720. * @param x X axis coordinate
  46721. * @param y Y axis coordinate
  46722. */
  46723. setPosition(x: number, y: number): void;
  46724. /**
  46725. * Defines a callback to call when the joystick is touched
  46726. * @param action defines the callback
  46727. */
  46728. setActionOnTouch(action: () => any): void;
  46729. /**
  46730. * Defines which axis you'd like to control for left & right
  46731. * @param axis defines the axis to use
  46732. */
  46733. setAxisForLeftRight(axis: JoystickAxis): void;
  46734. /**
  46735. * Defines which axis you'd like to control for up & down
  46736. * @param axis defines the axis to use
  46737. */
  46738. setAxisForUpDown(axis: JoystickAxis): void;
  46739. /**
  46740. * Clears the canvas from the previous puck / container draw
  46741. */
  46742. private _clearPreviousDraw;
  46743. /**
  46744. * Loads `urlPath` to be used for the container's image
  46745. * @param urlPath defines the urlPath of an image to use
  46746. */
  46747. setContainerImage(urlPath: string): void;
  46748. /**
  46749. * Loads `urlPath` to be used for the puck's image
  46750. * @param urlPath defines the urlPath of an image to use
  46751. */
  46752. setPuckImage(urlPath: string): void;
  46753. /**
  46754. * Draws the Virtual Joystick's container
  46755. */
  46756. private _drawContainer;
  46757. /**
  46758. * Draws the Virtual Joystick's puck
  46759. */
  46760. private _drawPuck;
  46761. private _drawVirtualJoystick;
  46762. /**
  46763. * Release internal HTML canvas
  46764. */
  46765. releaseCanvas(): void;
  46766. }
  46767. }
  46768. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46769. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46770. import { Nullable } from "babylonjs/types";
  46771. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46772. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46773. module "babylonjs/Cameras/freeCameraInputsManager" {
  46774. interface FreeCameraInputsManager {
  46775. /**
  46776. * Add virtual joystick input support to the input manager.
  46777. * @returns the current input manager
  46778. */
  46779. addVirtualJoystick(): FreeCameraInputsManager;
  46780. }
  46781. }
  46782. /**
  46783. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46784. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46785. */
  46786. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46787. /**
  46788. * Defines the camera the input is attached to.
  46789. */
  46790. camera: FreeCamera;
  46791. private _leftjoystick;
  46792. private _rightjoystick;
  46793. /**
  46794. * Gets the left stick of the virtual joystick.
  46795. * @returns The virtual Joystick
  46796. */
  46797. getLeftJoystick(): VirtualJoystick;
  46798. /**
  46799. * Gets the right stick of the virtual joystick.
  46800. * @returns The virtual Joystick
  46801. */
  46802. getRightJoystick(): VirtualJoystick;
  46803. /**
  46804. * Update the current camera state depending on the inputs that have been used this frame.
  46805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46806. */
  46807. checkInputs(): void;
  46808. /**
  46809. * Attach the input controls to a specific dom element to get the input from.
  46810. * @param element Defines the element the controls should be listened from
  46811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46812. */
  46813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46814. /**
  46815. * Detach the current controls from the specified dom element.
  46816. * @param element Defines the element to stop listening the inputs from
  46817. */
  46818. detachControl(element: Nullable<HTMLElement>): void;
  46819. /**
  46820. * Gets the class name of the current intput.
  46821. * @returns the class name
  46822. */
  46823. getClassName(): string;
  46824. /**
  46825. * Get the friendly name associated with the input class.
  46826. * @returns the input friendly name
  46827. */
  46828. getSimpleName(): string;
  46829. }
  46830. }
  46831. declare module "babylonjs/Cameras/Inputs/index" {
  46832. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46833. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46834. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46835. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46836. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46837. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46838. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46839. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46840. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46841. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46842. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46843. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46844. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46845. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46846. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46847. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46848. }
  46849. declare module "babylonjs/Cameras/touchCamera" {
  46850. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46851. import { Scene } from "babylonjs/scene";
  46852. import { Vector3 } from "babylonjs/Maths/math.vector";
  46853. /**
  46854. * This represents a FPS type of camera controlled by touch.
  46855. * This is like a universal camera minus the Gamepad controls.
  46856. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46857. */
  46858. export class TouchCamera extends FreeCamera {
  46859. /**
  46860. * Defines the touch sensibility for rotation.
  46861. * The higher the faster.
  46862. */
  46863. get touchAngularSensibility(): number;
  46864. set touchAngularSensibility(value: number);
  46865. /**
  46866. * Defines the touch sensibility for move.
  46867. * The higher the faster.
  46868. */
  46869. get touchMoveSensibility(): number;
  46870. set touchMoveSensibility(value: number);
  46871. /**
  46872. * Instantiates a new touch camera.
  46873. * This represents a FPS type of camera controlled by touch.
  46874. * This is like a universal camera minus the Gamepad controls.
  46875. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46876. * @param name Define the name of the camera in the scene
  46877. * @param position Define the start position of the camera in the scene
  46878. * @param scene Define the scene the camera belongs to
  46879. */
  46880. constructor(name: string, position: Vector3, scene: Scene);
  46881. /**
  46882. * Gets the current object class name.
  46883. * @return the class name
  46884. */
  46885. getClassName(): string;
  46886. /** @hidden */
  46887. _setupInputs(): void;
  46888. }
  46889. }
  46890. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46891. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46892. import { Scene } from "babylonjs/scene";
  46893. import { Vector3 } from "babylonjs/Maths/math.vector";
  46894. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46895. import { Axis } from "babylonjs/Maths/math.axis";
  46896. /**
  46897. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46898. * being tilted forward or back and left or right.
  46899. */
  46900. export class DeviceOrientationCamera extends FreeCamera {
  46901. private _initialQuaternion;
  46902. private _quaternionCache;
  46903. private _tmpDragQuaternion;
  46904. private _disablePointerInputWhenUsingDeviceOrientation;
  46905. /**
  46906. * Creates a new device orientation camera
  46907. * @param name The name of the camera
  46908. * @param position The start position camera
  46909. * @param scene The scene the camera belongs to
  46910. */
  46911. constructor(name: string, position: Vector3, scene: Scene);
  46912. /**
  46913. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46914. */
  46915. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46916. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46917. private _dragFactor;
  46918. /**
  46919. * Enabled turning on the y axis when the orientation sensor is active
  46920. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46921. */
  46922. enableHorizontalDragging(dragFactor?: number): void;
  46923. /**
  46924. * Gets the current instance class name ("DeviceOrientationCamera").
  46925. * This helps avoiding instanceof at run time.
  46926. * @returns the class name
  46927. */
  46928. getClassName(): string;
  46929. /**
  46930. * @hidden
  46931. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46932. */
  46933. _checkInputs(): void;
  46934. /**
  46935. * Reset the camera to its default orientation on the specified axis only.
  46936. * @param axis The axis to reset
  46937. */
  46938. resetToCurrentRotation(axis?: Axis): void;
  46939. }
  46940. }
  46941. declare module "babylonjs/Gamepads/xboxGamepad" {
  46942. import { Observable } from "babylonjs/Misc/observable";
  46943. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46944. /**
  46945. * Defines supported buttons for XBox360 compatible gamepads
  46946. */
  46947. export enum Xbox360Button {
  46948. /** A */
  46949. A = 0,
  46950. /** B */
  46951. B = 1,
  46952. /** X */
  46953. X = 2,
  46954. /** Y */
  46955. Y = 3,
  46956. /** Left button */
  46957. LB = 4,
  46958. /** Right button */
  46959. RB = 5,
  46960. /** Back */
  46961. Back = 8,
  46962. /** Start */
  46963. Start = 9,
  46964. /** Left stick */
  46965. LeftStick = 10,
  46966. /** Right stick */
  46967. RightStick = 11
  46968. }
  46969. /** Defines values for XBox360 DPad */
  46970. export enum Xbox360Dpad {
  46971. /** Up */
  46972. Up = 12,
  46973. /** Down */
  46974. Down = 13,
  46975. /** Left */
  46976. Left = 14,
  46977. /** Right */
  46978. Right = 15
  46979. }
  46980. /**
  46981. * Defines a XBox360 gamepad
  46982. */
  46983. export class Xbox360Pad extends Gamepad {
  46984. private _leftTrigger;
  46985. private _rightTrigger;
  46986. private _onlefttriggerchanged;
  46987. private _onrighttriggerchanged;
  46988. private _onbuttondown;
  46989. private _onbuttonup;
  46990. private _ondpaddown;
  46991. private _ondpadup;
  46992. /** Observable raised when a button is pressed */
  46993. onButtonDownObservable: Observable<Xbox360Button>;
  46994. /** Observable raised when a button is released */
  46995. onButtonUpObservable: Observable<Xbox360Button>;
  46996. /** Observable raised when a pad is pressed */
  46997. onPadDownObservable: Observable<Xbox360Dpad>;
  46998. /** Observable raised when a pad is released */
  46999. onPadUpObservable: Observable<Xbox360Dpad>;
  47000. private _buttonA;
  47001. private _buttonB;
  47002. private _buttonX;
  47003. private _buttonY;
  47004. private _buttonBack;
  47005. private _buttonStart;
  47006. private _buttonLB;
  47007. private _buttonRB;
  47008. private _buttonLeftStick;
  47009. private _buttonRightStick;
  47010. private _dPadUp;
  47011. private _dPadDown;
  47012. private _dPadLeft;
  47013. private _dPadRight;
  47014. private _isXboxOnePad;
  47015. /**
  47016. * Creates a new XBox360 gamepad object
  47017. * @param id defines the id of this gamepad
  47018. * @param index defines its index
  47019. * @param gamepad defines the internal HTML gamepad object
  47020. * @param xboxOne defines if it is a XBox One gamepad
  47021. */
  47022. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47023. /**
  47024. * Defines the callback to call when left trigger is pressed
  47025. * @param callback defines the callback to use
  47026. */
  47027. onlefttriggerchanged(callback: (value: number) => void): void;
  47028. /**
  47029. * Defines the callback to call when right trigger is pressed
  47030. * @param callback defines the callback to use
  47031. */
  47032. onrighttriggerchanged(callback: (value: number) => void): void;
  47033. /**
  47034. * Gets the left trigger value
  47035. */
  47036. get leftTrigger(): number;
  47037. /**
  47038. * Sets the left trigger value
  47039. */
  47040. set leftTrigger(newValue: number);
  47041. /**
  47042. * Gets the right trigger value
  47043. */
  47044. get rightTrigger(): number;
  47045. /**
  47046. * Sets the right trigger value
  47047. */
  47048. set rightTrigger(newValue: number);
  47049. /**
  47050. * Defines the callback to call when a button is pressed
  47051. * @param callback defines the callback to use
  47052. */
  47053. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47054. /**
  47055. * Defines the callback to call when a button is released
  47056. * @param callback defines the callback to use
  47057. */
  47058. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47059. /**
  47060. * Defines the callback to call when a pad is pressed
  47061. * @param callback defines the callback to use
  47062. */
  47063. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47064. /**
  47065. * Defines the callback to call when a pad is released
  47066. * @param callback defines the callback to use
  47067. */
  47068. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47069. private _setButtonValue;
  47070. private _setDPadValue;
  47071. /**
  47072. * Gets the value of the `A` button
  47073. */
  47074. get buttonA(): number;
  47075. /**
  47076. * Sets the value of the `A` button
  47077. */
  47078. set buttonA(value: number);
  47079. /**
  47080. * Gets the value of the `B` button
  47081. */
  47082. get buttonB(): number;
  47083. /**
  47084. * Sets the value of the `B` button
  47085. */
  47086. set buttonB(value: number);
  47087. /**
  47088. * Gets the value of the `X` button
  47089. */
  47090. get buttonX(): number;
  47091. /**
  47092. * Sets the value of the `X` button
  47093. */
  47094. set buttonX(value: number);
  47095. /**
  47096. * Gets the value of the `Y` button
  47097. */
  47098. get buttonY(): number;
  47099. /**
  47100. * Sets the value of the `Y` button
  47101. */
  47102. set buttonY(value: number);
  47103. /**
  47104. * Gets the value of the `Start` button
  47105. */
  47106. get buttonStart(): number;
  47107. /**
  47108. * Sets the value of the `Start` button
  47109. */
  47110. set buttonStart(value: number);
  47111. /**
  47112. * Gets the value of the `Back` button
  47113. */
  47114. get buttonBack(): number;
  47115. /**
  47116. * Sets the value of the `Back` button
  47117. */
  47118. set buttonBack(value: number);
  47119. /**
  47120. * Gets the value of the `Left` button
  47121. */
  47122. get buttonLB(): number;
  47123. /**
  47124. * Sets the value of the `Left` button
  47125. */
  47126. set buttonLB(value: number);
  47127. /**
  47128. * Gets the value of the `Right` button
  47129. */
  47130. get buttonRB(): number;
  47131. /**
  47132. * Sets the value of the `Right` button
  47133. */
  47134. set buttonRB(value: number);
  47135. /**
  47136. * Gets the value of the Left joystick
  47137. */
  47138. get buttonLeftStick(): number;
  47139. /**
  47140. * Sets the value of the Left joystick
  47141. */
  47142. set buttonLeftStick(value: number);
  47143. /**
  47144. * Gets the value of the Right joystick
  47145. */
  47146. get buttonRightStick(): number;
  47147. /**
  47148. * Sets the value of the Right joystick
  47149. */
  47150. set buttonRightStick(value: number);
  47151. /**
  47152. * Gets the value of D-pad up
  47153. */
  47154. get dPadUp(): number;
  47155. /**
  47156. * Sets the value of D-pad up
  47157. */
  47158. set dPadUp(value: number);
  47159. /**
  47160. * Gets the value of D-pad down
  47161. */
  47162. get dPadDown(): number;
  47163. /**
  47164. * Sets the value of D-pad down
  47165. */
  47166. set dPadDown(value: number);
  47167. /**
  47168. * Gets the value of D-pad left
  47169. */
  47170. get dPadLeft(): number;
  47171. /**
  47172. * Sets the value of D-pad left
  47173. */
  47174. set dPadLeft(value: number);
  47175. /**
  47176. * Gets the value of D-pad right
  47177. */
  47178. get dPadRight(): number;
  47179. /**
  47180. * Sets the value of D-pad right
  47181. */
  47182. set dPadRight(value: number);
  47183. /**
  47184. * Force the gamepad to synchronize with device values
  47185. */
  47186. update(): void;
  47187. /**
  47188. * Disposes the gamepad
  47189. */
  47190. dispose(): void;
  47191. }
  47192. }
  47193. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47194. import { Observable } from "babylonjs/Misc/observable";
  47195. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47196. /**
  47197. * Defines supported buttons for DualShock compatible gamepads
  47198. */
  47199. export enum DualShockButton {
  47200. /** Cross */
  47201. Cross = 0,
  47202. /** Circle */
  47203. Circle = 1,
  47204. /** Square */
  47205. Square = 2,
  47206. /** Triangle */
  47207. Triangle = 3,
  47208. /** L1 */
  47209. L1 = 4,
  47210. /** R1 */
  47211. R1 = 5,
  47212. /** Share */
  47213. Share = 8,
  47214. /** Options */
  47215. Options = 9,
  47216. /** Left stick */
  47217. LeftStick = 10,
  47218. /** Right stick */
  47219. RightStick = 11
  47220. }
  47221. /** Defines values for DualShock DPad */
  47222. export enum DualShockDpad {
  47223. /** Up */
  47224. Up = 12,
  47225. /** Down */
  47226. Down = 13,
  47227. /** Left */
  47228. Left = 14,
  47229. /** Right */
  47230. Right = 15
  47231. }
  47232. /**
  47233. * Defines a DualShock gamepad
  47234. */
  47235. export class DualShockPad extends Gamepad {
  47236. private _leftTrigger;
  47237. private _rightTrigger;
  47238. private _onlefttriggerchanged;
  47239. private _onrighttriggerchanged;
  47240. private _onbuttondown;
  47241. private _onbuttonup;
  47242. private _ondpaddown;
  47243. private _ondpadup;
  47244. /** Observable raised when a button is pressed */
  47245. onButtonDownObservable: Observable<DualShockButton>;
  47246. /** Observable raised when a button is released */
  47247. onButtonUpObservable: Observable<DualShockButton>;
  47248. /** Observable raised when a pad is pressed */
  47249. onPadDownObservable: Observable<DualShockDpad>;
  47250. /** Observable raised when a pad is released */
  47251. onPadUpObservable: Observable<DualShockDpad>;
  47252. private _buttonCross;
  47253. private _buttonCircle;
  47254. private _buttonSquare;
  47255. private _buttonTriangle;
  47256. private _buttonShare;
  47257. private _buttonOptions;
  47258. private _buttonL1;
  47259. private _buttonR1;
  47260. private _buttonLeftStick;
  47261. private _buttonRightStick;
  47262. private _dPadUp;
  47263. private _dPadDown;
  47264. private _dPadLeft;
  47265. private _dPadRight;
  47266. /**
  47267. * Creates a new DualShock gamepad object
  47268. * @param id defines the id of this gamepad
  47269. * @param index defines its index
  47270. * @param gamepad defines the internal HTML gamepad object
  47271. */
  47272. constructor(id: string, index: number, gamepad: any);
  47273. /**
  47274. * Defines the callback to call when left trigger is pressed
  47275. * @param callback defines the callback to use
  47276. */
  47277. onlefttriggerchanged(callback: (value: number) => void): void;
  47278. /**
  47279. * Defines the callback to call when right trigger is pressed
  47280. * @param callback defines the callback to use
  47281. */
  47282. onrighttriggerchanged(callback: (value: number) => void): void;
  47283. /**
  47284. * Gets the left trigger value
  47285. */
  47286. get leftTrigger(): number;
  47287. /**
  47288. * Sets the left trigger value
  47289. */
  47290. set leftTrigger(newValue: number);
  47291. /**
  47292. * Gets the right trigger value
  47293. */
  47294. get rightTrigger(): number;
  47295. /**
  47296. * Sets the right trigger value
  47297. */
  47298. set rightTrigger(newValue: number);
  47299. /**
  47300. * Defines the callback to call when a button is pressed
  47301. * @param callback defines the callback to use
  47302. */
  47303. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47304. /**
  47305. * Defines the callback to call when a button is released
  47306. * @param callback defines the callback to use
  47307. */
  47308. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47309. /**
  47310. * Defines the callback to call when a pad is pressed
  47311. * @param callback defines the callback to use
  47312. */
  47313. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47314. /**
  47315. * Defines the callback to call when a pad is released
  47316. * @param callback defines the callback to use
  47317. */
  47318. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47319. private _setButtonValue;
  47320. private _setDPadValue;
  47321. /**
  47322. * Gets the value of the `Cross` button
  47323. */
  47324. get buttonCross(): number;
  47325. /**
  47326. * Sets the value of the `Cross` button
  47327. */
  47328. set buttonCross(value: number);
  47329. /**
  47330. * Gets the value of the `Circle` button
  47331. */
  47332. get buttonCircle(): number;
  47333. /**
  47334. * Sets the value of the `Circle` button
  47335. */
  47336. set buttonCircle(value: number);
  47337. /**
  47338. * Gets the value of the `Square` button
  47339. */
  47340. get buttonSquare(): number;
  47341. /**
  47342. * Sets the value of the `Square` button
  47343. */
  47344. set buttonSquare(value: number);
  47345. /**
  47346. * Gets the value of the `Triangle` button
  47347. */
  47348. get buttonTriangle(): number;
  47349. /**
  47350. * Sets the value of the `Triangle` button
  47351. */
  47352. set buttonTriangle(value: number);
  47353. /**
  47354. * Gets the value of the `Options` button
  47355. */
  47356. get buttonOptions(): number;
  47357. /**
  47358. * Sets the value of the `Options` button
  47359. */
  47360. set buttonOptions(value: number);
  47361. /**
  47362. * Gets the value of the `Share` button
  47363. */
  47364. get buttonShare(): number;
  47365. /**
  47366. * Sets the value of the `Share` button
  47367. */
  47368. set buttonShare(value: number);
  47369. /**
  47370. * Gets the value of the `L1` button
  47371. */
  47372. get buttonL1(): number;
  47373. /**
  47374. * Sets the value of the `L1` button
  47375. */
  47376. set buttonL1(value: number);
  47377. /**
  47378. * Gets the value of the `R1` button
  47379. */
  47380. get buttonR1(): number;
  47381. /**
  47382. * Sets the value of the `R1` button
  47383. */
  47384. set buttonR1(value: number);
  47385. /**
  47386. * Gets the value of the Left joystick
  47387. */
  47388. get buttonLeftStick(): number;
  47389. /**
  47390. * Sets the value of the Left joystick
  47391. */
  47392. set buttonLeftStick(value: number);
  47393. /**
  47394. * Gets the value of the Right joystick
  47395. */
  47396. get buttonRightStick(): number;
  47397. /**
  47398. * Sets the value of the Right joystick
  47399. */
  47400. set buttonRightStick(value: number);
  47401. /**
  47402. * Gets the value of D-pad up
  47403. */
  47404. get dPadUp(): number;
  47405. /**
  47406. * Sets the value of D-pad up
  47407. */
  47408. set dPadUp(value: number);
  47409. /**
  47410. * Gets the value of D-pad down
  47411. */
  47412. get dPadDown(): number;
  47413. /**
  47414. * Sets the value of D-pad down
  47415. */
  47416. set dPadDown(value: number);
  47417. /**
  47418. * Gets the value of D-pad left
  47419. */
  47420. get dPadLeft(): number;
  47421. /**
  47422. * Sets the value of D-pad left
  47423. */
  47424. set dPadLeft(value: number);
  47425. /**
  47426. * Gets the value of D-pad right
  47427. */
  47428. get dPadRight(): number;
  47429. /**
  47430. * Sets the value of D-pad right
  47431. */
  47432. set dPadRight(value: number);
  47433. /**
  47434. * Force the gamepad to synchronize with device values
  47435. */
  47436. update(): void;
  47437. /**
  47438. * Disposes the gamepad
  47439. */
  47440. dispose(): void;
  47441. }
  47442. }
  47443. declare module "babylonjs/Gamepads/gamepadManager" {
  47444. import { Observable } from "babylonjs/Misc/observable";
  47445. import { Nullable } from "babylonjs/types";
  47446. import { Scene } from "babylonjs/scene";
  47447. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47448. /**
  47449. * Manager for handling gamepads
  47450. */
  47451. export class GamepadManager {
  47452. private _scene?;
  47453. private _babylonGamepads;
  47454. private _oneGamepadConnected;
  47455. /** @hidden */
  47456. _isMonitoring: boolean;
  47457. private _gamepadEventSupported;
  47458. private _gamepadSupport?;
  47459. /**
  47460. * observable to be triggered when the gamepad controller has been connected
  47461. */
  47462. onGamepadConnectedObservable: Observable<Gamepad>;
  47463. /**
  47464. * observable to be triggered when the gamepad controller has been disconnected
  47465. */
  47466. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47467. private _onGamepadConnectedEvent;
  47468. private _onGamepadDisconnectedEvent;
  47469. /**
  47470. * Initializes the gamepad manager
  47471. * @param _scene BabylonJS scene
  47472. */
  47473. constructor(_scene?: Scene | undefined);
  47474. /**
  47475. * The gamepads in the game pad manager
  47476. */
  47477. get gamepads(): Gamepad[];
  47478. /**
  47479. * Get the gamepad controllers based on type
  47480. * @param type The type of gamepad controller
  47481. * @returns Nullable gamepad
  47482. */
  47483. getGamepadByType(type?: number): Nullable<Gamepad>;
  47484. /**
  47485. * Disposes the gamepad manager
  47486. */
  47487. dispose(): void;
  47488. private _addNewGamepad;
  47489. private _startMonitoringGamepads;
  47490. private _stopMonitoringGamepads;
  47491. /** @hidden */
  47492. _checkGamepadsStatus(): void;
  47493. private _updateGamepadObjects;
  47494. }
  47495. }
  47496. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47497. import { Nullable } from "babylonjs/types";
  47498. import { Scene } from "babylonjs/scene";
  47499. import { ISceneComponent } from "babylonjs/sceneComponent";
  47500. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47501. module "babylonjs/scene" {
  47502. interface Scene {
  47503. /** @hidden */
  47504. _gamepadManager: Nullable<GamepadManager>;
  47505. /**
  47506. * Gets the gamepad manager associated with the scene
  47507. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47508. */
  47509. gamepadManager: GamepadManager;
  47510. }
  47511. }
  47512. module "babylonjs/Cameras/freeCameraInputsManager" {
  47513. /**
  47514. * Interface representing a free camera inputs manager
  47515. */
  47516. interface FreeCameraInputsManager {
  47517. /**
  47518. * Adds gamepad input support to the FreeCameraInputsManager.
  47519. * @returns the FreeCameraInputsManager
  47520. */
  47521. addGamepad(): FreeCameraInputsManager;
  47522. }
  47523. }
  47524. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47525. /**
  47526. * Interface representing an arc rotate camera inputs manager
  47527. */
  47528. interface ArcRotateCameraInputsManager {
  47529. /**
  47530. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47531. * @returns the camera inputs manager
  47532. */
  47533. addGamepad(): ArcRotateCameraInputsManager;
  47534. }
  47535. }
  47536. /**
  47537. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47538. */
  47539. export class GamepadSystemSceneComponent implements ISceneComponent {
  47540. /**
  47541. * The component name helpfull to identify the component in the list of scene components.
  47542. */
  47543. readonly name: string;
  47544. /**
  47545. * The scene the component belongs to.
  47546. */
  47547. scene: Scene;
  47548. /**
  47549. * Creates a new instance of the component for the given scene
  47550. * @param scene Defines the scene to register the component in
  47551. */
  47552. constructor(scene: Scene);
  47553. /**
  47554. * Registers the component in a given scene
  47555. */
  47556. register(): void;
  47557. /**
  47558. * Rebuilds the elements related to this component in case of
  47559. * context lost for instance.
  47560. */
  47561. rebuild(): void;
  47562. /**
  47563. * Disposes the component and the associated ressources
  47564. */
  47565. dispose(): void;
  47566. private _beforeCameraUpdate;
  47567. }
  47568. }
  47569. declare module "babylonjs/Cameras/universalCamera" {
  47570. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47571. import { Scene } from "babylonjs/scene";
  47572. import { Vector3 } from "babylonjs/Maths/math.vector";
  47573. import "babylonjs/Gamepads/gamepadSceneComponent";
  47574. /**
  47575. * 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,
  47576. * which still works and will still be found in many Playgrounds.
  47577. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47578. */
  47579. export class UniversalCamera extends TouchCamera {
  47580. /**
  47581. * Defines the gamepad rotation sensiblity.
  47582. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47583. */
  47584. get gamepadAngularSensibility(): number;
  47585. set gamepadAngularSensibility(value: number);
  47586. /**
  47587. * Defines the gamepad move sensiblity.
  47588. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47589. */
  47590. get gamepadMoveSensibility(): number;
  47591. set gamepadMoveSensibility(value: number);
  47592. /**
  47593. * 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,
  47594. * which still works and will still be found in many Playgrounds.
  47595. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47596. * @param name Define the name of the camera in the scene
  47597. * @param position Define the start position of the camera in the scene
  47598. * @param scene Define the scene the camera belongs to
  47599. */
  47600. constructor(name: string, position: Vector3, scene: Scene);
  47601. /**
  47602. * Gets the current object class name.
  47603. * @return the class name
  47604. */
  47605. getClassName(): string;
  47606. }
  47607. }
  47608. declare module "babylonjs/Cameras/gamepadCamera" {
  47609. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47610. import { Scene } from "babylonjs/scene";
  47611. import { Vector3 } from "babylonjs/Maths/math.vector";
  47612. /**
  47613. * This represents a FPS type of camera. This is only here for back compat purpose.
  47614. * Please use the UniversalCamera instead as both are identical.
  47615. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47616. */
  47617. export class GamepadCamera extends UniversalCamera {
  47618. /**
  47619. * Instantiates a new Gamepad Camera
  47620. * This represents a FPS type of camera. This is only here for back compat purpose.
  47621. * Please use the UniversalCamera instead as both are identical.
  47622. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47623. * @param name Define the name of the camera in the scene
  47624. * @param position Define the start position of the camera in the scene
  47625. * @param scene Define the scene the camera belongs to
  47626. */
  47627. constructor(name: string, position: Vector3, scene: Scene);
  47628. /**
  47629. * Gets the current object class name.
  47630. * @return the class name
  47631. */
  47632. getClassName(): string;
  47633. }
  47634. }
  47635. declare module "babylonjs/Shaders/pass.fragment" {
  47636. /** @hidden */
  47637. export var passPixelShader: {
  47638. name: string;
  47639. shader: string;
  47640. };
  47641. }
  47642. declare module "babylonjs/Shaders/passCube.fragment" {
  47643. /** @hidden */
  47644. export var passCubePixelShader: {
  47645. name: string;
  47646. shader: string;
  47647. };
  47648. }
  47649. declare module "babylonjs/PostProcesses/passPostProcess" {
  47650. import { Nullable } from "babylonjs/types";
  47651. import { Camera } from "babylonjs/Cameras/camera";
  47652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47653. import { Engine } from "babylonjs/Engines/engine";
  47654. import "babylonjs/Shaders/pass.fragment";
  47655. import "babylonjs/Shaders/passCube.fragment";
  47656. import { Scene } from "babylonjs/scene";
  47657. /**
  47658. * PassPostProcess which produces an output the same as it's input
  47659. */
  47660. export class PassPostProcess extends PostProcess {
  47661. /**
  47662. * Gets a string identifying the name of the class
  47663. * @returns "PassPostProcess" string
  47664. */
  47665. getClassName(): string;
  47666. /**
  47667. * Creates the PassPostProcess
  47668. * @param name The name of the effect.
  47669. * @param options The required width/height ratio to downsize to before computing the render pass.
  47670. * @param camera The camera to apply the render pass to.
  47671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47672. * @param engine The engine which the post process will be applied. (default: current engine)
  47673. * @param reusable If the post process can be reused on the same frame. (default: false)
  47674. * @param textureType The type of texture to be used when performing the post processing.
  47675. * @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)
  47676. */
  47677. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47678. /** @hidden */
  47679. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47680. }
  47681. /**
  47682. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47683. */
  47684. export class PassCubePostProcess extends PostProcess {
  47685. private _face;
  47686. /**
  47687. * Gets or sets the cube face to display.
  47688. * * 0 is +X
  47689. * * 1 is -X
  47690. * * 2 is +Y
  47691. * * 3 is -Y
  47692. * * 4 is +Z
  47693. * * 5 is -Z
  47694. */
  47695. get face(): number;
  47696. set face(value: number);
  47697. /**
  47698. * Gets a string identifying the name of the class
  47699. * @returns "PassCubePostProcess" string
  47700. */
  47701. getClassName(): string;
  47702. /**
  47703. * Creates the PassCubePostProcess
  47704. * @param name The name of the effect.
  47705. * @param options The required width/height ratio to downsize to before computing the render pass.
  47706. * @param camera The camera to apply the render pass to.
  47707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47708. * @param engine The engine which the post process will be applied. (default: current engine)
  47709. * @param reusable If the post process can be reused on the same frame. (default: false)
  47710. * @param textureType The type of texture to be used when performing the post processing.
  47711. * @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)
  47712. */
  47713. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47714. /** @hidden */
  47715. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47716. }
  47717. }
  47718. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47719. /** @hidden */
  47720. export var anaglyphPixelShader: {
  47721. name: string;
  47722. shader: string;
  47723. };
  47724. }
  47725. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47726. import { Engine } from "babylonjs/Engines/engine";
  47727. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47728. import { Camera } from "babylonjs/Cameras/camera";
  47729. import "babylonjs/Shaders/anaglyph.fragment";
  47730. /**
  47731. * Postprocess used to generate anaglyphic rendering
  47732. */
  47733. export class AnaglyphPostProcess extends PostProcess {
  47734. private _passedProcess;
  47735. /**
  47736. * Gets a string identifying the name of the class
  47737. * @returns "AnaglyphPostProcess" string
  47738. */
  47739. getClassName(): string;
  47740. /**
  47741. * Creates a new AnaglyphPostProcess
  47742. * @param name defines postprocess name
  47743. * @param options defines creation options or target ratio scale
  47744. * @param rigCameras defines cameras using this postprocess
  47745. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47746. * @param engine defines hosting engine
  47747. * @param reusable defines if the postprocess will be reused multiple times per frame
  47748. */
  47749. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47750. }
  47751. }
  47752. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47753. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47754. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47755. import { Scene } from "babylonjs/scene";
  47756. import { Vector3 } from "babylonjs/Maths/math.vector";
  47757. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47758. /**
  47759. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47760. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47761. */
  47762. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47763. /**
  47764. * Creates a new AnaglyphArcRotateCamera
  47765. * @param name defines camera name
  47766. * @param alpha defines alpha angle (in radians)
  47767. * @param beta defines beta angle (in radians)
  47768. * @param radius defines radius
  47769. * @param target defines camera target
  47770. * @param interaxialDistance defines distance between each color axis
  47771. * @param scene defines the hosting scene
  47772. */
  47773. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47774. /**
  47775. * Gets camera class name
  47776. * @returns AnaglyphArcRotateCamera
  47777. */
  47778. getClassName(): string;
  47779. }
  47780. }
  47781. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47782. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47783. import { Scene } from "babylonjs/scene";
  47784. import { Vector3 } from "babylonjs/Maths/math.vector";
  47785. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47786. /**
  47787. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47788. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47789. */
  47790. export class AnaglyphFreeCamera extends FreeCamera {
  47791. /**
  47792. * Creates a new AnaglyphFreeCamera
  47793. * @param name defines camera name
  47794. * @param position defines initial position
  47795. * @param interaxialDistance defines distance between each color axis
  47796. * @param scene defines the hosting scene
  47797. */
  47798. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47799. /**
  47800. * Gets camera class name
  47801. * @returns AnaglyphFreeCamera
  47802. */
  47803. getClassName(): string;
  47804. }
  47805. }
  47806. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47807. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47808. import { Scene } from "babylonjs/scene";
  47809. import { Vector3 } from "babylonjs/Maths/math.vector";
  47810. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47811. /**
  47812. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47813. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47814. */
  47815. export class AnaglyphGamepadCamera extends GamepadCamera {
  47816. /**
  47817. * Creates a new AnaglyphGamepadCamera
  47818. * @param name defines camera name
  47819. * @param position defines initial position
  47820. * @param interaxialDistance defines distance between each color axis
  47821. * @param scene defines the hosting scene
  47822. */
  47823. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47824. /**
  47825. * Gets camera class name
  47826. * @returns AnaglyphGamepadCamera
  47827. */
  47828. getClassName(): string;
  47829. }
  47830. }
  47831. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47832. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47833. import { Scene } from "babylonjs/scene";
  47834. import { Vector3 } from "babylonjs/Maths/math.vector";
  47835. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47836. /**
  47837. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47838. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47839. */
  47840. export class AnaglyphUniversalCamera extends UniversalCamera {
  47841. /**
  47842. * Creates a new AnaglyphUniversalCamera
  47843. * @param name defines camera name
  47844. * @param position defines initial position
  47845. * @param interaxialDistance defines distance between each color axis
  47846. * @param scene defines the hosting scene
  47847. */
  47848. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47849. /**
  47850. * Gets camera class name
  47851. * @returns AnaglyphUniversalCamera
  47852. */
  47853. getClassName(): string;
  47854. }
  47855. }
  47856. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47857. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47858. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47859. import { Scene } from "babylonjs/scene";
  47860. import { Vector3 } from "babylonjs/Maths/math.vector";
  47861. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47862. /**
  47863. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47864. * @see https://doc.babylonjs.com/features/cameras
  47865. */
  47866. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47867. /**
  47868. * Creates a new StereoscopicArcRotateCamera
  47869. * @param name defines camera name
  47870. * @param alpha defines alpha angle (in radians)
  47871. * @param beta defines beta angle (in radians)
  47872. * @param radius defines radius
  47873. * @param target defines camera target
  47874. * @param interaxialDistance defines distance between each color axis
  47875. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47876. * @param scene defines the hosting scene
  47877. */
  47878. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47879. /**
  47880. * Gets camera class name
  47881. * @returns StereoscopicArcRotateCamera
  47882. */
  47883. getClassName(): string;
  47884. }
  47885. }
  47886. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47887. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47888. import { Scene } from "babylonjs/scene";
  47889. import { Vector3 } from "babylonjs/Maths/math.vector";
  47890. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47891. /**
  47892. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47893. * @see https://doc.babylonjs.com/features/cameras
  47894. */
  47895. export class StereoscopicFreeCamera extends FreeCamera {
  47896. /**
  47897. * Creates a new StereoscopicFreeCamera
  47898. * @param name defines camera name
  47899. * @param position defines initial position
  47900. * @param interaxialDistance defines distance between each color axis
  47901. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47902. * @param scene defines the hosting scene
  47903. */
  47904. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47905. /**
  47906. * Gets camera class name
  47907. * @returns StereoscopicFreeCamera
  47908. */
  47909. getClassName(): string;
  47910. }
  47911. }
  47912. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47913. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47914. import { Scene } from "babylonjs/scene";
  47915. import { Vector3 } from "babylonjs/Maths/math.vector";
  47916. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47917. /**
  47918. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47919. * @see https://doc.babylonjs.com/features/cameras
  47920. */
  47921. export class StereoscopicGamepadCamera extends GamepadCamera {
  47922. /**
  47923. * Creates a new StereoscopicGamepadCamera
  47924. * @param name defines camera name
  47925. * @param position defines initial position
  47926. * @param interaxialDistance defines distance between each color axis
  47927. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47928. * @param scene defines the hosting scene
  47929. */
  47930. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47931. /**
  47932. * Gets camera class name
  47933. * @returns StereoscopicGamepadCamera
  47934. */
  47935. getClassName(): string;
  47936. }
  47937. }
  47938. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47939. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47940. import { Scene } from "babylonjs/scene";
  47941. import { Vector3 } from "babylonjs/Maths/math.vector";
  47942. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47943. /**
  47944. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47945. * @see https://doc.babylonjs.com/features/cameras
  47946. */
  47947. export class StereoscopicUniversalCamera extends UniversalCamera {
  47948. /**
  47949. * Creates a new StereoscopicUniversalCamera
  47950. * @param name defines camera name
  47951. * @param position defines initial position
  47952. * @param interaxialDistance defines distance between each color axis
  47953. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47954. * @param scene defines the hosting scene
  47955. */
  47956. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47957. /**
  47958. * Gets camera class name
  47959. * @returns StereoscopicUniversalCamera
  47960. */
  47961. getClassName(): string;
  47962. }
  47963. }
  47964. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47965. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47966. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47967. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47968. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47969. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47970. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47971. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47972. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47973. }
  47974. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47976. import { Scene } from "babylonjs/scene";
  47977. import { Vector3 } from "babylonjs/Maths/math.vector";
  47978. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47979. /**
  47980. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47981. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47982. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47983. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47984. */
  47985. export class VirtualJoysticksCamera extends FreeCamera {
  47986. /**
  47987. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47988. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47989. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47990. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47991. * @param name Define the name of the camera in the scene
  47992. * @param position Define the start position of the camera in the scene
  47993. * @param scene Define the scene the camera belongs to
  47994. */
  47995. constructor(name: string, position: Vector3, scene: Scene);
  47996. /**
  47997. * Gets the current object class name.
  47998. * @return the class name
  47999. */
  48000. getClassName(): string;
  48001. }
  48002. }
  48003. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48004. import { Matrix } from "babylonjs/Maths/math.vector";
  48005. /**
  48006. * This represents all the required metrics to create a VR camera.
  48007. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48008. */
  48009. export class VRCameraMetrics {
  48010. /**
  48011. * Define the horizontal resolution off the screen.
  48012. */
  48013. hResolution: number;
  48014. /**
  48015. * Define the vertical resolution off the screen.
  48016. */
  48017. vResolution: number;
  48018. /**
  48019. * Define the horizontal screen size.
  48020. */
  48021. hScreenSize: number;
  48022. /**
  48023. * Define the vertical screen size.
  48024. */
  48025. vScreenSize: number;
  48026. /**
  48027. * Define the vertical screen center position.
  48028. */
  48029. vScreenCenter: number;
  48030. /**
  48031. * Define the distance of the eyes to the screen.
  48032. */
  48033. eyeToScreenDistance: number;
  48034. /**
  48035. * Define the distance between both lenses
  48036. */
  48037. lensSeparationDistance: number;
  48038. /**
  48039. * Define the distance between both viewer's eyes.
  48040. */
  48041. interpupillaryDistance: number;
  48042. /**
  48043. * Define the distortion factor of the VR postprocess.
  48044. * Please, touch with care.
  48045. */
  48046. distortionK: number[];
  48047. /**
  48048. * Define the chromatic aberration correction factors for the VR post process.
  48049. */
  48050. chromaAbCorrection: number[];
  48051. /**
  48052. * Define the scale factor of the post process.
  48053. * The smaller the better but the slower.
  48054. */
  48055. postProcessScaleFactor: number;
  48056. /**
  48057. * Define an offset for the lens center.
  48058. */
  48059. lensCenterOffset: number;
  48060. /**
  48061. * Define if the current vr camera should compensate the distortion of the lense or not.
  48062. */
  48063. compensateDistortion: boolean;
  48064. /**
  48065. * Defines if multiview should be enabled when rendering (Default: false)
  48066. */
  48067. multiviewEnabled: boolean;
  48068. /**
  48069. * Gets the rendering aspect ratio based on the provided resolutions.
  48070. */
  48071. get aspectRatio(): number;
  48072. /**
  48073. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48074. */
  48075. get aspectRatioFov(): number;
  48076. /**
  48077. * @hidden
  48078. */
  48079. get leftHMatrix(): Matrix;
  48080. /**
  48081. * @hidden
  48082. */
  48083. get rightHMatrix(): Matrix;
  48084. /**
  48085. * @hidden
  48086. */
  48087. get leftPreViewMatrix(): Matrix;
  48088. /**
  48089. * @hidden
  48090. */
  48091. get rightPreViewMatrix(): Matrix;
  48092. /**
  48093. * Get the default VRMetrics based on the most generic setup.
  48094. * @returns the default vr metrics
  48095. */
  48096. static GetDefault(): VRCameraMetrics;
  48097. }
  48098. }
  48099. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48100. /** @hidden */
  48101. export var vrDistortionCorrectionPixelShader: {
  48102. name: string;
  48103. shader: string;
  48104. };
  48105. }
  48106. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48107. import { Camera } from "babylonjs/Cameras/camera";
  48108. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48109. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48110. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48111. /**
  48112. * VRDistortionCorrectionPostProcess used for mobile VR
  48113. */
  48114. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48115. private _isRightEye;
  48116. private _distortionFactors;
  48117. private _postProcessScaleFactor;
  48118. private _lensCenterOffset;
  48119. private _scaleIn;
  48120. private _scaleFactor;
  48121. private _lensCenter;
  48122. /**
  48123. * Gets a string identifying the name of the class
  48124. * @returns "VRDistortionCorrectionPostProcess" string
  48125. */
  48126. getClassName(): string;
  48127. /**
  48128. * Initializes the VRDistortionCorrectionPostProcess
  48129. * @param name The name of the effect.
  48130. * @param camera The camera to apply the render pass to.
  48131. * @param isRightEye If this is for the right eye distortion
  48132. * @param vrMetrics All the required metrics for the VR camera
  48133. */
  48134. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48135. }
  48136. }
  48137. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48138. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48139. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48140. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48141. import { Scene } from "babylonjs/scene";
  48142. import { Vector3 } from "babylonjs/Maths/math.vector";
  48143. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48144. import "babylonjs/Cameras/RigModes/vrRigMode";
  48145. /**
  48146. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48147. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48148. */
  48149. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48150. /**
  48151. * Creates a new VRDeviceOrientationArcRotateCamera
  48152. * @param name defines camera name
  48153. * @param alpha defines the camera rotation along the logitudinal axis
  48154. * @param beta defines the camera rotation along the latitudinal axis
  48155. * @param radius defines the camera distance from its target
  48156. * @param target defines the camera target
  48157. * @param scene defines the scene the camera belongs to
  48158. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48159. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48160. */
  48161. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48162. /**
  48163. * Gets camera class name
  48164. * @returns VRDeviceOrientationArcRotateCamera
  48165. */
  48166. getClassName(): string;
  48167. }
  48168. }
  48169. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48170. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48171. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48172. import { Scene } from "babylonjs/scene";
  48173. import { Vector3 } from "babylonjs/Maths/math.vector";
  48174. import "babylonjs/Cameras/RigModes/vrRigMode";
  48175. /**
  48176. * Camera used to simulate VR rendering (based on FreeCamera)
  48177. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48178. */
  48179. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48180. /**
  48181. * Creates a new VRDeviceOrientationFreeCamera
  48182. * @param name defines camera name
  48183. * @param position defines the start position of the camera
  48184. * @param scene defines the scene the camera belongs to
  48185. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48186. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48187. */
  48188. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48189. /**
  48190. * Gets camera class name
  48191. * @returns VRDeviceOrientationFreeCamera
  48192. */
  48193. getClassName(): string;
  48194. }
  48195. }
  48196. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48197. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48198. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48199. import { Scene } from "babylonjs/scene";
  48200. import { Vector3 } from "babylonjs/Maths/math.vector";
  48201. import "babylonjs/Gamepads/gamepadSceneComponent";
  48202. /**
  48203. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48204. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48205. */
  48206. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48207. /**
  48208. * Creates a new VRDeviceOrientationGamepadCamera
  48209. * @param name defines camera name
  48210. * @param position defines the start position of the camera
  48211. * @param scene defines the scene the camera belongs to
  48212. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48213. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48214. */
  48215. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48216. /**
  48217. * Gets camera class name
  48218. * @returns VRDeviceOrientationGamepadCamera
  48219. */
  48220. getClassName(): string;
  48221. }
  48222. }
  48223. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48224. import { Scene } from "babylonjs/scene";
  48225. import { Texture } from "babylonjs/Materials/Textures/texture";
  48226. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48227. /**
  48228. * A class extending Texture allowing drawing on a texture
  48229. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48230. */
  48231. export class DynamicTexture extends Texture {
  48232. private _generateMipMaps;
  48233. private _canvas;
  48234. private _context;
  48235. /**
  48236. * Creates a DynamicTexture
  48237. * @param name defines the name of the texture
  48238. * @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
  48239. * @param scene defines the scene where you want the texture
  48240. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48241. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48242. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48243. */
  48244. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48245. /**
  48246. * Get the current class name of the texture useful for serialization or dynamic coding.
  48247. * @returns "DynamicTexture"
  48248. */
  48249. getClassName(): string;
  48250. /**
  48251. * Gets the current state of canRescale
  48252. */
  48253. get canRescale(): boolean;
  48254. private _recreate;
  48255. /**
  48256. * Scales the texture
  48257. * @param ratio the scale factor to apply to both width and height
  48258. */
  48259. scale(ratio: number): void;
  48260. /**
  48261. * Resizes the texture
  48262. * @param width the new width
  48263. * @param height the new height
  48264. */
  48265. scaleTo(width: number, height: number): void;
  48266. /**
  48267. * Gets the context of the canvas used by the texture
  48268. * @returns the canvas context of the dynamic texture
  48269. */
  48270. getContext(): CanvasRenderingContext2D;
  48271. /**
  48272. * Clears the texture
  48273. */
  48274. clear(): void;
  48275. /**
  48276. * Updates the texture
  48277. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48278. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48279. */
  48280. update(invertY?: boolean, premulAlpha?: boolean): void;
  48281. /**
  48282. * Draws text onto the texture
  48283. * @param text defines the text to be drawn
  48284. * @param x defines the placement of the text from the left
  48285. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48286. * @param font defines the font to be used with font-style, font-size, font-name
  48287. * @param color defines the color used for the text
  48288. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48289. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48290. * @param update defines whether texture is immediately update (default is true)
  48291. */
  48292. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48293. /**
  48294. * Clones the texture
  48295. * @returns the clone of the texture.
  48296. */
  48297. clone(): DynamicTexture;
  48298. /**
  48299. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48300. * @returns a serialized dynamic texture object
  48301. */
  48302. serialize(): any;
  48303. private _IsCanvasElement;
  48304. /** @hidden */
  48305. _rebuild(): void;
  48306. }
  48307. }
  48308. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48309. import { Scene } from "babylonjs/scene";
  48310. import { Color3 } from "babylonjs/Maths/math.color";
  48311. import { Mesh } from "babylonjs/Meshes/mesh";
  48312. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48313. import { Nullable } from "babylonjs/types";
  48314. /**
  48315. * Class containing static functions to help procedurally build meshes
  48316. */
  48317. export class GroundBuilder {
  48318. /**
  48319. * Creates a ground mesh
  48320. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48321. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48323. * @param name defines the name of the mesh
  48324. * @param options defines the options used to create the mesh
  48325. * @param scene defines the hosting scene
  48326. * @returns the ground mesh
  48327. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48328. */
  48329. static CreateGround(name: string, options: {
  48330. width?: number;
  48331. height?: number;
  48332. subdivisions?: number;
  48333. subdivisionsX?: number;
  48334. subdivisionsY?: number;
  48335. updatable?: boolean;
  48336. }, scene: any): Mesh;
  48337. /**
  48338. * Creates a tiled ground mesh
  48339. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48340. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48341. * * 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
  48342. * * 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
  48343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48344. * @param name defines the name of the mesh
  48345. * @param options defines the options used to create the mesh
  48346. * @param scene defines the hosting scene
  48347. * @returns the tiled ground mesh
  48348. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48349. */
  48350. static CreateTiledGround(name: string, options: {
  48351. xmin: number;
  48352. zmin: number;
  48353. xmax: number;
  48354. zmax: number;
  48355. subdivisions?: {
  48356. w: number;
  48357. h: number;
  48358. };
  48359. precision?: {
  48360. w: number;
  48361. h: number;
  48362. };
  48363. updatable?: boolean;
  48364. }, scene?: Nullable<Scene>): Mesh;
  48365. /**
  48366. * Creates a ground mesh from a height map
  48367. * * The parameter `url` sets the URL of the height map image resource.
  48368. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48369. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48370. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48371. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48372. * * 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.
  48373. * * 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).
  48374. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48376. * @param name defines the name of the mesh
  48377. * @param url defines the url to the height map
  48378. * @param options defines the options used to create the mesh
  48379. * @param scene defines the hosting scene
  48380. * @returns the ground mesh
  48381. * @see https://doc.babylonjs.com/babylon101/height_map
  48382. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48383. */
  48384. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48385. width?: number;
  48386. height?: number;
  48387. subdivisions?: number;
  48388. minHeight?: number;
  48389. maxHeight?: number;
  48390. colorFilter?: Color3;
  48391. alphaFilter?: number;
  48392. updatable?: boolean;
  48393. onReady?: (mesh: GroundMesh) => void;
  48394. }, scene?: Nullable<Scene>): GroundMesh;
  48395. }
  48396. }
  48397. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48398. import { Vector4 } from "babylonjs/Maths/math.vector";
  48399. import { Mesh } from "babylonjs/Meshes/mesh";
  48400. /**
  48401. * Class containing static functions to help procedurally build meshes
  48402. */
  48403. export class TorusBuilder {
  48404. /**
  48405. * Creates a torus mesh
  48406. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48407. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48408. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48412. * @param name defines the name of the mesh
  48413. * @param options defines the options used to create the mesh
  48414. * @param scene defines the hosting scene
  48415. * @returns the torus mesh
  48416. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48417. */
  48418. static CreateTorus(name: string, options: {
  48419. diameter?: number;
  48420. thickness?: number;
  48421. tessellation?: number;
  48422. updatable?: boolean;
  48423. sideOrientation?: number;
  48424. frontUVs?: Vector4;
  48425. backUVs?: Vector4;
  48426. }, scene: any): Mesh;
  48427. }
  48428. }
  48429. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48430. import { Vector4 } from "babylonjs/Maths/math.vector";
  48431. import { Color4 } from "babylonjs/Maths/math.color";
  48432. import { Mesh } from "babylonjs/Meshes/mesh";
  48433. /**
  48434. * Class containing static functions to help procedurally build meshes
  48435. */
  48436. export class CylinderBuilder {
  48437. /**
  48438. * Creates a cylinder or a cone mesh
  48439. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48440. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48441. * * 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.
  48442. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48443. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48444. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48445. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48446. * * 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).
  48447. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48448. * * 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).
  48449. * * 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
  48450. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48451. * * 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
  48452. * * 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.
  48453. * * If `enclose` is false, a ring surface is one element.
  48454. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48455. * * 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
  48456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48459. * @param name defines the name of the mesh
  48460. * @param options defines the options used to create the mesh
  48461. * @param scene defines the hosting scene
  48462. * @returns the cylinder mesh
  48463. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48464. */
  48465. static CreateCylinder(name: string, options: {
  48466. height?: number;
  48467. diameterTop?: number;
  48468. diameterBottom?: number;
  48469. diameter?: number;
  48470. tessellation?: number;
  48471. subdivisions?: number;
  48472. arc?: number;
  48473. faceColors?: Color4[];
  48474. faceUV?: Vector4[];
  48475. updatable?: boolean;
  48476. hasRings?: boolean;
  48477. enclose?: boolean;
  48478. cap?: number;
  48479. sideOrientation?: number;
  48480. frontUVs?: Vector4;
  48481. backUVs?: Vector4;
  48482. }, scene: any): Mesh;
  48483. }
  48484. }
  48485. declare module "babylonjs/XR/webXRTypes" {
  48486. import { Nullable } from "babylonjs/types";
  48487. import { IDisposable } from "babylonjs/scene";
  48488. /**
  48489. * States of the webXR experience
  48490. */
  48491. export enum WebXRState {
  48492. /**
  48493. * Transitioning to being in XR mode
  48494. */
  48495. ENTERING_XR = 0,
  48496. /**
  48497. * Transitioning to non XR mode
  48498. */
  48499. EXITING_XR = 1,
  48500. /**
  48501. * In XR mode and presenting
  48502. */
  48503. IN_XR = 2,
  48504. /**
  48505. * Not entered XR mode
  48506. */
  48507. NOT_IN_XR = 3
  48508. }
  48509. /**
  48510. * Abstraction of the XR render target
  48511. */
  48512. export interface WebXRRenderTarget extends IDisposable {
  48513. /**
  48514. * xrpresent context of the canvas which can be used to display/mirror xr content
  48515. */
  48516. canvasContext: WebGLRenderingContext;
  48517. /**
  48518. * xr layer for the canvas
  48519. */
  48520. xrLayer: Nullable<XRWebGLLayer>;
  48521. /**
  48522. * Initializes the xr layer for the session
  48523. * @param xrSession xr session
  48524. * @returns a promise that will resolve once the XR Layer has been created
  48525. */
  48526. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48527. }
  48528. }
  48529. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48530. import { Nullable } from "babylonjs/types";
  48531. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48532. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48533. import { Observable } from "babylonjs/Misc/observable";
  48534. /**
  48535. * COnfiguration object for WebXR output canvas
  48536. */
  48537. export class WebXRManagedOutputCanvasOptions {
  48538. /**
  48539. * An optional canvas in case you wish to create it yourself and provide it here.
  48540. * If not provided, a new canvas will be created
  48541. */
  48542. canvasElement?: HTMLCanvasElement;
  48543. /**
  48544. * Options for this XR Layer output
  48545. */
  48546. canvasOptions?: XRWebGLLayerOptions;
  48547. /**
  48548. * CSS styling for a newly created canvas (if not provided)
  48549. */
  48550. newCanvasCssStyle?: string;
  48551. /**
  48552. * Get the default values of the configuration object
  48553. * @returns default values of this configuration object
  48554. */
  48555. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48556. }
  48557. /**
  48558. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48559. */
  48560. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48561. private _options;
  48562. private _canvas;
  48563. private _engine;
  48564. private _originalCanvasSize;
  48565. /**
  48566. * Rendering context of the canvas which can be used to display/mirror xr content
  48567. */
  48568. canvasContext: WebGLRenderingContext;
  48569. /**
  48570. * xr layer for the canvas
  48571. */
  48572. xrLayer: Nullable<XRWebGLLayer>;
  48573. /**
  48574. * Obseervers registered here will be triggered when the xr layer was initialized
  48575. */
  48576. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48577. /**
  48578. * Initializes the canvas to be added/removed upon entering/exiting xr
  48579. * @param _xrSessionManager The XR Session manager
  48580. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48581. */
  48582. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48583. /**
  48584. * Disposes of the object
  48585. */
  48586. dispose(): void;
  48587. /**
  48588. * Initializes the xr layer for the session
  48589. * @param xrSession xr session
  48590. * @returns a promise that will resolve once the XR Layer has been created
  48591. */
  48592. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48593. private _addCanvas;
  48594. private _removeCanvas;
  48595. private _setCanvasSize;
  48596. private _setManagedOutputCanvas;
  48597. }
  48598. }
  48599. declare module "babylonjs/XR/webXRSessionManager" {
  48600. import { Observable } from "babylonjs/Misc/observable";
  48601. import { Nullable } from "babylonjs/types";
  48602. import { IDisposable, Scene } from "babylonjs/scene";
  48603. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48604. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48605. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48606. /**
  48607. * Manages an XRSession to work with Babylon's engine
  48608. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48609. */
  48610. export class WebXRSessionManager implements IDisposable {
  48611. /** The scene which the session should be created for */
  48612. scene: Scene;
  48613. private _referenceSpace;
  48614. private _rttProvider;
  48615. private _sessionEnded;
  48616. private _xrNavigator;
  48617. private baseLayer;
  48618. /**
  48619. * The base reference space from which the session started. good if you want to reset your
  48620. * reference space
  48621. */
  48622. baseReferenceSpace: XRReferenceSpace;
  48623. /**
  48624. * Current XR frame
  48625. */
  48626. currentFrame: Nullable<XRFrame>;
  48627. /** WebXR timestamp updated every frame */
  48628. currentTimestamp: number;
  48629. /**
  48630. * Used just in case of a failure to initialize an immersive session.
  48631. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48632. */
  48633. defaultHeightCompensation: number;
  48634. /**
  48635. * Fires every time a new xrFrame arrives which can be used to update the camera
  48636. */
  48637. onXRFrameObservable: Observable<XRFrame>;
  48638. /**
  48639. * Fires when the reference space changed
  48640. */
  48641. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48642. /**
  48643. * Fires when the xr session is ended either by the device or manually done
  48644. */
  48645. onXRSessionEnded: Observable<any>;
  48646. /**
  48647. * Fires when the xr session is ended either by the device or manually done
  48648. */
  48649. onXRSessionInit: Observable<XRSession>;
  48650. /**
  48651. * Underlying xr session
  48652. */
  48653. session: XRSession;
  48654. /**
  48655. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48656. * or get the offset the player is currently at.
  48657. */
  48658. viewerReferenceSpace: XRReferenceSpace;
  48659. /**
  48660. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48661. * @param scene The scene which the session should be created for
  48662. */
  48663. constructor(
  48664. /** The scene which the session should be created for */
  48665. scene: Scene);
  48666. /**
  48667. * The current reference space used in this session. This reference space can constantly change!
  48668. * It is mainly used to offset the camera's position.
  48669. */
  48670. get referenceSpace(): XRReferenceSpace;
  48671. /**
  48672. * Set a new reference space and triggers the observable
  48673. */
  48674. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48675. /**
  48676. * Disposes of the session manager
  48677. */
  48678. dispose(): void;
  48679. /**
  48680. * Stops the xrSession and restores the render loop
  48681. * @returns Promise which resolves after it exits XR
  48682. */
  48683. exitXRAsync(): Promise<void>;
  48684. /**
  48685. * Gets the correct render target texture to be rendered this frame for this eye
  48686. * @param eye the eye for which to get the render target
  48687. * @returns the render target for the specified eye
  48688. */
  48689. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48690. /**
  48691. * Creates a WebXRRenderTarget object for the XR session
  48692. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48693. * @param options optional options to provide when creating a new render target
  48694. * @returns a WebXR render target to which the session can render
  48695. */
  48696. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48697. /**
  48698. * Initializes the manager
  48699. * After initialization enterXR can be called to start an XR session
  48700. * @returns Promise which resolves after it is initialized
  48701. */
  48702. initializeAsync(): Promise<void>;
  48703. /**
  48704. * Initializes an xr session
  48705. * @param xrSessionMode mode to initialize
  48706. * @param xrSessionInit defines optional and required values to pass to the session builder
  48707. * @returns a promise which will resolve once the session has been initialized
  48708. */
  48709. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48710. /**
  48711. * Checks if a session would be supported for the creation options specified
  48712. * @param sessionMode session mode to check if supported eg. immersive-vr
  48713. * @returns A Promise that resolves to true if supported and false if not
  48714. */
  48715. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48716. /**
  48717. * Resets the reference space to the one started the session
  48718. */
  48719. resetReferenceSpace(): void;
  48720. /**
  48721. * Starts rendering to the xr layer
  48722. */
  48723. runXRRenderLoop(): void;
  48724. /**
  48725. * Sets the reference space on the xr session
  48726. * @param referenceSpaceType space to set
  48727. * @returns a promise that will resolve once the reference space has been set
  48728. */
  48729. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48730. /**
  48731. * Updates the render state of the session
  48732. * @param state state to set
  48733. * @returns a promise that resolves once the render state has been updated
  48734. */
  48735. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48736. /**
  48737. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48738. * @param sessionMode defines the session to test
  48739. * @returns a promise with boolean as final value
  48740. */
  48741. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48742. private _createRenderTargetTexture;
  48743. }
  48744. }
  48745. declare module "babylonjs/XR/webXRCamera" {
  48746. import { Vector3 } from "babylonjs/Maths/math.vector";
  48747. import { Scene } from "babylonjs/scene";
  48748. import { Camera } from "babylonjs/Cameras/camera";
  48749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48750. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48751. import { Observable } from "babylonjs/Misc/observable";
  48752. /**
  48753. * WebXR Camera which holds the views for the xrSession
  48754. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48755. */
  48756. export class WebXRCamera extends FreeCamera {
  48757. private _xrSessionManager;
  48758. private _firstFrame;
  48759. private _referenceQuaternion;
  48760. private _referencedPosition;
  48761. private _xrInvPositionCache;
  48762. private _xrInvQuaternionCache;
  48763. /**
  48764. * Observable raised before camera teleportation
  48765. */
  48766. onBeforeCameraTeleport: Observable<Vector3>;
  48767. /**
  48768. * Observable raised after camera teleportation
  48769. */
  48770. onAfterCameraTeleport: Observable<Vector3>;
  48771. /**
  48772. * Should position compensation execute on first frame.
  48773. * This is used when copying the position from a native (non XR) camera
  48774. */
  48775. compensateOnFirstFrame: boolean;
  48776. /**
  48777. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48778. * @param name the name of the camera
  48779. * @param scene the scene to add the camera to
  48780. * @param _xrSessionManager a constructed xr session manager
  48781. */
  48782. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48783. /**
  48784. * Return the user's height, unrelated to the current ground.
  48785. * This will be the y position of this camera, when ground level is 0.
  48786. */
  48787. get realWorldHeight(): number;
  48788. /** @hidden */
  48789. _updateForDualEyeDebugging(): void;
  48790. /**
  48791. * Sets this camera's transformation based on a non-vr camera
  48792. * @param otherCamera the non-vr camera to copy the transformation from
  48793. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48794. */
  48795. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48796. /**
  48797. * Gets the current instance class name ("WebXRCamera").
  48798. * @returns the class name
  48799. */
  48800. getClassName(): string;
  48801. private _rotate180;
  48802. private _updateFromXRSession;
  48803. private _updateNumberOfRigCameras;
  48804. private _updateReferenceSpace;
  48805. private _updateReferenceSpaceOffset;
  48806. }
  48807. }
  48808. declare module "babylonjs/XR/webXRFeaturesManager" {
  48809. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48810. import { IDisposable } from "babylonjs/scene";
  48811. /**
  48812. * Defining the interface required for a (webxr) feature
  48813. */
  48814. export interface IWebXRFeature extends IDisposable {
  48815. /**
  48816. * Is this feature attached
  48817. */
  48818. attached: boolean;
  48819. /**
  48820. * Should auto-attach be disabled?
  48821. */
  48822. disableAutoAttach: boolean;
  48823. /**
  48824. * Attach the feature to the session
  48825. * Will usually be called by the features manager
  48826. *
  48827. * @param force should attachment be forced (even when already attached)
  48828. * @returns true if successful.
  48829. */
  48830. attach(force?: boolean): boolean;
  48831. /**
  48832. * Detach the feature from the session
  48833. * Will usually be called by the features manager
  48834. *
  48835. * @returns true if successful.
  48836. */
  48837. detach(): boolean;
  48838. /**
  48839. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48840. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48841. *
  48842. * @returns whether or not the feature is compatible in this environment
  48843. */
  48844. isCompatible(): boolean;
  48845. /**
  48846. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48847. */
  48848. xrNativeFeatureName?: string;
  48849. }
  48850. /**
  48851. * A list of the currently available features without referencing them
  48852. */
  48853. export class WebXRFeatureName {
  48854. /**
  48855. * The name of the anchor system feature
  48856. */
  48857. static ANCHOR_SYSTEM: string;
  48858. /**
  48859. * The name of the background remover feature
  48860. */
  48861. static BACKGROUND_REMOVER: string;
  48862. /**
  48863. * The name of the hit test feature
  48864. */
  48865. static HIT_TEST: string;
  48866. /**
  48867. * physics impostors for xr controllers feature
  48868. */
  48869. static PHYSICS_CONTROLLERS: string;
  48870. /**
  48871. * The name of the plane detection feature
  48872. */
  48873. static PLANE_DETECTION: string;
  48874. /**
  48875. * The name of the pointer selection feature
  48876. */
  48877. static POINTER_SELECTION: string;
  48878. /**
  48879. * The name of the teleportation feature
  48880. */
  48881. static TELEPORTATION: string;
  48882. }
  48883. /**
  48884. * Defining the constructor of a feature. Used to register the modules.
  48885. */
  48886. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48887. /**
  48888. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48889. * It is mainly used in AR sessions.
  48890. *
  48891. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48892. */
  48893. export class WebXRFeaturesManager implements IDisposable {
  48894. private _xrSessionManager;
  48895. private static readonly _AvailableFeatures;
  48896. private _features;
  48897. /**
  48898. * constructs a new features manages.
  48899. *
  48900. * @param _xrSessionManager an instance of WebXRSessionManager
  48901. */
  48902. constructor(_xrSessionManager: WebXRSessionManager);
  48903. /**
  48904. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48905. * Mainly used internally.
  48906. *
  48907. * @param featureName the name of the feature to register
  48908. * @param constructorFunction the function used to construct the module
  48909. * @param version the (babylon) version of the module
  48910. * @param stable is that a stable version of this module
  48911. */
  48912. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48913. /**
  48914. * Returns a constructor of a specific feature.
  48915. *
  48916. * @param featureName the name of the feature to construct
  48917. * @param version the version of the feature to load
  48918. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48919. * @param options optional options provided to the module.
  48920. * @returns a function that, when called, will return a new instance of this feature
  48921. */
  48922. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48923. /**
  48924. * Can be used to return the list of features currently registered
  48925. *
  48926. * @returns an Array of available features
  48927. */
  48928. static GetAvailableFeatures(): string[];
  48929. /**
  48930. * Gets the versions available for a specific feature
  48931. * @param featureName the name of the feature
  48932. * @returns an array with the available versions
  48933. */
  48934. static GetAvailableVersions(featureName: string): string[];
  48935. /**
  48936. * Return the latest unstable version of this feature
  48937. * @param featureName the name of the feature to search
  48938. * @returns the version number. if not found will return -1
  48939. */
  48940. static GetLatestVersionOfFeature(featureName: string): number;
  48941. /**
  48942. * Return the latest stable version of this feature
  48943. * @param featureName the name of the feature to search
  48944. * @returns the version number. if not found will return -1
  48945. */
  48946. static GetStableVersionOfFeature(featureName: string): number;
  48947. /**
  48948. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48949. * Can be used during a session to start a feature
  48950. * @param featureName the name of feature to attach
  48951. */
  48952. attachFeature(featureName: string): void;
  48953. /**
  48954. * Can be used inside a session or when the session ends to detach a specific feature
  48955. * @param featureName the name of the feature to detach
  48956. */
  48957. detachFeature(featureName: string): void;
  48958. /**
  48959. * Used to disable an already-enabled feature
  48960. * The feature will be disposed and will be recreated once enabled.
  48961. * @param featureName the feature to disable
  48962. * @returns true if disable was successful
  48963. */
  48964. disableFeature(featureName: string | {
  48965. Name: string;
  48966. }): boolean;
  48967. /**
  48968. * dispose this features manager
  48969. */
  48970. dispose(): void;
  48971. /**
  48972. * 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.
  48973. * 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.
  48974. *
  48975. * @param featureName the name of the feature to load or the class of the feature
  48976. * @param version optional version to load. if not provided the latest version will be enabled
  48977. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48978. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48979. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48980. * @returns a new constructed feature or throws an error if feature not found.
  48981. */
  48982. enableFeature(featureName: string | {
  48983. Name: string;
  48984. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48985. /**
  48986. * get the implementation of an enabled feature.
  48987. * @param featureName the name of the feature to load
  48988. * @returns the feature class, if found
  48989. */
  48990. getEnabledFeature(featureName: string): IWebXRFeature;
  48991. /**
  48992. * Get the list of enabled features
  48993. * @returns an array of enabled features
  48994. */
  48995. getEnabledFeatures(): string[];
  48996. /**
  48997. * This function will exten the session creation configuration object with enabled features.
  48998. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48999. * according to the defined "required" variable, provided during enableFeature call
  49000. * @param xrSessionInit the xr Session init object to extend
  49001. *
  49002. * @returns an extended XRSessionInit object
  49003. */
  49004. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49005. }
  49006. }
  49007. declare module "babylonjs/XR/webXRExperienceHelper" {
  49008. import { Observable } from "babylonjs/Misc/observable";
  49009. import { IDisposable, Scene } from "babylonjs/scene";
  49010. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49011. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49012. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49013. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49014. /**
  49015. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49016. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49017. */
  49018. export class WebXRExperienceHelper implements IDisposable {
  49019. private scene;
  49020. private _nonVRCamera;
  49021. private _originalSceneAutoClear;
  49022. private _supported;
  49023. /**
  49024. * Camera used to render xr content
  49025. */
  49026. camera: WebXRCamera;
  49027. /** A features manager for this xr session */
  49028. featuresManager: WebXRFeaturesManager;
  49029. /**
  49030. * Observers registered here will be triggered after the camera's initial transformation is set
  49031. * This can be used to set a different ground level or an extra rotation.
  49032. *
  49033. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49034. * to the position set after this observable is done executing.
  49035. */
  49036. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49037. /**
  49038. * Fires when the state of the experience helper has changed
  49039. */
  49040. onStateChangedObservable: Observable<WebXRState>;
  49041. /** Session manager used to keep track of xr session */
  49042. sessionManager: WebXRSessionManager;
  49043. /**
  49044. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49045. */
  49046. state: WebXRState;
  49047. /**
  49048. * Creates a WebXRExperienceHelper
  49049. * @param scene The scene the helper should be created in
  49050. */
  49051. private constructor();
  49052. /**
  49053. * Creates the experience helper
  49054. * @param scene the scene to attach the experience helper to
  49055. * @returns a promise for the experience helper
  49056. */
  49057. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49058. /**
  49059. * Disposes of the experience helper
  49060. */
  49061. dispose(): void;
  49062. /**
  49063. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49064. * @param sessionMode options for the XR session
  49065. * @param referenceSpaceType frame of reference of the XR session
  49066. * @param renderTarget the output canvas that will be used to enter XR mode
  49067. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49068. * @returns promise that resolves after xr mode has entered
  49069. */
  49070. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49071. /**
  49072. * Exits XR mode and returns the scene to its original state
  49073. * @returns promise that resolves after xr mode has exited
  49074. */
  49075. exitXRAsync(): Promise<void>;
  49076. private _nonXRToXRCamera;
  49077. private _setState;
  49078. }
  49079. }
  49080. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49081. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49082. import { Observable } from "babylonjs/Misc/observable";
  49083. import { IDisposable } from "babylonjs/scene";
  49084. /**
  49085. * X-Y values for axes in WebXR
  49086. */
  49087. export interface IWebXRMotionControllerAxesValue {
  49088. /**
  49089. * The value of the x axis
  49090. */
  49091. x: number;
  49092. /**
  49093. * The value of the y-axis
  49094. */
  49095. y: number;
  49096. }
  49097. /**
  49098. * changed / previous values for the values of this component
  49099. */
  49100. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49101. /**
  49102. * current (this frame) value
  49103. */
  49104. current: T;
  49105. /**
  49106. * previous (last change) value
  49107. */
  49108. previous: T;
  49109. }
  49110. /**
  49111. * Represents changes in the component between current frame and last values recorded
  49112. */
  49113. export interface IWebXRMotionControllerComponentChanges {
  49114. /**
  49115. * will be populated with previous and current values if axes changed
  49116. */
  49117. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49118. /**
  49119. * will be populated with previous and current values if pressed changed
  49120. */
  49121. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49122. /**
  49123. * will be populated with previous and current values if touched changed
  49124. */
  49125. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49126. /**
  49127. * will be populated with previous and current values if value changed
  49128. */
  49129. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49130. }
  49131. /**
  49132. * This class represents a single component (for example button or thumbstick) of a motion controller
  49133. */
  49134. export class WebXRControllerComponent implements IDisposable {
  49135. /**
  49136. * the id of this component
  49137. */
  49138. id: string;
  49139. /**
  49140. * the type of the component
  49141. */
  49142. type: MotionControllerComponentType;
  49143. private _buttonIndex;
  49144. private _axesIndices;
  49145. private _axes;
  49146. private _changes;
  49147. private _currentValue;
  49148. private _hasChanges;
  49149. private _pressed;
  49150. private _touched;
  49151. /**
  49152. * button component type
  49153. */
  49154. static BUTTON_TYPE: MotionControllerComponentType;
  49155. /**
  49156. * squeeze component type
  49157. */
  49158. static SQUEEZE_TYPE: MotionControllerComponentType;
  49159. /**
  49160. * Thumbstick component type
  49161. */
  49162. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49163. /**
  49164. * Touchpad component type
  49165. */
  49166. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49167. /**
  49168. * trigger component type
  49169. */
  49170. static TRIGGER_TYPE: MotionControllerComponentType;
  49171. /**
  49172. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49173. * the axes data changes
  49174. */
  49175. onAxisValueChangedObservable: Observable<{
  49176. x: number;
  49177. y: number;
  49178. }>;
  49179. /**
  49180. * Observers registered here will be triggered when the state of a button changes
  49181. * State change is either pressed / touched / value
  49182. */
  49183. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49184. /**
  49185. * Creates a new component for a motion controller.
  49186. * It is created by the motion controller itself
  49187. *
  49188. * @param id the id of this component
  49189. * @param type the type of the component
  49190. * @param _buttonIndex index in the buttons array of the gamepad
  49191. * @param _axesIndices indices of the values in the axes array of the gamepad
  49192. */
  49193. constructor(
  49194. /**
  49195. * the id of this component
  49196. */
  49197. id: string,
  49198. /**
  49199. * the type of the component
  49200. */
  49201. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49202. /**
  49203. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49204. */
  49205. get axes(): IWebXRMotionControllerAxesValue;
  49206. /**
  49207. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49208. */
  49209. get changes(): IWebXRMotionControllerComponentChanges;
  49210. /**
  49211. * Return whether or not the component changed the last frame
  49212. */
  49213. get hasChanges(): boolean;
  49214. /**
  49215. * is the button currently pressed
  49216. */
  49217. get pressed(): boolean;
  49218. /**
  49219. * is the button currently touched
  49220. */
  49221. get touched(): boolean;
  49222. /**
  49223. * Get the current value of this component
  49224. */
  49225. get value(): number;
  49226. /**
  49227. * Dispose this component
  49228. */
  49229. dispose(): void;
  49230. /**
  49231. * Are there axes correlating to this component
  49232. * @return true is axes data is available
  49233. */
  49234. isAxes(): boolean;
  49235. /**
  49236. * Is this component a button (hence - pressable)
  49237. * @returns true if can be pressed
  49238. */
  49239. isButton(): boolean;
  49240. /**
  49241. * update this component using the gamepad object it is in. Called on every frame
  49242. * @param nativeController the native gamepad controller object
  49243. */
  49244. update(nativeController: IMinimalMotionControllerObject): void;
  49245. }
  49246. }
  49247. declare module "babylonjs/Loading/sceneLoader" {
  49248. import { Observable } from "babylonjs/Misc/observable";
  49249. import { Nullable } from "babylonjs/types";
  49250. import { Scene } from "babylonjs/scene";
  49251. import { Engine } from "babylonjs/Engines/engine";
  49252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49253. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49254. import { AssetContainer } from "babylonjs/assetContainer";
  49255. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49256. import { Skeleton } from "babylonjs/Bones/skeleton";
  49257. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49258. import { WebRequest } from "babylonjs/Misc/webRequest";
  49259. /**
  49260. * Interface used to represent data loading progression
  49261. */
  49262. export interface ISceneLoaderProgressEvent {
  49263. /**
  49264. * Defines if data length to load can be evaluated
  49265. */
  49266. readonly lengthComputable: boolean;
  49267. /**
  49268. * Defines the loaded data length
  49269. */
  49270. readonly loaded: number;
  49271. /**
  49272. * Defines the data length to load
  49273. */
  49274. readonly total: number;
  49275. }
  49276. /**
  49277. * Interface used by SceneLoader plugins to define supported file extensions
  49278. */
  49279. export interface ISceneLoaderPluginExtensions {
  49280. /**
  49281. * Defines the list of supported extensions
  49282. */
  49283. [extension: string]: {
  49284. isBinary: boolean;
  49285. };
  49286. }
  49287. /**
  49288. * Interface used by SceneLoader plugin factory
  49289. */
  49290. export interface ISceneLoaderPluginFactory {
  49291. /**
  49292. * Defines the name of the factory
  49293. */
  49294. name: string;
  49295. /**
  49296. * Function called to create a new plugin
  49297. * @return the new plugin
  49298. */
  49299. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49300. /**
  49301. * The callback that returns true if the data can be directly loaded.
  49302. * @param data string containing the file data
  49303. * @returns if the data can be loaded directly
  49304. */
  49305. canDirectLoad?(data: string): boolean;
  49306. }
  49307. /**
  49308. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49309. */
  49310. export interface ISceneLoaderPluginBase {
  49311. /**
  49312. * The friendly name of this plugin.
  49313. */
  49314. name: string;
  49315. /**
  49316. * The file extensions supported by this plugin.
  49317. */
  49318. extensions: string | ISceneLoaderPluginExtensions;
  49319. /**
  49320. * The callback called when loading from a url.
  49321. * @param scene scene loading this url
  49322. * @param url url to load
  49323. * @param onSuccess callback called when the file successfully loads
  49324. * @param onProgress callback called while file is loading (if the server supports this mode)
  49325. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49326. * @param onError callback called when the file fails to load
  49327. * @returns a file request object
  49328. */
  49329. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49330. /**
  49331. * The callback called when loading from a file object.
  49332. * @param scene scene loading this file
  49333. * @param file defines the file to load
  49334. * @param onSuccess defines the callback to call when data is loaded
  49335. * @param onProgress defines the callback to call during loading process
  49336. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49337. * @param onError defines the callback to call when an error occurs
  49338. * @returns a file request object
  49339. */
  49340. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49341. /**
  49342. * The callback that returns true if the data can be directly loaded.
  49343. * @param data string containing the file data
  49344. * @returns if the data can be loaded directly
  49345. */
  49346. canDirectLoad?(data: string): boolean;
  49347. /**
  49348. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49349. * @param scene scene loading this data
  49350. * @param data string containing the data
  49351. * @returns data to pass to the plugin
  49352. */
  49353. directLoad?(scene: Scene, data: string): any;
  49354. /**
  49355. * The callback that allows custom handling of the root url based on the response url.
  49356. * @param rootUrl the original root url
  49357. * @param responseURL the response url if available
  49358. * @returns the new root url
  49359. */
  49360. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49361. }
  49362. /**
  49363. * Interface used to define a SceneLoader plugin
  49364. */
  49365. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49366. /**
  49367. * Import meshes into a scene.
  49368. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49369. * @param scene The scene to import into
  49370. * @param data The data to import
  49371. * @param rootUrl The root url for scene and resources
  49372. * @param meshes The meshes array to import into
  49373. * @param particleSystems The particle systems array to import into
  49374. * @param skeletons The skeletons array to import into
  49375. * @param onError The callback when import fails
  49376. * @returns True if successful or false otherwise
  49377. */
  49378. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49379. /**
  49380. * Load into a scene.
  49381. * @param scene The scene to load into
  49382. * @param data The data to import
  49383. * @param rootUrl The root url for scene and resources
  49384. * @param onError The callback when import fails
  49385. * @returns True if successful or false otherwise
  49386. */
  49387. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49388. /**
  49389. * Load into an asset container.
  49390. * @param scene The scene to load into
  49391. * @param data The data to import
  49392. * @param rootUrl The root url for scene and resources
  49393. * @param onError The callback when import fails
  49394. * @returns The loaded asset container
  49395. */
  49396. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49397. }
  49398. /**
  49399. * Interface used to define an async SceneLoader plugin
  49400. */
  49401. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49402. /**
  49403. * Import meshes into a scene.
  49404. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49405. * @param scene The scene to import into
  49406. * @param data The data to import
  49407. * @param rootUrl The root url for scene and resources
  49408. * @param onProgress The callback when the load progresses
  49409. * @param fileName Defines the name of the file to load
  49410. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49411. */
  49412. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49413. meshes: AbstractMesh[];
  49414. particleSystems: IParticleSystem[];
  49415. skeletons: Skeleton[];
  49416. animationGroups: AnimationGroup[];
  49417. }>;
  49418. /**
  49419. * Load into a scene.
  49420. * @param scene The scene to load into
  49421. * @param data The data to import
  49422. * @param rootUrl The root url for scene and resources
  49423. * @param onProgress The callback when the load progresses
  49424. * @param fileName Defines the name of the file to load
  49425. * @returns Nothing
  49426. */
  49427. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49428. /**
  49429. * Load into an asset container.
  49430. * @param scene The scene to load into
  49431. * @param data The data to import
  49432. * @param rootUrl The root url for scene and resources
  49433. * @param onProgress The callback when the load progresses
  49434. * @param fileName Defines the name of the file to load
  49435. * @returns The loaded asset container
  49436. */
  49437. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49438. }
  49439. /**
  49440. * Mode that determines how to handle old animation groups before loading new ones.
  49441. */
  49442. export enum SceneLoaderAnimationGroupLoadingMode {
  49443. /**
  49444. * Reset all old animations to initial state then dispose them.
  49445. */
  49446. Clean = 0,
  49447. /**
  49448. * Stop all old animations.
  49449. */
  49450. Stop = 1,
  49451. /**
  49452. * Restart old animations from first frame.
  49453. */
  49454. Sync = 2,
  49455. /**
  49456. * Old animations remains untouched.
  49457. */
  49458. NoSync = 3
  49459. }
  49460. /**
  49461. * Defines a plugin registered by the SceneLoader
  49462. */
  49463. interface IRegisteredPlugin {
  49464. /**
  49465. * Defines the plugin to use
  49466. */
  49467. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49468. /**
  49469. * Defines if the plugin supports binary data
  49470. */
  49471. isBinary: boolean;
  49472. }
  49473. /**
  49474. * Class used to load scene from various file formats using registered plugins
  49475. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49476. */
  49477. export class SceneLoader {
  49478. /**
  49479. * No logging while loading
  49480. */
  49481. static readonly NO_LOGGING: number;
  49482. /**
  49483. * Minimal logging while loading
  49484. */
  49485. static readonly MINIMAL_LOGGING: number;
  49486. /**
  49487. * Summary logging while loading
  49488. */
  49489. static readonly SUMMARY_LOGGING: number;
  49490. /**
  49491. * Detailled logging while loading
  49492. */
  49493. static readonly DETAILED_LOGGING: number;
  49494. /**
  49495. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49496. */
  49497. static get ForceFullSceneLoadingForIncremental(): boolean;
  49498. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49499. /**
  49500. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49501. */
  49502. static get ShowLoadingScreen(): boolean;
  49503. static set ShowLoadingScreen(value: boolean);
  49504. /**
  49505. * Defines the current logging level (while loading the scene)
  49506. * @ignorenaming
  49507. */
  49508. static get loggingLevel(): number;
  49509. static set loggingLevel(value: number);
  49510. /**
  49511. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49512. */
  49513. static get CleanBoneMatrixWeights(): boolean;
  49514. static set CleanBoneMatrixWeights(value: boolean);
  49515. /**
  49516. * Event raised when a plugin is used to load a scene
  49517. */
  49518. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49519. private static _registeredPlugins;
  49520. private static _showingLoadingScreen;
  49521. /**
  49522. * Gets the default plugin (used to load Babylon files)
  49523. * @returns the .babylon plugin
  49524. */
  49525. static GetDefaultPlugin(): IRegisteredPlugin;
  49526. private static _GetPluginForExtension;
  49527. private static _GetPluginForDirectLoad;
  49528. private static _GetPluginForFilename;
  49529. private static _GetDirectLoad;
  49530. private static _LoadData;
  49531. private static _GetFileInfo;
  49532. /**
  49533. * Gets a plugin that can load the given extension
  49534. * @param extension defines the extension to load
  49535. * @returns a plugin or null if none works
  49536. */
  49537. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49538. /**
  49539. * Gets a boolean indicating that the given extension can be loaded
  49540. * @param extension defines the extension to load
  49541. * @returns true if the extension is supported
  49542. */
  49543. static IsPluginForExtensionAvailable(extension: string): boolean;
  49544. /**
  49545. * Adds a new plugin to the list of registered plugins
  49546. * @param plugin defines the plugin to add
  49547. */
  49548. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49549. /**
  49550. * Import meshes into a scene
  49551. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49552. * @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)
  49553. * @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)
  49554. * @param scene the instance of BABYLON.Scene to append to
  49555. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49556. * @param onProgress a callback with a progress event for each file being loaded
  49557. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49558. * @param pluginExtension the extension used to determine the plugin
  49559. * @returns The loaded plugin
  49560. */
  49561. 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>;
  49562. /**
  49563. * Import meshes into a scene
  49564. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49565. * @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)
  49566. * @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)
  49567. * @param scene the instance of BABYLON.Scene to append to
  49568. * @param onProgress a callback with a progress event for each file being loaded
  49569. * @param pluginExtension the extension used to determine the plugin
  49570. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49571. */
  49572. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49573. meshes: AbstractMesh[];
  49574. particleSystems: IParticleSystem[];
  49575. skeletons: Skeleton[];
  49576. animationGroups: AnimationGroup[];
  49577. }>;
  49578. /**
  49579. * Load a scene
  49580. * @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)
  49581. * @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)
  49582. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49583. * @param onSuccess a callback with the scene when import succeeds
  49584. * @param onProgress a callback with a progress event for each file being loaded
  49585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49586. * @param pluginExtension the extension used to determine the plugin
  49587. * @returns The loaded plugin
  49588. */
  49589. 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>;
  49590. /**
  49591. * Load a scene
  49592. * @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)
  49593. * @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)
  49594. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49595. * @param onProgress a callback with a progress event for each file being loaded
  49596. * @param pluginExtension the extension used to determine the plugin
  49597. * @returns The loaded scene
  49598. */
  49599. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49600. /**
  49601. * Append a scene
  49602. * @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)
  49603. * @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)
  49604. * @param scene is the instance of BABYLON.Scene to append to
  49605. * @param onSuccess a callback with the scene when import succeeds
  49606. * @param onProgress a callback with a progress event for each file being loaded
  49607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49608. * @param pluginExtension the extension used to determine the plugin
  49609. * @returns The loaded plugin
  49610. */
  49611. 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>;
  49612. /**
  49613. * Append a scene
  49614. * @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)
  49615. * @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)
  49616. * @param scene is the instance of BABYLON.Scene to append to
  49617. * @param onProgress a callback with a progress event for each file being loaded
  49618. * @param pluginExtension the extension used to determine the plugin
  49619. * @returns The given scene
  49620. */
  49621. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49622. /**
  49623. * Load a scene into an asset container
  49624. * @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)
  49625. * @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)
  49626. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49627. * @param onSuccess a callback with the scene when import succeeds
  49628. * @param onProgress a callback with a progress event for each file being loaded
  49629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49630. * @param pluginExtension the extension used to determine the plugin
  49631. * @returns The loaded plugin
  49632. */
  49633. 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>;
  49634. /**
  49635. * Load a scene into an asset container
  49636. * @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)
  49637. * @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)
  49638. * @param scene is the instance of Scene to append to
  49639. * @param onProgress a callback with a progress event for each file being loaded
  49640. * @param pluginExtension the extension used to determine the plugin
  49641. * @returns The loaded asset container
  49642. */
  49643. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49644. /**
  49645. * Import animations from a file into a scene
  49646. * @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)
  49647. * @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)
  49648. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49649. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49650. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49651. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49652. * @param onSuccess a callback with the scene when import succeeds
  49653. * @param onProgress a callback with a progress event for each file being loaded
  49654. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49655. * @param pluginExtension the extension used to determine the plugin
  49656. */
  49657. 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;
  49658. /**
  49659. * Import animations from a file into a scene
  49660. * @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)
  49661. * @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)
  49662. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49663. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49664. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49665. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49666. * @param onSuccess a callback with the scene when import succeeds
  49667. * @param onProgress a callback with a progress event for each file being loaded
  49668. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49669. * @param pluginExtension the extension used to determine the plugin
  49670. * @returns the updated scene with imported animations
  49671. */
  49672. 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>;
  49673. }
  49674. }
  49675. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49676. import { IDisposable, Scene } from "babylonjs/scene";
  49677. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49678. import { Observable } from "babylonjs/Misc/observable";
  49679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49680. import { Nullable } from "babylonjs/types";
  49681. /**
  49682. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49683. */
  49684. export type MotionControllerHandedness = "none" | "left" | "right";
  49685. /**
  49686. * The type of components available in motion controllers.
  49687. * This is not the name of the component.
  49688. */
  49689. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49690. /**
  49691. * The state of a controller component
  49692. */
  49693. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49694. /**
  49695. * The schema of motion controller layout.
  49696. * No object will be initialized using this interface
  49697. * This is used just to define the profile.
  49698. */
  49699. export interface IMotionControllerLayout {
  49700. /**
  49701. * Path to load the assets. Usually relative to the base path
  49702. */
  49703. assetPath: string;
  49704. /**
  49705. * Available components (unsorted)
  49706. */
  49707. components: {
  49708. /**
  49709. * A map of component Ids
  49710. */
  49711. [componentId: string]: {
  49712. /**
  49713. * The type of input the component outputs
  49714. */
  49715. type: MotionControllerComponentType;
  49716. /**
  49717. * The indices of this component in the gamepad object
  49718. */
  49719. gamepadIndices: {
  49720. /**
  49721. * Index of button
  49722. */
  49723. button?: number;
  49724. /**
  49725. * If available, index of x-axis
  49726. */
  49727. xAxis?: number;
  49728. /**
  49729. * If available, index of y-axis
  49730. */
  49731. yAxis?: number;
  49732. };
  49733. /**
  49734. * The mesh's root node name
  49735. */
  49736. rootNodeName: string;
  49737. /**
  49738. * Animation definitions for this model
  49739. */
  49740. visualResponses: {
  49741. [stateKey: string]: {
  49742. /**
  49743. * What property will be animated
  49744. */
  49745. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49746. /**
  49747. * What states influence this visual response
  49748. */
  49749. states: MotionControllerComponentStateType[];
  49750. /**
  49751. * Type of animation - movement or visibility
  49752. */
  49753. valueNodeProperty: "transform" | "visibility";
  49754. /**
  49755. * Base node name to move. Its position will be calculated according to the min and max nodes
  49756. */
  49757. valueNodeName?: string;
  49758. /**
  49759. * Minimum movement node
  49760. */
  49761. minNodeName?: string;
  49762. /**
  49763. * Max movement node
  49764. */
  49765. maxNodeName?: string;
  49766. };
  49767. };
  49768. /**
  49769. * If touch enabled, what is the name of node to display user feedback
  49770. */
  49771. touchPointNodeName?: string;
  49772. };
  49773. };
  49774. /**
  49775. * Is it xr standard mapping or not
  49776. */
  49777. gamepadMapping: "" | "xr-standard";
  49778. /**
  49779. * Base root node of this entire model
  49780. */
  49781. rootNodeName: string;
  49782. /**
  49783. * Defines the main button component id
  49784. */
  49785. selectComponentId: string;
  49786. }
  49787. /**
  49788. * A definition for the layout map in the input profile
  49789. */
  49790. export interface IMotionControllerLayoutMap {
  49791. /**
  49792. * Layouts with handedness type as a key
  49793. */
  49794. [handedness: string]: IMotionControllerLayout;
  49795. }
  49796. /**
  49797. * The XR Input profile schema
  49798. * Profiles can be found here:
  49799. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49800. */
  49801. export interface IMotionControllerProfile {
  49802. /**
  49803. * fallback profiles for this profileId
  49804. */
  49805. fallbackProfileIds: string[];
  49806. /**
  49807. * The layout map, with handedness as key
  49808. */
  49809. layouts: IMotionControllerLayoutMap;
  49810. /**
  49811. * The id of this profile
  49812. * correlates to the profile(s) in the xrInput.profiles array
  49813. */
  49814. profileId: string;
  49815. }
  49816. /**
  49817. * A helper-interface for the 3 meshes needed for controller button animation
  49818. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49819. */
  49820. export interface IMotionControllerButtonMeshMap {
  49821. /**
  49822. * the mesh that defines the pressed value mesh position.
  49823. * This is used to find the max-position of this button
  49824. */
  49825. pressedMesh: AbstractMesh;
  49826. /**
  49827. * the mesh that defines the unpressed value mesh position.
  49828. * This is used to find the min (or initial) position of this button
  49829. */
  49830. unpressedMesh: AbstractMesh;
  49831. /**
  49832. * The mesh that will be changed when value changes
  49833. */
  49834. valueMesh: AbstractMesh;
  49835. }
  49836. /**
  49837. * A helper-interface for the 3 meshes needed for controller axis animation.
  49838. * This will be expanded when touchpad animations are fully supported
  49839. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49840. */
  49841. export interface IMotionControllerMeshMap {
  49842. /**
  49843. * the mesh that defines the maximum value mesh position.
  49844. */
  49845. maxMesh?: AbstractMesh;
  49846. /**
  49847. * the mesh that defines the minimum value mesh position.
  49848. */
  49849. minMesh?: AbstractMesh;
  49850. /**
  49851. * The mesh that will be changed when axis value changes
  49852. */
  49853. valueMesh: AbstractMesh;
  49854. }
  49855. /**
  49856. * The elements needed for change-detection of the gamepad objects in motion controllers
  49857. */
  49858. export interface IMinimalMotionControllerObject {
  49859. /**
  49860. * Available axes of this controller
  49861. */
  49862. axes: number[];
  49863. /**
  49864. * An array of available buttons
  49865. */
  49866. buttons: Array<{
  49867. /**
  49868. * Value of the button/trigger
  49869. */
  49870. value: number;
  49871. /**
  49872. * If the button/trigger is currently touched
  49873. */
  49874. touched: boolean;
  49875. /**
  49876. * If the button/trigger is currently pressed
  49877. */
  49878. pressed: boolean;
  49879. }>;
  49880. /**
  49881. * EXPERIMENTAL haptic support.
  49882. */
  49883. hapticActuators?: Array<{
  49884. pulse: (value: number, duration: number) => Promise<boolean>;
  49885. }>;
  49886. }
  49887. /**
  49888. * An Abstract Motion controller
  49889. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49890. * Each component has an observable to check for changes in value and state
  49891. */
  49892. export abstract class WebXRAbstractMotionController implements IDisposable {
  49893. protected scene: Scene;
  49894. protected layout: IMotionControllerLayout;
  49895. /**
  49896. * The gamepad object correlating to this controller
  49897. */
  49898. gamepadObject: IMinimalMotionControllerObject;
  49899. /**
  49900. * handedness (left/right/none) of this controller
  49901. */
  49902. handedness: MotionControllerHandedness;
  49903. private _initComponent;
  49904. private _modelReady;
  49905. /**
  49906. * A map of components (WebXRControllerComponent) in this motion controller
  49907. * Components have a ComponentType and can also have both button and axis definitions
  49908. */
  49909. readonly components: {
  49910. [id: string]: WebXRControllerComponent;
  49911. };
  49912. /**
  49913. * Disable the model's animation. Can be set at any time.
  49914. */
  49915. disableAnimation: boolean;
  49916. /**
  49917. * Observers registered here will be triggered when the model of this controller is done loading
  49918. */
  49919. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49920. /**
  49921. * The profile id of this motion controller
  49922. */
  49923. abstract profileId: string;
  49924. /**
  49925. * The root mesh of the model. It is null if the model was not yet initialized
  49926. */
  49927. rootMesh: Nullable<AbstractMesh>;
  49928. /**
  49929. * constructs a new abstract motion controller
  49930. * @param scene the scene to which the model of the controller will be added
  49931. * @param layout The profile layout to load
  49932. * @param gamepadObject The gamepad object correlating to this controller
  49933. * @param handedness handedness (left/right/none) of this controller
  49934. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49935. */
  49936. constructor(scene: Scene, layout: IMotionControllerLayout,
  49937. /**
  49938. * The gamepad object correlating to this controller
  49939. */
  49940. gamepadObject: IMinimalMotionControllerObject,
  49941. /**
  49942. * handedness (left/right/none) of this controller
  49943. */
  49944. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49945. /**
  49946. * Dispose this controller, the model mesh and all its components
  49947. */
  49948. dispose(): void;
  49949. /**
  49950. * Returns all components of specific type
  49951. * @param type the type to search for
  49952. * @return an array of components with this type
  49953. */
  49954. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49955. /**
  49956. * get a component based an its component id as defined in layout.components
  49957. * @param id the id of the component
  49958. * @returns the component correlates to the id or undefined if not found
  49959. */
  49960. getComponent(id: string): WebXRControllerComponent;
  49961. /**
  49962. * Get the list of components available in this motion controller
  49963. * @returns an array of strings correlating to available components
  49964. */
  49965. getComponentIds(): string[];
  49966. /**
  49967. * Get the first component of specific type
  49968. * @param type type of component to find
  49969. * @return a controller component or null if not found
  49970. */
  49971. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49972. /**
  49973. * Get the main (Select) component of this controller as defined in the layout
  49974. * @returns the main component of this controller
  49975. */
  49976. getMainComponent(): WebXRControllerComponent;
  49977. /**
  49978. * Loads the model correlating to this controller
  49979. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49980. * @returns A promise fulfilled with the result of the model loading
  49981. */
  49982. loadModel(): Promise<boolean>;
  49983. /**
  49984. * Update this model using the current XRFrame
  49985. * @param xrFrame the current xr frame to use and update the model
  49986. */
  49987. updateFromXRFrame(xrFrame: XRFrame): void;
  49988. /**
  49989. * Backwards compatibility due to a deeply-integrated typo
  49990. */
  49991. get handness(): XREye;
  49992. /**
  49993. * Pulse (vibrate) this controller
  49994. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49995. * Consecutive calls to this function will cancel the last pulse call
  49996. *
  49997. * @param value the strength of the pulse in 0.0...1.0 range
  49998. * @param duration Duration of the pulse in milliseconds
  49999. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50000. * @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
  50001. */
  50002. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50003. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  50004. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  50005. /**
  50006. * Moves the axis on the controller mesh based on its current state
  50007. * @param axis the index of the axis
  50008. * @param axisValue the value of the axis which determines the meshes new position
  50009. * @hidden
  50010. */
  50011. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50012. /**
  50013. * Update the model itself with the current frame data
  50014. * @param xrFrame the frame to use for updating the model mesh
  50015. */
  50016. protected updateModel(xrFrame: XRFrame): void;
  50017. /**
  50018. * Get the filename and path for this controller's model
  50019. * @returns a map of filename and path
  50020. */
  50021. protected abstract _getFilenameAndPath(): {
  50022. filename: string;
  50023. path: string;
  50024. };
  50025. /**
  50026. * This function is called before the mesh is loaded. It checks for loading constraints.
  50027. * For example, this function can check if the GLB loader is available
  50028. * If this function returns false, the generic controller will be loaded instead
  50029. * @returns Is the client ready to load the mesh
  50030. */
  50031. protected abstract _getModelLoadingConstraints(): boolean;
  50032. /**
  50033. * This function will be called after the model was successfully loaded and can be used
  50034. * for mesh transformations before it is available for the user
  50035. * @param meshes the loaded meshes
  50036. */
  50037. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50038. /**
  50039. * Set the root mesh for this controller. Important for the WebXR controller class
  50040. * @param meshes the loaded meshes
  50041. */
  50042. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50043. /**
  50044. * A function executed each frame that updates the mesh (if needed)
  50045. * @param xrFrame the current xrFrame
  50046. */
  50047. protected abstract _updateModel(xrFrame: XRFrame): void;
  50048. private _getGenericFilenameAndPath;
  50049. private _getGenericParentMesh;
  50050. }
  50051. }
  50052. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50053. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50055. import { Scene } from "babylonjs/scene";
  50056. /**
  50057. * A generic trigger-only motion controller for WebXR
  50058. */
  50059. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50060. /**
  50061. * Static version of the profile id of this controller
  50062. */
  50063. static ProfileId: string;
  50064. profileId: string;
  50065. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50066. protected _getFilenameAndPath(): {
  50067. filename: string;
  50068. path: string;
  50069. };
  50070. protected _getModelLoadingConstraints(): boolean;
  50071. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50072. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50073. protected _updateModel(): void;
  50074. }
  50075. }
  50076. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50077. import { Vector4 } from "babylonjs/Maths/math.vector";
  50078. import { Mesh } from "babylonjs/Meshes/mesh";
  50079. import { Scene } from "babylonjs/scene";
  50080. import { Nullable } from "babylonjs/types";
  50081. /**
  50082. * Class containing static functions to help procedurally build meshes
  50083. */
  50084. export class SphereBuilder {
  50085. /**
  50086. * Creates a sphere mesh
  50087. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50088. * * 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`)
  50089. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50090. * * 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
  50091. * * 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)
  50092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50093. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50095. * @param name defines the name of the mesh
  50096. * @param options defines the options used to create the mesh
  50097. * @param scene defines the hosting scene
  50098. * @returns the sphere mesh
  50099. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50100. */
  50101. static CreateSphere(name: string, options: {
  50102. segments?: number;
  50103. diameter?: number;
  50104. diameterX?: number;
  50105. diameterY?: number;
  50106. diameterZ?: number;
  50107. arc?: number;
  50108. slice?: number;
  50109. sideOrientation?: number;
  50110. frontUVs?: Vector4;
  50111. backUVs?: Vector4;
  50112. updatable?: boolean;
  50113. }, scene?: Nullable<Scene>): Mesh;
  50114. }
  50115. }
  50116. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50118. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50119. import { Scene } from "babylonjs/scene";
  50120. /**
  50121. * A profiled motion controller has its profile loaded from an online repository.
  50122. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50123. */
  50124. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50125. private _repositoryUrl;
  50126. private _buttonMeshMapping;
  50127. private _touchDots;
  50128. /**
  50129. * The profile ID of this controller. Will be populated when the controller initializes.
  50130. */
  50131. profileId: string;
  50132. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50133. dispose(): void;
  50134. protected _getFilenameAndPath(): {
  50135. filename: string;
  50136. path: string;
  50137. };
  50138. protected _getModelLoadingConstraints(): boolean;
  50139. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50140. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50141. protected _updateModel(_xrFrame: XRFrame): void;
  50142. }
  50143. }
  50144. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50145. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50146. import { Scene } from "babylonjs/scene";
  50147. /**
  50148. * A construction function type to create a new controller based on an xrInput object
  50149. */
  50150. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50151. /**
  50152. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50153. *
  50154. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50155. * it should be replaced with auto-loaded controllers.
  50156. *
  50157. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50158. */
  50159. export class WebXRMotionControllerManager {
  50160. private static _AvailableControllers;
  50161. private static _Fallbacks;
  50162. private static _ProfileLoadingPromises;
  50163. private static _ProfilesList;
  50164. /**
  50165. * The base URL of the online controller repository. Can be changed at any time.
  50166. */
  50167. static BaseRepositoryUrl: string;
  50168. /**
  50169. * Which repository gets priority - local or online
  50170. */
  50171. static PrioritizeOnlineRepository: boolean;
  50172. /**
  50173. * Use the online repository, or use only locally-defined controllers
  50174. */
  50175. static UseOnlineRepository: boolean;
  50176. /**
  50177. * Clear the cache used for profile loading and reload when requested again
  50178. */
  50179. static ClearProfilesCache(): void;
  50180. /**
  50181. * Register the default fallbacks.
  50182. * This function is called automatically when this file is imported.
  50183. */
  50184. static DefaultFallbacks(): void;
  50185. /**
  50186. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50187. * @param profileId the profile to which a fallback needs to be found
  50188. * @return an array with corresponding fallback profiles
  50189. */
  50190. static FindFallbackWithProfileId(profileId: string): string[];
  50191. /**
  50192. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50193. * The order of search:
  50194. *
  50195. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50196. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50197. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50198. * 4) return the generic trigger controller if none were found
  50199. *
  50200. * @param xrInput the xrInput to which a new controller is initialized
  50201. * @param scene the scene to which the model will be added
  50202. * @param forceProfile force a certain profile for this controller
  50203. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50204. */
  50205. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50206. /**
  50207. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50208. *
  50209. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50210. *
  50211. * @param type the profile type to register
  50212. * @param constructFunction the function to be called when loading this profile
  50213. */
  50214. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50215. /**
  50216. * Register a fallback to a specific profile.
  50217. * @param profileId the profileId that will receive the fallbacks
  50218. * @param fallbacks A list of fallback profiles
  50219. */
  50220. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50221. /**
  50222. * Will update the list of profiles available in the repository
  50223. * @return a promise that resolves to a map of profiles available online
  50224. */
  50225. static UpdateProfilesList(): Promise<{
  50226. [profile: string]: string;
  50227. }>;
  50228. private static _LoadProfileFromRepository;
  50229. private static _LoadProfilesFromAvailableControllers;
  50230. }
  50231. }
  50232. declare module "babylonjs/XR/webXRInputSource" {
  50233. import { Observable } from "babylonjs/Misc/observable";
  50234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50235. import { Ray } from "babylonjs/Culling/ray";
  50236. import { Scene } from "babylonjs/scene";
  50237. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50238. /**
  50239. * Configuration options for the WebXR controller creation
  50240. */
  50241. export interface IWebXRControllerOptions {
  50242. /**
  50243. * Should the controller mesh be animated when a user interacts with it
  50244. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50245. */
  50246. disableMotionControllerAnimation?: boolean;
  50247. /**
  50248. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50249. */
  50250. doNotLoadControllerMesh?: boolean;
  50251. /**
  50252. * Force a specific controller type for this controller.
  50253. * This can be used when creating your own profile or when testing different controllers
  50254. */
  50255. forceControllerProfile?: string;
  50256. /**
  50257. * Defines a rendering group ID for meshes that will be loaded.
  50258. * This is for the default controllers only.
  50259. */
  50260. renderingGroupId?: number;
  50261. }
  50262. /**
  50263. * Represents an XR controller
  50264. */
  50265. export class WebXRInputSource {
  50266. private _scene;
  50267. /** The underlying input source for the controller */
  50268. inputSource: XRInputSource;
  50269. private _options;
  50270. private _tmpVector;
  50271. private _uniqueId;
  50272. /**
  50273. * 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
  50274. */
  50275. grip?: AbstractMesh;
  50276. /**
  50277. * If available, this is the gamepad object related to this controller.
  50278. * Using this object it is possible to get click events and trackpad changes of the
  50279. * webxr controller that is currently being used.
  50280. */
  50281. motionController?: WebXRAbstractMotionController;
  50282. /**
  50283. * Event that fires when the controller is removed/disposed.
  50284. * The object provided as event data is this controller, after associated assets were disposed.
  50285. * uniqueId is still available.
  50286. */
  50287. onDisposeObservable: Observable<WebXRInputSource>;
  50288. /**
  50289. * Will be triggered when the mesh associated with the motion controller is done loading.
  50290. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50291. * A shortened version of controller -> motion controller -> on mesh loaded.
  50292. */
  50293. onMeshLoadedObservable: Observable<AbstractMesh>;
  50294. /**
  50295. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50296. */
  50297. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50298. /**
  50299. * Pointer which can be used to select objects or attach a visible laser to
  50300. */
  50301. pointer: AbstractMesh;
  50302. /**
  50303. * Creates the input source object
  50304. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50305. * @param _scene the scene which the controller should be associated to
  50306. * @param inputSource the underlying input source for the controller
  50307. * @param _options options for this controller creation
  50308. */
  50309. constructor(_scene: Scene,
  50310. /** The underlying input source for the controller */
  50311. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50312. /**
  50313. * Get this controllers unique id
  50314. */
  50315. get uniqueId(): string;
  50316. /**
  50317. * Disposes of the object
  50318. */
  50319. dispose(): void;
  50320. /**
  50321. * Gets a world space ray coming from the pointer or grip
  50322. * @param result the resulting ray
  50323. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50324. */
  50325. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50326. /**
  50327. * Updates the controller pose based on the given XRFrame
  50328. * @param xrFrame xr frame to update the pose with
  50329. * @param referenceSpace reference space to use
  50330. */
  50331. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50332. }
  50333. }
  50334. declare module "babylonjs/XR/webXRInput" {
  50335. import { Observable } from "babylonjs/Misc/observable";
  50336. import { IDisposable } from "babylonjs/scene";
  50337. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50338. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50339. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50340. /**
  50341. * The schema for initialization options of the XR Input class
  50342. */
  50343. export interface IWebXRInputOptions {
  50344. /**
  50345. * If set to true no model will be automatically loaded
  50346. */
  50347. doNotLoadControllerMeshes?: boolean;
  50348. /**
  50349. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50350. * If not found, the xr input profile data will be used.
  50351. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50352. */
  50353. forceInputProfile?: string;
  50354. /**
  50355. * Do not send a request to the controller repository to load the profile.
  50356. *
  50357. * Instead, use the controllers available in babylon itself.
  50358. */
  50359. disableOnlineControllerRepository?: boolean;
  50360. /**
  50361. * A custom URL for the controllers repository
  50362. */
  50363. customControllersRepositoryURL?: string;
  50364. /**
  50365. * Should the controller model's components not move according to the user input
  50366. */
  50367. disableControllerAnimation?: boolean;
  50368. /**
  50369. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50370. */
  50371. controllerOptions?: IWebXRControllerOptions;
  50372. }
  50373. /**
  50374. * XR input used to track XR inputs such as controllers/rays
  50375. */
  50376. export class WebXRInput implements IDisposable {
  50377. /**
  50378. * the xr session manager for this session
  50379. */
  50380. xrSessionManager: WebXRSessionManager;
  50381. /**
  50382. * the WebXR camera for this session. Mainly used for teleportation
  50383. */
  50384. xrCamera: WebXRCamera;
  50385. private readonly options;
  50386. /**
  50387. * XR controllers being tracked
  50388. */
  50389. controllers: Array<WebXRInputSource>;
  50390. private _frameObserver;
  50391. private _sessionEndedObserver;
  50392. private _sessionInitObserver;
  50393. /**
  50394. * Event when a controller has been connected/added
  50395. */
  50396. onControllerAddedObservable: Observable<WebXRInputSource>;
  50397. /**
  50398. * Event when a controller has been removed/disconnected
  50399. */
  50400. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50401. /**
  50402. * Initializes the WebXRInput
  50403. * @param xrSessionManager the xr session manager for this session
  50404. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50405. * @param options = initialization options for this xr input
  50406. */
  50407. constructor(
  50408. /**
  50409. * the xr session manager for this session
  50410. */
  50411. xrSessionManager: WebXRSessionManager,
  50412. /**
  50413. * the WebXR camera for this session. Mainly used for teleportation
  50414. */
  50415. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50416. private _onInputSourcesChange;
  50417. private _addAndRemoveControllers;
  50418. /**
  50419. * Disposes of the object
  50420. */
  50421. dispose(): void;
  50422. }
  50423. }
  50424. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50425. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50426. import { Observable, EventState } from "babylonjs/Misc/observable";
  50427. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50428. /**
  50429. * This is the base class for all WebXR features.
  50430. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50431. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50432. */
  50433. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50434. protected _xrSessionManager: WebXRSessionManager;
  50435. private _attached;
  50436. private _removeOnDetach;
  50437. /**
  50438. * Should auto-attach be disabled?
  50439. */
  50440. disableAutoAttach: boolean;
  50441. /**
  50442. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50443. */
  50444. xrNativeFeatureName: string;
  50445. /**
  50446. * Construct a new (abstract) WebXR feature
  50447. * @param _xrSessionManager the xr session manager for this feature
  50448. */
  50449. constructor(_xrSessionManager: WebXRSessionManager);
  50450. /**
  50451. * Is this feature attached
  50452. */
  50453. get attached(): boolean;
  50454. /**
  50455. * attach this feature
  50456. *
  50457. * @param force should attachment be forced (even when already attached)
  50458. * @returns true if successful, false is failed or already attached
  50459. */
  50460. attach(force?: boolean): boolean;
  50461. /**
  50462. * detach this feature.
  50463. *
  50464. * @returns true if successful, false if failed or already detached
  50465. */
  50466. detach(): boolean;
  50467. /**
  50468. * Dispose this feature and all of the resources attached
  50469. */
  50470. dispose(): void;
  50471. /**
  50472. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50473. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50474. *
  50475. * @returns whether or not the feature is compatible in this environment
  50476. */
  50477. isCompatible(): boolean;
  50478. /**
  50479. * This is used to register callbacks that will automatically be removed when detach is called.
  50480. * @param observable the observable to which the observer will be attached
  50481. * @param callback the callback to register
  50482. */
  50483. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50484. /**
  50485. * Code in this function will be executed on each xrFrame received from the browser.
  50486. * This function will not execute after the feature is detached.
  50487. * @param _xrFrame the current frame
  50488. */
  50489. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50490. }
  50491. }
  50492. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50493. import { IDisposable, Scene } from "babylonjs/scene";
  50494. import { Nullable } from "babylonjs/types";
  50495. import { Observable } from "babylonjs/Misc/observable";
  50496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50497. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50498. import { Camera } from "babylonjs/Cameras/camera";
  50499. /**
  50500. * Renders a layer on top of an existing scene
  50501. */
  50502. export class UtilityLayerRenderer implements IDisposable {
  50503. /** the original scene that will be rendered on top of */
  50504. originalScene: Scene;
  50505. private _pointerCaptures;
  50506. private _lastPointerEvents;
  50507. private static _DefaultUtilityLayer;
  50508. private static _DefaultKeepDepthUtilityLayer;
  50509. private _sharedGizmoLight;
  50510. private _renderCamera;
  50511. /**
  50512. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50513. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50514. * @returns the camera that is used when rendering the utility layer
  50515. */
  50516. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50517. /**
  50518. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50519. * @param cam the camera that should be used when rendering the utility layer
  50520. */
  50521. setRenderCamera(cam: Nullable<Camera>): void;
  50522. /**
  50523. * @hidden
  50524. * Light which used by gizmos to get light shading
  50525. */
  50526. _getSharedGizmoLight(): HemisphericLight;
  50527. /**
  50528. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50529. */
  50530. pickUtilitySceneFirst: boolean;
  50531. /**
  50532. * 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)
  50533. */
  50534. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50535. /**
  50536. * 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)
  50537. */
  50538. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50539. /**
  50540. * The scene that is rendered on top of the original scene
  50541. */
  50542. utilityLayerScene: Scene;
  50543. /**
  50544. * If the utility layer should automatically be rendered on top of existing scene
  50545. */
  50546. shouldRender: boolean;
  50547. /**
  50548. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50549. */
  50550. onlyCheckPointerDownEvents: boolean;
  50551. /**
  50552. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50553. */
  50554. processAllEvents: boolean;
  50555. /**
  50556. * Observable raised when the pointer move from the utility layer scene to the main scene
  50557. */
  50558. onPointerOutObservable: Observable<number>;
  50559. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50560. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50561. private _afterRenderObserver;
  50562. private _sceneDisposeObserver;
  50563. private _originalPointerObserver;
  50564. /**
  50565. * Instantiates a UtilityLayerRenderer
  50566. * @param originalScene the original scene that will be rendered on top of
  50567. * @param handleEvents boolean indicating if the utility layer should handle events
  50568. */
  50569. constructor(
  50570. /** the original scene that will be rendered on top of */
  50571. originalScene: Scene, handleEvents?: boolean);
  50572. private _notifyObservers;
  50573. /**
  50574. * Renders the utility layers scene on top of the original scene
  50575. */
  50576. render(): void;
  50577. /**
  50578. * Disposes of the renderer
  50579. */
  50580. dispose(): void;
  50581. private _updateCamera;
  50582. }
  50583. }
  50584. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50585. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50587. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50588. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50589. import { Scene } from "babylonjs/scene";
  50590. import { Nullable } from "babylonjs/types";
  50591. import { Color3 } from "babylonjs/Maths/math.color";
  50592. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50593. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50594. /**
  50595. * Options interface for the pointer selection module
  50596. */
  50597. export interface IWebXRControllerPointerSelectionOptions {
  50598. /**
  50599. * if provided, this scene will be used to render meshes.
  50600. */
  50601. customUtilityLayerScene?: Scene;
  50602. /**
  50603. * 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)
  50604. * If not disabled, the last picked point will be used to execute a pointer up event
  50605. * If disabled, pointer up event will be triggered right after the pointer down event.
  50606. * Used in screen and gaze target ray mode only
  50607. */
  50608. disablePointerUpOnTouchOut: boolean;
  50609. /**
  50610. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50611. */
  50612. forceGazeMode: boolean;
  50613. /**
  50614. * 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
  50615. * to start a new countdown to the pointer down event.
  50616. * Defaults to 1.
  50617. */
  50618. gazeModePointerMovedFactor?: number;
  50619. /**
  50620. * Different button type to use instead of the main component
  50621. */
  50622. overrideButtonId?: string;
  50623. /**
  50624. * use this rendering group id for the meshes (optional)
  50625. */
  50626. renderingGroupId?: number;
  50627. /**
  50628. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50629. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50630. * 3000 means 3 seconds between pointing at something and selecting it
  50631. */
  50632. timeToSelect?: number;
  50633. /**
  50634. * Should meshes created here be added to a utility layer or the main scene
  50635. */
  50636. useUtilityLayer?: boolean;
  50637. /**
  50638. * Optional WebXR camera to be used for gaze selection
  50639. */
  50640. gazeCamera?: WebXRCamera;
  50641. /**
  50642. * the xr input to use with this pointer selection
  50643. */
  50644. xrInput: WebXRInput;
  50645. }
  50646. /**
  50647. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50648. */
  50649. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50650. private readonly _options;
  50651. private static _idCounter;
  50652. private _attachController;
  50653. private _controllers;
  50654. private _scene;
  50655. private _tmpVectorForPickCompare;
  50656. /**
  50657. * The module's name
  50658. */
  50659. static readonly Name: string;
  50660. /**
  50661. * The (Babylon) version of this module.
  50662. * This is an integer representing the implementation version.
  50663. * This number does not correspond to the WebXR specs version
  50664. */
  50665. static readonly Version: number;
  50666. /**
  50667. * Disable lighting on the laser pointer (so it will always be visible)
  50668. */
  50669. disablePointerLighting: boolean;
  50670. /**
  50671. * Disable lighting on the selection mesh (so it will always be visible)
  50672. */
  50673. disableSelectionMeshLighting: boolean;
  50674. /**
  50675. * Should the laser pointer be displayed
  50676. */
  50677. displayLaserPointer: boolean;
  50678. /**
  50679. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50680. */
  50681. displaySelectionMesh: boolean;
  50682. /**
  50683. * This color will be set to the laser pointer when selection is triggered
  50684. */
  50685. laserPointerPickedColor: Color3;
  50686. /**
  50687. * Default color of the laser pointer
  50688. */
  50689. laserPointerDefaultColor: Color3;
  50690. /**
  50691. * default color of the selection ring
  50692. */
  50693. selectionMeshDefaultColor: Color3;
  50694. /**
  50695. * This color will be applied to the selection ring when selection is triggered
  50696. */
  50697. selectionMeshPickedColor: Color3;
  50698. /**
  50699. * Optional filter to be used for ray selection. This predicate shares behavior with
  50700. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50701. */
  50702. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50703. /**
  50704. * constructs a new background remover module
  50705. * @param _xrSessionManager the session manager for this module
  50706. * @param _options read-only options to be used in this module
  50707. */
  50708. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50709. /**
  50710. * attach this feature
  50711. * Will usually be called by the features manager
  50712. *
  50713. * @returns true if successful.
  50714. */
  50715. attach(): boolean;
  50716. /**
  50717. * detach this feature.
  50718. * Will usually be called by the features manager
  50719. *
  50720. * @returns true if successful.
  50721. */
  50722. detach(): boolean;
  50723. /**
  50724. * Will get the mesh under a specific pointer.
  50725. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50726. * @param controllerId the controllerId to check
  50727. * @returns The mesh under pointer or null if no mesh is under the pointer
  50728. */
  50729. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50730. /**
  50731. * Get the xr controller that correlates to the pointer id in the pointer event
  50732. *
  50733. * @param id the pointer id to search for
  50734. * @returns the controller that correlates to this id or null if not found
  50735. */
  50736. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50737. protected _onXRFrame(_xrFrame: XRFrame): void;
  50738. private _attachGazeMode;
  50739. private _attachScreenRayMode;
  50740. private _attachTrackedPointerRayMode;
  50741. private _convertNormalToDirectionOfRay;
  50742. private _detachController;
  50743. private _generateNewMeshPair;
  50744. private _pickingMoved;
  50745. private _updatePointerDistance;
  50746. /** @hidden */
  50747. get lasterPointerDefaultColor(): Color3;
  50748. }
  50749. }
  50750. declare module "babylonjs/XR/webXREnterExitUI" {
  50751. import { Nullable } from "babylonjs/types";
  50752. import { Observable } from "babylonjs/Misc/observable";
  50753. import { IDisposable, Scene } from "babylonjs/scene";
  50754. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50755. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50756. /**
  50757. * Button which can be used to enter a different mode of XR
  50758. */
  50759. export class WebXREnterExitUIButton {
  50760. /** button element */
  50761. element: HTMLElement;
  50762. /** XR initialization options for the button */
  50763. sessionMode: XRSessionMode;
  50764. /** Reference space type */
  50765. referenceSpaceType: XRReferenceSpaceType;
  50766. /**
  50767. * Creates a WebXREnterExitUIButton
  50768. * @param element button element
  50769. * @param sessionMode XR initialization session mode
  50770. * @param referenceSpaceType the type of reference space to be used
  50771. */
  50772. constructor(
  50773. /** button element */
  50774. element: HTMLElement,
  50775. /** XR initialization options for the button */
  50776. sessionMode: XRSessionMode,
  50777. /** Reference space type */
  50778. referenceSpaceType: XRReferenceSpaceType);
  50779. /**
  50780. * Extendable function which can be used to update the button's visuals when the state changes
  50781. * @param activeButton the current active button in the UI
  50782. */
  50783. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50784. }
  50785. /**
  50786. * Options to create the webXR UI
  50787. */
  50788. export class WebXREnterExitUIOptions {
  50789. /**
  50790. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50791. */
  50792. customButtons?: Array<WebXREnterExitUIButton>;
  50793. /**
  50794. * A reference space type to use when creating the default button.
  50795. * Default is local-floor
  50796. */
  50797. referenceSpaceType?: XRReferenceSpaceType;
  50798. /**
  50799. * Context to enter xr with
  50800. */
  50801. renderTarget?: Nullable<WebXRRenderTarget>;
  50802. /**
  50803. * A session mode to use when creating the default button.
  50804. * Default is immersive-vr
  50805. */
  50806. sessionMode?: XRSessionMode;
  50807. /**
  50808. * A list of optional features to init the session with
  50809. */
  50810. optionalFeatures?: string[];
  50811. /**
  50812. * A list of optional features to init the session with
  50813. */
  50814. requiredFeatures?: string[];
  50815. }
  50816. /**
  50817. * UI to allow the user to enter/exit XR mode
  50818. */
  50819. export class WebXREnterExitUI implements IDisposable {
  50820. private scene;
  50821. /** version of the options passed to this UI */
  50822. options: WebXREnterExitUIOptions;
  50823. private _activeButton;
  50824. private _buttons;
  50825. private _overlay;
  50826. /**
  50827. * Fired every time the active button is changed.
  50828. *
  50829. * When xr is entered via a button that launches xr that button will be the callback parameter
  50830. *
  50831. * When exiting xr the callback parameter will be null)
  50832. */
  50833. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50834. /**
  50835. *
  50836. * @param scene babylon scene object to use
  50837. * @param options (read-only) version of the options passed to this UI
  50838. */
  50839. private constructor();
  50840. /**
  50841. * Creates UI to allow the user to enter/exit XR mode
  50842. * @param scene the scene to add the ui to
  50843. * @param helper the xr experience helper to enter/exit xr with
  50844. * @param options options to configure the UI
  50845. * @returns the created ui
  50846. */
  50847. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50848. /**
  50849. * Disposes of the XR UI component
  50850. */
  50851. dispose(): void;
  50852. private _updateButtons;
  50853. }
  50854. }
  50855. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50856. import { Vector3 } from "babylonjs/Maths/math.vector";
  50857. import { Color4 } from "babylonjs/Maths/math.color";
  50858. import { Nullable } from "babylonjs/types";
  50859. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50860. import { Scene } from "babylonjs/scene";
  50861. /**
  50862. * Class containing static functions to help procedurally build meshes
  50863. */
  50864. export class LinesBuilder {
  50865. /**
  50866. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50867. * * 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
  50868. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50869. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50870. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50871. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50872. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50873. * * 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
  50874. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50877. * @param name defines the name of the new line system
  50878. * @param options defines the options used to create the line system
  50879. * @param scene defines the hosting scene
  50880. * @returns a new line system mesh
  50881. */
  50882. static CreateLineSystem(name: string, options: {
  50883. lines: Vector3[][];
  50884. updatable?: boolean;
  50885. instance?: Nullable<LinesMesh>;
  50886. colors?: Nullable<Color4[][]>;
  50887. useVertexAlpha?: boolean;
  50888. }, scene: Nullable<Scene>): LinesMesh;
  50889. /**
  50890. * Creates a line mesh
  50891. * 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
  50892. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50893. * * The parameter `points` is an array successive Vector3
  50894. * * 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
  50895. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50896. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50897. * * When updating an instance, remember that only point positions can change, not the number of points
  50898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50900. * @param name defines the name of the new line system
  50901. * @param options defines the options used to create the line system
  50902. * @param scene defines the hosting scene
  50903. * @returns a new line mesh
  50904. */
  50905. static CreateLines(name: string, options: {
  50906. points: Vector3[];
  50907. updatable?: boolean;
  50908. instance?: Nullable<LinesMesh>;
  50909. colors?: Color4[];
  50910. useVertexAlpha?: boolean;
  50911. }, scene?: Nullable<Scene>): LinesMesh;
  50912. /**
  50913. * Creates a dashed line mesh
  50914. * * 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
  50915. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50916. * * The parameter `points` is an array successive Vector3
  50917. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50918. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50919. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50920. * * 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
  50921. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50922. * * When updating an instance, remember that only point positions can change, not the number of points
  50923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50924. * @param name defines the name of the mesh
  50925. * @param options defines the options used to create the mesh
  50926. * @param scene defines the hosting scene
  50927. * @returns the dashed line mesh
  50928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50929. */
  50930. static CreateDashedLines(name: string, options: {
  50931. points: Vector3[];
  50932. dashSize?: number;
  50933. gapSize?: number;
  50934. dashNb?: number;
  50935. updatable?: boolean;
  50936. instance?: LinesMesh;
  50937. useVertexAlpha?: boolean;
  50938. }, scene?: Nullable<Scene>): LinesMesh;
  50939. }
  50940. }
  50941. declare module "babylonjs/Misc/timer" {
  50942. import { Observable, Observer } from "babylonjs/Misc/observable";
  50943. import { Nullable } from "babylonjs/types";
  50944. import { IDisposable } from "babylonjs/scene";
  50945. /**
  50946. * Construction options for a timer
  50947. */
  50948. export interface ITimerOptions<T> {
  50949. /**
  50950. * Time-to-end
  50951. */
  50952. timeout: number;
  50953. /**
  50954. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50955. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50956. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50957. */
  50958. contextObservable: Observable<T>;
  50959. /**
  50960. * Optional parameters when adding an observer to the observable
  50961. */
  50962. observableParameters?: {
  50963. mask?: number;
  50964. insertFirst?: boolean;
  50965. scope?: any;
  50966. };
  50967. /**
  50968. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50969. */
  50970. breakCondition?: (data?: ITimerData<T>) => boolean;
  50971. /**
  50972. * Will be triggered when the time condition has met
  50973. */
  50974. onEnded?: (data: ITimerData<any>) => void;
  50975. /**
  50976. * Will be triggered when the break condition has met (prematurely ended)
  50977. */
  50978. onAborted?: (data: ITimerData<any>) => void;
  50979. /**
  50980. * Optional function to execute on each tick (or count)
  50981. */
  50982. onTick?: (data: ITimerData<any>) => void;
  50983. }
  50984. /**
  50985. * An interface defining the data sent by the timer
  50986. */
  50987. export interface ITimerData<T> {
  50988. /**
  50989. * When did it start
  50990. */
  50991. startTime: number;
  50992. /**
  50993. * Time now
  50994. */
  50995. currentTime: number;
  50996. /**
  50997. * Time passed since started
  50998. */
  50999. deltaTime: number;
  51000. /**
  51001. * How much is completed, in [0.0...1.0].
  51002. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51003. */
  51004. completeRate: number;
  51005. /**
  51006. * What the registered observable sent in the last count
  51007. */
  51008. payload: T;
  51009. }
  51010. /**
  51011. * The current state of the timer
  51012. */
  51013. export enum TimerState {
  51014. /**
  51015. * Timer initialized, not yet started
  51016. */
  51017. INIT = 0,
  51018. /**
  51019. * Timer started and counting
  51020. */
  51021. STARTED = 1,
  51022. /**
  51023. * Timer ended (whether aborted or time reached)
  51024. */
  51025. ENDED = 2
  51026. }
  51027. /**
  51028. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51029. *
  51030. * @param options options with which to initialize this timer
  51031. */
  51032. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51033. /**
  51034. * An advanced implementation of a timer class
  51035. */
  51036. export class AdvancedTimer<T = any> implements IDisposable {
  51037. /**
  51038. * Will notify each time the timer calculates the remaining time
  51039. */
  51040. onEachCountObservable: Observable<ITimerData<T>>;
  51041. /**
  51042. * Will trigger when the timer was aborted due to the break condition
  51043. */
  51044. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51045. /**
  51046. * Will trigger when the timer ended successfully
  51047. */
  51048. onTimerEndedObservable: Observable<ITimerData<T>>;
  51049. /**
  51050. * Will trigger when the timer state has changed
  51051. */
  51052. onStateChangedObservable: Observable<TimerState>;
  51053. private _observer;
  51054. private _contextObservable;
  51055. private _observableParameters;
  51056. private _startTime;
  51057. private _timer;
  51058. private _state;
  51059. private _breakCondition;
  51060. private _timeToEnd;
  51061. private _breakOnNextTick;
  51062. /**
  51063. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51064. * @param options construction options for this advanced timer
  51065. */
  51066. constructor(options: ITimerOptions<T>);
  51067. /**
  51068. * set a breaking condition for this timer. Default is to never break during count
  51069. * @param predicate the new break condition. Returns true to break, false otherwise
  51070. */
  51071. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51072. /**
  51073. * Reset ALL associated observables in this advanced timer
  51074. */
  51075. clearObservables(): void;
  51076. /**
  51077. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51078. *
  51079. * @param timeToEnd how much time to measure until timer ended
  51080. */
  51081. start(timeToEnd?: number): void;
  51082. /**
  51083. * Will force a stop on the next tick.
  51084. */
  51085. stop(): void;
  51086. /**
  51087. * Dispose this timer, clearing all resources
  51088. */
  51089. dispose(): void;
  51090. private _setState;
  51091. private _tick;
  51092. private _stop;
  51093. }
  51094. }
  51095. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51096. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51097. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51098. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51100. import { Vector3 } from "babylonjs/Maths/math.vector";
  51101. import { Material } from "babylonjs/Materials/material";
  51102. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51103. import { Scene } from "babylonjs/scene";
  51104. /**
  51105. * The options container for the teleportation module
  51106. */
  51107. export interface IWebXRTeleportationOptions {
  51108. /**
  51109. * if provided, this scene will be used to render meshes.
  51110. */
  51111. customUtilityLayerScene?: Scene;
  51112. /**
  51113. * Values to configure the default target mesh
  51114. */
  51115. defaultTargetMeshOptions?: {
  51116. /**
  51117. * Fill color of the teleportation area
  51118. */
  51119. teleportationFillColor?: string;
  51120. /**
  51121. * Border color for the teleportation area
  51122. */
  51123. teleportationBorderColor?: string;
  51124. /**
  51125. * Disable the mesh's animation sequence
  51126. */
  51127. disableAnimation?: boolean;
  51128. /**
  51129. * Disable lighting on the material or the ring and arrow
  51130. */
  51131. disableLighting?: boolean;
  51132. /**
  51133. * Override the default material of the torus and arrow
  51134. */
  51135. torusArrowMaterial?: Material;
  51136. };
  51137. /**
  51138. * A list of meshes to use as floor meshes.
  51139. * Meshes can be added and removed after initializing the feature using the
  51140. * addFloorMesh and removeFloorMesh functions
  51141. * If empty, rotation will still work
  51142. */
  51143. floorMeshes?: AbstractMesh[];
  51144. /**
  51145. * use this rendering group id for the meshes (optional)
  51146. */
  51147. renderingGroupId?: number;
  51148. /**
  51149. * Should teleportation move only to snap points
  51150. */
  51151. snapPointsOnly?: boolean;
  51152. /**
  51153. * An array of points to which the teleportation will snap to.
  51154. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51155. */
  51156. snapPositions?: Vector3[];
  51157. /**
  51158. * How close should the teleportation ray be in order to snap to position.
  51159. * Default to 0.8 units (meters)
  51160. */
  51161. snapToPositionRadius?: number;
  51162. /**
  51163. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51164. * If you want to support rotation, make sure your mesh has a direction indicator.
  51165. *
  51166. * When left untouched, the default mesh will be initialized.
  51167. */
  51168. teleportationTargetMesh?: AbstractMesh;
  51169. /**
  51170. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51171. */
  51172. timeToTeleport?: number;
  51173. /**
  51174. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51175. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51176. */
  51177. useMainComponentOnly?: boolean;
  51178. /**
  51179. * Should meshes created here be added to a utility layer or the main scene
  51180. */
  51181. useUtilityLayer?: boolean;
  51182. /**
  51183. * Babylon XR Input class for controller
  51184. */
  51185. xrInput: WebXRInput;
  51186. }
  51187. /**
  51188. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51189. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51190. * the input of the attached controllers.
  51191. */
  51192. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51193. private _options;
  51194. private _controllers;
  51195. private _currentTeleportationControllerId;
  51196. private _floorMeshes;
  51197. private _quadraticBezierCurve;
  51198. private _selectionFeature;
  51199. private _snapToPositions;
  51200. private _snappedToPoint;
  51201. private _teleportationRingMaterial?;
  51202. private _tmpRay;
  51203. private _tmpVector;
  51204. /**
  51205. * The module's name
  51206. */
  51207. static readonly Name: string;
  51208. /**
  51209. * The (Babylon) version of this module.
  51210. * This is an integer representing the implementation version.
  51211. * This number does not correspond to the webxr specs version
  51212. */
  51213. static readonly Version: number;
  51214. /**
  51215. * Is movement backwards enabled
  51216. */
  51217. backwardsMovementEnabled: boolean;
  51218. /**
  51219. * Distance to travel when moving backwards
  51220. */
  51221. backwardsTeleportationDistance: number;
  51222. /**
  51223. * The distance from the user to the inspection point in the direction of the controller
  51224. * A higher number will allow the user to move further
  51225. * defaults to 5 (meters, in xr units)
  51226. */
  51227. parabolicCheckRadius: number;
  51228. /**
  51229. * Should the module support parabolic ray on top of direct ray
  51230. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51231. * Very helpful when moving between floors / different heights
  51232. */
  51233. parabolicRayEnabled: boolean;
  51234. /**
  51235. * How much rotation should be applied when rotating right and left
  51236. */
  51237. rotationAngle: number;
  51238. /**
  51239. * Is rotation enabled when moving forward?
  51240. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51241. */
  51242. rotationEnabled: boolean;
  51243. /**
  51244. * constructs a new anchor system
  51245. * @param _xrSessionManager an instance of WebXRSessionManager
  51246. * @param _options configuration object for this feature
  51247. */
  51248. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51249. /**
  51250. * Get the snapPointsOnly flag
  51251. */
  51252. get snapPointsOnly(): boolean;
  51253. /**
  51254. * Sets the snapPointsOnly flag
  51255. * @param snapToPoints should teleportation be exclusively to snap points
  51256. */
  51257. set snapPointsOnly(snapToPoints: boolean);
  51258. /**
  51259. * Add a new mesh to the floor meshes array
  51260. * @param mesh the mesh to use as floor mesh
  51261. */
  51262. addFloorMesh(mesh: AbstractMesh): void;
  51263. /**
  51264. * Add a new snap-to point to fix teleportation to this position
  51265. * @param newSnapPoint The new Snap-To point
  51266. */
  51267. addSnapPoint(newSnapPoint: Vector3): void;
  51268. attach(): boolean;
  51269. detach(): boolean;
  51270. dispose(): void;
  51271. /**
  51272. * Remove a mesh from the floor meshes array
  51273. * @param mesh the mesh to remove
  51274. */
  51275. removeFloorMesh(mesh: AbstractMesh): void;
  51276. /**
  51277. * Remove a mesh from the floor meshes array using its name
  51278. * @param name the mesh name to remove
  51279. */
  51280. removeFloorMeshByName(name: string): void;
  51281. /**
  51282. * 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
  51283. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51284. * @returns was the point found and removed or not
  51285. */
  51286. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51287. /**
  51288. * This function sets a selection feature that will be disabled when
  51289. * the forward ray is shown and will be reattached when hidden.
  51290. * This is used to remove the selection rays when moving.
  51291. * @param selectionFeature the feature to disable when forward movement is enabled
  51292. */
  51293. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51294. protected _onXRFrame(_xrFrame: XRFrame): void;
  51295. private _attachController;
  51296. private _createDefaultTargetMesh;
  51297. private _detachController;
  51298. private _findClosestSnapPointWithRadius;
  51299. private _setTargetMeshPosition;
  51300. private _setTargetMeshVisibility;
  51301. private _showParabolicPath;
  51302. private _teleportForward;
  51303. }
  51304. }
  51305. declare module "babylonjs/XR/webXRDefaultExperience" {
  51306. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51307. import { Scene } from "babylonjs/scene";
  51308. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51309. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51310. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51311. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51313. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51314. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51315. /**
  51316. * Options for the default xr helper
  51317. */
  51318. export class WebXRDefaultExperienceOptions {
  51319. /**
  51320. * Enable or disable default UI to enter XR
  51321. */
  51322. disableDefaultUI?: boolean;
  51323. /**
  51324. * Should teleportation not initialize. defaults to false.
  51325. */
  51326. disableTeleportation?: boolean;
  51327. /**
  51328. * Floor meshes that will be used for teleport
  51329. */
  51330. floorMeshes?: Array<AbstractMesh>;
  51331. /**
  51332. * If set to true, the first frame will not be used to reset position
  51333. * The first frame is mainly used when copying transformation from the old camera
  51334. * Mainly used in AR
  51335. */
  51336. ignoreNativeCameraTransformation?: boolean;
  51337. /**
  51338. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51339. */
  51340. inputOptions?: IWebXRInputOptions;
  51341. /**
  51342. * optional configuration for the output canvas
  51343. */
  51344. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51345. /**
  51346. * optional UI options. This can be used among other to change session mode and reference space type
  51347. */
  51348. uiOptions?: WebXREnterExitUIOptions;
  51349. /**
  51350. * When loading teleportation and pointer select, use stable versions instead of latest.
  51351. */
  51352. useStablePlugins?: boolean;
  51353. /**
  51354. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51355. */
  51356. renderingGroupId?: number;
  51357. /**
  51358. * A list of optional features to init the session with
  51359. * If set to true, all features we support will be added
  51360. */
  51361. optionalFeatures?: boolean | string[];
  51362. }
  51363. /**
  51364. * Default experience which provides a similar setup to the previous webVRExperience
  51365. */
  51366. export class WebXRDefaultExperience {
  51367. /**
  51368. * Base experience
  51369. */
  51370. baseExperience: WebXRExperienceHelper;
  51371. /**
  51372. * Enables ui for entering/exiting xr
  51373. */
  51374. enterExitUI: WebXREnterExitUI;
  51375. /**
  51376. * Input experience extension
  51377. */
  51378. input: WebXRInput;
  51379. /**
  51380. * Enables laser pointer and selection
  51381. */
  51382. pointerSelection: WebXRControllerPointerSelection;
  51383. /**
  51384. * Default target xr should render to
  51385. */
  51386. renderTarget: WebXRRenderTarget;
  51387. /**
  51388. * Enables teleportation
  51389. */
  51390. teleportation: WebXRMotionControllerTeleportation;
  51391. private constructor();
  51392. /**
  51393. * Creates the default xr experience
  51394. * @param scene scene
  51395. * @param options options for basic configuration
  51396. * @returns resulting WebXRDefaultExperience
  51397. */
  51398. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51399. /**
  51400. * DIsposes of the experience helper
  51401. */
  51402. dispose(): void;
  51403. }
  51404. }
  51405. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51406. import { Observable } from "babylonjs/Misc/observable";
  51407. import { Nullable } from "babylonjs/types";
  51408. import { Camera } from "babylonjs/Cameras/camera";
  51409. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51410. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51411. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51412. import { Scene } from "babylonjs/scene";
  51413. import { Vector3 } from "babylonjs/Maths/math.vector";
  51414. import { Color3 } from "babylonjs/Maths/math.color";
  51415. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51417. import { Mesh } from "babylonjs/Meshes/mesh";
  51418. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51419. import { EasingFunction } from "babylonjs/Animations/easing";
  51420. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51421. import "babylonjs/Meshes/Builders/groundBuilder";
  51422. import "babylonjs/Meshes/Builders/torusBuilder";
  51423. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51424. import "babylonjs/Gamepads/gamepadSceneComponent";
  51425. import "babylonjs/Animations/animatable";
  51426. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51427. /**
  51428. * Options to modify the vr teleportation behavior.
  51429. */
  51430. export interface VRTeleportationOptions {
  51431. /**
  51432. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51433. */
  51434. floorMeshName?: string;
  51435. /**
  51436. * A list of meshes to be used as the teleportation floor. (default: empty)
  51437. */
  51438. floorMeshes?: Mesh[];
  51439. /**
  51440. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51441. */
  51442. teleportationMode?: number;
  51443. /**
  51444. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51445. */
  51446. teleportationTime?: number;
  51447. /**
  51448. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51449. */
  51450. teleportationSpeed?: number;
  51451. /**
  51452. * The easing function used in the animation or null for Linear. (default CircleEase)
  51453. */
  51454. easingFunction?: EasingFunction;
  51455. }
  51456. /**
  51457. * Options to modify the vr experience helper's behavior.
  51458. */
  51459. export interface VRExperienceHelperOptions extends WebVROptions {
  51460. /**
  51461. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51462. */
  51463. createDeviceOrientationCamera?: boolean;
  51464. /**
  51465. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51466. */
  51467. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51468. /**
  51469. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51470. */
  51471. laserToggle?: boolean;
  51472. /**
  51473. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51474. */
  51475. floorMeshes?: Mesh[];
  51476. /**
  51477. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51478. */
  51479. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51480. /**
  51481. * Defines if WebXR should be used instead of WebVR (if available)
  51482. */
  51483. useXR?: boolean;
  51484. }
  51485. /**
  51486. * Event containing information after VR has been entered
  51487. */
  51488. export class OnAfterEnteringVRObservableEvent {
  51489. /**
  51490. * If entering vr was successful
  51491. */
  51492. success: boolean;
  51493. }
  51494. /**
  51495. * Helps to quickly add VR support to an existing scene.
  51496. * See https://doc.babylonjs.com/how_to/webvr_helper
  51497. */
  51498. export class VRExperienceHelper {
  51499. /** Options to modify the vr experience helper's behavior. */
  51500. webVROptions: VRExperienceHelperOptions;
  51501. private _scene;
  51502. private _position;
  51503. private _btnVR;
  51504. private _btnVRDisplayed;
  51505. private _webVRsupported;
  51506. private _webVRready;
  51507. private _webVRrequesting;
  51508. private _webVRpresenting;
  51509. private _hasEnteredVR;
  51510. private _fullscreenVRpresenting;
  51511. private _inputElement;
  51512. private _webVRCamera;
  51513. private _vrDeviceOrientationCamera;
  51514. private _deviceOrientationCamera;
  51515. private _existingCamera;
  51516. private _onKeyDown;
  51517. private _onVrDisplayPresentChange;
  51518. private _onVRDisplayChanged;
  51519. private _onVRRequestPresentStart;
  51520. private _onVRRequestPresentComplete;
  51521. /**
  51522. * 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)
  51523. */
  51524. enableGazeEvenWhenNoPointerLock: boolean;
  51525. /**
  51526. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51527. */
  51528. exitVROnDoubleTap: boolean;
  51529. /**
  51530. * Observable raised right before entering VR.
  51531. */
  51532. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51533. /**
  51534. * Observable raised when entering VR has completed.
  51535. */
  51536. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51537. /**
  51538. * Observable raised when exiting VR.
  51539. */
  51540. onExitingVRObservable: Observable<VRExperienceHelper>;
  51541. /**
  51542. * Observable raised when controller mesh is loaded.
  51543. */
  51544. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51545. /** Return this.onEnteringVRObservable
  51546. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51547. */
  51548. get onEnteringVR(): Observable<VRExperienceHelper>;
  51549. /** Return this.onExitingVRObservable
  51550. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51551. */
  51552. get onExitingVR(): Observable<VRExperienceHelper>;
  51553. /** Return this.onControllerMeshLoadedObservable
  51554. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51555. */
  51556. get onControllerMeshLoaded(): Observable<WebVRController>;
  51557. private _rayLength;
  51558. private _useCustomVRButton;
  51559. private _teleportationRequested;
  51560. private _teleportActive;
  51561. private _floorMeshName;
  51562. private _floorMeshesCollection;
  51563. private _teleportationMode;
  51564. private _teleportationTime;
  51565. private _teleportationSpeed;
  51566. private _teleportationEasing;
  51567. private _rotationAllowed;
  51568. private _teleportBackwardsVector;
  51569. private _teleportationTarget;
  51570. private _isDefaultTeleportationTarget;
  51571. private _postProcessMove;
  51572. private _teleportationFillColor;
  51573. private _teleportationBorderColor;
  51574. private _rotationAngle;
  51575. private _haloCenter;
  51576. private _cameraGazer;
  51577. private _padSensibilityUp;
  51578. private _padSensibilityDown;
  51579. private _leftController;
  51580. private _rightController;
  51581. private _gazeColor;
  51582. private _laserColor;
  51583. private _pickedLaserColor;
  51584. private _pickedGazeColor;
  51585. /**
  51586. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51587. */
  51588. onNewMeshSelected: Observable<AbstractMesh>;
  51589. /**
  51590. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51591. * This observable will provide the mesh and the controller used to select the mesh
  51592. */
  51593. onMeshSelectedWithController: Observable<{
  51594. mesh: AbstractMesh;
  51595. controller: WebVRController;
  51596. }>;
  51597. /**
  51598. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51599. */
  51600. onNewMeshPicked: Observable<PickingInfo>;
  51601. private _circleEase;
  51602. /**
  51603. * Observable raised before camera teleportation
  51604. */
  51605. onBeforeCameraTeleport: Observable<Vector3>;
  51606. /**
  51607. * Observable raised after camera teleportation
  51608. */
  51609. onAfterCameraTeleport: Observable<Vector3>;
  51610. /**
  51611. * Observable raised when current selected mesh gets unselected
  51612. */
  51613. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51614. private _raySelectionPredicate;
  51615. /**
  51616. * To be optionaly changed by user to define custom ray selection
  51617. */
  51618. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51619. /**
  51620. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51621. */
  51622. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51623. /**
  51624. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51625. */
  51626. teleportationEnabled: boolean;
  51627. private _defaultHeight;
  51628. private _teleportationInitialized;
  51629. private _interactionsEnabled;
  51630. private _interactionsRequested;
  51631. private _displayGaze;
  51632. private _displayLaserPointer;
  51633. /**
  51634. * The mesh used to display where the user is going to teleport.
  51635. */
  51636. get teleportationTarget(): Mesh;
  51637. /**
  51638. * Sets the mesh to be used to display where the user is going to teleport.
  51639. */
  51640. set teleportationTarget(value: Mesh);
  51641. /**
  51642. * 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
  51643. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51644. * See https://doc.babylonjs.com/resources/baking_transformations
  51645. */
  51646. get gazeTrackerMesh(): Mesh;
  51647. set gazeTrackerMesh(value: Mesh);
  51648. /**
  51649. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51650. */
  51651. updateGazeTrackerScale: boolean;
  51652. /**
  51653. * If the gaze trackers color should be updated when selecting meshes
  51654. */
  51655. updateGazeTrackerColor: boolean;
  51656. /**
  51657. * If the controller laser color should be updated when selecting meshes
  51658. */
  51659. updateControllerLaserColor: boolean;
  51660. /**
  51661. * The gaze tracking mesh corresponding to the left controller
  51662. */
  51663. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51664. /**
  51665. * The gaze tracking mesh corresponding to the right controller
  51666. */
  51667. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51668. /**
  51669. * If the ray of the gaze should be displayed.
  51670. */
  51671. get displayGaze(): boolean;
  51672. /**
  51673. * Sets if the ray of the gaze should be displayed.
  51674. */
  51675. set displayGaze(value: boolean);
  51676. /**
  51677. * If the ray of the LaserPointer should be displayed.
  51678. */
  51679. get displayLaserPointer(): boolean;
  51680. /**
  51681. * Sets if the ray of the LaserPointer should be displayed.
  51682. */
  51683. set displayLaserPointer(value: boolean);
  51684. /**
  51685. * The deviceOrientationCamera used as the camera when not in VR.
  51686. */
  51687. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51688. /**
  51689. * Based on the current WebVR support, returns the current VR camera used.
  51690. */
  51691. get currentVRCamera(): Nullable<Camera>;
  51692. /**
  51693. * The webVRCamera which is used when in VR.
  51694. */
  51695. get webVRCamera(): WebVRFreeCamera;
  51696. /**
  51697. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51698. */
  51699. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51700. /**
  51701. * The html button that is used to trigger entering into VR.
  51702. */
  51703. get vrButton(): Nullable<HTMLButtonElement>;
  51704. private get _teleportationRequestInitiated();
  51705. /**
  51706. * Defines whether or not Pointer lock should be requested when switching to
  51707. * full screen.
  51708. */
  51709. requestPointerLockOnFullScreen: boolean;
  51710. /**
  51711. * If asking to force XR, this will be populated with the default xr experience
  51712. */
  51713. xr: WebXRDefaultExperience;
  51714. /**
  51715. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51716. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51717. */
  51718. xrTestDone: boolean;
  51719. /**
  51720. * Instantiates a VRExperienceHelper.
  51721. * Helps to quickly add VR support to an existing scene.
  51722. * @param scene The scene the VRExperienceHelper belongs to.
  51723. * @param webVROptions Options to modify the vr experience helper's behavior.
  51724. */
  51725. constructor(scene: Scene,
  51726. /** Options to modify the vr experience helper's behavior. */
  51727. webVROptions?: VRExperienceHelperOptions);
  51728. private completeVRInit;
  51729. private _onDefaultMeshLoaded;
  51730. private _onResize;
  51731. private _onFullscreenChange;
  51732. /**
  51733. * Gets a value indicating if we are currently in VR mode.
  51734. */
  51735. get isInVRMode(): boolean;
  51736. private onVrDisplayPresentChange;
  51737. private onVRDisplayChanged;
  51738. private moveButtonToBottomRight;
  51739. private displayVRButton;
  51740. private updateButtonVisibility;
  51741. private _cachedAngularSensibility;
  51742. /**
  51743. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51744. * Otherwise, will use the fullscreen API.
  51745. */
  51746. enterVR(): void;
  51747. /**
  51748. * Attempt to exit VR, or fullscreen.
  51749. */
  51750. exitVR(): void;
  51751. /**
  51752. * The position of the vr experience helper.
  51753. */
  51754. get position(): Vector3;
  51755. /**
  51756. * Sets the position of the vr experience helper.
  51757. */
  51758. set position(value: Vector3);
  51759. /**
  51760. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51761. */
  51762. enableInteractions(): void;
  51763. private get _noControllerIsActive();
  51764. private beforeRender;
  51765. private _isTeleportationFloor;
  51766. /**
  51767. * Adds a floor mesh to be used for teleportation.
  51768. * @param floorMesh the mesh to be used for teleportation.
  51769. */
  51770. addFloorMesh(floorMesh: Mesh): void;
  51771. /**
  51772. * Removes a floor mesh from being used for teleportation.
  51773. * @param floorMesh the mesh to be removed.
  51774. */
  51775. removeFloorMesh(floorMesh: Mesh): void;
  51776. /**
  51777. * Enables interactions and teleportation using the VR controllers and gaze.
  51778. * @param vrTeleportationOptions options to modify teleportation behavior.
  51779. */
  51780. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51781. private _onNewGamepadConnected;
  51782. private _tryEnableInteractionOnController;
  51783. private _onNewGamepadDisconnected;
  51784. private _enableInteractionOnController;
  51785. private _checkTeleportWithRay;
  51786. private _checkRotate;
  51787. private _checkTeleportBackwards;
  51788. private _enableTeleportationOnController;
  51789. private _createTeleportationCircles;
  51790. private _displayTeleportationTarget;
  51791. private _hideTeleportationTarget;
  51792. private _rotateCamera;
  51793. private _moveTeleportationSelectorTo;
  51794. private _workingVector;
  51795. private _workingQuaternion;
  51796. private _workingMatrix;
  51797. /**
  51798. * Time Constant Teleportation Mode
  51799. */
  51800. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51801. /**
  51802. * Speed Constant Teleportation Mode
  51803. */
  51804. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51805. /**
  51806. * Teleports the users feet to the desired location
  51807. * @param location The location where the user's feet should be placed
  51808. */
  51809. teleportCamera(location: Vector3): void;
  51810. private _convertNormalToDirectionOfRay;
  51811. private _castRayAndSelectObject;
  51812. private _notifySelectedMeshUnselected;
  51813. /**
  51814. * Permanently set new colors for the laser pointer
  51815. * @param color the new laser color
  51816. * @param pickedColor the new laser color when picked mesh detected
  51817. */
  51818. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51819. /**
  51820. * Set lighting enabled / disabled on the laser pointer of both controllers
  51821. * @param enabled should the lighting be enabled on the laser pointer
  51822. */
  51823. setLaserLightingState(enabled?: boolean): void;
  51824. /**
  51825. * Permanently set new colors for the gaze pointer
  51826. * @param color the new gaze color
  51827. * @param pickedColor the new gaze color when picked mesh detected
  51828. */
  51829. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51830. /**
  51831. * Sets the color of the laser ray from the vr controllers.
  51832. * @param color new color for the ray.
  51833. */
  51834. changeLaserColor(color: Color3): void;
  51835. /**
  51836. * Sets the color of the ray from the vr headsets gaze.
  51837. * @param color new color for the ray.
  51838. */
  51839. changeGazeColor(color: Color3): void;
  51840. /**
  51841. * Exits VR and disposes of the vr experience helper
  51842. */
  51843. dispose(): void;
  51844. /**
  51845. * Gets the name of the VRExperienceHelper class
  51846. * @returns "VRExperienceHelper"
  51847. */
  51848. getClassName(): string;
  51849. }
  51850. }
  51851. declare module "babylonjs/Cameras/VR/index" {
  51852. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51853. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51854. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51855. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51856. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51857. export * from "babylonjs/Cameras/VR/webVRCamera";
  51858. }
  51859. declare module "babylonjs/Cameras/RigModes/index" {
  51860. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51861. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51862. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51863. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51864. }
  51865. declare module "babylonjs/Cameras/index" {
  51866. export * from "babylonjs/Cameras/Inputs/index";
  51867. export * from "babylonjs/Cameras/cameraInputsManager";
  51868. export * from "babylonjs/Cameras/camera";
  51869. export * from "babylonjs/Cameras/targetCamera";
  51870. export * from "babylonjs/Cameras/freeCamera";
  51871. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51872. export * from "babylonjs/Cameras/touchCamera";
  51873. export * from "babylonjs/Cameras/arcRotateCamera";
  51874. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51875. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51876. export * from "babylonjs/Cameras/flyCamera";
  51877. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51878. export * from "babylonjs/Cameras/followCamera";
  51879. export * from "babylonjs/Cameras/followCameraInputsManager";
  51880. export * from "babylonjs/Cameras/gamepadCamera";
  51881. export * from "babylonjs/Cameras/Stereoscopic/index";
  51882. export * from "babylonjs/Cameras/universalCamera";
  51883. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51884. export * from "babylonjs/Cameras/VR/index";
  51885. export * from "babylonjs/Cameras/RigModes/index";
  51886. }
  51887. declare module "babylonjs/Collisions/index" {
  51888. export * from "babylonjs/Collisions/collider";
  51889. export * from "babylonjs/Collisions/collisionCoordinator";
  51890. export * from "babylonjs/Collisions/pickingInfo";
  51891. export * from "babylonjs/Collisions/intersectionInfo";
  51892. export * from "babylonjs/Collisions/meshCollisionData";
  51893. }
  51894. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51895. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51896. import { Vector3 } from "babylonjs/Maths/math.vector";
  51897. import { Ray } from "babylonjs/Culling/ray";
  51898. import { Plane } from "babylonjs/Maths/math.plane";
  51899. /**
  51900. * Contains an array of blocks representing the octree
  51901. */
  51902. export interface IOctreeContainer<T> {
  51903. /**
  51904. * Blocks within the octree
  51905. */
  51906. blocks: Array<OctreeBlock<T>>;
  51907. }
  51908. /**
  51909. * Class used to store a cell in an octree
  51910. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51911. */
  51912. export class OctreeBlock<T> {
  51913. /**
  51914. * Gets the content of the current block
  51915. */
  51916. entries: T[];
  51917. /**
  51918. * Gets the list of block children
  51919. */
  51920. blocks: Array<OctreeBlock<T>>;
  51921. private _depth;
  51922. private _maxDepth;
  51923. private _capacity;
  51924. private _minPoint;
  51925. private _maxPoint;
  51926. private _boundingVectors;
  51927. private _creationFunc;
  51928. /**
  51929. * Creates a new block
  51930. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51931. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51932. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51933. * @param depth defines the current depth of this block in the octree
  51934. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51935. * @param creationFunc defines a callback to call when an element is added to the block
  51936. */
  51937. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51938. /**
  51939. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51940. */
  51941. get capacity(): number;
  51942. /**
  51943. * Gets the minimum vector (in world space) of the block's bounding box
  51944. */
  51945. get minPoint(): Vector3;
  51946. /**
  51947. * Gets the maximum vector (in world space) of the block's bounding box
  51948. */
  51949. get maxPoint(): Vector3;
  51950. /**
  51951. * Add a new element to this block
  51952. * @param entry defines the element to add
  51953. */
  51954. addEntry(entry: T): void;
  51955. /**
  51956. * Remove an element from this block
  51957. * @param entry defines the element to remove
  51958. */
  51959. removeEntry(entry: T): void;
  51960. /**
  51961. * Add an array of elements to this block
  51962. * @param entries defines the array of elements to add
  51963. */
  51964. addEntries(entries: T[]): void;
  51965. /**
  51966. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51967. * @param frustumPlanes defines the frustum planes to test
  51968. * @param selection defines the array to store current content if selection is positive
  51969. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51970. */
  51971. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51972. /**
  51973. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51974. * @param sphereCenter defines the bounding sphere center
  51975. * @param sphereRadius defines the bounding sphere radius
  51976. * @param selection defines the array to store current content if selection is positive
  51977. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51978. */
  51979. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51980. /**
  51981. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51982. * @param ray defines the ray to test with
  51983. * @param selection defines the array to store current content if selection is positive
  51984. */
  51985. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51986. /**
  51987. * Subdivide the content into child blocks (this block will then be empty)
  51988. */
  51989. createInnerBlocks(): void;
  51990. /**
  51991. * @hidden
  51992. */
  51993. 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;
  51994. }
  51995. }
  51996. declare module "babylonjs/Culling/Octrees/octree" {
  51997. import { SmartArray } from "babylonjs/Misc/smartArray";
  51998. import { Vector3 } from "babylonjs/Maths/math.vector";
  51999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52001. import { Ray } from "babylonjs/Culling/ray";
  52002. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52003. import { Plane } from "babylonjs/Maths/math.plane";
  52004. /**
  52005. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52006. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52007. */
  52008. export class Octree<T> {
  52009. /** 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.) */
  52010. maxDepth: number;
  52011. /**
  52012. * Blocks within the octree containing objects
  52013. */
  52014. blocks: Array<OctreeBlock<T>>;
  52015. /**
  52016. * Content stored in the octree
  52017. */
  52018. dynamicContent: T[];
  52019. private _maxBlockCapacity;
  52020. private _selectionContent;
  52021. private _creationFunc;
  52022. /**
  52023. * Creates a octree
  52024. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52025. * @param creationFunc function to be used to instatiate the octree
  52026. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52027. * @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.)
  52028. */
  52029. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52030. /** 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.) */
  52031. maxDepth?: number);
  52032. /**
  52033. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52034. * @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);
  52035. * @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);
  52036. * @param entries meshes to be added to the octree blocks
  52037. */
  52038. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52039. /**
  52040. * Adds a mesh to the octree
  52041. * @param entry Mesh to add to the octree
  52042. */
  52043. addMesh(entry: T): void;
  52044. /**
  52045. * Remove an element from the octree
  52046. * @param entry defines the element to remove
  52047. */
  52048. removeMesh(entry: T): void;
  52049. /**
  52050. * Selects an array of meshes within the frustum
  52051. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52052. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52053. * @returns array of meshes within the frustum
  52054. */
  52055. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52056. /**
  52057. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52058. * @param sphereCenter defines the bounding sphere center
  52059. * @param sphereRadius defines the bounding sphere radius
  52060. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52061. * @returns an array of objects that intersect the sphere
  52062. */
  52063. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52064. /**
  52065. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52066. * @param ray defines the ray to test with
  52067. * @returns array of intersected objects
  52068. */
  52069. intersectsRay(ray: Ray): SmartArray<T>;
  52070. /**
  52071. * Adds a mesh into the octree block if it intersects the block
  52072. */
  52073. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52074. /**
  52075. * Adds a submesh into the octree block if it intersects the block
  52076. */
  52077. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52078. }
  52079. }
  52080. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52081. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52082. import { Scene } from "babylonjs/scene";
  52083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52085. import { Ray } from "babylonjs/Culling/ray";
  52086. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52087. import { Collider } from "babylonjs/Collisions/collider";
  52088. module "babylonjs/scene" {
  52089. interface Scene {
  52090. /**
  52091. * @hidden
  52092. * Backing Filed
  52093. */
  52094. _selectionOctree: Octree<AbstractMesh>;
  52095. /**
  52096. * Gets the octree used to boost mesh selection (picking)
  52097. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52098. */
  52099. selectionOctree: Octree<AbstractMesh>;
  52100. /**
  52101. * Creates or updates the octree used to boost selection (picking)
  52102. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52103. * @param maxCapacity defines the maximum capacity per leaf
  52104. * @param maxDepth defines the maximum depth of the octree
  52105. * @returns an octree of AbstractMesh
  52106. */
  52107. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52108. }
  52109. }
  52110. module "babylonjs/Meshes/abstractMesh" {
  52111. interface AbstractMesh {
  52112. /**
  52113. * @hidden
  52114. * Backing Field
  52115. */
  52116. _submeshesOctree: Octree<SubMesh>;
  52117. /**
  52118. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52119. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52120. * @param maxCapacity defines the maximum size of each block (64 by default)
  52121. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52122. * @returns the new octree
  52123. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52124. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52125. */
  52126. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52127. }
  52128. }
  52129. /**
  52130. * Defines the octree scene component responsible to manage any octrees
  52131. * in a given scene.
  52132. */
  52133. export class OctreeSceneComponent {
  52134. /**
  52135. * The component name help to identify the component in the list of scene components.
  52136. */
  52137. readonly name: string;
  52138. /**
  52139. * The scene the component belongs to.
  52140. */
  52141. scene: Scene;
  52142. /**
  52143. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52144. */
  52145. readonly checksIsEnabled: boolean;
  52146. /**
  52147. * Creates a new instance of the component for the given scene
  52148. * @param scene Defines the scene to register the component in
  52149. */
  52150. constructor(scene: Scene);
  52151. /**
  52152. * Registers the component in a given scene
  52153. */
  52154. register(): void;
  52155. /**
  52156. * Return the list of active meshes
  52157. * @returns the list of active meshes
  52158. */
  52159. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52160. /**
  52161. * Return the list of active sub meshes
  52162. * @param mesh The mesh to get the candidates sub meshes from
  52163. * @returns the list of active sub meshes
  52164. */
  52165. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52166. private _tempRay;
  52167. /**
  52168. * Return the list of sub meshes intersecting with a given local ray
  52169. * @param mesh defines the mesh to find the submesh for
  52170. * @param localRay defines the ray in local space
  52171. * @returns the list of intersecting sub meshes
  52172. */
  52173. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52174. /**
  52175. * Return the list of sub meshes colliding with a collider
  52176. * @param mesh defines the mesh to find the submesh for
  52177. * @param collider defines the collider to evaluate the collision against
  52178. * @returns the list of colliding sub meshes
  52179. */
  52180. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52181. /**
  52182. * Rebuilds the elements related to this component in case of
  52183. * context lost for instance.
  52184. */
  52185. rebuild(): void;
  52186. /**
  52187. * Disposes the component and the associated ressources.
  52188. */
  52189. dispose(): void;
  52190. }
  52191. }
  52192. declare module "babylonjs/Culling/Octrees/index" {
  52193. export * from "babylonjs/Culling/Octrees/octree";
  52194. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52195. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52196. }
  52197. declare module "babylonjs/Culling/index" {
  52198. export * from "babylonjs/Culling/boundingBox";
  52199. export * from "babylonjs/Culling/boundingInfo";
  52200. export * from "babylonjs/Culling/boundingSphere";
  52201. export * from "babylonjs/Culling/Octrees/index";
  52202. export * from "babylonjs/Culling/ray";
  52203. }
  52204. declare module "babylonjs/Gizmos/gizmo" {
  52205. import { Nullable } from "babylonjs/types";
  52206. import { IDisposable } from "babylonjs/scene";
  52207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52208. import { Mesh } from "babylonjs/Meshes/mesh";
  52209. import { Node } from "babylonjs/node";
  52210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52211. /**
  52212. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52213. */
  52214. export class Gizmo implements IDisposable {
  52215. /** The utility layer the gizmo will be added to */
  52216. gizmoLayer: UtilityLayerRenderer;
  52217. /**
  52218. * The root mesh of the gizmo
  52219. */
  52220. _rootMesh: Mesh;
  52221. private _attachedMesh;
  52222. private _attachedNode;
  52223. /**
  52224. * Ratio for the scale of the gizmo (Default: 1)
  52225. */
  52226. scaleRatio: number;
  52227. /**
  52228. * If a custom mesh has been set (Default: false)
  52229. */
  52230. protected _customMeshSet: boolean;
  52231. /**
  52232. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52233. * * When set, interactions will be enabled
  52234. */
  52235. get attachedMesh(): Nullable<AbstractMesh>;
  52236. set attachedMesh(value: Nullable<AbstractMesh>);
  52237. /**
  52238. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52239. * * When set, interactions will be enabled
  52240. */
  52241. get attachedNode(): Nullable<Node>;
  52242. set attachedNode(value: Nullable<Node>);
  52243. /**
  52244. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52245. * @param mesh The mesh to replace the default mesh of the gizmo
  52246. */
  52247. setCustomMesh(mesh: Mesh): void;
  52248. /**
  52249. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52250. */
  52251. updateGizmoRotationToMatchAttachedMesh: boolean;
  52252. /**
  52253. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52254. */
  52255. updateGizmoPositionToMatchAttachedMesh: boolean;
  52256. /**
  52257. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52258. */
  52259. updateScale: boolean;
  52260. protected _interactionsEnabled: boolean;
  52261. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52262. private _beforeRenderObserver;
  52263. private _tempQuaternion;
  52264. private _tempVector;
  52265. private _tempVector2;
  52266. /**
  52267. * Creates a gizmo
  52268. * @param gizmoLayer The utility layer the gizmo will be added to
  52269. */
  52270. constructor(
  52271. /** The utility layer the gizmo will be added to */
  52272. gizmoLayer?: UtilityLayerRenderer);
  52273. /**
  52274. * Updates the gizmo to match the attached mesh's position/rotation
  52275. */
  52276. protected _update(): void;
  52277. /**
  52278. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52279. * @param value Node, TransformNode or mesh
  52280. */
  52281. protected _matrixChanged(): void;
  52282. /**
  52283. * Disposes of the gizmo
  52284. */
  52285. dispose(): void;
  52286. }
  52287. }
  52288. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52289. import { Observable } from "babylonjs/Misc/observable";
  52290. import { Nullable } from "babylonjs/types";
  52291. import { Vector3 } from "babylonjs/Maths/math.vector";
  52292. import { Color3 } from "babylonjs/Maths/math.color";
  52293. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52294. import { Node } from "babylonjs/node";
  52295. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52296. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52297. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52298. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52299. import { Scene } from "babylonjs/scene";
  52300. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52301. /**
  52302. * Single plane drag gizmo
  52303. */
  52304. export class PlaneDragGizmo extends Gizmo {
  52305. /**
  52306. * Drag behavior responsible for the gizmos dragging interactions
  52307. */
  52308. dragBehavior: PointerDragBehavior;
  52309. private _pointerObserver;
  52310. /**
  52311. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52312. */
  52313. snapDistance: number;
  52314. /**
  52315. * Event that fires each time the gizmo snaps to a new location.
  52316. * * snapDistance is the the change in distance
  52317. */
  52318. onSnapObservable: Observable<{
  52319. snapDistance: number;
  52320. }>;
  52321. private _plane;
  52322. private _coloredMaterial;
  52323. private _hoverMaterial;
  52324. private _isEnabled;
  52325. private _parent;
  52326. /** @hidden */
  52327. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52328. /** @hidden */
  52329. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52330. /**
  52331. * Creates a PlaneDragGizmo
  52332. * @param gizmoLayer The utility layer the gizmo will be added to
  52333. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52334. * @param color The color of the gizmo
  52335. */
  52336. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52337. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52338. /**
  52339. * If the gizmo is enabled
  52340. */
  52341. set isEnabled(value: boolean);
  52342. get isEnabled(): boolean;
  52343. /**
  52344. * Disposes of the gizmo
  52345. */
  52346. dispose(): void;
  52347. }
  52348. }
  52349. declare module "babylonjs/Gizmos/positionGizmo" {
  52350. import { Observable } from "babylonjs/Misc/observable";
  52351. import { Nullable } from "babylonjs/types";
  52352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52353. import { Node } from "babylonjs/node";
  52354. import { Mesh } from "babylonjs/Meshes/mesh";
  52355. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52356. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52357. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52358. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52359. /**
  52360. * Gizmo that enables dragging a mesh along 3 axis
  52361. */
  52362. export class PositionGizmo extends Gizmo {
  52363. /**
  52364. * Internal gizmo used for interactions on the x axis
  52365. */
  52366. xGizmo: AxisDragGizmo;
  52367. /**
  52368. * Internal gizmo used for interactions on the y axis
  52369. */
  52370. yGizmo: AxisDragGizmo;
  52371. /**
  52372. * Internal gizmo used for interactions on the z axis
  52373. */
  52374. zGizmo: AxisDragGizmo;
  52375. /**
  52376. * Internal gizmo used for interactions on the yz plane
  52377. */
  52378. xPlaneGizmo: PlaneDragGizmo;
  52379. /**
  52380. * Internal gizmo used for interactions on the xz plane
  52381. */
  52382. yPlaneGizmo: PlaneDragGizmo;
  52383. /**
  52384. * Internal gizmo used for interactions on the xy plane
  52385. */
  52386. zPlaneGizmo: PlaneDragGizmo;
  52387. /**
  52388. * private variables
  52389. */
  52390. private _meshAttached;
  52391. private _nodeAttached;
  52392. private _updateGizmoRotationToMatchAttachedMesh;
  52393. private _snapDistance;
  52394. private _scaleRatio;
  52395. /** Fires an event when any of it's sub gizmos are dragged */
  52396. onDragStartObservable: Observable<unknown>;
  52397. /** Fires an event when any of it's sub gizmos are released from dragging */
  52398. onDragEndObservable: Observable<unknown>;
  52399. /**
  52400. * If set to true, planar drag is enabled
  52401. */
  52402. private _planarGizmoEnabled;
  52403. get attachedMesh(): Nullable<AbstractMesh>;
  52404. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52405. get attachedNode(): Nullable<Node>;
  52406. set attachedNode(node: Nullable<Node>);
  52407. /**
  52408. * Creates a PositionGizmo
  52409. * @param gizmoLayer The utility layer the gizmo will be added to
  52410. @param thickness display gizmo axis thickness
  52411. */
  52412. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52413. /**
  52414. * If the planar drag gizmo is enabled
  52415. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52416. */
  52417. set planarGizmoEnabled(value: boolean);
  52418. get planarGizmoEnabled(): boolean;
  52419. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52420. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52421. /**
  52422. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52423. */
  52424. set snapDistance(value: number);
  52425. get snapDistance(): number;
  52426. /**
  52427. * Ratio for the scale of the gizmo (Default: 1)
  52428. */
  52429. set scaleRatio(value: number);
  52430. get scaleRatio(): number;
  52431. /**
  52432. * Disposes of the gizmo
  52433. */
  52434. dispose(): void;
  52435. /**
  52436. * CustomMeshes are not supported by this gizmo
  52437. * @param mesh The mesh to replace the default mesh of the gizmo
  52438. */
  52439. setCustomMesh(mesh: Mesh): void;
  52440. }
  52441. }
  52442. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52443. import { Observable } from "babylonjs/Misc/observable";
  52444. import { Nullable } from "babylonjs/types";
  52445. import { Vector3 } from "babylonjs/Maths/math.vector";
  52446. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52447. import { Node } from "babylonjs/node";
  52448. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52449. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52450. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52451. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52452. import { Scene } from "babylonjs/scene";
  52453. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52454. import { Color3 } from "babylonjs/Maths/math.color";
  52455. /**
  52456. * Single axis drag gizmo
  52457. */
  52458. export class AxisDragGizmo extends Gizmo {
  52459. /**
  52460. * Drag behavior responsible for the gizmos dragging interactions
  52461. */
  52462. dragBehavior: PointerDragBehavior;
  52463. private _pointerObserver;
  52464. /**
  52465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52466. */
  52467. snapDistance: number;
  52468. /**
  52469. * Event that fires each time the gizmo snaps to a new location.
  52470. * * snapDistance is the the change in distance
  52471. */
  52472. onSnapObservable: Observable<{
  52473. snapDistance: number;
  52474. }>;
  52475. private _isEnabled;
  52476. private _parent;
  52477. private _arrow;
  52478. private _coloredMaterial;
  52479. private _hoverMaterial;
  52480. /** @hidden */
  52481. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52482. /** @hidden */
  52483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52484. /**
  52485. * Creates an AxisDragGizmo
  52486. * @param gizmoLayer The utility layer the gizmo will be added to
  52487. * @param dragAxis The axis which the gizmo will be able to drag on
  52488. * @param color The color of the gizmo
  52489. * @param thickness display gizmo axis thickness
  52490. */
  52491. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52492. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52493. /**
  52494. * If the gizmo is enabled
  52495. */
  52496. set isEnabled(value: boolean);
  52497. get isEnabled(): boolean;
  52498. /**
  52499. * Disposes of the gizmo
  52500. */
  52501. dispose(): void;
  52502. }
  52503. }
  52504. declare module "babylonjs/Debug/axesViewer" {
  52505. import { Vector3 } from "babylonjs/Maths/math.vector";
  52506. import { Nullable } from "babylonjs/types";
  52507. import { Scene } from "babylonjs/scene";
  52508. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52509. /**
  52510. * The Axes viewer will show 3 axes in a specific point in space
  52511. */
  52512. export class AxesViewer {
  52513. private _xAxis;
  52514. private _yAxis;
  52515. private _zAxis;
  52516. private _scaleLinesFactor;
  52517. private _instanced;
  52518. /**
  52519. * Gets the hosting scene
  52520. */
  52521. scene: Scene;
  52522. /**
  52523. * Gets or sets a number used to scale line length
  52524. */
  52525. scaleLines: number;
  52526. /** Gets the node hierarchy used to render x-axis */
  52527. get xAxis(): TransformNode;
  52528. /** Gets the node hierarchy used to render y-axis */
  52529. get yAxis(): TransformNode;
  52530. /** Gets the node hierarchy used to render z-axis */
  52531. get zAxis(): TransformNode;
  52532. /**
  52533. * Creates a new AxesViewer
  52534. * @param scene defines the hosting scene
  52535. * @param scaleLines defines a number used to scale line length (1 by default)
  52536. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52537. * @param xAxis defines the node hierarchy used to render the x-axis
  52538. * @param yAxis defines the node hierarchy used to render the y-axis
  52539. * @param zAxis defines the node hierarchy used to render the z-axis
  52540. */
  52541. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52542. /**
  52543. * Force the viewer to update
  52544. * @param position defines the position of the viewer
  52545. * @param xaxis defines the x axis of the viewer
  52546. * @param yaxis defines the y axis of the viewer
  52547. * @param zaxis defines the z axis of the viewer
  52548. */
  52549. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52550. /**
  52551. * Creates an instance of this axes viewer.
  52552. * @returns a new axes viewer with instanced meshes
  52553. */
  52554. createInstance(): AxesViewer;
  52555. /** Releases resources */
  52556. dispose(): void;
  52557. private static _SetRenderingGroupId;
  52558. }
  52559. }
  52560. declare module "babylonjs/Debug/boneAxesViewer" {
  52561. import { Nullable } from "babylonjs/types";
  52562. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52563. import { Vector3 } from "babylonjs/Maths/math.vector";
  52564. import { Mesh } from "babylonjs/Meshes/mesh";
  52565. import { Bone } from "babylonjs/Bones/bone";
  52566. import { Scene } from "babylonjs/scene";
  52567. /**
  52568. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52569. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52570. */
  52571. export class BoneAxesViewer extends AxesViewer {
  52572. /**
  52573. * Gets or sets the target mesh where to display the axes viewer
  52574. */
  52575. mesh: Nullable<Mesh>;
  52576. /**
  52577. * Gets or sets the target bone where to display the axes viewer
  52578. */
  52579. bone: Nullable<Bone>;
  52580. /** Gets current position */
  52581. pos: Vector3;
  52582. /** Gets direction of X axis */
  52583. xaxis: Vector3;
  52584. /** Gets direction of Y axis */
  52585. yaxis: Vector3;
  52586. /** Gets direction of Z axis */
  52587. zaxis: Vector3;
  52588. /**
  52589. * Creates a new BoneAxesViewer
  52590. * @param scene defines the hosting scene
  52591. * @param bone defines the target bone
  52592. * @param mesh defines the target mesh
  52593. * @param scaleLines defines a scaling factor for line length (1 by default)
  52594. */
  52595. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52596. /**
  52597. * Force the viewer to update
  52598. */
  52599. update(): void;
  52600. /** Releases resources */
  52601. dispose(): void;
  52602. }
  52603. }
  52604. declare module "babylonjs/Debug/debugLayer" {
  52605. import { Scene } from "babylonjs/scene";
  52606. /**
  52607. * Interface used to define scene explorer extensibility option
  52608. */
  52609. export interface IExplorerExtensibilityOption {
  52610. /**
  52611. * Define the option label
  52612. */
  52613. label: string;
  52614. /**
  52615. * Defines the action to execute on click
  52616. */
  52617. action: (entity: any) => void;
  52618. }
  52619. /**
  52620. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52621. */
  52622. export interface IExplorerExtensibilityGroup {
  52623. /**
  52624. * Defines a predicate to test if a given type mut be extended
  52625. */
  52626. predicate: (entity: any) => boolean;
  52627. /**
  52628. * Gets the list of options added to a type
  52629. */
  52630. entries: IExplorerExtensibilityOption[];
  52631. }
  52632. /**
  52633. * Interface used to define the options to use to create the Inspector
  52634. */
  52635. export interface IInspectorOptions {
  52636. /**
  52637. * Display in overlay mode (default: false)
  52638. */
  52639. overlay?: boolean;
  52640. /**
  52641. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52642. */
  52643. globalRoot?: HTMLElement;
  52644. /**
  52645. * Display the Scene explorer
  52646. */
  52647. showExplorer?: boolean;
  52648. /**
  52649. * Display the property inspector
  52650. */
  52651. showInspector?: boolean;
  52652. /**
  52653. * Display in embed mode (both panes on the right)
  52654. */
  52655. embedMode?: boolean;
  52656. /**
  52657. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52658. */
  52659. handleResize?: boolean;
  52660. /**
  52661. * Allow the panes to popup (default: true)
  52662. */
  52663. enablePopup?: boolean;
  52664. /**
  52665. * Allow the panes to be closed by users (default: true)
  52666. */
  52667. enableClose?: boolean;
  52668. /**
  52669. * Optional list of extensibility entries
  52670. */
  52671. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52672. /**
  52673. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52674. */
  52675. inspectorURL?: string;
  52676. /**
  52677. * Optional initial tab (default to DebugLayerTab.Properties)
  52678. */
  52679. initialTab?: DebugLayerTab;
  52680. }
  52681. module "babylonjs/scene" {
  52682. interface Scene {
  52683. /**
  52684. * @hidden
  52685. * Backing field
  52686. */
  52687. _debugLayer: DebugLayer;
  52688. /**
  52689. * Gets the debug layer (aka Inspector) associated with the scene
  52690. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52691. */
  52692. debugLayer: DebugLayer;
  52693. }
  52694. }
  52695. /**
  52696. * Enum of inspector action tab
  52697. */
  52698. export enum DebugLayerTab {
  52699. /**
  52700. * Properties tag (default)
  52701. */
  52702. Properties = 0,
  52703. /**
  52704. * Debug tab
  52705. */
  52706. Debug = 1,
  52707. /**
  52708. * Statistics tab
  52709. */
  52710. Statistics = 2,
  52711. /**
  52712. * Tools tab
  52713. */
  52714. Tools = 3,
  52715. /**
  52716. * Settings tab
  52717. */
  52718. Settings = 4
  52719. }
  52720. /**
  52721. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52722. * what is happening in your scene
  52723. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52724. */
  52725. export class DebugLayer {
  52726. /**
  52727. * Define the url to get the inspector script from.
  52728. * By default it uses the babylonjs CDN.
  52729. * @ignoreNaming
  52730. */
  52731. static InspectorURL: string;
  52732. private _scene;
  52733. private BJSINSPECTOR;
  52734. private _onPropertyChangedObservable?;
  52735. /**
  52736. * Observable triggered when a property is changed through the inspector.
  52737. */
  52738. get onPropertyChangedObservable(): any;
  52739. /**
  52740. * Instantiates a new debug layer.
  52741. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52742. * what is happening in your scene
  52743. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52744. * @param scene Defines the scene to inspect
  52745. */
  52746. constructor(scene: Scene);
  52747. /** Creates the inspector window. */
  52748. private _createInspector;
  52749. /**
  52750. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52751. * @param entity defines the entity to select
  52752. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52753. */
  52754. select(entity: any, lineContainerTitles?: string | string[]): void;
  52755. /** Get the inspector from bundle or global */
  52756. private _getGlobalInspector;
  52757. /**
  52758. * Get if the inspector is visible or not.
  52759. * @returns true if visible otherwise, false
  52760. */
  52761. isVisible(): boolean;
  52762. /**
  52763. * Hide the inspector and close its window.
  52764. */
  52765. hide(): void;
  52766. /**
  52767. * Update the scene in the inspector
  52768. */
  52769. setAsActiveScene(): void;
  52770. /**
  52771. * Launch the debugLayer.
  52772. * @param config Define the configuration of the inspector
  52773. * @return a promise fulfilled when the debug layer is visible
  52774. */
  52775. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52776. }
  52777. }
  52778. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52779. import { Nullable } from "babylonjs/types";
  52780. import { Scene } from "babylonjs/scene";
  52781. import { Vector4 } from "babylonjs/Maths/math.vector";
  52782. import { Color4 } from "babylonjs/Maths/math.color";
  52783. import { Mesh } from "babylonjs/Meshes/mesh";
  52784. /**
  52785. * Class containing static functions to help procedurally build meshes
  52786. */
  52787. export class BoxBuilder {
  52788. /**
  52789. * Creates a box mesh
  52790. * * The parameter `size` sets the size (float) of each box side (default 1)
  52791. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52792. * * 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)
  52793. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52797. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52798. * @param name defines the name of the mesh
  52799. * @param options defines the options used to create the mesh
  52800. * @param scene defines the hosting scene
  52801. * @returns the box mesh
  52802. */
  52803. static CreateBox(name: string, options: {
  52804. size?: number;
  52805. width?: number;
  52806. height?: number;
  52807. depth?: number;
  52808. faceUV?: Vector4[];
  52809. faceColors?: Color4[];
  52810. sideOrientation?: number;
  52811. frontUVs?: Vector4;
  52812. backUVs?: Vector4;
  52813. wrap?: boolean;
  52814. topBaseAt?: number;
  52815. bottomBaseAt?: number;
  52816. updatable?: boolean;
  52817. }, scene?: Nullable<Scene>): Mesh;
  52818. }
  52819. }
  52820. declare module "babylonjs/Debug/physicsViewer" {
  52821. import { Nullable } from "babylonjs/types";
  52822. import { Scene } from "babylonjs/scene";
  52823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52824. import { Mesh } from "babylonjs/Meshes/mesh";
  52825. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52826. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52827. /**
  52828. * Used to show the physics impostor around the specific mesh
  52829. */
  52830. export class PhysicsViewer {
  52831. /** @hidden */
  52832. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52833. /** @hidden */
  52834. protected _meshes: Array<Nullable<AbstractMesh>>;
  52835. /** @hidden */
  52836. protected _scene: Nullable<Scene>;
  52837. /** @hidden */
  52838. protected _numMeshes: number;
  52839. /** @hidden */
  52840. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52841. private _renderFunction;
  52842. private _utilityLayer;
  52843. private _debugBoxMesh;
  52844. private _debugSphereMesh;
  52845. private _debugCylinderMesh;
  52846. private _debugMaterial;
  52847. private _debugMeshMeshes;
  52848. /**
  52849. * Creates a new PhysicsViewer
  52850. * @param scene defines the hosting scene
  52851. */
  52852. constructor(scene: Scene);
  52853. /** @hidden */
  52854. protected _updateDebugMeshes(): void;
  52855. /**
  52856. * Renders a specified physic impostor
  52857. * @param impostor defines the impostor to render
  52858. * @param targetMesh defines the mesh represented by the impostor
  52859. * @returns the new debug mesh used to render the impostor
  52860. */
  52861. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52862. /**
  52863. * Hides a specified physic impostor
  52864. * @param impostor defines the impostor to hide
  52865. */
  52866. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52867. private _getDebugMaterial;
  52868. private _getDebugBoxMesh;
  52869. private _getDebugSphereMesh;
  52870. private _getDebugCylinderMesh;
  52871. private _getDebugMeshMesh;
  52872. private _getDebugMesh;
  52873. /** Releases all resources */
  52874. dispose(): void;
  52875. }
  52876. }
  52877. declare module "babylonjs/Debug/rayHelper" {
  52878. import { Nullable } from "babylonjs/types";
  52879. import { Ray } from "babylonjs/Culling/ray";
  52880. import { Vector3 } from "babylonjs/Maths/math.vector";
  52881. import { Color3 } from "babylonjs/Maths/math.color";
  52882. import { Scene } from "babylonjs/scene";
  52883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52884. import "babylonjs/Meshes/Builders/linesBuilder";
  52885. /**
  52886. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52887. * in order to better appreciate the issue one might have.
  52888. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52889. */
  52890. export class RayHelper {
  52891. /**
  52892. * Defines the ray we are currently tryin to visualize.
  52893. */
  52894. ray: Nullable<Ray>;
  52895. private _renderPoints;
  52896. private _renderLine;
  52897. private _renderFunction;
  52898. private _scene;
  52899. private _onAfterRenderObserver;
  52900. private _onAfterStepObserver;
  52901. private _attachedToMesh;
  52902. private _meshSpaceDirection;
  52903. private _meshSpaceOrigin;
  52904. /**
  52905. * Helper function to create a colored helper in a scene in one line.
  52906. * @param ray Defines the ray we are currently tryin to visualize
  52907. * @param scene Defines the scene the ray is used in
  52908. * @param color Defines the color we want to see the ray in
  52909. * @returns The newly created ray helper.
  52910. */
  52911. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52912. /**
  52913. * Instantiate a new ray helper.
  52914. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52915. * in order to better appreciate the issue one might have.
  52916. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52917. * @param ray Defines the ray we are currently tryin to visualize
  52918. */
  52919. constructor(ray: Ray);
  52920. /**
  52921. * Shows the ray we are willing to debug.
  52922. * @param scene Defines the scene the ray needs to be rendered in
  52923. * @param color Defines the color the ray needs to be rendered in
  52924. */
  52925. show(scene: Scene, color?: Color3): void;
  52926. /**
  52927. * Hides the ray we are debugging.
  52928. */
  52929. hide(): void;
  52930. private _render;
  52931. /**
  52932. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52933. * @param mesh Defines the mesh we want the helper attached to
  52934. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52935. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52936. * @param length Defines the length of the ray
  52937. */
  52938. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52939. /**
  52940. * Detach the ray helper from the mesh it has previously been attached to.
  52941. */
  52942. detachFromMesh(): void;
  52943. private _updateToMesh;
  52944. /**
  52945. * Dispose the helper and release its associated resources.
  52946. */
  52947. dispose(): void;
  52948. }
  52949. }
  52950. declare module "babylonjs/Debug/ISkeletonViewer" {
  52951. /**
  52952. * Defines the options associated with the creation of a SkeletonViewer.
  52953. */
  52954. export interface ISkeletonViewerOptions {
  52955. /** Should the system pause animations before building the Viewer? */
  52956. pauseAnimations: boolean;
  52957. /** Should the system return the skeleton to rest before building? */
  52958. returnToRest: boolean;
  52959. /** public Display Mode of the Viewer */
  52960. displayMode: number;
  52961. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52962. displayOptions: ISkeletonViewerDisplayOptions;
  52963. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52964. computeBonesUsingShaders: boolean;
  52965. }
  52966. /**
  52967. * Defines how to display the various bone meshes for the viewer.
  52968. */
  52969. export interface ISkeletonViewerDisplayOptions {
  52970. /** How far down to start tapering the bone spurs */
  52971. midStep?: number;
  52972. /** How big is the midStep? */
  52973. midStepFactor?: number;
  52974. /** Base for the Sphere Size */
  52975. sphereBaseSize?: number;
  52976. /** The ratio of the sphere to the longest bone in units */
  52977. sphereScaleUnit?: number;
  52978. /** Ratio for the Sphere Size */
  52979. sphereFactor?: number;
  52980. }
  52981. }
  52982. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52983. import { Nullable } from "babylonjs/types";
  52984. import { Scene } from "babylonjs/scene";
  52985. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52986. import { Color4 } from "babylonjs/Maths/math.color";
  52987. import { Mesh } from "babylonjs/Meshes/mesh";
  52988. /**
  52989. * Class containing static functions to help procedurally build meshes
  52990. */
  52991. export class RibbonBuilder {
  52992. /**
  52993. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52994. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52995. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52996. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52997. * * 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
  52998. * * 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
  52999. * * 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
  53000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53003. * * 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
  53004. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53005. * * 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
  53006. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53008. * @param name defines the name of the mesh
  53009. * @param options defines the options used to create the mesh
  53010. * @param scene defines the hosting scene
  53011. * @returns the ribbon mesh
  53012. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53013. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53014. */
  53015. static CreateRibbon(name: string, options: {
  53016. pathArray: Vector3[][];
  53017. closeArray?: boolean;
  53018. closePath?: boolean;
  53019. offset?: number;
  53020. updatable?: boolean;
  53021. sideOrientation?: number;
  53022. frontUVs?: Vector4;
  53023. backUVs?: Vector4;
  53024. instance?: Mesh;
  53025. invertUV?: boolean;
  53026. uvs?: Vector2[];
  53027. colors?: Color4[];
  53028. }, scene?: Nullable<Scene>): Mesh;
  53029. }
  53030. }
  53031. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53032. import { Nullable } from "babylonjs/types";
  53033. import { Scene } from "babylonjs/scene";
  53034. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53035. import { Mesh } from "babylonjs/Meshes/mesh";
  53036. /**
  53037. * Class containing static functions to help procedurally build meshes
  53038. */
  53039. export class ShapeBuilder {
  53040. /**
  53041. * 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.
  53042. * * 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.
  53043. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53044. * * 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.
  53045. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53046. * * 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
  53047. * * 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
  53048. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53053. * @param name defines the name of the mesh
  53054. * @param options defines the options used to create the mesh
  53055. * @param scene defines the hosting scene
  53056. * @returns the extruded shape mesh
  53057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53059. */
  53060. static ExtrudeShape(name: string, options: {
  53061. shape: Vector3[];
  53062. path: Vector3[];
  53063. scale?: number;
  53064. rotation?: number;
  53065. cap?: number;
  53066. updatable?: boolean;
  53067. sideOrientation?: number;
  53068. frontUVs?: Vector4;
  53069. backUVs?: Vector4;
  53070. instance?: Mesh;
  53071. invertUV?: boolean;
  53072. }, scene?: Nullable<Scene>): Mesh;
  53073. /**
  53074. * Creates an custom extruded shape mesh.
  53075. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53076. * * 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.
  53077. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53078. * * 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
  53079. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53080. * * 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
  53081. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53082. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53083. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53084. * * 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
  53085. * * 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
  53086. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53091. * @param name defines the name of the mesh
  53092. * @param options defines the options used to create the mesh
  53093. * @param scene defines the hosting scene
  53094. * @returns the custom extruded shape mesh
  53095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53098. */
  53099. static ExtrudeShapeCustom(name: string, options: {
  53100. shape: Vector3[];
  53101. path: Vector3[];
  53102. scaleFunction?: any;
  53103. rotationFunction?: any;
  53104. ribbonCloseArray?: boolean;
  53105. ribbonClosePath?: boolean;
  53106. cap?: number;
  53107. updatable?: boolean;
  53108. sideOrientation?: number;
  53109. frontUVs?: Vector4;
  53110. backUVs?: Vector4;
  53111. instance?: Mesh;
  53112. invertUV?: boolean;
  53113. }, scene?: Nullable<Scene>): Mesh;
  53114. private static _ExtrudeShapeGeneric;
  53115. }
  53116. }
  53117. declare module "babylonjs/Debug/skeletonViewer" {
  53118. import { Color3 } from "babylonjs/Maths/math.color";
  53119. import { Scene } from "babylonjs/scene";
  53120. import { Nullable } from "babylonjs/types";
  53121. import { Skeleton } from "babylonjs/Bones/skeleton";
  53122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53123. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53124. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53125. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  53126. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  53127. /**
  53128. * Class used to render a debug view of a given skeleton
  53129. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53130. */
  53131. export class SkeletonViewer {
  53132. /** defines the skeleton to render */
  53133. skeleton: Skeleton;
  53134. /** defines the mesh attached to the skeleton */
  53135. mesh: AbstractMesh;
  53136. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53137. autoUpdateBonesMatrices: boolean;
  53138. /** defines the rendering group id to use with the viewer */
  53139. renderingGroupId: number;
  53140. /** is the options for the viewer */
  53141. options: Partial<ISkeletonViewerOptions>;
  53142. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53143. static readonly DISPLAY_LINES: number;
  53144. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53145. static readonly DISPLAY_SPHERES: number;
  53146. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53147. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53148. /** If SkeletonViewer scene scope. */
  53149. private _scene;
  53150. /** Gets or sets the color used to render the skeleton */
  53151. color: Color3;
  53152. /** Array of the points of the skeleton fo the line view. */
  53153. private _debugLines;
  53154. /** The SkeletonViewers Mesh. */
  53155. private _debugMesh;
  53156. /** If SkeletonViewer is enabled. */
  53157. private _isEnabled;
  53158. /** If SkeletonViewer is ready. */
  53159. private _ready;
  53160. /** SkeletonViewer render observable. */
  53161. private _obs;
  53162. /** The Utility Layer to render the gizmos in. */
  53163. private _utilityLayer;
  53164. private _boneIndices;
  53165. /** Gets the Scene. */
  53166. get scene(): Scene;
  53167. /** Gets the utilityLayer. */
  53168. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53169. /** Checks Ready Status. */
  53170. get isReady(): Boolean;
  53171. /** Sets Ready Status. */
  53172. set ready(value: boolean);
  53173. /** Gets the debugMesh */
  53174. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53175. /** Sets the debugMesh */
  53176. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53177. /** Gets the material */
  53178. get material(): StandardMaterial;
  53179. /** Sets the material */
  53180. set material(value: StandardMaterial);
  53181. /** Gets the material */
  53182. get displayMode(): number;
  53183. /** Sets the material */
  53184. set displayMode(value: number);
  53185. /**
  53186. * Creates a new SkeletonViewer
  53187. * @param skeleton defines the skeleton to render
  53188. * @param mesh defines the mesh attached to the skeleton
  53189. * @param scene defines the hosting scene
  53190. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53191. * @param renderingGroupId defines the rendering group id to use with the viewer
  53192. * @param options All of the extra constructor options for the SkeletonViewer
  53193. */
  53194. constructor(
  53195. /** defines the skeleton to render */
  53196. skeleton: Skeleton,
  53197. /** defines the mesh attached to the skeleton */
  53198. mesh: AbstractMesh,
  53199. /** The Scene scope*/
  53200. scene: Scene,
  53201. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53202. autoUpdateBonesMatrices?: boolean,
  53203. /** defines the rendering group id to use with the viewer */
  53204. renderingGroupId?: number,
  53205. /** is the options for the viewer */
  53206. options?: Partial<ISkeletonViewerOptions>);
  53207. /** The Dynamic bindings for the update functions */
  53208. private _bindObs;
  53209. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53210. update(): void;
  53211. /** Gets or sets a boolean indicating if the viewer is enabled */
  53212. set isEnabled(value: boolean);
  53213. get isEnabled(): boolean;
  53214. private _getBonePosition;
  53215. private _getLinesForBonesWithLength;
  53216. private _getLinesForBonesNoLength;
  53217. /** function to revert the mesh and scene back to the initial state. */
  53218. private _revert;
  53219. /** function to build and bind sphere joint points and spur bone representations. */
  53220. private _buildSpheresAndSpurs;
  53221. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53222. private _displayLinesUpdate;
  53223. /** Changes the displayMode of the skeleton viewer
  53224. * @param mode The displayMode numerical value
  53225. */
  53226. changeDisplayMode(mode: number): void;
  53227. /** Changes the displayMode of the skeleton viewer
  53228. * @param option String of the option name
  53229. * @param value The numerical option value
  53230. */
  53231. changeDisplayOptions(option: string, value: number): void;
  53232. /** Release associated resources */
  53233. dispose(): void;
  53234. }
  53235. }
  53236. declare module "babylonjs/Debug/index" {
  53237. export * from "babylonjs/Debug/axesViewer";
  53238. export * from "babylonjs/Debug/boneAxesViewer";
  53239. export * from "babylonjs/Debug/debugLayer";
  53240. export * from "babylonjs/Debug/physicsViewer";
  53241. export * from "babylonjs/Debug/rayHelper";
  53242. export * from "babylonjs/Debug/skeletonViewer";
  53243. export * from "babylonjs/Debug/ISkeletonViewer";
  53244. }
  53245. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53246. /**
  53247. * Enum for Device Types
  53248. */
  53249. export enum DeviceType {
  53250. /** Generic */
  53251. Generic = 0,
  53252. /** Keyboard */
  53253. Keyboard = 1,
  53254. /** Mouse */
  53255. Mouse = 2,
  53256. /** Touch Pointers */
  53257. Touch = 3,
  53258. /** PS4 Dual Shock */
  53259. DualShock = 4,
  53260. /** Xbox */
  53261. Xbox = 5,
  53262. /** Switch Controller */
  53263. Switch = 6
  53264. }
  53265. /**
  53266. * Enum for All Pointers (Touch/Mouse)
  53267. */
  53268. export enum PointerInput {
  53269. /** Horizontal Axis */
  53270. Horizontal = 0,
  53271. /** Vertical Axis */
  53272. Vertical = 1,
  53273. /** Left Click or Touch */
  53274. LeftClick = 2,
  53275. /** Middle Click */
  53276. MiddleClick = 3,
  53277. /** Right Click */
  53278. RightClick = 4,
  53279. /** Browser Back */
  53280. BrowserBack = 5,
  53281. /** Browser Forward */
  53282. BrowserForward = 6
  53283. }
  53284. /**
  53285. * Enum for Dual Shock Gamepad
  53286. */
  53287. export enum DualShockInput {
  53288. /** Cross */
  53289. Cross = 0,
  53290. /** Circle */
  53291. Circle = 1,
  53292. /** Square */
  53293. Square = 2,
  53294. /** Triangle */
  53295. Triangle = 3,
  53296. /** L1 */
  53297. L1 = 4,
  53298. /** R1 */
  53299. R1 = 5,
  53300. /** L2 */
  53301. L2 = 6,
  53302. /** R2 */
  53303. R2 = 7,
  53304. /** Share */
  53305. Share = 8,
  53306. /** Options */
  53307. Options = 9,
  53308. /** L3 */
  53309. L3 = 10,
  53310. /** R3 */
  53311. R3 = 11,
  53312. /** DPadUp */
  53313. DPadUp = 12,
  53314. /** DPadDown */
  53315. DPadDown = 13,
  53316. /** DPadLeft */
  53317. DPadLeft = 14,
  53318. /** DRight */
  53319. DPadRight = 15,
  53320. /** Home */
  53321. Home = 16,
  53322. /** TouchPad */
  53323. TouchPad = 17,
  53324. /** LStickXAxis */
  53325. LStickXAxis = 18,
  53326. /** LStickYAxis */
  53327. LStickYAxis = 19,
  53328. /** RStickXAxis */
  53329. RStickXAxis = 20,
  53330. /** RStickYAxis */
  53331. RStickYAxis = 21
  53332. }
  53333. /**
  53334. * Enum for Xbox Gamepad
  53335. */
  53336. export enum XboxInput {
  53337. /** A */
  53338. A = 0,
  53339. /** B */
  53340. B = 1,
  53341. /** X */
  53342. X = 2,
  53343. /** Y */
  53344. Y = 3,
  53345. /** LB */
  53346. LB = 4,
  53347. /** RB */
  53348. RB = 5,
  53349. /** LT */
  53350. LT = 6,
  53351. /** RT */
  53352. RT = 7,
  53353. /** Back */
  53354. Back = 8,
  53355. /** Start */
  53356. Start = 9,
  53357. /** LS */
  53358. LS = 10,
  53359. /** RS */
  53360. RS = 11,
  53361. /** DPadUp */
  53362. DPadUp = 12,
  53363. /** DPadDown */
  53364. DPadDown = 13,
  53365. /** DPadLeft */
  53366. DPadLeft = 14,
  53367. /** DRight */
  53368. DPadRight = 15,
  53369. /** Home */
  53370. Home = 16,
  53371. /** LStickXAxis */
  53372. LStickXAxis = 17,
  53373. /** LStickYAxis */
  53374. LStickYAxis = 18,
  53375. /** RStickXAxis */
  53376. RStickXAxis = 19,
  53377. /** RStickYAxis */
  53378. RStickYAxis = 20
  53379. }
  53380. /**
  53381. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53382. */
  53383. export enum SwitchInput {
  53384. /** B */
  53385. B = 0,
  53386. /** A */
  53387. A = 1,
  53388. /** Y */
  53389. Y = 2,
  53390. /** X */
  53391. X = 3,
  53392. /** L */
  53393. L = 4,
  53394. /** R */
  53395. R = 5,
  53396. /** ZL */
  53397. ZL = 6,
  53398. /** ZR */
  53399. ZR = 7,
  53400. /** Minus */
  53401. Minus = 8,
  53402. /** Plus */
  53403. Plus = 9,
  53404. /** LS */
  53405. LS = 10,
  53406. /** RS */
  53407. RS = 11,
  53408. /** DPadUp */
  53409. DPadUp = 12,
  53410. /** DPadDown */
  53411. DPadDown = 13,
  53412. /** DPadLeft */
  53413. DPadLeft = 14,
  53414. /** DRight */
  53415. DPadRight = 15,
  53416. /** Home */
  53417. Home = 16,
  53418. /** Capture */
  53419. Capture = 17,
  53420. /** LStickXAxis */
  53421. LStickXAxis = 18,
  53422. /** LStickYAxis */
  53423. LStickYAxis = 19,
  53424. /** RStickXAxis */
  53425. RStickXAxis = 20,
  53426. /** RStickYAxis */
  53427. RStickYAxis = 21
  53428. }
  53429. }
  53430. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53431. import { Engine } from "babylonjs/Engines/engine";
  53432. import { IDisposable } from "babylonjs/scene";
  53433. import { Nullable } from "babylonjs/types";
  53434. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53435. /**
  53436. * This class will take all inputs from Keyboard, Pointer, and
  53437. * any Gamepads and provide a polling system that all devices
  53438. * will use. This class assumes that there will only be one
  53439. * pointer device and one keyboard.
  53440. */
  53441. export class DeviceInputSystem implements IDisposable {
  53442. /**
  53443. * Callback to be triggered when a device is connected
  53444. */
  53445. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53446. /**
  53447. * Callback to be triggered when a device is disconnected
  53448. */
  53449. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53450. /**
  53451. * Callback to be triggered when event driven input is updated
  53452. */
  53453. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53454. private _inputs;
  53455. private _gamepads;
  53456. private _keyboardActive;
  53457. private _pointerActive;
  53458. private _elementToAttachTo;
  53459. private _keyboardDownEvent;
  53460. private _keyboardUpEvent;
  53461. private _pointerMoveEvent;
  53462. private _pointerDownEvent;
  53463. private _pointerUpEvent;
  53464. private _gamepadConnectedEvent;
  53465. private _gamepadDisconnectedEvent;
  53466. private static _MAX_KEYCODES;
  53467. private static _MAX_POINTER_INPUTS;
  53468. private constructor();
  53469. /**
  53470. * Creates a new DeviceInputSystem instance
  53471. * @param engine Engine to pull input element from
  53472. * @returns The new instance
  53473. */
  53474. static Create(engine: Engine): DeviceInputSystem;
  53475. /**
  53476. * Checks for current device input value, given an id and input index
  53477. * @param deviceName Id of connected device
  53478. * @param inputIndex Index of device input
  53479. * @returns Current value of input
  53480. */
  53481. /**
  53482. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53483. * @param deviceType Enum specifiying device type
  53484. * @param deviceSlot "Slot" or index that device is referenced in
  53485. * @param inputIndex Id of input to be checked
  53486. * @returns Current value of input
  53487. */
  53488. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53489. /**
  53490. * Dispose of all the eventlisteners
  53491. */
  53492. dispose(): void;
  53493. /**
  53494. * Add device and inputs to device array
  53495. * @param deviceType Enum specifiying device type
  53496. * @param deviceSlot "Slot" or index that device is referenced in
  53497. * @param numberOfInputs Number of input entries to create for given device
  53498. */
  53499. private _registerDevice;
  53500. /**
  53501. * Given a specific device name, remove that device from the device map
  53502. * @param deviceType Enum specifiying device type
  53503. * @param deviceSlot "Slot" or index that device is referenced in
  53504. */
  53505. private _unregisterDevice;
  53506. /**
  53507. * Handle all actions that come from keyboard interaction
  53508. */
  53509. private _handleKeyActions;
  53510. /**
  53511. * Handle all actions that come from pointer interaction
  53512. */
  53513. private _handlePointerActions;
  53514. /**
  53515. * Handle all actions that come from gamepad interaction
  53516. */
  53517. private _handleGamepadActions;
  53518. /**
  53519. * Update all non-event based devices with each frame
  53520. * @param deviceType Enum specifiying device type
  53521. * @param deviceSlot "Slot" or index that device is referenced in
  53522. * @param inputIndex Id of input to be checked
  53523. */
  53524. private _updateDevice;
  53525. /**
  53526. * Gets DeviceType from the device name
  53527. * @param deviceName Name of Device from DeviceInputSystem
  53528. * @returns DeviceType enum value
  53529. */
  53530. private _getGamepadDeviceType;
  53531. }
  53532. }
  53533. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53534. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53535. /**
  53536. * Type to handle enforcement of inputs
  53537. */
  53538. 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;
  53539. }
  53540. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53541. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53542. import { Engine } from "babylonjs/Engines/engine";
  53543. import { IDisposable } from "babylonjs/scene";
  53544. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53545. import { Nullable } from "babylonjs/types";
  53546. import { Observable } from "babylonjs/Misc/observable";
  53547. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53548. /**
  53549. * Class that handles all input for a specific device
  53550. */
  53551. export class DeviceSource<T extends DeviceType> {
  53552. /** Type of device */
  53553. readonly deviceType: DeviceType;
  53554. /** "Slot" or index that device is referenced in */
  53555. readonly deviceSlot: number;
  53556. /**
  53557. * Observable to handle device input changes per device
  53558. */
  53559. readonly onInputChangedObservable: Observable<{
  53560. inputIndex: DeviceInput<T>;
  53561. previousState: Nullable<number>;
  53562. currentState: Nullable<number>;
  53563. }>;
  53564. private readonly _deviceInputSystem;
  53565. /**
  53566. * Default Constructor
  53567. * @param deviceInputSystem Reference to DeviceInputSystem
  53568. * @param deviceType Type of device
  53569. * @param deviceSlot "Slot" or index that device is referenced in
  53570. */
  53571. constructor(deviceInputSystem: DeviceInputSystem,
  53572. /** Type of device */
  53573. deviceType: DeviceType,
  53574. /** "Slot" or index that device is referenced in */
  53575. deviceSlot?: number);
  53576. /**
  53577. * Get input for specific input
  53578. * @param inputIndex index of specific input on device
  53579. * @returns Input value from DeviceInputSystem
  53580. */
  53581. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53582. }
  53583. /**
  53584. * Class to keep track of devices
  53585. */
  53586. export class DeviceSourceManager implements IDisposable {
  53587. /**
  53588. * Observable to be triggered when before a device is connected
  53589. */
  53590. readonly onBeforeDeviceConnectedObservable: Observable<{
  53591. deviceType: DeviceType;
  53592. deviceSlot: number;
  53593. }>;
  53594. /**
  53595. * Observable to be triggered when before a device is disconnected
  53596. */
  53597. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53598. deviceType: DeviceType;
  53599. deviceSlot: number;
  53600. }>;
  53601. /**
  53602. * Observable to be triggered when after a device is connected
  53603. */
  53604. readonly onAfterDeviceConnectedObservable: Observable<{
  53605. deviceType: DeviceType;
  53606. deviceSlot: number;
  53607. }>;
  53608. /**
  53609. * Observable to be triggered when after a device is disconnected
  53610. */
  53611. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53612. deviceType: DeviceType;
  53613. deviceSlot: number;
  53614. }>;
  53615. private readonly _devices;
  53616. private readonly _firstDevice;
  53617. private readonly _deviceInputSystem;
  53618. /**
  53619. * Default Constructor
  53620. * @param engine engine to pull input element from
  53621. */
  53622. constructor(engine: Engine);
  53623. /**
  53624. * Gets a DeviceSource, given a type and slot
  53625. * @param deviceType Enum specifying device type
  53626. * @param deviceSlot "Slot" or index that device is referenced in
  53627. * @returns DeviceSource object
  53628. */
  53629. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53630. /**
  53631. * Gets an array of DeviceSource objects for a given device type
  53632. * @param deviceType Enum specifying device type
  53633. * @returns Array of DeviceSource objects
  53634. */
  53635. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53636. /**
  53637. * Dispose of DeviceInputSystem and other parts
  53638. */
  53639. dispose(): void;
  53640. /**
  53641. * Function to add device name to device list
  53642. * @param deviceType Enum specifying device type
  53643. * @param deviceSlot "Slot" or index that device is referenced in
  53644. */
  53645. private _addDevice;
  53646. /**
  53647. * Function to remove device name to device list
  53648. * @param deviceType Enum specifying device type
  53649. * @param deviceSlot "Slot" or index that device is referenced in
  53650. */
  53651. private _removeDevice;
  53652. /**
  53653. * Updates array storing first connected device of each type
  53654. * @param type Type of Device
  53655. */
  53656. private _updateFirstDevices;
  53657. }
  53658. }
  53659. declare module "babylonjs/DeviceInput/index" {
  53660. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53661. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53662. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53663. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53664. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53665. }
  53666. declare module "babylonjs/Engines/nullEngine" {
  53667. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53668. import { Engine } from "babylonjs/Engines/engine";
  53669. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53670. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53671. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53672. import { Effect } from "babylonjs/Materials/effect";
  53673. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53674. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53675. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53676. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53677. /**
  53678. * Options to create the null engine
  53679. */
  53680. export class NullEngineOptions {
  53681. /**
  53682. * Render width (Default: 512)
  53683. */
  53684. renderWidth: number;
  53685. /**
  53686. * Render height (Default: 256)
  53687. */
  53688. renderHeight: number;
  53689. /**
  53690. * Texture size (Default: 512)
  53691. */
  53692. textureSize: number;
  53693. /**
  53694. * If delta time between frames should be constant
  53695. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53696. */
  53697. deterministicLockstep: boolean;
  53698. /**
  53699. * Maximum about of steps between frames (Default: 4)
  53700. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53701. */
  53702. lockstepMaxSteps: number;
  53703. /**
  53704. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53705. */
  53706. useHighPrecisionMatrix?: boolean;
  53707. }
  53708. /**
  53709. * The null engine class provides support for headless version of babylon.js.
  53710. * This can be used in server side scenario or for testing purposes
  53711. */
  53712. export class NullEngine extends Engine {
  53713. private _options;
  53714. /**
  53715. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53716. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53717. * @returns true if engine is in deterministic lock step mode
  53718. */
  53719. isDeterministicLockStep(): boolean;
  53720. /**
  53721. * Gets the max steps when engine is running in deterministic lock step
  53722. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53723. * @returns the max steps
  53724. */
  53725. getLockstepMaxSteps(): number;
  53726. /**
  53727. * Gets the current hardware scaling level.
  53728. * By default the hardware scaling level is computed from the window device ratio.
  53729. * 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.
  53730. * @returns a number indicating the current hardware scaling level
  53731. */
  53732. getHardwareScalingLevel(): number;
  53733. constructor(options?: NullEngineOptions);
  53734. /**
  53735. * Creates a vertex buffer
  53736. * @param vertices the data for the vertex buffer
  53737. * @returns the new WebGL static buffer
  53738. */
  53739. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53740. /**
  53741. * Creates a new index buffer
  53742. * @param indices defines the content of the index buffer
  53743. * @param updatable defines if the index buffer must be updatable
  53744. * @returns a new webGL buffer
  53745. */
  53746. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53747. /**
  53748. * Clear the current render buffer or the current render target (if any is set up)
  53749. * @param color defines the color to use
  53750. * @param backBuffer defines if the back buffer must be cleared
  53751. * @param depth defines if the depth buffer must be cleared
  53752. * @param stencil defines if the stencil buffer must be cleared
  53753. */
  53754. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53755. /**
  53756. * Gets the current render width
  53757. * @param useScreen defines if screen size must be used (or the current render target if any)
  53758. * @returns a number defining the current render width
  53759. */
  53760. getRenderWidth(useScreen?: boolean): number;
  53761. /**
  53762. * Gets the current render height
  53763. * @param useScreen defines if screen size must be used (or the current render target if any)
  53764. * @returns a number defining the current render height
  53765. */
  53766. getRenderHeight(useScreen?: boolean): number;
  53767. /**
  53768. * Set the WebGL's viewport
  53769. * @param viewport defines the viewport element to be used
  53770. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53771. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53772. */
  53773. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53774. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53775. /**
  53776. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53777. * @param pipelineContext defines the pipeline context to use
  53778. * @param uniformsNames defines the list of uniform names
  53779. * @returns an array of webGL uniform locations
  53780. */
  53781. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53782. /**
  53783. * Gets the lsit of active attributes for a given webGL program
  53784. * @param pipelineContext defines the pipeline context to use
  53785. * @param attributesNames defines the list of attribute names to get
  53786. * @returns an array of indices indicating the offset of each attribute
  53787. */
  53788. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53789. /**
  53790. * Binds an effect to the webGL context
  53791. * @param effect defines the effect to bind
  53792. */
  53793. bindSamplers(effect: Effect): void;
  53794. /**
  53795. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53796. * @param effect defines the effect to activate
  53797. */
  53798. enableEffect(effect: Effect): void;
  53799. /**
  53800. * Set various states to the webGL context
  53801. * @param culling defines backface culling state
  53802. * @param zOffset defines the value to apply to zOffset (0 by default)
  53803. * @param force defines if states must be applied even if cache is up to date
  53804. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53805. */
  53806. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53807. /**
  53808. * Set the value of an uniform to an array of int32
  53809. * @param uniform defines the webGL uniform location where to store the value
  53810. * @param array defines the array of int32 to store
  53811. */
  53812. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53813. /**
  53814. * Set the value of an uniform to an array of int32 (stored as vec2)
  53815. * @param uniform defines the webGL uniform location where to store the value
  53816. * @param array defines the array of int32 to store
  53817. */
  53818. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53819. /**
  53820. * Set the value of an uniform to an array of int32 (stored as vec3)
  53821. * @param uniform defines the webGL uniform location where to store the value
  53822. * @param array defines the array of int32 to store
  53823. */
  53824. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53825. /**
  53826. * Set the value of an uniform to an array of int32 (stored as vec4)
  53827. * @param uniform defines the webGL uniform location where to store the value
  53828. * @param array defines the array of int32 to store
  53829. */
  53830. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53831. /**
  53832. * Set the value of an uniform to an array of float32
  53833. * @param uniform defines the webGL uniform location where to store the value
  53834. * @param array defines the array of float32 to store
  53835. */
  53836. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53837. /**
  53838. * Set the value of an uniform to an array of float32 (stored as vec2)
  53839. * @param uniform defines the webGL uniform location where to store the value
  53840. * @param array defines the array of float32 to store
  53841. */
  53842. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53843. /**
  53844. * Set the value of an uniform to an array of float32 (stored as vec3)
  53845. * @param uniform defines the webGL uniform location where to store the value
  53846. * @param array defines the array of float32 to store
  53847. */
  53848. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53849. /**
  53850. * Set the value of an uniform to an array of float32 (stored as vec4)
  53851. * @param uniform defines the webGL uniform location where to store the value
  53852. * @param array defines the array of float32 to store
  53853. */
  53854. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53855. /**
  53856. * Set the value of an uniform to an array of number
  53857. * @param uniform defines the webGL uniform location where to store the value
  53858. * @param array defines the array of number to store
  53859. */
  53860. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53861. /**
  53862. * Set the value of an uniform to an array of number (stored as vec2)
  53863. * @param uniform defines the webGL uniform location where to store the value
  53864. * @param array defines the array of number to store
  53865. */
  53866. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53867. /**
  53868. * Set the value of an uniform to an array of number (stored as vec3)
  53869. * @param uniform defines the webGL uniform location where to store the value
  53870. * @param array defines the array of number to store
  53871. */
  53872. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53873. /**
  53874. * Set the value of an uniform to an array of number (stored as vec4)
  53875. * @param uniform defines the webGL uniform location where to store the value
  53876. * @param array defines the array of number to store
  53877. */
  53878. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53879. /**
  53880. * Set the value of an uniform to an array of float32 (stored as matrices)
  53881. * @param uniform defines the webGL uniform location where to store the value
  53882. * @param matrices defines the array of float32 to store
  53883. */
  53884. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53885. /**
  53886. * Set the value of an uniform to a matrix (3x3)
  53887. * @param uniform defines the webGL uniform location where to store the value
  53888. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53889. */
  53890. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53891. /**
  53892. * Set the value of an uniform to a matrix (2x2)
  53893. * @param uniform defines the webGL uniform location where to store the value
  53894. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53895. */
  53896. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53897. /**
  53898. * Set the value of an uniform to a number (float)
  53899. * @param uniform defines the webGL uniform location where to store the value
  53900. * @param value defines the float number to store
  53901. */
  53902. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53903. /**
  53904. * Set the value of an uniform to a vec2
  53905. * @param uniform defines the webGL uniform location where to store the value
  53906. * @param x defines the 1st component of the value
  53907. * @param y defines the 2nd component of the value
  53908. */
  53909. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53910. /**
  53911. * Set the value of an uniform to a vec3
  53912. * @param uniform defines the webGL uniform location where to store the value
  53913. * @param x defines the 1st component of the value
  53914. * @param y defines the 2nd component of the value
  53915. * @param z defines the 3rd component of the value
  53916. */
  53917. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53918. /**
  53919. * Set the value of an uniform to a boolean
  53920. * @param uniform defines the webGL uniform location where to store the value
  53921. * @param bool defines the boolean to store
  53922. */
  53923. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53924. /**
  53925. * Set the value of an uniform to a vec4
  53926. * @param uniform defines the webGL uniform location where to store the value
  53927. * @param x defines the 1st component of the value
  53928. * @param y defines the 2nd component of the value
  53929. * @param z defines the 3rd component of the value
  53930. * @param w defines the 4th component of the value
  53931. */
  53932. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53933. /**
  53934. * Sets the current alpha mode
  53935. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53936. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53937. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53938. */
  53939. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53940. /**
  53941. * Bind webGl buffers directly to the webGL context
  53942. * @param vertexBuffers defines the vertex buffer to bind
  53943. * @param indexBuffer defines the index buffer to bind
  53944. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53945. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53946. * @param effect defines the effect associated with the vertex buffer
  53947. */
  53948. bindBuffers(vertexBuffers: {
  53949. [key: string]: VertexBuffer;
  53950. }, indexBuffer: DataBuffer, effect: Effect): void;
  53951. /**
  53952. * Force the entire cache to be cleared
  53953. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53954. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53955. */
  53956. wipeCaches(bruteForce?: boolean): void;
  53957. /**
  53958. * Send a draw order
  53959. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53960. * @param indexStart defines the starting index
  53961. * @param indexCount defines the number of index to draw
  53962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53963. */
  53964. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53965. /**
  53966. * Draw a list of indexed primitives
  53967. * @param fillMode defines the primitive to use
  53968. * @param indexStart defines the starting index
  53969. * @param indexCount defines the number of index to draw
  53970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53971. */
  53972. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53973. /**
  53974. * Draw a list of unindexed primitives
  53975. * @param fillMode defines the primitive to use
  53976. * @param verticesStart defines the index of first vertex to draw
  53977. * @param verticesCount defines the count of vertices to draw
  53978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53979. */
  53980. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53981. /** @hidden */
  53982. _createTexture(): WebGLTexture;
  53983. /** @hidden */
  53984. _releaseTexture(texture: InternalTexture): void;
  53985. /**
  53986. * Usually called from Texture.ts.
  53987. * Passed information to create a WebGLTexture
  53988. * @param urlArg defines a value which contains one of the following:
  53989. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53990. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53991. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53992. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53993. * @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)
  53994. * @param scene needed for loading to the correct scene
  53995. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53996. * @param onLoad optional callback to be called upon successful completion
  53997. * @param onError optional callback to be called upon failure
  53998. * @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
  53999. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54000. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54001. * @param forcedExtension defines the extension to use to pick the right loader
  54002. * @param mimeType defines an optional mime type
  54003. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54004. */
  54005. 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;
  54006. /**
  54007. * Creates a new render target texture
  54008. * @param size defines the size of the texture
  54009. * @param options defines the options used to create the texture
  54010. * @returns a new render target texture stored in an InternalTexture
  54011. */
  54012. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54013. /**
  54014. * Update the sampling mode of a given texture
  54015. * @param samplingMode defines the required sampling mode
  54016. * @param texture defines the texture to update
  54017. */
  54018. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54019. /**
  54020. * Binds the frame buffer to the specified texture.
  54021. * @param texture The texture to render to or null for the default canvas
  54022. * @param faceIndex The face of the texture to render to in case of cube texture
  54023. * @param requiredWidth The width of the target to render to
  54024. * @param requiredHeight The height of the target to render to
  54025. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54026. * @param lodLevel defines le lod level to bind to the frame buffer
  54027. */
  54028. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54029. /**
  54030. * Unbind the current render target texture from the webGL context
  54031. * @param texture defines the render target texture to unbind
  54032. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54033. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54034. */
  54035. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54036. /**
  54037. * Creates a dynamic vertex buffer
  54038. * @param vertices the data for the dynamic vertex buffer
  54039. * @returns the new WebGL dynamic buffer
  54040. */
  54041. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54042. /**
  54043. * Update the content of a dynamic texture
  54044. * @param texture defines the texture to update
  54045. * @param canvas defines the canvas containing the source
  54046. * @param invertY defines if data must be stored with Y axis inverted
  54047. * @param premulAlpha defines if alpha is stored as premultiplied
  54048. * @param format defines the format of the data
  54049. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54050. */
  54051. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54052. /**
  54053. * Gets a boolean indicating if all created effects are ready
  54054. * @returns true if all effects are ready
  54055. */
  54056. areAllEffectsReady(): boolean;
  54057. /**
  54058. * @hidden
  54059. * Get the current error code of the webGL context
  54060. * @returns the error code
  54061. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54062. */
  54063. getError(): number;
  54064. /** @hidden */
  54065. _getUnpackAlignement(): number;
  54066. /** @hidden */
  54067. _unpackFlipY(value: boolean): void;
  54068. /**
  54069. * Update a dynamic index buffer
  54070. * @param indexBuffer defines the target index buffer
  54071. * @param indices defines the data to update
  54072. * @param offset defines the offset in the target index buffer where update should start
  54073. */
  54074. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54075. /**
  54076. * Updates a dynamic vertex buffer.
  54077. * @param vertexBuffer the vertex buffer to update
  54078. * @param vertices the data used to update the vertex buffer
  54079. * @param byteOffset the byte offset of the data (optional)
  54080. * @param byteLength the byte length of the data (optional)
  54081. */
  54082. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54083. /** @hidden */
  54084. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54085. /** @hidden */
  54086. _bindTexture(channel: number, texture: InternalTexture): void;
  54087. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54088. /**
  54089. * 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
  54090. */
  54091. releaseEffects(): void;
  54092. displayLoadingUI(): void;
  54093. hideLoadingUI(): void;
  54094. /** @hidden */
  54095. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54096. /** @hidden */
  54097. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54098. /** @hidden */
  54099. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54100. /** @hidden */
  54101. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54102. }
  54103. }
  54104. declare module "babylonjs/Instrumentation/timeToken" {
  54105. import { Nullable } from "babylonjs/types";
  54106. /**
  54107. * @hidden
  54108. **/
  54109. export class _TimeToken {
  54110. _startTimeQuery: Nullable<WebGLQuery>;
  54111. _endTimeQuery: Nullable<WebGLQuery>;
  54112. _timeElapsedQuery: Nullable<WebGLQuery>;
  54113. _timeElapsedQueryEnded: boolean;
  54114. }
  54115. }
  54116. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54117. import { Nullable, int } from "babylonjs/types";
  54118. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54119. /** @hidden */
  54120. export class _OcclusionDataStorage {
  54121. /** @hidden */
  54122. occlusionInternalRetryCounter: number;
  54123. /** @hidden */
  54124. isOcclusionQueryInProgress: boolean;
  54125. /** @hidden */
  54126. isOccluded: boolean;
  54127. /** @hidden */
  54128. occlusionRetryCount: number;
  54129. /** @hidden */
  54130. occlusionType: number;
  54131. /** @hidden */
  54132. occlusionQueryAlgorithmType: number;
  54133. }
  54134. module "babylonjs/Engines/engine" {
  54135. interface Engine {
  54136. /**
  54137. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54138. * @return the new query
  54139. */
  54140. createQuery(): WebGLQuery;
  54141. /**
  54142. * Delete and release a webGL query
  54143. * @param query defines the query to delete
  54144. * @return the current engine
  54145. */
  54146. deleteQuery(query: WebGLQuery): Engine;
  54147. /**
  54148. * Check if a given query has resolved and got its value
  54149. * @param query defines the query to check
  54150. * @returns true if the query got its value
  54151. */
  54152. isQueryResultAvailable(query: WebGLQuery): boolean;
  54153. /**
  54154. * Gets the value of a given query
  54155. * @param query defines the query to check
  54156. * @returns the value of the query
  54157. */
  54158. getQueryResult(query: WebGLQuery): number;
  54159. /**
  54160. * Initiates an occlusion query
  54161. * @param algorithmType defines the algorithm to use
  54162. * @param query defines the query to use
  54163. * @returns the current engine
  54164. * @see https://doc.babylonjs.com/features/occlusionquery
  54165. */
  54166. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54167. /**
  54168. * Ends an occlusion query
  54169. * @see https://doc.babylonjs.com/features/occlusionquery
  54170. * @param algorithmType defines the algorithm to use
  54171. * @returns the current engine
  54172. */
  54173. endOcclusionQuery(algorithmType: number): Engine;
  54174. /**
  54175. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54176. * Please note that only one query can be issued at a time
  54177. * @returns a time token used to track the time span
  54178. */
  54179. startTimeQuery(): Nullable<_TimeToken>;
  54180. /**
  54181. * Ends a time query
  54182. * @param token defines the token used to measure the time span
  54183. * @returns the time spent (in ns)
  54184. */
  54185. endTimeQuery(token: _TimeToken): int;
  54186. /** @hidden */
  54187. _currentNonTimestampToken: Nullable<_TimeToken>;
  54188. /** @hidden */
  54189. _createTimeQuery(): WebGLQuery;
  54190. /** @hidden */
  54191. _deleteTimeQuery(query: WebGLQuery): void;
  54192. /** @hidden */
  54193. _getGlAlgorithmType(algorithmType: number): number;
  54194. /** @hidden */
  54195. _getTimeQueryResult(query: WebGLQuery): any;
  54196. /** @hidden */
  54197. _getTimeQueryAvailability(query: WebGLQuery): any;
  54198. }
  54199. }
  54200. module "babylonjs/Meshes/abstractMesh" {
  54201. interface AbstractMesh {
  54202. /**
  54203. * Backing filed
  54204. * @hidden
  54205. */
  54206. __occlusionDataStorage: _OcclusionDataStorage;
  54207. /**
  54208. * Access property
  54209. * @hidden
  54210. */
  54211. _occlusionDataStorage: _OcclusionDataStorage;
  54212. /**
  54213. * 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.
  54214. * The default value is -1 which means don't break the query and wait till the result
  54215. * @see https://doc.babylonjs.com/features/occlusionquery
  54216. */
  54217. occlusionRetryCount: number;
  54218. /**
  54219. * 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:
  54220. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54221. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54222. * * 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.
  54223. * @see https://doc.babylonjs.com/features/occlusionquery
  54224. */
  54225. occlusionType: number;
  54226. /**
  54227. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54228. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54229. * * 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.
  54230. * @see https://doc.babylonjs.com/features/occlusionquery
  54231. */
  54232. occlusionQueryAlgorithmType: number;
  54233. /**
  54234. * 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
  54235. * @see https://doc.babylonjs.com/features/occlusionquery
  54236. */
  54237. isOccluded: boolean;
  54238. /**
  54239. * Flag to check the progress status of the query
  54240. * @see https://doc.babylonjs.com/features/occlusionquery
  54241. */
  54242. isOcclusionQueryInProgress: boolean;
  54243. }
  54244. }
  54245. }
  54246. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54247. import { Nullable } from "babylonjs/types";
  54248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54249. /** @hidden */
  54250. export var _forceTransformFeedbackToBundle: boolean;
  54251. module "babylonjs/Engines/engine" {
  54252. interface Engine {
  54253. /**
  54254. * Creates a webGL transform feedback object
  54255. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54256. * @returns the webGL transform feedback object
  54257. */
  54258. createTransformFeedback(): WebGLTransformFeedback;
  54259. /**
  54260. * Delete a webGL transform feedback object
  54261. * @param value defines the webGL transform feedback object to delete
  54262. */
  54263. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54264. /**
  54265. * Bind a webGL transform feedback object to the webgl context
  54266. * @param value defines the webGL transform feedback object to bind
  54267. */
  54268. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54269. /**
  54270. * Begins a transform feedback operation
  54271. * @param usePoints defines if points or triangles must be used
  54272. */
  54273. beginTransformFeedback(usePoints: boolean): void;
  54274. /**
  54275. * Ends a transform feedback operation
  54276. */
  54277. endTransformFeedback(): void;
  54278. /**
  54279. * Specify the varyings to use with transform feedback
  54280. * @param program defines the associated webGL program
  54281. * @param value defines the list of strings representing the varying names
  54282. */
  54283. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54284. /**
  54285. * Bind a webGL buffer for a transform feedback operation
  54286. * @param value defines the webGL buffer to bind
  54287. */
  54288. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54289. }
  54290. }
  54291. }
  54292. declare module "babylonjs/Engines/Extensions/engine.views" {
  54293. import { Camera } from "babylonjs/Cameras/camera";
  54294. import { Nullable } from "babylonjs/types";
  54295. /**
  54296. * Class used to define an additional view for the engine
  54297. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54298. */
  54299. export class EngineView {
  54300. /** Defines the canvas where to render the view */
  54301. target: HTMLCanvasElement;
  54302. /** Defines an optional camera used to render the view (will use active camera else) */
  54303. camera?: Camera;
  54304. }
  54305. module "babylonjs/Engines/engine" {
  54306. interface Engine {
  54307. /**
  54308. * Gets or sets the HTML element to use for attaching events
  54309. */
  54310. inputElement: Nullable<HTMLElement>;
  54311. /**
  54312. * Gets the current engine view
  54313. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54314. */
  54315. activeView: Nullable<EngineView>;
  54316. /** Gets or sets the list of views */
  54317. views: EngineView[];
  54318. /**
  54319. * Register a new child canvas
  54320. * @param canvas defines the canvas to register
  54321. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54322. * @returns the associated view
  54323. */
  54324. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54325. /**
  54326. * Remove a registered child canvas
  54327. * @param canvas defines the canvas to remove
  54328. * @returns the current engine
  54329. */
  54330. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54331. }
  54332. }
  54333. }
  54334. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54335. import { Nullable } from "babylonjs/types";
  54336. module "babylonjs/Engines/engine" {
  54337. interface Engine {
  54338. /** @hidden */
  54339. _excludedCompressedTextures: string[];
  54340. /** @hidden */
  54341. _textureFormatInUse: string;
  54342. /**
  54343. * Gets the list of texture formats supported
  54344. */
  54345. readonly texturesSupported: Array<string>;
  54346. /**
  54347. * Gets the texture format in use
  54348. */
  54349. readonly textureFormatInUse: Nullable<string>;
  54350. /**
  54351. * Set the compressed texture extensions or file names to skip.
  54352. *
  54353. * @param skippedFiles defines the list of those texture files you want to skip
  54354. * Example: [".dds", ".env", "myfile.png"]
  54355. */
  54356. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54357. /**
  54358. * Set the compressed texture format to use, based on the formats you have, and the formats
  54359. * supported by the hardware / browser.
  54360. *
  54361. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54362. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54363. * to API arguments needed to compressed textures. This puts the burden on the container
  54364. * generator to house the arcane code for determining these for current & future formats.
  54365. *
  54366. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54367. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54368. *
  54369. * Note: The result of this call is not taken into account when a texture is base64.
  54370. *
  54371. * @param formatsAvailable defines the list of those format families you have created
  54372. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54373. *
  54374. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54375. * @returns The extension selected.
  54376. */
  54377. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54378. }
  54379. }
  54380. }
  54381. declare module "babylonjs/Engines/Extensions/index" {
  54382. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54383. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54384. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54385. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54386. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54387. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54388. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54389. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54390. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54391. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54392. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54393. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54394. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54395. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54396. export * from "babylonjs/Engines/Extensions/engine.views";
  54397. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54398. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54399. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54400. }
  54401. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54402. import { Nullable } from "babylonjs/types";
  54403. /**
  54404. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54405. */
  54406. export interface CubeMapInfo {
  54407. /**
  54408. * The pixel array for the front face.
  54409. * This is stored in format, left to right, up to down format.
  54410. */
  54411. front: Nullable<ArrayBufferView>;
  54412. /**
  54413. * The pixel array for the back face.
  54414. * This is stored in format, left to right, up to down format.
  54415. */
  54416. back: Nullable<ArrayBufferView>;
  54417. /**
  54418. * The pixel array for the left face.
  54419. * This is stored in format, left to right, up to down format.
  54420. */
  54421. left: Nullable<ArrayBufferView>;
  54422. /**
  54423. * The pixel array for the right face.
  54424. * This is stored in format, left to right, up to down format.
  54425. */
  54426. right: Nullable<ArrayBufferView>;
  54427. /**
  54428. * The pixel array for the up face.
  54429. * This is stored in format, left to right, up to down format.
  54430. */
  54431. up: Nullable<ArrayBufferView>;
  54432. /**
  54433. * The pixel array for the down face.
  54434. * This is stored in format, left to right, up to down format.
  54435. */
  54436. down: Nullable<ArrayBufferView>;
  54437. /**
  54438. * The size of the cubemap stored.
  54439. *
  54440. * Each faces will be size * size pixels.
  54441. */
  54442. size: number;
  54443. /**
  54444. * The format of the texture.
  54445. *
  54446. * RGBA, RGB.
  54447. */
  54448. format: number;
  54449. /**
  54450. * The type of the texture data.
  54451. *
  54452. * UNSIGNED_INT, FLOAT.
  54453. */
  54454. type: number;
  54455. /**
  54456. * Specifies whether the texture is in gamma space.
  54457. */
  54458. gammaSpace: boolean;
  54459. }
  54460. /**
  54461. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54462. */
  54463. export class PanoramaToCubeMapTools {
  54464. private static FACE_LEFT;
  54465. private static FACE_RIGHT;
  54466. private static FACE_FRONT;
  54467. private static FACE_BACK;
  54468. private static FACE_DOWN;
  54469. private static FACE_UP;
  54470. /**
  54471. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54472. *
  54473. * @param float32Array The source data.
  54474. * @param inputWidth The width of the input panorama.
  54475. * @param inputHeight The height of the input panorama.
  54476. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54477. * @return The cubemap data
  54478. */
  54479. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54480. private static CreateCubemapTexture;
  54481. private static CalcProjectionSpherical;
  54482. }
  54483. }
  54484. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54485. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54487. import { Nullable } from "babylonjs/types";
  54488. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54489. /**
  54490. * Helper class dealing with the extraction of spherical polynomial dataArray
  54491. * from a cube map.
  54492. */
  54493. export class CubeMapToSphericalPolynomialTools {
  54494. private static FileFaces;
  54495. /**
  54496. * Converts a texture to the according Spherical Polynomial data.
  54497. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54498. *
  54499. * @param texture The texture to extract the information from.
  54500. * @return The Spherical Polynomial data.
  54501. */
  54502. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54503. /**
  54504. * Converts a cubemap to the according Spherical Polynomial data.
  54505. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54506. *
  54507. * @param cubeInfo The Cube map to extract the information from.
  54508. * @return The Spherical Polynomial data.
  54509. */
  54510. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54511. }
  54512. }
  54513. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54514. import { Nullable } from "babylonjs/types";
  54515. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54516. module "babylonjs/Materials/Textures/baseTexture" {
  54517. interface BaseTexture {
  54518. /**
  54519. * Get the polynomial representation of the texture data.
  54520. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54521. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54522. */
  54523. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54524. }
  54525. }
  54526. }
  54527. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54528. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54529. /** @hidden */
  54530. export var rgbdEncodePixelShader: {
  54531. name: string;
  54532. shader: string;
  54533. };
  54534. }
  54535. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54536. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54537. /** @hidden */
  54538. export var rgbdDecodePixelShader: {
  54539. name: string;
  54540. shader: string;
  54541. };
  54542. }
  54543. declare module "babylonjs/Misc/environmentTextureTools" {
  54544. import { Nullable } from "babylonjs/types";
  54545. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54548. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54549. import "babylonjs/Engines/Extensions/engine.readTexture";
  54550. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54551. import "babylonjs/Shaders/rgbdEncode.fragment";
  54552. import "babylonjs/Shaders/rgbdDecode.fragment";
  54553. /**
  54554. * Raw texture data and descriptor sufficient for WebGL texture upload
  54555. */
  54556. export interface EnvironmentTextureInfo {
  54557. /**
  54558. * Version of the environment map
  54559. */
  54560. version: number;
  54561. /**
  54562. * Width of image
  54563. */
  54564. width: number;
  54565. /**
  54566. * Irradiance information stored in the file.
  54567. */
  54568. irradiance: any;
  54569. /**
  54570. * Specular information stored in the file.
  54571. */
  54572. specular: any;
  54573. }
  54574. /**
  54575. * Defines One Image in the file. It requires only the position in the file
  54576. * as well as the length.
  54577. */
  54578. interface BufferImageData {
  54579. /**
  54580. * Length of the image data.
  54581. */
  54582. length: number;
  54583. /**
  54584. * Position of the data from the null terminator delimiting the end of the JSON.
  54585. */
  54586. position: number;
  54587. }
  54588. /**
  54589. * Defines the specular data enclosed in the file.
  54590. * This corresponds to the version 1 of the data.
  54591. */
  54592. export interface EnvironmentTextureSpecularInfoV1 {
  54593. /**
  54594. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54595. */
  54596. specularDataPosition?: number;
  54597. /**
  54598. * This contains all the images data needed to reconstruct the cubemap.
  54599. */
  54600. mipmaps: Array<BufferImageData>;
  54601. /**
  54602. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54603. */
  54604. lodGenerationScale: number;
  54605. }
  54606. /**
  54607. * Sets of helpers addressing the serialization and deserialization of environment texture
  54608. * stored in a BabylonJS env file.
  54609. * Those files are usually stored as .env files.
  54610. */
  54611. export class EnvironmentTextureTools {
  54612. /**
  54613. * Magic number identifying the env file.
  54614. */
  54615. private static _MagicBytes;
  54616. /**
  54617. * Gets the environment info from an env file.
  54618. * @param data The array buffer containing the .env bytes.
  54619. * @returns the environment file info (the json header) if successfully parsed.
  54620. */
  54621. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54622. /**
  54623. * Creates an environment texture from a loaded cube texture.
  54624. * @param texture defines the cube texture to convert in env file
  54625. * @return a promise containing the environment data if succesfull.
  54626. */
  54627. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54628. /**
  54629. * Creates a JSON representation of the spherical data.
  54630. * @param texture defines the texture containing the polynomials
  54631. * @return the JSON representation of the spherical info
  54632. */
  54633. private static _CreateEnvTextureIrradiance;
  54634. /**
  54635. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54636. * @param data the image data
  54637. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54638. * @return the views described by info providing access to the underlying buffer
  54639. */
  54640. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54641. /**
  54642. * Uploads the texture info contained in the env file to the GPU.
  54643. * @param texture defines the internal texture to upload to
  54644. * @param data defines the data to load
  54645. * @param info defines the texture info retrieved through the GetEnvInfo method
  54646. * @returns a promise
  54647. */
  54648. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54649. private static _OnImageReadyAsync;
  54650. /**
  54651. * Uploads the levels of image data to the GPU.
  54652. * @param texture defines the internal texture to upload to
  54653. * @param imageData defines the array buffer views of image data [mipmap][face]
  54654. * @returns a promise
  54655. */
  54656. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54657. /**
  54658. * Uploads spherical polynomials information to the texture.
  54659. * @param texture defines the texture we are trying to upload the information to
  54660. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54661. */
  54662. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54663. /** @hidden */
  54664. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54665. }
  54666. }
  54667. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54668. /**
  54669. * Class used to inline functions in shader code
  54670. */
  54671. export class ShaderCodeInliner {
  54672. private static readonly _RegexpFindFunctionNameAndType;
  54673. private _sourceCode;
  54674. private _functionDescr;
  54675. private _numMaxIterations;
  54676. /** Gets or sets the token used to mark the functions to inline */
  54677. inlineToken: string;
  54678. /** Gets or sets the debug mode */
  54679. debug: boolean;
  54680. /** Gets the code after the inlining process */
  54681. get code(): string;
  54682. /**
  54683. * Initializes the inliner
  54684. * @param sourceCode shader code source to inline
  54685. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54686. */
  54687. constructor(sourceCode: string, numMaxIterations?: number);
  54688. /**
  54689. * Start the processing of the shader code
  54690. */
  54691. processCode(): void;
  54692. private _collectFunctions;
  54693. private _processInlining;
  54694. private _extractBetweenMarkers;
  54695. private _skipWhitespaces;
  54696. private _removeComments;
  54697. private _replaceFunctionCallsByCode;
  54698. private _findBackward;
  54699. private _escapeRegExp;
  54700. private _replaceNames;
  54701. }
  54702. }
  54703. declare module "babylonjs/Engines/nativeEngine" {
  54704. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54705. import { Engine } from "babylonjs/Engines/engine";
  54706. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54709. import { Effect } from "babylonjs/Materials/effect";
  54710. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54711. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54712. import { IColor4Like } from "babylonjs/Maths/math.like";
  54713. import { Scene } from "babylonjs/scene";
  54714. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54715. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54716. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54717. /**
  54718. * Container for accessors for natively-stored mesh data buffers.
  54719. */
  54720. class NativeDataBuffer extends DataBuffer {
  54721. /**
  54722. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54723. */
  54724. nativeIndexBuffer?: any;
  54725. /**
  54726. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54727. */
  54728. nativeVertexBuffer?: any;
  54729. }
  54730. /** @hidden */
  54731. class NativeTexture extends InternalTexture {
  54732. getInternalTexture(): InternalTexture;
  54733. getViewCount(): number;
  54734. }
  54735. /** @hidden */
  54736. export class NativeEngine extends Engine {
  54737. private readonly _native;
  54738. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54739. private readonly INVALID_HANDLE;
  54740. private _boundBuffersVertexArray;
  54741. getHardwareScalingLevel(): number;
  54742. constructor();
  54743. dispose(): void;
  54744. /**
  54745. * Can be used to override the current requestAnimationFrame requester.
  54746. * @hidden
  54747. */
  54748. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54749. /**
  54750. * Override default engine behavior.
  54751. * @param color
  54752. * @param backBuffer
  54753. * @param depth
  54754. * @param stencil
  54755. */
  54756. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54757. /**
  54758. * Gets host document
  54759. * @returns the host document object
  54760. */
  54761. getHostDocument(): Nullable<Document>;
  54762. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54763. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54764. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54765. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54766. [key: string]: VertexBuffer;
  54767. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54768. bindBuffers(vertexBuffers: {
  54769. [key: string]: VertexBuffer;
  54770. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54771. recordVertexArrayObject(vertexBuffers: {
  54772. [key: string]: VertexBuffer;
  54773. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54774. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54775. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54776. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54777. /**
  54778. * Draw a list of indexed primitives
  54779. * @param fillMode defines the primitive to use
  54780. * @param indexStart defines the starting index
  54781. * @param indexCount defines the number of index to draw
  54782. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54783. */
  54784. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54785. /**
  54786. * Draw a list of unindexed primitives
  54787. * @param fillMode defines the primitive to use
  54788. * @param verticesStart defines the index of first vertex to draw
  54789. * @param verticesCount defines the count of vertices to draw
  54790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54791. */
  54792. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54793. createPipelineContext(): IPipelineContext;
  54794. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54795. /** @hidden */
  54796. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54797. /** @hidden */
  54798. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54799. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54800. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54801. protected _setProgram(program: WebGLProgram): void;
  54802. _releaseEffect(effect: Effect): void;
  54803. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54804. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54805. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54806. bindSamplers(effect: Effect): void;
  54807. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54808. getRenderWidth(useScreen?: boolean): number;
  54809. getRenderHeight(useScreen?: boolean): number;
  54810. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54811. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54812. /**
  54813. * Set the z offset to apply to current rendering
  54814. * @param value defines the offset to apply
  54815. */
  54816. setZOffset(value: number): void;
  54817. /**
  54818. * Gets the current value of the zOffset
  54819. * @returns the current zOffset state
  54820. */
  54821. getZOffset(): number;
  54822. /**
  54823. * Enable or disable depth buffering
  54824. * @param enable defines the state to set
  54825. */
  54826. setDepthBuffer(enable: boolean): void;
  54827. /**
  54828. * Gets a boolean indicating if depth writing is enabled
  54829. * @returns the current depth writing state
  54830. */
  54831. getDepthWrite(): boolean;
  54832. /**
  54833. * Enable or disable depth writing
  54834. * @param enable defines the state to set
  54835. */
  54836. setDepthWrite(enable: boolean): void;
  54837. /**
  54838. * Enable or disable color writing
  54839. * @param enable defines the state to set
  54840. */
  54841. setColorWrite(enable: boolean): void;
  54842. /**
  54843. * Gets a boolean indicating if color writing is enabled
  54844. * @returns the current color writing state
  54845. */
  54846. getColorWrite(): boolean;
  54847. /**
  54848. * Sets alpha constants used by some alpha blending modes
  54849. * @param r defines the red component
  54850. * @param g defines the green component
  54851. * @param b defines the blue component
  54852. * @param a defines the alpha component
  54853. */
  54854. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54855. /**
  54856. * Sets the current alpha mode
  54857. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54858. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54859. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54860. */
  54861. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54862. /**
  54863. * Gets the current alpha mode
  54864. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54865. * @returns the current alpha mode
  54866. */
  54867. getAlphaMode(): number;
  54868. setInt(uniform: WebGLUniformLocation, int: number): void;
  54869. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54870. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54871. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54872. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54873. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54874. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54875. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54876. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54877. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54878. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54879. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54880. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54881. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54882. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54883. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54884. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54885. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54886. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54887. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54888. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54889. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54890. wipeCaches(bruteForce?: boolean): void;
  54891. _createTexture(): WebGLTexture;
  54892. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54893. /**
  54894. * Usually called from Texture.ts.
  54895. * Passed information to create a WebGLTexture
  54896. * @param url defines a value which contains one of the following:
  54897. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54898. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54899. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54900. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54901. * @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)
  54902. * @param scene needed for loading to the correct scene
  54903. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54904. * @param onLoad optional callback to be called upon successful completion
  54905. * @param onError optional callback to be called upon failure
  54906. * @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
  54907. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54908. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54909. * @param forcedExtension defines the extension to use to pick the right loader
  54910. * @param mimeType defines an optional mime type
  54911. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54912. */
  54913. 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;
  54914. /**
  54915. * Creates a cube texture
  54916. * @param rootUrl defines the url where the files to load is located
  54917. * @param scene defines the current scene
  54918. * @param files defines the list of files to load (1 per face)
  54919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54920. * @param onLoad defines an optional callback raised when the texture is loaded
  54921. * @param onError defines an optional callback raised if there is an issue to load the texture
  54922. * @param format defines the format of the data
  54923. * @param forcedExtension defines the extension to use to pick the right loader
  54924. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54927. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54928. * @returns the cube texture as an InternalTexture
  54929. */
  54930. 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;
  54931. private _getSamplingFilter;
  54932. private static _GetNativeTextureFormat;
  54933. createRenderTargetTexture(size: number | {
  54934. width: number;
  54935. height: number;
  54936. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54937. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54938. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54939. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54940. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54941. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54942. /**
  54943. * Updates a dynamic vertex buffer.
  54944. * @param vertexBuffer the vertex buffer to update
  54945. * @param data the data used to update the vertex buffer
  54946. * @param byteOffset the byte offset of the data (optional)
  54947. * @param byteLength the byte length of the data (optional)
  54948. */
  54949. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54950. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54951. private _updateAnisotropicLevel;
  54952. private _getAddressMode;
  54953. /** @hidden */
  54954. _bindTexture(channel: number, texture: InternalTexture): void;
  54955. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54956. releaseEffects(): void;
  54957. /** @hidden */
  54958. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54959. /** @hidden */
  54960. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54961. /** @hidden */
  54962. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54963. /** @hidden */
  54964. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54965. }
  54966. }
  54967. declare module "babylonjs/Engines/index" {
  54968. export * from "babylonjs/Engines/constants";
  54969. export * from "babylonjs/Engines/engineCapabilities";
  54970. export * from "babylonjs/Engines/instancingAttributeInfo";
  54971. export * from "babylonjs/Engines/thinEngine";
  54972. export * from "babylonjs/Engines/engine";
  54973. export * from "babylonjs/Engines/engineStore";
  54974. export * from "babylonjs/Engines/nullEngine";
  54975. export * from "babylonjs/Engines/Extensions/index";
  54976. export * from "babylonjs/Engines/IPipelineContext";
  54977. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54978. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54979. export * from "babylonjs/Engines/nativeEngine";
  54980. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54981. export * from "babylonjs/Engines/performanceConfigurator";
  54982. }
  54983. declare module "babylonjs/Events/clipboardEvents" {
  54984. /**
  54985. * Gather the list of clipboard event types as constants.
  54986. */
  54987. export class ClipboardEventTypes {
  54988. /**
  54989. * The clipboard event is fired when a copy command is active (pressed).
  54990. */
  54991. static readonly COPY: number;
  54992. /**
  54993. * The clipboard event is fired when a cut command is active (pressed).
  54994. */
  54995. static readonly CUT: number;
  54996. /**
  54997. * The clipboard event is fired when a paste command is active (pressed).
  54998. */
  54999. static readonly PASTE: number;
  55000. }
  55001. /**
  55002. * This class is used to store clipboard related info for the onClipboardObservable event.
  55003. */
  55004. export class ClipboardInfo {
  55005. /**
  55006. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55007. */
  55008. type: number;
  55009. /**
  55010. * Defines the related dom event
  55011. */
  55012. event: ClipboardEvent;
  55013. /**
  55014. *Creates an instance of ClipboardInfo.
  55015. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55016. * @param event Defines the related dom event
  55017. */
  55018. constructor(
  55019. /**
  55020. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55021. */
  55022. type: number,
  55023. /**
  55024. * Defines the related dom event
  55025. */
  55026. event: ClipboardEvent);
  55027. /**
  55028. * Get the clipboard event's type from the keycode.
  55029. * @param keyCode Defines the keyCode for the current keyboard event.
  55030. * @return {number}
  55031. */
  55032. static GetTypeFromCharacter(keyCode: number): number;
  55033. }
  55034. }
  55035. declare module "babylonjs/Events/index" {
  55036. export * from "babylonjs/Events/keyboardEvents";
  55037. export * from "babylonjs/Events/pointerEvents";
  55038. export * from "babylonjs/Events/clipboardEvents";
  55039. }
  55040. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55041. import { Scene } from "babylonjs/scene";
  55042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55043. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55044. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55045. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55046. /**
  55047. * Google Daydream controller
  55048. */
  55049. export class DaydreamController extends WebVRController {
  55050. /**
  55051. * Base Url for the controller model.
  55052. */
  55053. static MODEL_BASE_URL: string;
  55054. /**
  55055. * File name for the controller model.
  55056. */
  55057. static MODEL_FILENAME: string;
  55058. /**
  55059. * Gamepad Id prefix used to identify Daydream Controller.
  55060. */
  55061. static readonly GAMEPAD_ID_PREFIX: string;
  55062. /**
  55063. * Creates a new DaydreamController from a gamepad
  55064. * @param vrGamepad the gamepad that the controller should be created from
  55065. */
  55066. constructor(vrGamepad: any);
  55067. /**
  55068. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55069. * @param scene scene in which to add meshes
  55070. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55071. */
  55072. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55073. /**
  55074. * Called once for each button that changed state since the last frame
  55075. * @param buttonIdx Which button index changed
  55076. * @param state New state of the button
  55077. * @param changes Which properties on the state changed since last frame
  55078. */
  55079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55080. }
  55081. }
  55082. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55083. import { Scene } from "babylonjs/scene";
  55084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55085. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55086. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55087. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55088. /**
  55089. * Gear VR Controller
  55090. */
  55091. export class GearVRController extends WebVRController {
  55092. /**
  55093. * Base Url for the controller model.
  55094. */
  55095. static MODEL_BASE_URL: string;
  55096. /**
  55097. * File name for the controller model.
  55098. */
  55099. static MODEL_FILENAME: string;
  55100. /**
  55101. * Gamepad Id prefix used to identify this controller.
  55102. */
  55103. static readonly GAMEPAD_ID_PREFIX: string;
  55104. private readonly _buttonIndexToObservableNameMap;
  55105. /**
  55106. * Creates a new GearVRController from a gamepad
  55107. * @param vrGamepad the gamepad that the controller should be created from
  55108. */
  55109. constructor(vrGamepad: any);
  55110. /**
  55111. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55112. * @param scene scene in which to add meshes
  55113. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55114. */
  55115. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55116. /**
  55117. * Called once for each button that changed state since the last frame
  55118. * @param buttonIdx Which button index changed
  55119. * @param state New state of the button
  55120. * @param changes Which properties on the state changed since last frame
  55121. */
  55122. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55123. }
  55124. }
  55125. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55126. import { Scene } from "babylonjs/scene";
  55127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55128. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55129. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55130. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55131. /**
  55132. * Generic Controller
  55133. */
  55134. export class GenericController extends WebVRController {
  55135. /**
  55136. * Base Url for the controller model.
  55137. */
  55138. static readonly MODEL_BASE_URL: string;
  55139. /**
  55140. * File name for the controller model.
  55141. */
  55142. static readonly MODEL_FILENAME: string;
  55143. /**
  55144. * Creates a new GenericController from a gamepad
  55145. * @param vrGamepad the gamepad that the controller should be created from
  55146. */
  55147. constructor(vrGamepad: any);
  55148. /**
  55149. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55150. * @param scene scene in which to add meshes
  55151. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55152. */
  55153. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55154. /**
  55155. * Called once for each button that changed state since the last frame
  55156. * @param buttonIdx Which button index changed
  55157. * @param state New state of the button
  55158. * @param changes Which properties on the state changed since last frame
  55159. */
  55160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55161. }
  55162. }
  55163. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55164. import { Observable } from "babylonjs/Misc/observable";
  55165. import { Scene } from "babylonjs/scene";
  55166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55167. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55168. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55169. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55170. /**
  55171. * Oculus Touch Controller
  55172. */
  55173. export class OculusTouchController extends WebVRController {
  55174. /**
  55175. * Base Url for the controller model.
  55176. */
  55177. static MODEL_BASE_URL: string;
  55178. /**
  55179. * File name for the left controller model.
  55180. */
  55181. static MODEL_LEFT_FILENAME: string;
  55182. /**
  55183. * File name for the right controller model.
  55184. */
  55185. static MODEL_RIGHT_FILENAME: string;
  55186. /**
  55187. * Base Url for the Quest controller model.
  55188. */
  55189. static QUEST_MODEL_BASE_URL: string;
  55190. /**
  55191. * @hidden
  55192. * If the controllers are running on a device that needs the updated Quest controller models
  55193. */
  55194. static _IsQuest: boolean;
  55195. /**
  55196. * Fired when the secondary trigger on this controller is modified
  55197. */
  55198. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55199. /**
  55200. * Fired when the thumb rest on this controller is modified
  55201. */
  55202. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55203. /**
  55204. * Creates a new OculusTouchController from a gamepad
  55205. * @param vrGamepad the gamepad that the controller should be created from
  55206. */
  55207. constructor(vrGamepad: any);
  55208. /**
  55209. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55210. * @param scene scene in which to add meshes
  55211. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55212. */
  55213. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55214. /**
  55215. * Fired when the A button on this controller is modified
  55216. */
  55217. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55218. /**
  55219. * Fired when the B button on this controller is modified
  55220. */
  55221. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55222. /**
  55223. * Fired when the X button on this controller is modified
  55224. */
  55225. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55226. /**
  55227. * Fired when the Y button on this controller is modified
  55228. */
  55229. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55230. /**
  55231. * Called once for each button that changed state since the last frame
  55232. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55233. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55234. * 2) secondary trigger (same)
  55235. * 3) A (right) X (left), touch, pressed = value
  55236. * 4) B / Y
  55237. * 5) thumb rest
  55238. * @param buttonIdx Which button index changed
  55239. * @param state New state of the button
  55240. * @param changes Which properties on the state changed since last frame
  55241. */
  55242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55243. }
  55244. }
  55245. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55246. import { Scene } from "babylonjs/scene";
  55247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55249. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55250. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55251. import { Observable } from "babylonjs/Misc/observable";
  55252. /**
  55253. * Vive Controller
  55254. */
  55255. export class ViveController extends WebVRController {
  55256. /**
  55257. * Base Url for the controller model.
  55258. */
  55259. static MODEL_BASE_URL: string;
  55260. /**
  55261. * File name for the controller model.
  55262. */
  55263. static MODEL_FILENAME: string;
  55264. /**
  55265. * Creates a new ViveController from a gamepad
  55266. * @param vrGamepad the gamepad that the controller should be created from
  55267. */
  55268. constructor(vrGamepad: any);
  55269. /**
  55270. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55271. * @param scene scene in which to add meshes
  55272. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55273. */
  55274. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55275. /**
  55276. * Fired when the left button on this controller is modified
  55277. */
  55278. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55279. /**
  55280. * Fired when the right button on this controller is modified
  55281. */
  55282. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55283. /**
  55284. * Fired when the menu button on this controller is modified
  55285. */
  55286. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55287. /**
  55288. * Called once for each button that changed state since the last frame
  55289. * Vive mapping:
  55290. * 0: touchpad
  55291. * 1: trigger
  55292. * 2: left AND right buttons
  55293. * 3: menu button
  55294. * @param buttonIdx Which button index changed
  55295. * @param state New state of the button
  55296. * @param changes Which properties on the state changed since last frame
  55297. */
  55298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55299. }
  55300. }
  55301. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55302. import { Observable } from "babylonjs/Misc/observable";
  55303. import { Scene } from "babylonjs/scene";
  55304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55305. import { Ray } from "babylonjs/Culling/ray";
  55306. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55307. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55308. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55309. /**
  55310. * Defines the WindowsMotionController object that the state of the windows motion controller
  55311. */
  55312. export class WindowsMotionController extends WebVRController {
  55313. /**
  55314. * The base url used to load the left and right controller models
  55315. */
  55316. static MODEL_BASE_URL: string;
  55317. /**
  55318. * The name of the left controller model file
  55319. */
  55320. static MODEL_LEFT_FILENAME: string;
  55321. /**
  55322. * The name of the right controller model file
  55323. */
  55324. static MODEL_RIGHT_FILENAME: string;
  55325. /**
  55326. * The controller name prefix for this controller type
  55327. */
  55328. static readonly GAMEPAD_ID_PREFIX: string;
  55329. /**
  55330. * The controller id pattern for this controller type
  55331. */
  55332. private static readonly GAMEPAD_ID_PATTERN;
  55333. private _loadedMeshInfo;
  55334. protected readonly _mapping: {
  55335. buttons: string[];
  55336. buttonMeshNames: {
  55337. trigger: string;
  55338. menu: string;
  55339. grip: string;
  55340. thumbstick: string;
  55341. trackpad: string;
  55342. };
  55343. buttonObservableNames: {
  55344. trigger: string;
  55345. menu: string;
  55346. grip: string;
  55347. thumbstick: string;
  55348. trackpad: string;
  55349. };
  55350. axisMeshNames: string[];
  55351. pointingPoseMeshName: string;
  55352. };
  55353. /**
  55354. * Fired when the trackpad on this controller is clicked
  55355. */
  55356. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55357. /**
  55358. * Fired when the trackpad on this controller is modified
  55359. */
  55360. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55361. /**
  55362. * The current x and y values of this controller's trackpad
  55363. */
  55364. trackpad: StickValues;
  55365. /**
  55366. * Creates a new WindowsMotionController from a gamepad
  55367. * @param vrGamepad the gamepad that the controller should be created from
  55368. */
  55369. constructor(vrGamepad: any);
  55370. /**
  55371. * Fired when the trigger on this controller is modified
  55372. */
  55373. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55374. /**
  55375. * Fired when the menu button on this controller is modified
  55376. */
  55377. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55378. /**
  55379. * Fired when the grip button on this controller is modified
  55380. */
  55381. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55382. /**
  55383. * Fired when the thumbstick button on this controller is modified
  55384. */
  55385. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55386. /**
  55387. * Fired when the touchpad button on this controller is modified
  55388. */
  55389. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55390. /**
  55391. * Fired when the touchpad values on this controller are modified
  55392. */
  55393. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55394. protected _updateTrackpad(): void;
  55395. /**
  55396. * Called once per frame by the engine.
  55397. */
  55398. update(): void;
  55399. /**
  55400. * Called once for each button that changed state since the last frame
  55401. * @param buttonIdx Which button index changed
  55402. * @param state New state of the button
  55403. * @param changes Which properties on the state changed since last frame
  55404. */
  55405. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55406. /**
  55407. * Moves the buttons on the controller mesh based on their current state
  55408. * @param buttonName the name of the button to move
  55409. * @param buttonValue the value of the button which determines the buttons new position
  55410. */
  55411. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55412. /**
  55413. * Moves the axis on the controller mesh based on its current state
  55414. * @param axis the index of the axis
  55415. * @param axisValue the value of the axis which determines the meshes new position
  55416. * @hidden
  55417. */
  55418. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55419. /**
  55420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55421. * @param scene scene in which to add meshes
  55422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55423. */
  55424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55425. /**
  55426. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55427. * can be transformed by button presses and axes values, based on this._mapping.
  55428. *
  55429. * @param scene scene in which the meshes exist
  55430. * @param meshes list of meshes that make up the controller model to process
  55431. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55432. */
  55433. private processModel;
  55434. private createMeshInfo;
  55435. /**
  55436. * Gets the ray of the controller in the direction the controller is pointing
  55437. * @param length the length the resulting ray should be
  55438. * @returns a ray in the direction the controller is pointing
  55439. */
  55440. getForwardRay(length?: number): Ray;
  55441. /**
  55442. * Disposes of the controller
  55443. */
  55444. dispose(): void;
  55445. }
  55446. /**
  55447. * This class represents a new windows motion controller in XR.
  55448. */
  55449. export class XRWindowsMotionController extends WindowsMotionController {
  55450. /**
  55451. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55452. */
  55453. protected readonly _mapping: {
  55454. buttons: string[];
  55455. buttonMeshNames: {
  55456. trigger: string;
  55457. menu: string;
  55458. grip: string;
  55459. thumbstick: string;
  55460. trackpad: string;
  55461. };
  55462. buttonObservableNames: {
  55463. trigger: string;
  55464. menu: string;
  55465. grip: string;
  55466. thumbstick: string;
  55467. trackpad: string;
  55468. };
  55469. axisMeshNames: string[];
  55470. pointingPoseMeshName: string;
  55471. };
  55472. /**
  55473. * Construct a new XR-Based windows motion controller
  55474. *
  55475. * @param gamepadInfo the gamepad object from the browser
  55476. */
  55477. constructor(gamepadInfo: any);
  55478. /**
  55479. * holds the thumbstick values (X,Y)
  55480. */
  55481. thumbstickValues: StickValues;
  55482. /**
  55483. * Fired when the thumbstick on this controller is clicked
  55484. */
  55485. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55486. /**
  55487. * Fired when the thumbstick on this controller is modified
  55488. */
  55489. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55490. /**
  55491. * Fired when the touchpad button on this controller is modified
  55492. */
  55493. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55494. /**
  55495. * Fired when the touchpad values on this controller are modified
  55496. */
  55497. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55498. /**
  55499. * Fired when the thumbstick button on this controller is modified
  55500. * here to prevent breaking changes
  55501. */
  55502. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55503. /**
  55504. * updating the thumbstick(!) and not the trackpad.
  55505. * This is named this way due to the difference between WebVR and XR and to avoid
  55506. * changing the parent class.
  55507. */
  55508. protected _updateTrackpad(): void;
  55509. /**
  55510. * Disposes the class with joy
  55511. */
  55512. dispose(): void;
  55513. }
  55514. }
  55515. declare module "babylonjs/Gamepads/Controllers/index" {
  55516. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55517. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55518. export * from "babylonjs/Gamepads/Controllers/genericController";
  55519. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55520. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55521. export * from "babylonjs/Gamepads/Controllers/viveController";
  55522. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55523. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55524. }
  55525. declare module "babylonjs/Gamepads/index" {
  55526. export * from "babylonjs/Gamepads/Controllers/index";
  55527. export * from "babylonjs/Gamepads/gamepad";
  55528. export * from "babylonjs/Gamepads/gamepadManager";
  55529. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55530. export * from "babylonjs/Gamepads/xboxGamepad";
  55531. export * from "babylonjs/Gamepads/dualShockGamepad";
  55532. }
  55533. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55534. import { Scene } from "babylonjs/scene";
  55535. import { Vector4 } from "babylonjs/Maths/math.vector";
  55536. import { Color4 } from "babylonjs/Maths/math.color";
  55537. import { Mesh } from "babylonjs/Meshes/mesh";
  55538. import { Nullable } from "babylonjs/types";
  55539. /**
  55540. * Class containing static functions to help procedurally build meshes
  55541. */
  55542. export class PolyhedronBuilder {
  55543. /**
  55544. * Creates a polyhedron mesh
  55545. * * 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
  55546. * * The parameter `size` (positive float, default 1) sets the polygon size
  55547. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55548. * * 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`
  55549. * * 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
  55550. * * 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)`)
  55551. * * 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
  55552. * * 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
  55553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55556. * @param name defines the name of the mesh
  55557. * @param options defines the options used to create the mesh
  55558. * @param scene defines the hosting scene
  55559. * @returns the polyhedron mesh
  55560. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55561. */
  55562. static CreatePolyhedron(name: string, options: {
  55563. type?: number;
  55564. size?: number;
  55565. sizeX?: number;
  55566. sizeY?: number;
  55567. sizeZ?: number;
  55568. custom?: any;
  55569. faceUV?: Vector4[];
  55570. faceColors?: Color4[];
  55571. flat?: boolean;
  55572. updatable?: boolean;
  55573. sideOrientation?: number;
  55574. frontUVs?: Vector4;
  55575. backUVs?: Vector4;
  55576. }, scene?: Nullable<Scene>): Mesh;
  55577. }
  55578. }
  55579. declare module "babylonjs/Gizmos/scaleGizmo" {
  55580. import { Observable } from "babylonjs/Misc/observable";
  55581. import { Nullable } from "babylonjs/types";
  55582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55583. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55584. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55585. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55586. import { Node } from "babylonjs/node";
  55587. /**
  55588. * Gizmo that enables scaling a mesh along 3 axis
  55589. */
  55590. export class ScaleGizmo extends Gizmo {
  55591. /**
  55592. * Internal gizmo used for interactions on the x axis
  55593. */
  55594. xGizmo: AxisScaleGizmo;
  55595. /**
  55596. * Internal gizmo used for interactions on the y axis
  55597. */
  55598. yGizmo: AxisScaleGizmo;
  55599. /**
  55600. * Internal gizmo used for interactions on the z axis
  55601. */
  55602. zGizmo: AxisScaleGizmo;
  55603. /**
  55604. * Internal gizmo used to scale all axis equally
  55605. */
  55606. uniformScaleGizmo: AxisScaleGizmo;
  55607. private _meshAttached;
  55608. private _nodeAttached;
  55609. private _updateGizmoRotationToMatchAttachedMesh;
  55610. private _snapDistance;
  55611. private _scaleRatio;
  55612. private _uniformScalingMesh;
  55613. private _octahedron;
  55614. private _sensitivity;
  55615. /** Fires an event when any of it's sub gizmos are dragged */
  55616. onDragStartObservable: Observable<unknown>;
  55617. /** Fires an event when any of it's sub gizmos are released from dragging */
  55618. onDragEndObservable: Observable<unknown>;
  55619. get attachedMesh(): Nullable<AbstractMesh>;
  55620. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55621. get attachedNode(): Nullable<Node>;
  55622. set attachedNode(node: Nullable<Node>);
  55623. /**
  55624. * Creates a ScaleGizmo
  55625. * @param gizmoLayer The utility layer the gizmo will be added to
  55626. * @param thickness display gizmo axis thickness
  55627. */
  55628. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55629. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55630. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55631. /**
  55632. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55633. */
  55634. set snapDistance(value: number);
  55635. get snapDistance(): number;
  55636. /**
  55637. * Ratio for the scale of the gizmo (Default: 1)
  55638. */
  55639. set scaleRatio(value: number);
  55640. get scaleRatio(): number;
  55641. /**
  55642. * Sensitivity factor for dragging (Default: 1)
  55643. */
  55644. set sensitivity(value: number);
  55645. get sensitivity(): number;
  55646. /**
  55647. * Disposes of the gizmo
  55648. */
  55649. dispose(): void;
  55650. }
  55651. }
  55652. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55653. import { Observable } from "babylonjs/Misc/observable";
  55654. import { Nullable } from "babylonjs/types";
  55655. import { Vector3 } from "babylonjs/Maths/math.vector";
  55656. import { Node } from "babylonjs/node";
  55657. import { Mesh } from "babylonjs/Meshes/mesh";
  55658. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55659. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55660. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55661. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55662. import { Color3 } from "babylonjs/Maths/math.color";
  55663. /**
  55664. * Single axis scale gizmo
  55665. */
  55666. export class AxisScaleGizmo extends Gizmo {
  55667. /**
  55668. * Drag behavior responsible for the gizmos dragging interactions
  55669. */
  55670. dragBehavior: PointerDragBehavior;
  55671. private _pointerObserver;
  55672. /**
  55673. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55674. */
  55675. snapDistance: number;
  55676. /**
  55677. * Event that fires each time the gizmo snaps to a new location.
  55678. * * snapDistance is the the change in distance
  55679. */
  55680. onSnapObservable: Observable<{
  55681. snapDistance: number;
  55682. }>;
  55683. /**
  55684. * If the scaling operation should be done on all axis (default: false)
  55685. */
  55686. uniformScaling: boolean;
  55687. /**
  55688. * Custom sensitivity value for the drag strength
  55689. */
  55690. sensitivity: number;
  55691. private _isEnabled;
  55692. private _parent;
  55693. private _arrow;
  55694. private _coloredMaterial;
  55695. private _hoverMaterial;
  55696. /**
  55697. * Creates an AxisScaleGizmo
  55698. * @param gizmoLayer The utility layer the gizmo will be added to
  55699. * @param dragAxis The axis which the gizmo will be able to scale on
  55700. * @param color The color of the gizmo
  55701. * @param thickness display gizmo axis thickness
  55702. */
  55703. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55704. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55705. /**
  55706. * If the gizmo is enabled
  55707. */
  55708. set isEnabled(value: boolean);
  55709. get isEnabled(): boolean;
  55710. /**
  55711. * Disposes of the gizmo
  55712. */
  55713. dispose(): void;
  55714. /**
  55715. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55716. * @param mesh The mesh to replace the default mesh of the gizmo
  55717. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55718. */
  55719. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55720. }
  55721. }
  55722. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55723. import { Observable } from "babylonjs/Misc/observable";
  55724. import { Nullable } from "babylonjs/types";
  55725. import { Vector3 } from "babylonjs/Maths/math.vector";
  55726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55727. import { Mesh } from "babylonjs/Meshes/mesh";
  55728. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55729. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55730. import { Color3 } from "babylonjs/Maths/math.color";
  55731. import "babylonjs/Meshes/Builders/boxBuilder";
  55732. /**
  55733. * Bounding box gizmo
  55734. */
  55735. export class BoundingBoxGizmo extends Gizmo {
  55736. private _lineBoundingBox;
  55737. private _rotateSpheresParent;
  55738. private _scaleBoxesParent;
  55739. private _boundingDimensions;
  55740. private _renderObserver;
  55741. private _pointerObserver;
  55742. private _scaleDragSpeed;
  55743. private _tmpQuaternion;
  55744. private _tmpVector;
  55745. private _tmpRotationMatrix;
  55746. /**
  55747. * 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)
  55748. */
  55749. ignoreChildren: boolean;
  55750. /**
  55751. * 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)
  55752. */
  55753. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55754. /**
  55755. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55756. */
  55757. rotationSphereSize: number;
  55758. /**
  55759. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55760. */
  55761. scaleBoxSize: number;
  55762. /**
  55763. * 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)
  55764. */
  55765. fixedDragMeshScreenSize: boolean;
  55766. /**
  55767. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55768. */
  55769. fixedDragMeshScreenSizeDistanceFactor: number;
  55770. /**
  55771. * Fired when a rotation sphere or scale box is dragged
  55772. */
  55773. onDragStartObservable: Observable<{}>;
  55774. /**
  55775. * Fired when a scale box is dragged
  55776. */
  55777. onScaleBoxDragObservable: Observable<{}>;
  55778. /**
  55779. * Fired when a scale box drag is ended
  55780. */
  55781. onScaleBoxDragEndObservable: Observable<{}>;
  55782. /**
  55783. * Fired when a rotation sphere is dragged
  55784. */
  55785. onRotationSphereDragObservable: Observable<{}>;
  55786. /**
  55787. * Fired when a rotation sphere drag is ended
  55788. */
  55789. onRotationSphereDragEndObservable: Observable<{}>;
  55790. /**
  55791. * 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)
  55792. */
  55793. scalePivot: Nullable<Vector3>;
  55794. /**
  55795. * Mesh used as a pivot to rotate the attached node
  55796. */
  55797. private _anchorMesh;
  55798. private _existingMeshScale;
  55799. private _dragMesh;
  55800. private pointerDragBehavior;
  55801. private coloredMaterial;
  55802. private hoverColoredMaterial;
  55803. /**
  55804. * Sets the color of the bounding box gizmo
  55805. * @param color the color to set
  55806. */
  55807. setColor(color: Color3): void;
  55808. /**
  55809. * Creates an BoundingBoxGizmo
  55810. * @param gizmoLayer The utility layer the gizmo will be added to
  55811. * @param color The color of the gizmo
  55812. */
  55813. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55814. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55815. private _selectNode;
  55816. /**
  55817. * Updates the bounding box information for the Gizmo
  55818. */
  55819. updateBoundingBox(): void;
  55820. private _updateRotationSpheres;
  55821. private _updateScaleBoxes;
  55822. /**
  55823. * Enables rotation on the specified axis and disables rotation on the others
  55824. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55825. */
  55826. setEnabledRotationAxis(axis: string): void;
  55827. /**
  55828. * Enables/disables scaling
  55829. * @param enable if scaling should be enabled
  55830. * @param homogeneousScaling defines if scaling should only be homogeneous
  55831. */
  55832. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55833. private _updateDummy;
  55834. /**
  55835. * Enables a pointer drag behavior on the bounding box of the gizmo
  55836. */
  55837. enableDragBehavior(): void;
  55838. /**
  55839. * Disposes of the gizmo
  55840. */
  55841. dispose(): void;
  55842. /**
  55843. * 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)
  55844. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55845. * @returns the bounding box mesh with the passed in mesh as a child
  55846. */
  55847. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55848. /**
  55849. * CustomMeshes are not supported by this gizmo
  55850. * @param mesh The mesh to replace the default mesh of the gizmo
  55851. */
  55852. setCustomMesh(mesh: Mesh): void;
  55853. }
  55854. }
  55855. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55856. import { Observable } from "babylonjs/Misc/observable";
  55857. import { Nullable } from "babylonjs/types";
  55858. import { Vector3 } from "babylonjs/Maths/math.vector";
  55859. import { Color3 } from "babylonjs/Maths/math.color";
  55860. import { Node } from "babylonjs/node";
  55861. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55862. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55863. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55864. import "babylonjs/Meshes/Builders/linesBuilder";
  55865. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55866. /**
  55867. * Single plane rotation gizmo
  55868. */
  55869. export class PlaneRotationGizmo extends Gizmo {
  55870. /**
  55871. * Drag behavior responsible for the gizmos dragging interactions
  55872. */
  55873. dragBehavior: PointerDragBehavior;
  55874. private _pointerObserver;
  55875. /**
  55876. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55877. */
  55878. snapDistance: number;
  55879. /**
  55880. * Event that fires each time the gizmo snaps to a new location.
  55881. * * snapDistance is the the change in distance
  55882. */
  55883. onSnapObservable: Observable<{
  55884. snapDistance: number;
  55885. }>;
  55886. private _isEnabled;
  55887. private _parent;
  55888. /**
  55889. * Creates a PlaneRotationGizmo
  55890. * @param gizmoLayer The utility layer the gizmo will be added to
  55891. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55892. * @param color The color of the gizmo
  55893. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55894. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55895. * @param thickness display gizmo axis thickness
  55896. */
  55897. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55898. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55899. /**
  55900. * If the gizmo is enabled
  55901. */
  55902. set isEnabled(value: boolean);
  55903. get isEnabled(): boolean;
  55904. /**
  55905. * Disposes of the gizmo
  55906. */
  55907. dispose(): void;
  55908. }
  55909. }
  55910. declare module "babylonjs/Gizmos/rotationGizmo" {
  55911. import { Observable } from "babylonjs/Misc/observable";
  55912. import { Nullable } from "babylonjs/types";
  55913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55914. import { Mesh } from "babylonjs/Meshes/mesh";
  55915. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55916. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55917. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55918. import { Node } from "babylonjs/node";
  55919. /**
  55920. * Gizmo that enables rotating a mesh along 3 axis
  55921. */
  55922. export class RotationGizmo extends Gizmo {
  55923. /**
  55924. * Internal gizmo used for interactions on the x axis
  55925. */
  55926. xGizmo: PlaneRotationGizmo;
  55927. /**
  55928. * Internal gizmo used for interactions on the y axis
  55929. */
  55930. yGizmo: PlaneRotationGizmo;
  55931. /**
  55932. * Internal gizmo used for interactions on the z axis
  55933. */
  55934. zGizmo: PlaneRotationGizmo;
  55935. /** Fires an event when any of it's sub gizmos are dragged */
  55936. onDragStartObservable: Observable<unknown>;
  55937. /** Fires an event when any of it's sub gizmos are released from dragging */
  55938. onDragEndObservable: Observable<unknown>;
  55939. private _meshAttached;
  55940. private _nodeAttached;
  55941. get attachedMesh(): Nullable<AbstractMesh>;
  55942. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55943. get attachedNode(): Nullable<Node>;
  55944. set attachedNode(node: Nullable<Node>);
  55945. /**
  55946. * Creates a RotationGizmo
  55947. * @param gizmoLayer The utility layer the gizmo will be added to
  55948. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55949. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55950. * @param thickness display gizmo axis thickness
  55951. */
  55952. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55953. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55954. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55955. /**
  55956. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55957. */
  55958. set snapDistance(value: number);
  55959. get snapDistance(): number;
  55960. /**
  55961. * Ratio for the scale of the gizmo (Default: 1)
  55962. */
  55963. set scaleRatio(value: number);
  55964. get scaleRatio(): number;
  55965. /**
  55966. * Disposes of the gizmo
  55967. */
  55968. dispose(): void;
  55969. /**
  55970. * CustomMeshes are not supported by this gizmo
  55971. * @param mesh The mesh to replace the default mesh of the gizmo
  55972. */
  55973. setCustomMesh(mesh: Mesh): void;
  55974. }
  55975. }
  55976. declare module "babylonjs/Gizmos/gizmoManager" {
  55977. import { Observable } from "babylonjs/Misc/observable";
  55978. import { Nullable } from "babylonjs/types";
  55979. import { Scene, IDisposable } from "babylonjs/scene";
  55980. import { Node } from "babylonjs/node";
  55981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55982. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55983. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55984. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55985. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55986. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55987. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55988. /**
  55989. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  55990. */
  55991. export class GizmoManager implements IDisposable {
  55992. private scene;
  55993. /**
  55994. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55995. */
  55996. gizmos: {
  55997. positionGizmo: Nullable<PositionGizmo>;
  55998. rotationGizmo: Nullable<RotationGizmo>;
  55999. scaleGizmo: Nullable<ScaleGizmo>;
  56000. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56001. };
  56002. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56003. clearGizmoOnEmptyPointerEvent: boolean;
  56004. /** Fires an event when the manager is attached to a mesh */
  56005. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56006. /** Fires an event when the manager is attached to a node */
  56007. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56008. private _gizmosEnabled;
  56009. private _pointerObserver;
  56010. private _attachedMesh;
  56011. private _attachedNode;
  56012. private _boundingBoxColor;
  56013. private _defaultUtilityLayer;
  56014. private _defaultKeepDepthUtilityLayer;
  56015. private _thickness;
  56016. /**
  56017. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56018. */
  56019. boundingBoxDragBehavior: SixDofDragBehavior;
  56020. /**
  56021. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56022. */
  56023. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56024. /**
  56025. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56026. */
  56027. attachableNodes: Nullable<Array<Node>>;
  56028. /**
  56029. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56030. */
  56031. usePointerToAttachGizmos: boolean;
  56032. /**
  56033. * Utility layer that the bounding box gizmo belongs to
  56034. */
  56035. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56036. /**
  56037. * Utility layer that all gizmos besides bounding box belong to
  56038. */
  56039. get utilityLayer(): UtilityLayerRenderer;
  56040. /**
  56041. * Instatiates a gizmo manager
  56042. * @param scene the scene to overlay the gizmos on top of
  56043. * @param thickness display gizmo axis thickness
  56044. */
  56045. constructor(scene: Scene, thickness?: number);
  56046. /**
  56047. * Attaches a set of gizmos to the specified mesh
  56048. * @param mesh The mesh the gizmo's should be attached to
  56049. */
  56050. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56051. /**
  56052. * Attaches a set of gizmos to the specified node
  56053. * @param node The node the gizmo's should be attached to
  56054. */
  56055. attachToNode(node: Nullable<Node>): void;
  56056. /**
  56057. * If the position gizmo is enabled
  56058. */
  56059. set positionGizmoEnabled(value: boolean);
  56060. get positionGizmoEnabled(): boolean;
  56061. /**
  56062. * If the rotation gizmo is enabled
  56063. */
  56064. set rotationGizmoEnabled(value: boolean);
  56065. get rotationGizmoEnabled(): boolean;
  56066. /**
  56067. * If the scale gizmo is enabled
  56068. */
  56069. set scaleGizmoEnabled(value: boolean);
  56070. get scaleGizmoEnabled(): boolean;
  56071. /**
  56072. * If the boundingBox gizmo is enabled
  56073. */
  56074. set boundingBoxGizmoEnabled(value: boolean);
  56075. get boundingBoxGizmoEnabled(): boolean;
  56076. /**
  56077. * Disposes of the gizmo manager
  56078. */
  56079. dispose(): void;
  56080. }
  56081. }
  56082. declare module "babylonjs/Lights/directionalLight" {
  56083. import { Camera } from "babylonjs/Cameras/camera";
  56084. import { Scene } from "babylonjs/scene";
  56085. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56087. import { Light } from "babylonjs/Lights/light";
  56088. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56089. import { Effect } from "babylonjs/Materials/effect";
  56090. /**
  56091. * A directional light is defined by a direction (what a surprise!).
  56092. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56093. * 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.
  56094. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56095. */
  56096. export class DirectionalLight extends ShadowLight {
  56097. private _shadowFrustumSize;
  56098. /**
  56099. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56100. */
  56101. get shadowFrustumSize(): number;
  56102. /**
  56103. * Specifies a fix frustum size for the shadow generation.
  56104. */
  56105. set shadowFrustumSize(value: number);
  56106. private _shadowOrthoScale;
  56107. /**
  56108. * Gets the shadow projection scale against the optimal computed one.
  56109. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56110. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56111. */
  56112. get shadowOrthoScale(): number;
  56113. /**
  56114. * Sets the shadow projection scale against the optimal computed one.
  56115. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56116. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56117. */
  56118. set shadowOrthoScale(value: number);
  56119. /**
  56120. * Automatically compute the projection matrix to best fit (including all the casters)
  56121. * on each frame.
  56122. */
  56123. autoUpdateExtends: boolean;
  56124. /**
  56125. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56126. * on each frame. autoUpdateExtends must be set to true for this to work
  56127. */
  56128. autoCalcShadowZBounds: boolean;
  56129. private _orthoLeft;
  56130. private _orthoRight;
  56131. private _orthoTop;
  56132. private _orthoBottom;
  56133. /**
  56134. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56135. * The directional light is emitted from everywhere in the given direction.
  56136. * It can cast shadows.
  56137. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56138. * @param name The friendly name of the light
  56139. * @param direction The direction of the light
  56140. * @param scene The scene the light belongs to
  56141. */
  56142. constructor(name: string, direction: Vector3, scene: Scene);
  56143. /**
  56144. * Returns the string "DirectionalLight".
  56145. * @return The class name
  56146. */
  56147. getClassName(): string;
  56148. /**
  56149. * Returns the integer 1.
  56150. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56151. */
  56152. getTypeID(): number;
  56153. /**
  56154. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56155. * Returns the DirectionalLight Shadow projection matrix.
  56156. */
  56157. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56158. /**
  56159. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56160. * Returns the DirectionalLight Shadow projection matrix.
  56161. */
  56162. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56163. /**
  56164. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56165. * Returns the DirectionalLight Shadow projection matrix.
  56166. */
  56167. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56168. protected _buildUniformLayout(): void;
  56169. /**
  56170. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56171. * @param effect The effect to update
  56172. * @param lightIndex The index of the light in the effect to update
  56173. * @returns The directional light
  56174. */
  56175. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56176. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56177. /**
  56178. * Gets the minZ used for shadow according to both the scene and the light.
  56179. *
  56180. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56181. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56182. * @param activeCamera The camera we are returning the min for
  56183. * @returns the depth min z
  56184. */
  56185. getDepthMinZ(activeCamera: Camera): number;
  56186. /**
  56187. * Gets the maxZ used for shadow according to both the scene and the light.
  56188. *
  56189. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56190. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56191. * @param activeCamera The camera we are returning the max for
  56192. * @returns the depth max z
  56193. */
  56194. getDepthMaxZ(activeCamera: Camera): number;
  56195. /**
  56196. * Prepares the list of defines specific to the light type.
  56197. * @param defines the list of defines
  56198. * @param lightIndex defines the index of the light for the effect
  56199. */
  56200. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56201. }
  56202. }
  56203. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56204. import { Mesh } from "babylonjs/Meshes/mesh";
  56205. /**
  56206. * Class containing static functions to help procedurally build meshes
  56207. */
  56208. export class HemisphereBuilder {
  56209. /**
  56210. * Creates a hemisphere mesh
  56211. * @param name defines the name of the mesh
  56212. * @param options defines the options used to create the mesh
  56213. * @param scene defines the hosting scene
  56214. * @returns the hemisphere mesh
  56215. */
  56216. static CreateHemisphere(name: string, options: {
  56217. segments?: number;
  56218. diameter?: number;
  56219. sideOrientation?: number;
  56220. }, scene: any): Mesh;
  56221. }
  56222. }
  56223. declare module "babylonjs/Lights/spotLight" {
  56224. import { Nullable } from "babylonjs/types";
  56225. import { Scene } from "babylonjs/scene";
  56226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56228. import { Effect } from "babylonjs/Materials/effect";
  56229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56230. import { Light } from "babylonjs/Lights/light";
  56231. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56232. /**
  56233. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56234. * These values define a cone of light starting from the position, emitting toward the direction.
  56235. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56236. * and the exponent defines the speed of the decay of the light with distance (reach).
  56237. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56238. */
  56239. export class SpotLight extends ShadowLight {
  56240. private _angle;
  56241. private _innerAngle;
  56242. private _cosHalfAngle;
  56243. private _lightAngleScale;
  56244. private _lightAngleOffset;
  56245. /**
  56246. * Gets the cone angle of the spot light in Radians.
  56247. */
  56248. get angle(): number;
  56249. /**
  56250. * Sets the cone angle of the spot light in Radians.
  56251. */
  56252. set angle(value: number);
  56253. /**
  56254. * Only used in gltf falloff mode, this defines the angle where
  56255. * the directional falloff will start before cutting at angle which could be seen
  56256. * as outer angle.
  56257. */
  56258. get innerAngle(): number;
  56259. /**
  56260. * Only used in gltf falloff mode, this defines the angle where
  56261. * the directional falloff will start before cutting at angle which could be seen
  56262. * as outer angle.
  56263. */
  56264. set innerAngle(value: number);
  56265. private _shadowAngleScale;
  56266. /**
  56267. * Allows scaling the angle of the light for shadow generation only.
  56268. */
  56269. get shadowAngleScale(): number;
  56270. /**
  56271. * Allows scaling the angle of the light for shadow generation only.
  56272. */
  56273. set shadowAngleScale(value: number);
  56274. /**
  56275. * The light decay speed with the distance from the emission spot.
  56276. */
  56277. exponent: number;
  56278. private _projectionTextureMatrix;
  56279. /**
  56280. * Allows reading the projecton texture
  56281. */
  56282. get projectionTextureMatrix(): Matrix;
  56283. protected _projectionTextureLightNear: number;
  56284. /**
  56285. * Gets the near clip of the Spotlight for texture projection.
  56286. */
  56287. get projectionTextureLightNear(): number;
  56288. /**
  56289. * Sets the near clip of the Spotlight for texture projection.
  56290. */
  56291. set projectionTextureLightNear(value: number);
  56292. protected _projectionTextureLightFar: number;
  56293. /**
  56294. * Gets the far clip of the Spotlight for texture projection.
  56295. */
  56296. get projectionTextureLightFar(): number;
  56297. /**
  56298. * Sets the far clip of the Spotlight for texture projection.
  56299. */
  56300. set projectionTextureLightFar(value: number);
  56301. protected _projectionTextureUpDirection: Vector3;
  56302. /**
  56303. * Gets the Up vector of the Spotlight for texture projection.
  56304. */
  56305. get projectionTextureUpDirection(): Vector3;
  56306. /**
  56307. * Sets the Up vector of the Spotlight for texture projection.
  56308. */
  56309. set projectionTextureUpDirection(value: Vector3);
  56310. private _projectionTexture;
  56311. /**
  56312. * Gets the projection texture of the light.
  56313. */
  56314. get projectionTexture(): Nullable<BaseTexture>;
  56315. /**
  56316. * Sets the projection texture of the light.
  56317. */
  56318. set projectionTexture(value: Nullable<BaseTexture>);
  56319. private _projectionTextureViewLightDirty;
  56320. private _projectionTextureProjectionLightDirty;
  56321. private _projectionTextureDirty;
  56322. private _projectionTextureViewTargetVector;
  56323. private _projectionTextureViewLightMatrix;
  56324. private _projectionTextureProjectionLightMatrix;
  56325. private _projectionTextureScalingMatrix;
  56326. /**
  56327. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56328. * It can cast shadows.
  56329. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56330. * @param name The light friendly name
  56331. * @param position The position of the spot light in the scene
  56332. * @param direction The direction of the light in the scene
  56333. * @param angle The cone angle of the light in Radians
  56334. * @param exponent The light decay speed with the distance from the emission spot
  56335. * @param scene The scene the lights belongs to
  56336. */
  56337. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56338. /**
  56339. * Returns the string "SpotLight".
  56340. * @returns the class name
  56341. */
  56342. getClassName(): string;
  56343. /**
  56344. * Returns the integer 2.
  56345. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56346. */
  56347. getTypeID(): number;
  56348. /**
  56349. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56350. */
  56351. protected _setDirection(value: Vector3): void;
  56352. /**
  56353. * Overrides the position setter to recompute the projection texture view light Matrix.
  56354. */
  56355. protected _setPosition(value: Vector3): void;
  56356. /**
  56357. * 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.
  56358. * Returns the SpotLight.
  56359. */
  56360. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56361. protected _computeProjectionTextureViewLightMatrix(): void;
  56362. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56363. /**
  56364. * Main function for light texture projection matrix computing.
  56365. */
  56366. protected _computeProjectionTextureMatrix(): void;
  56367. protected _buildUniformLayout(): void;
  56368. private _computeAngleValues;
  56369. /**
  56370. * Sets the passed Effect "effect" with the Light textures.
  56371. * @param effect The effect to update
  56372. * @param lightIndex The index of the light in the effect to update
  56373. * @returns The light
  56374. */
  56375. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56376. /**
  56377. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56378. * @param effect The effect to update
  56379. * @param lightIndex The index of the light in the effect to update
  56380. * @returns The spot light
  56381. */
  56382. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56383. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56384. /**
  56385. * Disposes the light and the associated resources.
  56386. */
  56387. dispose(): void;
  56388. /**
  56389. * Prepares the list of defines specific to the light type.
  56390. * @param defines the list of defines
  56391. * @param lightIndex defines the index of the light for the effect
  56392. */
  56393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56394. }
  56395. }
  56396. declare module "babylonjs/Gizmos/lightGizmo" {
  56397. import { Nullable } from "babylonjs/types";
  56398. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56399. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56400. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56401. import { Light } from "babylonjs/Lights/light";
  56402. /**
  56403. * Gizmo that enables viewing a light
  56404. */
  56405. export class LightGizmo extends Gizmo {
  56406. private _lightMesh;
  56407. private _material;
  56408. private _cachedPosition;
  56409. private _cachedForward;
  56410. private _attachedMeshParent;
  56411. /**
  56412. * Creates a LightGizmo
  56413. * @param gizmoLayer The utility layer the gizmo will be added to
  56414. */
  56415. constructor(gizmoLayer?: UtilityLayerRenderer);
  56416. private _light;
  56417. /**
  56418. * The light that the gizmo is attached to
  56419. */
  56420. set light(light: Nullable<Light>);
  56421. get light(): Nullable<Light>;
  56422. /**
  56423. * Gets the material used to render the light gizmo
  56424. */
  56425. get material(): StandardMaterial;
  56426. /**
  56427. * @hidden
  56428. * Updates the gizmo to match the attached mesh's position/rotation
  56429. */
  56430. protected _update(): void;
  56431. private static _Scale;
  56432. /**
  56433. * Creates the lines for a light mesh
  56434. */
  56435. private static _CreateLightLines;
  56436. /**
  56437. * Disposes of the light gizmo
  56438. */
  56439. dispose(): void;
  56440. private static _CreateHemisphericLightMesh;
  56441. private static _CreatePointLightMesh;
  56442. private static _CreateSpotLightMesh;
  56443. private static _CreateDirectionalLightMesh;
  56444. }
  56445. }
  56446. declare module "babylonjs/Gizmos/cameraGizmo" {
  56447. import { Nullable } from "babylonjs/types";
  56448. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56449. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56450. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56451. import { Camera } from "babylonjs/Cameras/camera";
  56452. /**
  56453. * Gizmo that enables viewing a camera
  56454. */
  56455. export class CameraGizmo extends Gizmo {
  56456. private _cameraMesh;
  56457. private _cameraLinesMesh;
  56458. private _material;
  56459. /**
  56460. * Creates a CameraGizmo
  56461. * @param gizmoLayer The utility layer the gizmo will be added to
  56462. */
  56463. constructor(gizmoLayer?: UtilityLayerRenderer);
  56464. private _camera;
  56465. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56466. get displayFrustum(): boolean;
  56467. set displayFrustum(value: boolean);
  56468. /**
  56469. * The camera that the gizmo is attached to
  56470. */
  56471. set camera(camera: Nullable<Camera>);
  56472. get camera(): Nullable<Camera>;
  56473. /**
  56474. * Gets the material used to render the camera gizmo
  56475. */
  56476. get material(): StandardMaterial;
  56477. /**
  56478. * @hidden
  56479. * Updates the gizmo to match the attached mesh's position/rotation
  56480. */
  56481. protected _update(): void;
  56482. private static _Scale;
  56483. private _invProjection;
  56484. /**
  56485. * Disposes of the camera gizmo
  56486. */
  56487. dispose(): void;
  56488. private static _CreateCameraMesh;
  56489. private static _CreateCameraFrustum;
  56490. }
  56491. }
  56492. declare module "babylonjs/Gizmos/index" {
  56493. export * from "babylonjs/Gizmos/axisDragGizmo";
  56494. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56495. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56496. export * from "babylonjs/Gizmos/gizmo";
  56497. export * from "babylonjs/Gizmos/gizmoManager";
  56498. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56499. export * from "babylonjs/Gizmos/positionGizmo";
  56500. export * from "babylonjs/Gizmos/rotationGizmo";
  56501. export * from "babylonjs/Gizmos/scaleGizmo";
  56502. export * from "babylonjs/Gizmos/lightGizmo";
  56503. export * from "babylonjs/Gizmos/cameraGizmo";
  56504. export * from "babylonjs/Gizmos/planeDragGizmo";
  56505. }
  56506. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56507. /** @hidden */
  56508. export var backgroundFragmentDeclaration: {
  56509. name: string;
  56510. shader: string;
  56511. };
  56512. }
  56513. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56514. /** @hidden */
  56515. export var backgroundUboDeclaration: {
  56516. name: string;
  56517. shader: string;
  56518. };
  56519. }
  56520. declare module "babylonjs/Shaders/background.fragment" {
  56521. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56522. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56523. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56524. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56525. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56526. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56527. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56528. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56529. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56530. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56531. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56532. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56533. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56534. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56535. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56536. /** @hidden */
  56537. export var backgroundPixelShader: {
  56538. name: string;
  56539. shader: string;
  56540. };
  56541. }
  56542. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56543. /** @hidden */
  56544. export var backgroundVertexDeclaration: {
  56545. name: string;
  56546. shader: string;
  56547. };
  56548. }
  56549. declare module "babylonjs/Shaders/background.vertex" {
  56550. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56551. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56552. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56553. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56554. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56555. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56556. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56557. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56558. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56559. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56560. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56561. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56562. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56563. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56564. /** @hidden */
  56565. export var backgroundVertexShader: {
  56566. name: string;
  56567. shader: string;
  56568. };
  56569. }
  56570. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56571. import { Nullable, int, float } from "babylonjs/types";
  56572. import { Scene } from "babylonjs/scene";
  56573. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56574. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56576. import { Mesh } from "babylonjs/Meshes/mesh";
  56577. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56578. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56579. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56580. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56581. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56582. import { Color3 } from "babylonjs/Maths/math.color";
  56583. import "babylonjs/Shaders/background.fragment";
  56584. import "babylonjs/Shaders/background.vertex";
  56585. /**
  56586. * Background material used to create an efficient environement around your scene.
  56587. */
  56588. export class BackgroundMaterial extends PushMaterial {
  56589. /**
  56590. * Standard reflectance value at parallel view angle.
  56591. */
  56592. static StandardReflectance0: number;
  56593. /**
  56594. * Standard reflectance value at grazing angle.
  56595. */
  56596. static StandardReflectance90: number;
  56597. protected _primaryColor: Color3;
  56598. /**
  56599. * Key light Color (multiply against the environement texture)
  56600. */
  56601. primaryColor: Color3;
  56602. protected __perceptualColor: Nullable<Color3>;
  56603. /**
  56604. * Experimental Internal Use Only.
  56605. *
  56606. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56607. * This acts as a helper to set the primary color to a more "human friendly" value.
  56608. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56609. * output color as close as possible from the chosen value.
  56610. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56611. * part of lighting setup.)
  56612. */
  56613. get _perceptualColor(): Nullable<Color3>;
  56614. set _perceptualColor(value: Nullable<Color3>);
  56615. protected _primaryColorShadowLevel: float;
  56616. /**
  56617. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56618. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56619. */
  56620. get primaryColorShadowLevel(): float;
  56621. set primaryColorShadowLevel(value: float);
  56622. protected _primaryColorHighlightLevel: float;
  56623. /**
  56624. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56625. * The primary color is used at the level chosen to define what the white area would look.
  56626. */
  56627. get primaryColorHighlightLevel(): float;
  56628. set primaryColorHighlightLevel(value: float);
  56629. protected _reflectionTexture: Nullable<BaseTexture>;
  56630. /**
  56631. * Reflection Texture used in the material.
  56632. * Should be author in a specific way for the best result (refer to the documentation).
  56633. */
  56634. reflectionTexture: Nullable<BaseTexture>;
  56635. protected _reflectionBlur: float;
  56636. /**
  56637. * Reflection Texture level of blur.
  56638. *
  56639. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56640. * texture twice.
  56641. */
  56642. reflectionBlur: float;
  56643. protected _diffuseTexture: Nullable<BaseTexture>;
  56644. /**
  56645. * Diffuse Texture used in the material.
  56646. * Should be author in a specific way for the best result (refer to the documentation).
  56647. */
  56648. diffuseTexture: Nullable<BaseTexture>;
  56649. protected _shadowLights: Nullable<IShadowLight[]>;
  56650. /**
  56651. * Specify the list of lights casting shadow on the material.
  56652. * All scene shadow lights will be included if null.
  56653. */
  56654. shadowLights: Nullable<IShadowLight[]>;
  56655. protected _shadowLevel: float;
  56656. /**
  56657. * Helps adjusting the shadow to a softer level if required.
  56658. * 0 means black shadows and 1 means no shadows.
  56659. */
  56660. shadowLevel: float;
  56661. protected _sceneCenter: Vector3;
  56662. /**
  56663. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56664. * It is usually zero but might be interesting to modify according to your setup.
  56665. */
  56666. sceneCenter: Vector3;
  56667. protected _opacityFresnel: boolean;
  56668. /**
  56669. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56670. * This helps ensuring a nice transition when the camera goes under the ground.
  56671. */
  56672. opacityFresnel: boolean;
  56673. protected _reflectionFresnel: boolean;
  56674. /**
  56675. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56676. * This helps adding a mirror texture on the ground.
  56677. */
  56678. reflectionFresnel: boolean;
  56679. protected _reflectionFalloffDistance: number;
  56680. /**
  56681. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56682. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56683. */
  56684. reflectionFalloffDistance: number;
  56685. protected _reflectionAmount: number;
  56686. /**
  56687. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56688. */
  56689. reflectionAmount: number;
  56690. protected _reflectionReflectance0: number;
  56691. /**
  56692. * This specifies the weight of the reflection at grazing angle.
  56693. */
  56694. reflectionReflectance0: number;
  56695. protected _reflectionReflectance90: number;
  56696. /**
  56697. * This specifies the weight of the reflection at a perpendicular point of view.
  56698. */
  56699. reflectionReflectance90: number;
  56700. /**
  56701. * Sets the reflection reflectance fresnel values according to the default standard
  56702. * empirically know to work well :-)
  56703. */
  56704. set reflectionStandardFresnelWeight(value: number);
  56705. protected _useRGBColor: boolean;
  56706. /**
  56707. * Helps to directly use the maps channels instead of their level.
  56708. */
  56709. useRGBColor: boolean;
  56710. protected _enableNoise: boolean;
  56711. /**
  56712. * This helps reducing the banding effect that could occur on the background.
  56713. */
  56714. enableNoise: boolean;
  56715. /**
  56716. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56717. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56718. * Recommended to be keep at 1.0 except for special cases.
  56719. */
  56720. get fovMultiplier(): number;
  56721. set fovMultiplier(value: number);
  56722. private _fovMultiplier;
  56723. /**
  56724. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56725. */
  56726. useEquirectangularFOV: boolean;
  56727. private _maxSimultaneousLights;
  56728. /**
  56729. * Number of Simultaneous lights allowed on the material.
  56730. */
  56731. maxSimultaneousLights: int;
  56732. private _shadowOnly;
  56733. /**
  56734. * Make the material only render shadows
  56735. */
  56736. shadowOnly: boolean;
  56737. /**
  56738. * Default configuration related to image processing available in the Background Material.
  56739. */
  56740. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56741. /**
  56742. * Keep track of the image processing observer to allow dispose and replace.
  56743. */
  56744. private _imageProcessingObserver;
  56745. /**
  56746. * Attaches a new image processing configuration to the PBR Material.
  56747. * @param configuration (if null the scene configuration will be use)
  56748. */
  56749. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56750. /**
  56751. * Gets the image processing configuration used either in this material.
  56752. */
  56753. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56754. /**
  56755. * Sets the Default image processing configuration used either in the this material.
  56756. *
  56757. * If sets to null, the scene one is in use.
  56758. */
  56759. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56760. /**
  56761. * Gets wether the color curves effect is enabled.
  56762. */
  56763. get cameraColorCurvesEnabled(): boolean;
  56764. /**
  56765. * Sets wether the color curves effect is enabled.
  56766. */
  56767. set cameraColorCurvesEnabled(value: boolean);
  56768. /**
  56769. * Gets wether the color grading effect is enabled.
  56770. */
  56771. get cameraColorGradingEnabled(): boolean;
  56772. /**
  56773. * Gets wether the color grading effect is enabled.
  56774. */
  56775. set cameraColorGradingEnabled(value: boolean);
  56776. /**
  56777. * Gets wether tonemapping is enabled or not.
  56778. */
  56779. get cameraToneMappingEnabled(): boolean;
  56780. /**
  56781. * Sets wether tonemapping is enabled or not
  56782. */
  56783. set cameraToneMappingEnabled(value: boolean);
  56784. /**
  56785. * The camera exposure used on this material.
  56786. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56787. * This corresponds to a photographic exposure.
  56788. */
  56789. get cameraExposure(): float;
  56790. /**
  56791. * The camera exposure used on this material.
  56792. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56793. * This corresponds to a photographic exposure.
  56794. */
  56795. set cameraExposure(value: float);
  56796. /**
  56797. * Gets The camera contrast used on this material.
  56798. */
  56799. get cameraContrast(): float;
  56800. /**
  56801. * Sets The camera contrast used on this material.
  56802. */
  56803. set cameraContrast(value: float);
  56804. /**
  56805. * Gets the Color Grading 2D Lookup Texture.
  56806. */
  56807. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56808. /**
  56809. * Sets the Color Grading 2D Lookup Texture.
  56810. */
  56811. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56812. /**
  56813. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56814. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56815. * 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;
  56816. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56817. */
  56818. get cameraColorCurves(): Nullable<ColorCurves>;
  56819. /**
  56820. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56821. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56822. * 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;
  56823. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56824. */
  56825. set cameraColorCurves(value: Nullable<ColorCurves>);
  56826. /**
  56827. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56828. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56829. */
  56830. switchToBGR: boolean;
  56831. private _renderTargets;
  56832. private _reflectionControls;
  56833. private _white;
  56834. private _primaryShadowColor;
  56835. private _primaryHighlightColor;
  56836. /**
  56837. * Instantiates a Background Material in the given scene
  56838. * @param name The friendly name of the material
  56839. * @param scene The scene to add the material to
  56840. */
  56841. constructor(name: string, scene: Scene);
  56842. /**
  56843. * Gets a boolean indicating that current material needs to register RTT
  56844. */
  56845. get hasRenderTargetTextures(): boolean;
  56846. /**
  56847. * The entire material has been created in order to prevent overdraw.
  56848. * @returns false
  56849. */
  56850. needAlphaTesting(): boolean;
  56851. /**
  56852. * The entire material has been created in order to prevent overdraw.
  56853. * @returns true if blending is enable
  56854. */
  56855. needAlphaBlending(): boolean;
  56856. /**
  56857. * Checks wether the material is ready to be rendered for a given mesh.
  56858. * @param mesh The mesh to render
  56859. * @param subMesh The submesh to check against
  56860. * @param useInstances Specify wether or not the material is used with instances
  56861. * @returns true if all the dependencies are ready (Textures, Effects...)
  56862. */
  56863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56864. /**
  56865. * Compute the primary color according to the chosen perceptual color.
  56866. */
  56867. private _computePrimaryColorFromPerceptualColor;
  56868. /**
  56869. * Compute the highlights and shadow colors according to their chosen levels.
  56870. */
  56871. private _computePrimaryColors;
  56872. /**
  56873. * Build the uniform buffer used in the material.
  56874. */
  56875. buildUniformLayout(): void;
  56876. /**
  56877. * Unbind the material.
  56878. */
  56879. unbind(): void;
  56880. /**
  56881. * Bind only the world matrix to the material.
  56882. * @param world The world matrix to bind.
  56883. */
  56884. bindOnlyWorldMatrix(world: Matrix): void;
  56885. /**
  56886. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56887. * @param world The world matrix to bind.
  56888. * @param subMesh The submesh to bind for.
  56889. */
  56890. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56891. /**
  56892. * Checks to see if a texture is used in the material.
  56893. * @param texture - Base texture to use.
  56894. * @returns - Boolean specifying if a texture is used in the material.
  56895. */
  56896. hasTexture(texture: BaseTexture): boolean;
  56897. /**
  56898. * Dispose the material.
  56899. * @param forceDisposeEffect Force disposal of the associated effect.
  56900. * @param forceDisposeTextures Force disposal of the associated textures.
  56901. */
  56902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56903. /**
  56904. * Clones the material.
  56905. * @param name The cloned name.
  56906. * @returns The cloned material.
  56907. */
  56908. clone(name: string): BackgroundMaterial;
  56909. /**
  56910. * Serializes the current material to its JSON representation.
  56911. * @returns The JSON representation.
  56912. */
  56913. serialize(): any;
  56914. /**
  56915. * Gets the class name of the material
  56916. * @returns "BackgroundMaterial"
  56917. */
  56918. getClassName(): string;
  56919. /**
  56920. * Parse a JSON input to create back a background material.
  56921. * @param source The JSON data to parse
  56922. * @param scene The scene to create the parsed material in
  56923. * @param rootUrl The root url of the assets the material depends upon
  56924. * @returns the instantiated BackgroundMaterial.
  56925. */
  56926. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56927. }
  56928. }
  56929. declare module "babylonjs/Helpers/environmentHelper" {
  56930. import { Observable } from "babylonjs/Misc/observable";
  56931. import { Nullable } from "babylonjs/types";
  56932. import { Scene } from "babylonjs/scene";
  56933. import { Vector3 } from "babylonjs/Maths/math.vector";
  56934. import { Color3 } from "babylonjs/Maths/math.color";
  56935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56936. import { Mesh } from "babylonjs/Meshes/mesh";
  56937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56938. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56939. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56940. import "babylonjs/Meshes/Builders/planeBuilder";
  56941. import "babylonjs/Meshes/Builders/boxBuilder";
  56942. /**
  56943. * Represents the different options available during the creation of
  56944. * a Environment helper.
  56945. *
  56946. * This can control the default ground, skybox and image processing setup of your scene.
  56947. */
  56948. export interface IEnvironmentHelperOptions {
  56949. /**
  56950. * Specifies whether or not to create a ground.
  56951. * True by default.
  56952. */
  56953. createGround: boolean;
  56954. /**
  56955. * Specifies the ground size.
  56956. * 15 by default.
  56957. */
  56958. groundSize: number;
  56959. /**
  56960. * The texture used on the ground for the main color.
  56961. * Comes from the BabylonJS CDN by default.
  56962. *
  56963. * Remarks: Can be either a texture or a url.
  56964. */
  56965. groundTexture: string | BaseTexture;
  56966. /**
  56967. * The color mixed in the ground texture by default.
  56968. * BabylonJS clearColor by default.
  56969. */
  56970. groundColor: Color3;
  56971. /**
  56972. * Specifies the ground opacity.
  56973. * 1 by default.
  56974. */
  56975. groundOpacity: number;
  56976. /**
  56977. * Enables the ground to receive shadows.
  56978. * True by default.
  56979. */
  56980. enableGroundShadow: boolean;
  56981. /**
  56982. * Helps preventing the shadow to be fully black on the ground.
  56983. * 0.5 by default.
  56984. */
  56985. groundShadowLevel: number;
  56986. /**
  56987. * Creates a mirror texture attach to the ground.
  56988. * false by default.
  56989. */
  56990. enableGroundMirror: boolean;
  56991. /**
  56992. * Specifies the ground mirror size ratio.
  56993. * 0.3 by default as the default kernel is 64.
  56994. */
  56995. groundMirrorSizeRatio: number;
  56996. /**
  56997. * Specifies the ground mirror blur kernel size.
  56998. * 64 by default.
  56999. */
  57000. groundMirrorBlurKernel: number;
  57001. /**
  57002. * Specifies the ground mirror visibility amount.
  57003. * 1 by default
  57004. */
  57005. groundMirrorAmount: number;
  57006. /**
  57007. * Specifies the ground mirror reflectance weight.
  57008. * This uses the standard weight of the background material to setup the fresnel effect
  57009. * of the mirror.
  57010. * 1 by default.
  57011. */
  57012. groundMirrorFresnelWeight: number;
  57013. /**
  57014. * Specifies the ground mirror Falloff distance.
  57015. * This can helps reducing the size of the reflection.
  57016. * 0 by Default.
  57017. */
  57018. groundMirrorFallOffDistance: number;
  57019. /**
  57020. * Specifies the ground mirror texture type.
  57021. * Unsigned Int by Default.
  57022. */
  57023. groundMirrorTextureType: number;
  57024. /**
  57025. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57026. * the shown objects.
  57027. */
  57028. groundYBias: number;
  57029. /**
  57030. * Specifies whether or not to create a skybox.
  57031. * True by default.
  57032. */
  57033. createSkybox: boolean;
  57034. /**
  57035. * Specifies the skybox size.
  57036. * 20 by default.
  57037. */
  57038. skyboxSize: number;
  57039. /**
  57040. * The texture used on the skybox for the main color.
  57041. * Comes from the BabylonJS CDN by default.
  57042. *
  57043. * Remarks: Can be either a texture or a url.
  57044. */
  57045. skyboxTexture: string | BaseTexture;
  57046. /**
  57047. * The color mixed in the skybox texture by default.
  57048. * BabylonJS clearColor by default.
  57049. */
  57050. skyboxColor: Color3;
  57051. /**
  57052. * The background rotation around the Y axis of the scene.
  57053. * This helps aligning the key lights of your scene with the background.
  57054. * 0 by default.
  57055. */
  57056. backgroundYRotation: number;
  57057. /**
  57058. * Compute automatically the size of the elements to best fit with the scene.
  57059. */
  57060. sizeAuto: boolean;
  57061. /**
  57062. * Default position of the rootMesh if autoSize is not true.
  57063. */
  57064. rootPosition: Vector3;
  57065. /**
  57066. * Sets up the image processing in the scene.
  57067. * true by default.
  57068. */
  57069. setupImageProcessing: boolean;
  57070. /**
  57071. * The texture used as your environment texture in the scene.
  57072. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57073. *
  57074. * Remarks: Can be either a texture or a url.
  57075. */
  57076. environmentTexture: string | BaseTexture;
  57077. /**
  57078. * The value of the exposure to apply to the scene.
  57079. * 0.6 by default if setupImageProcessing is true.
  57080. */
  57081. cameraExposure: number;
  57082. /**
  57083. * The value of the contrast to apply to the scene.
  57084. * 1.6 by default if setupImageProcessing is true.
  57085. */
  57086. cameraContrast: number;
  57087. /**
  57088. * Specifies whether or not tonemapping should be enabled in the scene.
  57089. * true by default if setupImageProcessing is true.
  57090. */
  57091. toneMappingEnabled: boolean;
  57092. }
  57093. /**
  57094. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57095. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57096. * It also helps with the default setup of your imageProcessing configuration.
  57097. */
  57098. export class EnvironmentHelper {
  57099. /**
  57100. * Default ground texture URL.
  57101. */
  57102. private static _groundTextureCDNUrl;
  57103. /**
  57104. * Default skybox texture URL.
  57105. */
  57106. private static _skyboxTextureCDNUrl;
  57107. /**
  57108. * Default environment texture URL.
  57109. */
  57110. private static _environmentTextureCDNUrl;
  57111. /**
  57112. * Creates the default options for the helper.
  57113. */
  57114. private static _getDefaultOptions;
  57115. private _rootMesh;
  57116. /**
  57117. * Gets the root mesh created by the helper.
  57118. */
  57119. get rootMesh(): Mesh;
  57120. private _skybox;
  57121. /**
  57122. * Gets the skybox created by the helper.
  57123. */
  57124. get skybox(): Nullable<Mesh>;
  57125. private _skyboxTexture;
  57126. /**
  57127. * Gets the skybox texture created by the helper.
  57128. */
  57129. get skyboxTexture(): Nullable<BaseTexture>;
  57130. private _skyboxMaterial;
  57131. /**
  57132. * Gets the skybox material created by the helper.
  57133. */
  57134. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57135. private _ground;
  57136. /**
  57137. * Gets the ground mesh created by the helper.
  57138. */
  57139. get ground(): Nullable<Mesh>;
  57140. private _groundTexture;
  57141. /**
  57142. * Gets the ground texture created by the helper.
  57143. */
  57144. get groundTexture(): Nullable<BaseTexture>;
  57145. private _groundMirror;
  57146. /**
  57147. * Gets the ground mirror created by the helper.
  57148. */
  57149. get groundMirror(): Nullable<MirrorTexture>;
  57150. /**
  57151. * Gets the ground mirror render list to helps pushing the meshes
  57152. * you wish in the ground reflection.
  57153. */
  57154. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57155. private _groundMaterial;
  57156. /**
  57157. * Gets the ground material created by the helper.
  57158. */
  57159. get groundMaterial(): Nullable<BackgroundMaterial>;
  57160. /**
  57161. * Stores the creation options.
  57162. */
  57163. private readonly _scene;
  57164. private _options;
  57165. /**
  57166. * This observable will be notified with any error during the creation of the environment,
  57167. * mainly texture creation errors.
  57168. */
  57169. onErrorObservable: Observable<{
  57170. message?: string;
  57171. exception?: any;
  57172. }>;
  57173. /**
  57174. * constructor
  57175. * @param options Defines the options we want to customize the helper
  57176. * @param scene The scene to add the material to
  57177. */
  57178. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57179. /**
  57180. * Updates the background according to the new options
  57181. * @param options
  57182. */
  57183. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57184. /**
  57185. * Sets the primary color of all the available elements.
  57186. * @param color the main color to affect to the ground and the background
  57187. */
  57188. setMainColor(color: Color3): void;
  57189. /**
  57190. * Setup the image processing according to the specified options.
  57191. */
  57192. private _setupImageProcessing;
  57193. /**
  57194. * Setup the environment texture according to the specified options.
  57195. */
  57196. private _setupEnvironmentTexture;
  57197. /**
  57198. * Setup the background according to the specified options.
  57199. */
  57200. private _setupBackground;
  57201. /**
  57202. * Get the scene sizes according to the setup.
  57203. */
  57204. private _getSceneSize;
  57205. /**
  57206. * Setup the ground according to the specified options.
  57207. */
  57208. private _setupGround;
  57209. /**
  57210. * Setup the ground material according to the specified options.
  57211. */
  57212. private _setupGroundMaterial;
  57213. /**
  57214. * Setup the ground diffuse texture according to the specified options.
  57215. */
  57216. private _setupGroundDiffuseTexture;
  57217. /**
  57218. * Setup the ground mirror texture according to the specified options.
  57219. */
  57220. private _setupGroundMirrorTexture;
  57221. /**
  57222. * Setup the ground to receive the mirror texture.
  57223. */
  57224. private _setupMirrorInGroundMaterial;
  57225. /**
  57226. * Setup the skybox according to the specified options.
  57227. */
  57228. private _setupSkybox;
  57229. /**
  57230. * Setup the skybox material according to the specified options.
  57231. */
  57232. private _setupSkyboxMaterial;
  57233. /**
  57234. * Setup the skybox reflection texture according to the specified options.
  57235. */
  57236. private _setupSkyboxReflectionTexture;
  57237. private _errorHandler;
  57238. /**
  57239. * Dispose all the elements created by the Helper.
  57240. */
  57241. dispose(): void;
  57242. }
  57243. }
  57244. declare module "babylonjs/Helpers/photoDome" {
  57245. import { Observable } from "babylonjs/Misc/observable";
  57246. import { Nullable } from "babylonjs/types";
  57247. import { Scene } from "babylonjs/scene";
  57248. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57249. import { Mesh } from "babylonjs/Meshes/mesh";
  57250. import { Texture } from "babylonjs/Materials/Textures/texture";
  57251. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57252. import "babylonjs/Meshes/Builders/sphereBuilder";
  57253. /**
  57254. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57255. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57256. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57257. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57258. */
  57259. export class PhotoDome extends TransformNode {
  57260. /**
  57261. * Define the image as a Monoscopic panoramic 360 image.
  57262. */
  57263. static readonly MODE_MONOSCOPIC: number;
  57264. /**
  57265. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57266. */
  57267. static readonly MODE_TOPBOTTOM: number;
  57268. /**
  57269. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57270. */
  57271. static readonly MODE_SIDEBYSIDE: number;
  57272. private _useDirectMapping;
  57273. /**
  57274. * The texture being displayed on the sphere
  57275. */
  57276. protected _photoTexture: Texture;
  57277. /**
  57278. * Gets or sets the texture being displayed on the sphere
  57279. */
  57280. get photoTexture(): Texture;
  57281. set photoTexture(value: Texture);
  57282. /**
  57283. * Observable raised when an error occured while loading the 360 image
  57284. */
  57285. onLoadErrorObservable: Observable<string>;
  57286. /**
  57287. * The skybox material
  57288. */
  57289. protected _material: BackgroundMaterial;
  57290. /**
  57291. * The surface used for the skybox
  57292. */
  57293. protected _mesh: Mesh;
  57294. /**
  57295. * Gets the mesh used for the skybox.
  57296. */
  57297. get mesh(): Mesh;
  57298. /**
  57299. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57300. * Also see the options.resolution property.
  57301. */
  57302. get fovMultiplier(): number;
  57303. set fovMultiplier(value: number);
  57304. private _imageMode;
  57305. /**
  57306. * Gets or set the current video mode for the video. It can be:
  57307. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57308. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57309. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57310. */
  57311. get imageMode(): number;
  57312. set imageMode(value: number);
  57313. /**
  57314. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57315. * @param name Element's name, child elements will append suffixes for their own names.
  57316. * @param urlsOfPhoto defines the url of the photo to display
  57317. * @param options defines an object containing optional or exposed sub element properties
  57318. * @param onError defines a callback called when an error occured while loading the texture
  57319. */
  57320. constructor(name: string, urlOfPhoto: string, options: {
  57321. resolution?: number;
  57322. size?: number;
  57323. useDirectMapping?: boolean;
  57324. faceForward?: boolean;
  57325. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57326. private _onBeforeCameraRenderObserver;
  57327. private _changeImageMode;
  57328. /**
  57329. * Releases resources associated with this node.
  57330. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57331. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57332. */
  57333. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57334. }
  57335. }
  57336. declare module "babylonjs/Misc/rgbdTextureTools" {
  57337. import "babylonjs/Shaders/rgbdDecode.fragment";
  57338. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57339. import { Texture } from "babylonjs/Materials/Textures/texture";
  57340. /**
  57341. * Class used to host RGBD texture specific utilities
  57342. */
  57343. export class RGBDTextureTools {
  57344. /**
  57345. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57346. * @param texture the texture to expand.
  57347. */
  57348. static ExpandRGBDTexture(texture: Texture): void;
  57349. }
  57350. }
  57351. declare module "babylonjs/Misc/brdfTextureTools" {
  57352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57353. import { Scene } from "babylonjs/scene";
  57354. /**
  57355. * Class used to host texture specific utilities
  57356. */
  57357. export class BRDFTextureTools {
  57358. /**
  57359. * Prevents texture cache collision
  57360. */
  57361. private static _instanceNumber;
  57362. /**
  57363. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57364. * @param scene defines the hosting scene
  57365. * @returns the environment BRDF texture
  57366. */
  57367. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57368. private static _environmentBRDFBase64Texture;
  57369. }
  57370. }
  57371. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57372. import { Nullable } from "babylonjs/types";
  57373. import { Color3 } from "babylonjs/Maths/math.color";
  57374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57376. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57377. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57378. import { Engine } from "babylonjs/Engines/engine";
  57379. import { Scene } from "babylonjs/scene";
  57380. /**
  57381. * @hidden
  57382. */
  57383. export interface IMaterialClearCoatDefines {
  57384. CLEARCOAT: boolean;
  57385. CLEARCOAT_DEFAULTIOR: boolean;
  57386. CLEARCOAT_TEXTURE: boolean;
  57387. CLEARCOAT_TEXTUREDIRECTUV: number;
  57388. CLEARCOAT_BUMP: boolean;
  57389. CLEARCOAT_BUMPDIRECTUV: number;
  57390. CLEARCOAT_TINT: boolean;
  57391. CLEARCOAT_TINT_TEXTURE: boolean;
  57392. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57393. /** @hidden */
  57394. _areTexturesDirty: boolean;
  57395. }
  57396. /**
  57397. * Define the code related to the clear coat parameters of the pbr material.
  57398. */
  57399. export class PBRClearCoatConfiguration {
  57400. /**
  57401. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57402. * The default fits with a polyurethane material.
  57403. */
  57404. private static readonly _DefaultIndexOfRefraction;
  57405. private _isEnabled;
  57406. /**
  57407. * Defines if the clear coat is enabled in the material.
  57408. */
  57409. isEnabled: boolean;
  57410. /**
  57411. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57412. */
  57413. intensity: number;
  57414. /**
  57415. * Defines the clear coat layer roughness.
  57416. */
  57417. roughness: number;
  57418. private _indexOfRefraction;
  57419. /**
  57420. * Defines the index of refraction of the clear coat.
  57421. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57422. * The default fits with a polyurethane material.
  57423. * Changing the default value is more performance intensive.
  57424. */
  57425. indexOfRefraction: number;
  57426. private _texture;
  57427. /**
  57428. * Stores the clear coat values in a texture.
  57429. */
  57430. texture: Nullable<BaseTexture>;
  57431. private _bumpTexture;
  57432. /**
  57433. * Define the clear coat specific bump texture.
  57434. */
  57435. bumpTexture: Nullable<BaseTexture>;
  57436. private _isTintEnabled;
  57437. /**
  57438. * Defines if the clear coat tint is enabled in the material.
  57439. */
  57440. isTintEnabled: boolean;
  57441. /**
  57442. * Defines the clear coat tint of the material.
  57443. * This is only use if tint is enabled
  57444. */
  57445. tintColor: Color3;
  57446. /**
  57447. * Defines the distance at which the tint color should be found in the
  57448. * clear coat media.
  57449. * This is only use if tint is enabled
  57450. */
  57451. tintColorAtDistance: number;
  57452. /**
  57453. * Defines the clear coat layer thickness.
  57454. * This is only use if tint is enabled
  57455. */
  57456. tintThickness: number;
  57457. private _tintTexture;
  57458. /**
  57459. * Stores the clear tint values in a texture.
  57460. * rgb is tint
  57461. * a is a thickness factor
  57462. */
  57463. tintTexture: Nullable<BaseTexture>;
  57464. /** @hidden */
  57465. private _internalMarkAllSubMeshesAsTexturesDirty;
  57466. /** @hidden */
  57467. _markAllSubMeshesAsTexturesDirty(): void;
  57468. /**
  57469. * Instantiate a new istance of clear coat configuration.
  57470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57471. */
  57472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57473. /**
  57474. * Gets wehter the submesh is ready to be used or not.
  57475. * @param defines the list of "defines" to update.
  57476. * @param scene defines the scene the material belongs to.
  57477. * @param engine defines the engine the material belongs to.
  57478. * @param disableBumpMap defines wether the material disables bump or not.
  57479. * @returns - boolean indicating that the submesh is ready or not.
  57480. */
  57481. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57482. /**
  57483. * Checks to see if a texture is used in the material.
  57484. * @param defines the list of "defines" to update.
  57485. * @param scene defines the scene to the material belongs to.
  57486. */
  57487. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57488. /**
  57489. * Binds the material data.
  57490. * @param uniformBuffer defines the Uniform buffer to fill in.
  57491. * @param scene defines the scene the material belongs to.
  57492. * @param engine defines the engine the material belongs to.
  57493. * @param disableBumpMap defines wether the material disables bump or not.
  57494. * @param isFrozen defines wether the material is frozen or not.
  57495. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57496. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57497. */
  57498. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57499. /**
  57500. * Checks to see if a texture is used in the material.
  57501. * @param texture - Base texture to use.
  57502. * @returns - Boolean specifying if a texture is used in the material.
  57503. */
  57504. hasTexture(texture: BaseTexture): boolean;
  57505. /**
  57506. * Returns an array of the actively used textures.
  57507. * @param activeTextures Array of BaseTextures
  57508. */
  57509. getActiveTextures(activeTextures: BaseTexture[]): void;
  57510. /**
  57511. * Returns the animatable textures.
  57512. * @param animatables Array of animatable textures.
  57513. */
  57514. getAnimatables(animatables: IAnimatable[]): void;
  57515. /**
  57516. * Disposes the resources of the material.
  57517. * @param forceDisposeTextures - Forces the disposal of all textures.
  57518. */
  57519. dispose(forceDisposeTextures?: boolean): void;
  57520. /**
  57521. * Get the current class name of the texture useful for serialization or dynamic coding.
  57522. * @returns "PBRClearCoatConfiguration"
  57523. */
  57524. getClassName(): string;
  57525. /**
  57526. * Add fallbacks to the effect fallbacks list.
  57527. * @param defines defines the Base texture to use.
  57528. * @param fallbacks defines the current fallback list.
  57529. * @param currentRank defines the current fallback rank.
  57530. * @returns the new fallback rank.
  57531. */
  57532. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57533. /**
  57534. * Add the required uniforms to the current list.
  57535. * @param uniforms defines the current uniform list.
  57536. */
  57537. static AddUniforms(uniforms: string[]): void;
  57538. /**
  57539. * Add the required samplers to the current list.
  57540. * @param samplers defines the current sampler list.
  57541. */
  57542. static AddSamplers(samplers: string[]): void;
  57543. /**
  57544. * Add the required uniforms to the current buffer.
  57545. * @param uniformBuffer defines the current uniform buffer.
  57546. */
  57547. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57548. /**
  57549. * Makes a duplicate of the current configuration into another one.
  57550. * @param clearCoatConfiguration define the config where to copy the info
  57551. */
  57552. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57553. /**
  57554. * Serializes this clear coat configuration.
  57555. * @returns - An object with the serialized config.
  57556. */
  57557. serialize(): any;
  57558. /**
  57559. * Parses a anisotropy Configuration from a serialized object.
  57560. * @param source - Serialized object.
  57561. * @param scene Defines the scene we are parsing for
  57562. * @param rootUrl Defines the rootUrl to load from
  57563. */
  57564. parse(source: any, scene: Scene, rootUrl: string): void;
  57565. }
  57566. }
  57567. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57568. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57570. import { Vector2 } from "babylonjs/Maths/math.vector";
  57571. import { Scene } from "babylonjs/scene";
  57572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57573. import { Nullable } from "babylonjs/types";
  57574. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57575. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57576. /**
  57577. * @hidden
  57578. */
  57579. export interface IMaterialAnisotropicDefines {
  57580. ANISOTROPIC: boolean;
  57581. ANISOTROPIC_TEXTURE: boolean;
  57582. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57583. MAINUV1: boolean;
  57584. _areTexturesDirty: boolean;
  57585. _needUVs: boolean;
  57586. }
  57587. /**
  57588. * Define the code related to the anisotropic parameters of the pbr material.
  57589. */
  57590. export class PBRAnisotropicConfiguration {
  57591. private _isEnabled;
  57592. /**
  57593. * Defines if the anisotropy is enabled in the material.
  57594. */
  57595. isEnabled: boolean;
  57596. /**
  57597. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57598. */
  57599. intensity: number;
  57600. /**
  57601. * Defines if the effect is along the tangents, bitangents or in between.
  57602. * By default, the effect is "strectching" the highlights along the tangents.
  57603. */
  57604. direction: Vector2;
  57605. private _texture;
  57606. /**
  57607. * Stores the anisotropy values in a texture.
  57608. * rg is direction (like normal from -1 to 1)
  57609. * b is a intensity
  57610. */
  57611. texture: Nullable<BaseTexture>;
  57612. /** @hidden */
  57613. private _internalMarkAllSubMeshesAsTexturesDirty;
  57614. /** @hidden */
  57615. _markAllSubMeshesAsTexturesDirty(): void;
  57616. /**
  57617. * Instantiate a new istance of anisotropy configuration.
  57618. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57619. */
  57620. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57621. /**
  57622. * Specifies that the submesh is ready to be used.
  57623. * @param defines the list of "defines" to update.
  57624. * @param scene defines the scene the material belongs to.
  57625. * @returns - boolean indicating that the submesh is ready or not.
  57626. */
  57627. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57628. /**
  57629. * Checks to see if a texture is used in the material.
  57630. * @param defines the list of "defines" to update.
  57631. * @param mesh the mesh we are preparing the defines for.
  57632. * @param scene defines the scene the material belongs to.
  57633. */
  57634. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57635. /**
  57636. * Binds the material data.
  57637. * @param uniformBuffer defines the Uniform buffer to fill in.
  57638. * @param scene defines the scene the material belongs to.
  57639. * @param isFrozen defines wether the material is frozen or not.
  57640. */
  57641. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57642. /**
  57643. * Checks to see if a texture is used in the material.
  57644. * @param texture - Base texture to use.
  57645. * @returns - Boolean specifying if a texture is used in the material.
  57646. */
  57647. hasTexture(texture: BaseTexture): boolean;
  57648. /**
  57649. * Returns an array of the actively used textures.
  57650. * @param activeTextures Array of BaseTextures
  57651. */
  57652. getActiveTextures(activeTextures: BaseTexture[]): void;
  57653. /**
  57654. * Returns the animatable textures.
  57655. * @param animatables Array of animatable textures.
  57656. */
  57657. getAnimatables(animatables: IAnimatable[]): void;
  57658. /**
  57659. * Disposes the resources of the material.
  57660. * @param forceDisposeTextures - Forces the disposal of all textures.
  57661. */
  57662. dispose(forceDisposeTextures?: boolean): void;
  57663. /**
  57664. * Get the current class name of the texture useful for serialization or dynamic coding.
  57665. * @returns "PBRAnisotropicConfiguration"
  57666. */
  57667. getClassName(): string;
  57668. /**
  57669. * Add fallbacks to the effect fallbacks list.
  57670. * @param defines defines the Base texture to use.
  57671. * @param fallbacks defines the current fallback list.
  57672. * @param currentRank defines the current fallback rank.
  57673. * @returns the new fallback rank.
  57674. */
  57675. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57676. /**
  57677. * Add the required uniforms to the current list.
  57678. * @param uniforms defines the current uniform list.
  57679. */
  57680. static AddUniforms(uniforms: string[]): void;
  57681. /**
  57682. * Add the required uniforms to the current buffer.
  57683. * @param uniformBuffer defines the current uniform buffer.
  57684. */
  57685. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57686. /**
  57687. * Add the required samplers to the current list.
  57688. * @param samplers defines the current sampler list.
  57689. */
  57690. static AddSamplers(samplers: string[]): void;
  57691. /**
  57692. * Makes a duplicate of the current configuration into another one.
  57693. * @param anisotropicConfiguration define the config where to copy the info
  57694. */
  57695. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57696. /**
  57697. * Serializes this anisotropy configuration.
  57698. * @returns - An object with the serialized config.
  57699. */
  57700. serialize(): any;
  57701. /**
  57702. * Parses a anisotropy Configuration from a serialized object.
  57703. * @param source - Serialized object.
  57704. * @param scene Defines the scene we are parsing for
  57705. * @param rootUrl Defines the rootUrl to load from
  57706. */
  57707. parse(source: any, scene: Scene, rootUrl: string): void;
  57708. }
  57709. }
  57710. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57711. import { Scene } from "babylonjs/scene";
  57712. /**
  57713. * @hidden
  57714. */
  57715. export interface IMaterialBRDFDefines {
  57716. BRDF_V_HEIGHT_CORRELATED: boolean;
  57717. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57718. SPHERICAL_HARMONICS: boolean;
  57719. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57720. /** @hidden */
  57721. _areMiscDirty: boolean;
  57722. }
  57723. /**
  57724. * Define the code related to the BRDF parameters of the pbr material.
  57725. */
  57726. export class PBRBRDFConfiguration {
  57727. /**
  57728. * Default value used for the energy conservation.
  57729. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57730. */
  57731. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57732. /**
  57733. * Default value used for the Smith Visibility Height Correlated mode.
  57734. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57735. */
  57736. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57737. /**
  57738. * Default value used for the IBL diffuse part.
  57739. * This can help switching back to the polynomials mode globally which is a tiny bit
  57740. * less GPU intensive at the drawback of a lower quality.
  57741. */
  57742. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57743. /**
  57744. * Default value used for activating energy conservation for the specular workflow.
  57745. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57746. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57747. */
  57748. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57749. private _useEnergyConservation;
  57750. /**
  57751. * Defines if the material uses energy conservation.
  57752. */
  57753. useEnergyConservation: boolean;
  57754. private _useSmithVisibilityHeightCorrelated;
  57755. /**
  57756. * LEGACY Mode set to false
  57757. * Defines if the material uses height smith correlated visibility term.
  57758. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57759. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57760. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57761. * Not relying on height correlated will also disable energy conservation.
  57762. */
  57763. useSmithVisibilityHeightCorrelated: boolean;
  57764. private _useSphericalHarmonics;
  57765. /**
  57766. * LEGACY Mode set to false
  57767. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57768. * diffuse part of the IBL.
  57769. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57770. * to the ground truth.
  57771. */
  57772. useSphericalHarmonics: boolean;
  57773. private _useSpecularGlossinessInputEnergyConservation;
  57774. /**
  57775. * Defines if the material uses energy conservation, when the specular workflow is active.
  57776. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57777. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57778. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57779. */
  57780. useSpecularGlossinessInputEnergyConservation: boolean;
  57781. /** @hidden */
  57782. private _internalMarkAllSubMeshesAsMiscDirty;
  57783. /** @hidden */
  57784. _markAllSubMeshesAsMiscDirty(): void;
  57785. /**
  57786. * Instantiate a new istance of clear coat configuration.
  57787. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57788. */
  57789. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57790. /**
  57791. * Checks to see if a texture is used in the material.
  57792. * @param defines the list of "defines" to update.
  57793. */
  57794. prepareDefines(defines: IMaterialBRDFDefines): void;
  57795. /**
  57796. * Get the current class name of the texture useful for serialization or dynamic coding.
  57797. * @returns "PBRClearCoatConfiguration"
  57798. */
  57799. getClassName(): string;
  57800. /**
  57801. * Makes a duplicate of the current configuration into another one.
  57802. * @param brdfConfiguration define the config where to copy the info
  57803. */
  57804. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57805. /**
  57806. * Serializes this BRDF configuration.
  57807. * @returns - An object with the serialized config.
  57808. */
  57809. serialize(): any;
  57810. /**
  57811. * Parses a anisotropy Configuration from a serialized object.
  57812. * @param source - Serialized object.
  57813. * @param scene Defines the scene we are parsing for
  57814. * @param rootUrl Defines the rootUrl to load from
  57815. */
  57816. parse(source: any, scene: Scene, rootUrl: string): void;
  57817. }
  57818. }
  57819. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57820. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57821. import { Color3 } from "babylonjs/Maths/math.color";
  57822. import { Scene } from "babylonjs/scene";
  57823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57824. import { Nullable } from "babylonjs/types";
  57825. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57826. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57827. /**
  57828. * @hidden
  57829. */
  57830. export interface IMaterialSheenDefines {
  57831. SHEEN: boolean;
  57832. SHEEN_TEXTURE: boolean;
  57833. SHEEN_TEXTUREDIRECTUV: number;
  57834. SHEEN_LINKWITHALBEDO: boolean;
  57835. SHEEN_ROUGHNESS: boolean;
  57836. SHEEN_ALBEDOSCALING: boolean;
  57837. /** @hidden */
  57838. _areTexturesDirty: boolean;
  57839. }
  57840. /**
  57841. * Define the code related to the Sheen parameters of the pbr material.
  57842. */
  57843. export class PBRSheenConfiguration {
  57844. private _isEnabled;
  57845. /**
  57846. * Defines if the material uses sheen.
  57847. */
  57848. isEnabled: boolean;
  57849. private _linkSheenWithAlbedo;
  57850. /**
  57851. * Defines if the sheen is linked to the sheen color.
  57852. */
  57853. linkSheenWithAlbedo: boolean;
  57854. /**
  57855. * Defines the sheen intensity.
  57856. */
  57857. intensity: number;
  57858. /**
  57859. * Defines the sheen color.
  57860. */
  57861. color: Color3;
  57862. private _texture;
  57863. /**
  57864. * Stores the sheen tint values in a texture.
  57865. * rgb is tint
  57866. * a is a intensity or roughness if roughness has been defined
  57867. */
  57868. texture: Nullable<BaseTexture>;
  57869. private _roughness;
  57870. /**
  57871. * Defines the sheen roughness.
  57872. * It is not taken into account if linkSheenWithAlbedo is true.
  57873. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57874. */
  57875. roughness: Nullable<number>;
  57876. private _albedoScaling;
  57877. /**
  57878. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57879. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57880. * making it easier to setup and tweak the effect
  57881. */
  57882. albedoScaling: boolean;
  57883. /** @hidden */
  57884. private _internalMarkAllSubMeshesAsTexturesDirty;
  57885. /** @hidden */
  57886. _markAllSubMeshesAsTexturesDirty(): void;
  57887. /**
  57888. * Instantiate a new istance of clear coat configuration.
  57889. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57890. */
  57891. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57892. /**
  57893. * Specifies that the submesh is ready to be used.
  57894. * @param defines the list of "defines" to update.
  57895. * @param scene defines the scene the material belongs to.
  57896. * @returns - boolean indicating that the submesh is ready or not.
  57897. */
  57898. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57899. /**
  57900. * Checks to see if a texture is used in the material.
  57901. * @param defines the list of "defines" to update.
  57902. * @param scene defines the scene the material belongs to.
  57903. */
  57904. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57905. /**
  57906. * Binds the material data.
  57907. * @param uniformBuffer defines the Uniform buffer to fill in.
  57908. * @param scene defines the scene the material belongs to.
  57909. * @param isFrozen defines wether the material is frozen or not.
  57910. */
  57911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57912. /**
  57913. * Checks to see if a texture is used in the material.
  57914. * @param texture - Base texture to use.
  57915. * @returns - Boolean specifying if a texture is used in the material.
  57916. */
  57917. hasTexture(texture: BaseTexture): boolean;
  57918. /**
  57919. * Returns an array of the actively used textures.
  57920. * @param activeTextures Array of BaseTextures
  57921. */
  57922. getActiveTextures(activeTextures: BaseTexture[]): void;
  57923. /**
  57924. * Returns the animatable textures.
  57925. * @param animatables Array of animatable textures.
  57926. */
  57927. getAnimatables(animatables: IAnimatable[]): void;
  57928. /**
  57929. * Disposes the resources of the material.
  57930. * @param forceDisposeTextures - Forces the disposal of all textures.
  57931. */
  57932. dispose(forceDisposeTextures?: boolean): void;
  57933. /**
  57934. * Get the current class name of the texture useful for serialization or dynamic coding.
  57935. * @returns "PBRSheenConfiguration"
  57936. */
  57937. getClassName(): string;
  57938. /**
  57939. * Add fallbacks to the effect fallbacks list.
  57940. * @param defines defines the Base texture to use.
  57941. * @param fallbacks defines the current fallback list.
  57942. * @param currentRank defines the current fallback rank.
  57943. * @returns the new fallback rank.
  57944. */
  57945. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57946. /**
  57947. * Add the required uniforms to the current list.
  57948. * @param uniforms defines the current uniform list.
  57949. */
  57950. static AddUniforms(uniforms: string[]): void;
  57951. /**
  57952. * Add the required uniforms to the current buffer.
  57953. * @param uniformBuffer defines the current uniform buffer.
  57954. */
  57955. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57956. /**
  57957. * Add the required samplers to the current list.
  57958. * @param samplers defines the current sampler list.
  57959. */
  57960. static AddSamplers(samplers: string[]): void;
  57961. /**
  57962. * Makes a duplicate of the current configuration into another one.
  57963. * @param sheenConfiguration define the config where to copy the info
  57964. */
  57965. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57966. /**
  57967. * Serializes this BRDF configuration.
  57968. * @returns - An object with the serialized config.
  57969. */
  57970. serialize(): any;
  57971. /**
  57972. * Parses a anisotropy Configuration from a serialized object.
  57973. * @param source - Serialized object.
  57974. * @param scene Defines the scene we are parsing for
  57975. * @param rootUrl Defines the rootUrl to load from
  57976. */
  57977. parse(source: any, scene: Scene, rootUrl: string): void;
  57978. }
  57979. }
  57980. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57981. import { Nullable } from "babylonjs/types";
  57982. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57983. import { Color3 } from "babylonjs/Maths/math.color";
  57984. import { SmartArray } from "babylonjs/Misc/smartArray";
  57985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57986. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57987. import { Effect } from "babylonjs/Materials/effect";
  57988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57989. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57990. import { Engine } from "babylonjs/Engines/engine";
  57991. import { Scene } from "babylonjs/scene";
  57992. /**
  57993. * @hidden
  57994. */
  57995. export interface IMaterialSubSurfaceDefines {
  57996. SUBSURFACE: boolean;
  57997. SS_REFRACTION: boolean;
  57998. SS_TRANSLUCENCY: boolean;
  57999. SS_SCATTERING: boolean;
  58000. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58001. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58002. SS_REFRACTIONMAP_3D: boolean;
  58003. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58004. SS_LODINREFRACTIONALPHA: boolean;
  58005. SS_GAMMAREFRACTION: boolean;
  58006. SS_RGBDREFRACTION: boolean;
  58007. SS_LINEARSPECULARREFRACTION: boolean;
  58008. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58009. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58010. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58011. /** @hidden */
  58012. _areTexturesDirty: boolean;
  58013. }
  58014. /**
  58015. * Define the code related to the sub surface parameters of the pbr material.
  58016. */
  58017. export class PBRSubSurfaceConfiguration {
  58018. private _isRefractionEnabled;
  58019. /**
  58020. * Defines if the refraction is enabled in the material.
  58021. */
  58022. isRefractionEnabled: boolean;
  58023. private _isTranslucencyEnabled;
  58024. /**
  58025. * Defines if the translucency is enabled in the material.
  58026. */
  58027. isTranslucencyEnabled: boolean;
  58028. private _isScatteringEnabled;
  58029. /**
  58030. * Defines if the sub surface scattering is enabled in the material.
  58031. */
  58032. isScatteringEnabled: boolean;
  58033. private _scatteringDiffusionProfileIndex;
  58034. /**
  58035. * Diffusion profile for subsurface scattering.
  58036. * Useful for better scattering in the skins or foliages.
  58037. */
  58038. get scatteringDiffusionProfile(): Nullable<Color3>;
  58039. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58040. /**
  58041. * Defines the refraction intensity of the material.
  58042. * The refraction when enabled replaces the Diffuse part of the material.
  58043. * The intensity helps transitionning between diffuse and refraction.
  58044. */
  58045. refractionIntensity: number;
  58046. /**
  58047. * Defines the translucency intensity of the material.
  58048. * When translucency has been enabled, this defines how much of the "translucency"
  58049. * is addded to the diffuse part of the material.
  58050. */
  58051. translucencyIntensity: number;
  58052. /**
  58053. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58054. */
  58055. useAlbedoToTintRefraction: boolean;
  58056. private _thicknessTexture;
  58057. /**
  58058. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58059. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58060. * 0 would mean minimumThickness
  58061. * 1 would mean maximumThickness
  58062. * The other channels might be use as a mask to vary the different effects intensity.
  58063. */
  58064. thicknessTexture: Nullable<BaseTexture>;
  58065. private _refractionTexture;
  58066. /**
  58067. * Defines the texture to use for refraction.
  58068. */
  58069. refractionTexture: Nullable<BaseTexture>;
  58070. private _indexOfRefraction;
  58071. /**
  58072. * Index of refraction of the material base layer.
  58073. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58074. *
  58075. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58076. *
  58077. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58078. */
  58079. indexOfRefraction: number;
  58080. private _volumeIndexOfRefraction;
  58081. /**
  58082. * Index of refraction of the material's volume.
  58083. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58084. *
  58085. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58086. * the volume will use the same IOR as the surface.
  58087. */
  58088. get volumeIndexOfRefraction(): number;
  58089. set volumeIndexOfRefraction(value: number);
  58090. private _invertRefractionY;
  58091. /**
  58092. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58093. */
  58094. invertRefractionY: boolean;
  58095. private _linkRefractionWithTransparency;
  58096. /**
  58097. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58098. * Materials half opaque for instance using refraction could benefit from this control.
  58099. */
  58100. linkRefractionWithTransparency: boolean;
  58101. /**
  58102. * Defines the minimum thickness stored in the thickness map.
  58103. * If no thickness map is defined, this value will be used to simulate thickness.
  58104. */
  58105. minimumThickness: number;
  58106. /**
  58107. * Defines the maximum thickness stored in the thickness map.
  58108. */
  58109. maximumThickness: number;
  58110. /**
  58111. * Defines the volume tint of the material.
  58112. * This is used for both translucency and scattering.
  58113. */
  58114. tintColor: Color3;
  58115. /**
  58116. * Defines the distance at which the tint color should be found in the media.
  58117. * This is used for refraction only.
  58118. */
  58119. tintColorAtDistance: number;
  58120. /**
  58121. * Defines how far each channel transmit through the media.
  58122. * It is defined as a color to simplify it selection.
  58123. */
  58124. diffusionDistance: Color3;
  58125. private _useMaskFromThicknessTexture;
  58126. /**
  58127. * Stores the intensity of the different subsurface effects in the thickness texture.
  58128. * * the green channel is the translucency intensity.
  58129. * * the blue channel is the scattering intensity.
  58130. * * the alpha channel is the refraction intensity.
  58131. */
  58132. useMaskFromThicknessTexture: boolean;
  58133. private _scene;
  58134. /** @hidden */
  58135. private _internalMarkAllSubMeshesAsTexturesDirty;
  58136. private _internalMarkScenePrePassDirty;
  58137. /** @hidden */
  58138. _markAllSubMeshesAsTexturesDirty(): void;
  58139. /** @hidden */
  58140. _markScenePrePassDirty(): void;
  58141. /**
  58142. * Instantiate a new istance of sub surface configuration.
  58143. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58144. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58145. * @param scene The scene
  58146. */
  58147. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58148. /**
  58149. * Gets wehter the submesh is ready to be used or not.
  58150. * @param defines the list of "defines" to update.
  58151. * @param scene defines the scene the material belongs to.
  58152. * @returns - boolean indicating that the submesh is ready or not.
  58153. */
  58154. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58155. /**
  58156. * Checks to see if a texture is used in the material.
  58157. * @param defines the list of "defines" to update.
  58158. * @param scene defines the scene to the material belongs to.
  58159. */
  58160. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58161. /**
  58162. * Binds the material data.
  58163. * @param uniformBuffer defines the Uniform buffer to fill in.
  58164. * @param scene defines the scene the material belongs to.
  58165. * @param engine defines the engine the material belongs to.
  58166. * @param isFrozen defines whether the material is frozen or not.
  58167. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58168. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58169. */
  58170. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58171. /**
  58172. * Unbinds the material from the mesh.
  58173. * @param activeEffect defines the effect that should be unbound from.
  58174. * @returns true if unbound, otherwise false
  58175. */
  58176. unbind(activeEffect: Effect): boolean;
  58177. /**
  58178. * Returns the texture used for refraction or null if none is used.
  58179. * @param scene defines the scene the material belongs to.
  58180. * @returns - Refraction texture if present. If no refraction texture and refraction
  58181. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58182. */
  58183. private _getRefractionTexture;
  58184. /**
  58185. * Returns true if alpha blending should be disabled.
  58186. */
  58187. get disableAlphaBlending(): boolean;
  58188. /**
  58189. * Fills the list of render target textures.
  58190. * @param renderTargets the list of render targets to update
  58191. */
  58192. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58193. /**
  58194. * Checks to see if a texture is used in the material.
  58195. * @param texture - Base texture to use.
  58196. * @returns - Boolean specifying if a texture is used in the material.
  58197. */
  58198. hasTexture(texture: BaseTexture): boolean;
  58199. /**
  58200. * Gets a boolean indicating that current material needs to register RTT
  58201. * @returns true if this uses a render target otherwise false.
  58202. */
  58203. hasRenderTargetTextures(): boolean;
  58204. /**
  58205. * Returns an array of the actively used textures.
  58206. * @param activeTextures Array of BaseTextures
  58207. */
  58208. getActiveTextures(activeTextures: BaseTexture[]): void;
  58209. /**
  58210. * Returns the animatable textures.
  58211. * @param animatables Array of animatable textures.
  58212. */
  58213. getAnimatables(animatables: IAnimatable[]): void;
  58214. /**
  58215. * Disposes the resources of the material.
  58216. * @param forceDisposeTextures - Forces the disposal of all textures.
  58217. */
  58218. dispose(forceDisposeTextures?: boolean): void;
  58219. /**
  58220. * Get the current class name of the texture useful for serialization or dynamic coding.
  58221. * @returns "PBRSubSurfaceConfiguration"
  58222. */
  58223. getClassName(): string;
  58224. /**
  58225. * Add fallbacks to the effect fallbacks list.
  58226. * @param defines defines the Base texture to use.
  58227. * @param fallbacks defines the current fallback list.
  58228. * @param currentRank defines the current fallback rank.
  58229. * @returns the new fallback rank.
  58230. */
  58231. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58232. /**
  58233. * Add the required uniforms to the current list.
  58234. * @param uniforms defines the current uniform list.
  58235. */
  58236. static AddUniforms(uniforms: string[]): void;
  58237. /**
  58238. * Add the required samplers to the current list.
  58239. * @param samplers defines the current sampler list.
  58240. */
  58241. static AddSamplers(samplers: string[]): void;
  58242. /**
  58243. * Add the required uniforms to the current buffer.
  58244. * @param uniformBuffer defines the current uniform buffer.
  58245. */
  58246. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58247. /**
  58248. * Makes a duplicate of the current configuration into another one.
  58249. * @param configuration define the config where to copy the info
  58250. */
  58251. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58252. /**
  58253. * Serializes this Sub Surface configuration.
  58254. * @returns - An object with the serialized config.
  58255. */
  58256. serialize(): any;
  58257. /**
  58258. * Parses a anisotropy Configuration from a serialized object.
  58259. * @param source - Serialized object.
  58260. * @param scene Defines the scene we are parsing for
  58261. * @param rootUrl Defines the rootUrl to load from
  58262. */
  58263. parse(source: any, scene: Scene, rootUrl: string): void;
  58264. }
  58265. }
  58266. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58267. /** @hidden */
  58268. export var pbrFragmentDeclaration: {
  58269. name: string;
  58270. shader: string;
  58271. };
  58272. }
  58273. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58274. /** @hidden */
  58275. export var pbrUboDeclaration: {
  58276. name: string;
  58277. shader: string;
  58278. };
  58279. }
  58280. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58281. /** @hidden */
  58282. export var pbrFragmentExtraDeclaration: {
  58283. name: string;
  58284. shader: string;
  58285. };
  58286. }
  58287. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58288. /** @hidden */
  58289. export var pbrFragmentSamplersDeclaration: {
  58290. name: string;
  58291. shader: string;
  58292. };
  58293. }
  58294. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58295. /** @hidden */
  58296. export var importanceSampling: {
  58297. name: string;
  58298. shader: string;
  58299. };
  58300. }
  58301. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58302. /** @hidden */
  58303. export var pbrHelperFunctions: {
  58304. name: string;
  58305. shader: string;
  58306. };
  58307. }
  58308. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58309. /** @hidden */
  58310. export var harmonicsFunctions: {
  58311. name: string;
  58312. shader: string;
  58313. };
  58314. }
  58315. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58316. /** @hidden */
  58317. export var pbrDirectLightingSetupFunctions: {
  58318. name: string;
  58319. shader: string;
  58320. };
  58321. }
  58322. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58323. /** @hidden */
  58324. export var pbrDirectLightingFalloffFunctions: {
  58325. name: string;
  58326. shader: string;
  58327. };
  58328. }
  58329. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58330. /** @hidden */
  58331. export var pbrBRDFFunctions: {
  58332. name: string;
  58333. shader: string;
  58334. };
  58335. }
  58336. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58337. /** @hidden */
  58338. export var hdrFilteringFunctions: {
  58339. name: string;
  58340. shader: string;
  58341. };
  58342. }
  58343. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58344. /** @hidden */
  58345. export var pbrDirectLightingFunctions: {
  58346. name: string;
  58347. shader: string;
  58348. };
  58349. }
  58350. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58351. /** @hidden */
  58352. export var pbrIBLFunctions: {
  58353. name: string;
  58354. shader: string;
  58355. };
  58356. }
  58357. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58358. /** @hidden */
  58359. export var pbrBlockAlbedoOpacity: {
  58360. name: string;
  58361. shader: string;
  58362. };
  58363. }
  58364. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58365. /** @hidden */
  58366. export var pbrBlockReflectivity: {
  58367. name: string;
  58368. shader: string;
  58369. };
  58370. }
  58371. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58372. /** @hidden */
  58373. export var pbrBlockAmbientOcclusion: {
  58374. name: string;
  58375. shader: string;
  58376. };
  58377. }
  58378. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58379. /** @hidden */
  58380. export var pbrBlockAlphaFresnel: {
  58381. name: string;
  58382. shader: string;
  58383. };
  58384. }
  58385. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58386. /** @hidden */
  58387. export var pbrBlockAnisotropic: {
  58388. name: string;
  58389. shader: string;
  58390. };
  58391. }
  58392. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58393. /** @hidden */
  58394. export var pbrBlockReflection: {
  58395. name: string;
  58396. shader: string;
  58397. };
  58398. }
  58399. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58400. /** @hidden */
  58401. export var pbrBlockSheen: {
  58402. name: string;
  58403. shader: string;
  58404. };
  58405. }
  58406. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58407. /** @hidden */
  58408. export var pbrBlockClearcoat: {
  58409. name: string;
  58410. shader: string;
  58411. };
  58412. }
  58413. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58414. /** @hidden */
  58415. export var pbrBlockSubSurface: {
  58416. name: string;
  58417. shader: string;
  58418. };
  58419. }
  58420. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58421. /** @hidden */
  58422. export var pbrBlockNormalGeometric: {
  58423. name: string;
  58424. shader: string;
  58425. };
  58426. }
  58427. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58428. /** @hidden */
  58429. export var pbrBlockNormalFinal: {
  58430. name: string;
  58431. shader: string;
  58432. };
  58433. }
  58434. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58435. /** @hidden */
  58436. export var pbrBlockLightmapInit: {
  58437. name: string;
  58438. shader: string;
  58439. };
  58440. }
  58441. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58442. /** @hidden */
  58443. export var pbrBlockGeometryInfo: {
  58444. name: string;
  58445. shader: string;
  58446. };
  58447. }
  58448. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58449. /** @hidden */
  58450. export var pbrBlockReflectance0: {
  58451. name: string;
  58452. shader: string;
  58453. };
  58454. }
  58455. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58456. /** @hidden */
  58457. export var pbrBlockReflectance: {
  58458. name: string;
  58459. shader: string;
  58460. };
  58461. }
  58462. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58463. /** @hidden */
  58464. export var pbrBlockDirectLighting: {
  58465. name: string;
  58466. shader: string;
  58467. };
  58468. }
  58469. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58470. /** @hidden */
  58471. export var pbrBlockFinalLitComponents: {
  58472. name: string;
  58473. shader: string;
  58474. };
  58475. }
  58476. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58477. /** @hidden */
  58478. export var pbrBlockFinalUnlitComponents: {
  58479. name: string;
  58480. shader: string;
  58481. };
  58482. }
  58483. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58484. /** @hidden */
  58485. export var pbrBlockFinalColorComposition: {
  58486. name: string;
  58487. shader: string;
  58488. };
  58489. }
  58490. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58491. /** @hidden */
  58492. export var pbrBlockImageProcessing: {
  58493. name: string;
  58494. shader: string;
  58495. };
  58496. }
  58497. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58498. /** @hidden */
  58499. export var pbrDebug: {
  58500. name: string;
  58501. shader: string;
  58502. };
  58503. }
  58504. declare module "babylonjs/Shaders/pbr.fragment" {
  58505. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58506. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58507. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58508. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58509. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58510. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58511. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58512. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58513. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58514. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58515. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58516. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58517. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58518. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58519. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58520. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58521. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58522. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58523. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58524. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58525. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58526. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58527. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58528. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58529. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58530. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58531. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58532. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58533. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58534. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58535. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58536. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58537. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58538. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58539. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58540. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58541. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58542. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58543. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58544. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58545. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58546. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58547. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58548. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58549. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58550. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58551. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58552. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58553. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58554. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58555. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58556. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58557. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58558. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58559. /** @hidden */
  58560. export var pbrPixelShader: {
  58561. name: string;
  58562. shader: string;
  58563. };
  58564. }
  58565. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58566. /** @hidden */
  58567. export var pbrVertexDeclaration: {
  58568. name: string;
  58569. shader: string;
  58570. };
  58571. }
  58572. declare module "babylonjs/Shaders/pbr.vertex" {
  58573. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58574. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58575. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58576. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58577. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58578. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58579. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58580. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58581. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58582. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58583. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58584. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58585. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58586. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58588. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58589. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58590. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58591. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58592. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58593. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58594. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58595. /** @hidden */
  58596. export var pbrVertexShader: {
  58597. name: string;
  58598. shader: string;
  58599. };
  58600. }
  58601. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58602. import { Nullable } from "babylonjs/types";
  58603. import { Scene } from "babylonjs/scene";
  58604. import { Matrix } from "babylonjs/Maths/math.vector";
  58605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58607. import { Mesh } from "babylonjs/Meshes/mesh";
  58608. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58609. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58610. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58611. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58612. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58613. import { Color3 } from "babylonjs/Maths/math.color";
  58614. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58615. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58616. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58617. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58619. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58620. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58621. import "babylonjs/Shaders/pbr.fragment";
  58622. import "babylonjs/Shaders/pbr.vertex";
  58623. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58624. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58625. /**
  58626. * Manages the defines for the PBR Material.
  58627. * @hidden
  58628. */
  58629. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58630. PBR: boolean;
  58631. NUM_SAMPLES: string;
  58632. REALTIME_FILTERING: boolean;
  58633. MAINUV1: boolean;
  58634. MAINUV2: boolean;
  58635. UV1: boolean;
  58636. UV2: boolean;
  58637. ALBEDO: boolean;
  58638. GAMMAALBEDO: boolean;
  58639. ALBEDODIRECTUV: number;
  58640. VERTEXCOLOR: boolean;
  58641. DETAIL: boolean;
  58642. DETAILDIRECTUV: number;
  58643. DETAIL_NORMALBLENDMETHOD: number;
  58644. AMBIENT: boolean;
  58645. AMBIENTDIRECTUV: number;
  58646. AMBIENTINGRAYSCALE: boolean;
  58647. OPACITY: boolean;
  58648. VERTEXALPHA: boolean;
  58649. OPACITYDIRECTUV: number;
  58650. OPACITYRGB: boolean;
  58651. ALPHATEST: boolean;
  58652. DEPTHPREPASS: boolean;
  58653. ALPHABLEND: boolean;
  58654. ALPHAFROMALBEDO: boolean;
  58655. ALPHATESTVALUE: string;
  58656. SPECULAROVERALPHA: boolean;
  58657. RADIANCEOVERALPHA: boolean;
  58658. ALPHAFRESNEL: boolean;
  58659. LINEARALPHAFRESNEL: boolean;
  58660. PREMULTIPLYALPHA: boolean;
  58661. EMISSIVE: boolean;
  58662. EMISSIVEDIRECTUV: number;
  58663. REFLECTIVITY: boolean;
  58664. REFLECTIVITYDIRECTUV: number;
  58665. SPECULARTERM: boolean;
  58666. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58667. MICROSURFACEAUTOMATIC: boolean;
  58668. LODBASEDMICROSFURACE: boolean;
  58669. MICROSURFACEMAP: boolean;
  58670. MICROSURFACEMAPDIRECTUV: number;
  58671. METALLICWORKFLOW: boolean;
  58672. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58673. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58674. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58675. AOSTOREINMETALMAPRED: boolean;
  58676. METALLIC_REFLECTANCE: boolean;
  58677. METALLIC_REFLECTANCEDIRECTUV: number;
  58678. ENVIRONMENTBRDF: boolean;
  58679. ENVIRONMENTBRDF_RGBD: boolean;
  58680. NORMAL: boolean;
  58681. TANGENT: boolean;
  58682. BUMP: boolean;
  58683. BUMPDIRECTUV: number;
  58684. OBJECTSPACE_NORMALMAP: boolean;
  58685. PARALLAX: boolean;
  58686. PARALLAXOCCLUSION: boolean;
  58687. NORMALXYSCALE: boolean;
  58688. LIGHTMAP: boolean;
  58689. LIGHTMAPDIRECTUV: number;
  58690. USELIGHTMAPASSHADOWMAP: boolean;
  58691. GAMMALIGHTMAP: boolean;
  58692. RGBDLIGHTMAP: boolean;
  58693. REFLECTION: boolean;
  58694. REFLECTIONMAP_3D: boolean;
  58695. REFLECTIONMAP_SPHERICAL: boolean;
  58696. REFLECTIONMAP_PLANAR: boolean;
  58697. REFLECTIONMAP_CUBIC: boolean;
  58698. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58699. REFLECTIONMAP_PROJECTION: boolean;
  58700. REFLECTIONMAP_SKYBOX: boolean;
  58701. REFLECTIONMAP_EXPLICIT: boolean;
  58702. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58703. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58704. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58705. INVERTCUBICMAP: boolean;
  58706. USESPHERICALFROMREFLECTIONMAP: boolean;
  58707. USEIRRADIANCEMAP: boolean;
  58708. SPHERICAL_HARMONICS: boolean;
  58709. USESPHERICALINVERTEX: boolean;
  58710. REFLECTIONMAP_OPPOSITEZ: boolean;
  58711. LODINREFLECTIONALPHA: boolean;
  58712. GAMMAREFLECTION: boolean;
  58713. RGBDREFLECTION: boolean;
  58714. LINEARSPECULARREFLECTION: boolean;
  58715. RADIANCEOCCLUSION: boolean;
  58716. HORIZONOCCLUSION: boolean;
  58717. INSTANCES: boolean;
  58718. THIN_INSTANCES: boolean;
  58719. PREPASS: boolean;
  58720. SCENE_MRT_COUNT: number;
  58721. NUM_BONE_INFLUENCERS: number;
  58722. BonesPerMesh: number;
  58723. BONETEXTURE: boolean;
  58724. NONUNIFORMSCALING: boolean;
  58725. MORPHTARGETS: boolean;
  58726. MORPHTARGETS_NORMAL: boolean;
  58727. MORPHTARGETS_TANGENT: boolean;
  58728. MORPHTARGETS_UV: boolean;
  58729. NUM_MORPH_INFLUENCERS: number;
  58730. IMAGEPROCESSING: boolean;
  58731. VIGNETTE: boolean;
  58732. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58733. VIGNETTEBLENDMODEOPAQUE: boolean;
  58734. TONEMAPPING: boolean;
  58735. TONEMAPPING_ACES: boolean;
  58736. CONTRAST: boolean;
  58737. COLORCURVES: boolean;
  58738. COLORGRADING: boolean;
  58739. COLORGRADING3D: boolean;
  58740. SAMPLER3DGREENDEPTH: boolean;
  58741. SAMPLER3DBGRMAP: boolean;
  58742. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58743. EXPOSURE: boolean;
  58744. MULTIVIEW: boolean;
  58745. USEPHYSICALLIGHTFALLOFF: boolean;
  58746. USEGLTFLIGHTFALLOFF: boolean;
  58747. TWOSIDEDLIGHTING: boolean;
  58748. SHADOWFLOAT: boolean;
  58749. CLIPPLANE: boolean;
  58750. CLIPPLANE2: boolean;
  58751. CLIPPLANE3: boolean;
  58752. CLIPPLANE4: boolean;
  58753. CLIPPLANE5: boolean;
  58754. CLIPPLANE6: boolean;
  58755. POINTSIZE: boolean;
  58756. FOG: boolean;
  58757. LOGARITHMICDEPTH: boolean;
  58758. FORCENORMALFORWARD: boolean;
  58759. SPECULARAA: boolean;
  58760. CLEARCOAT: boolean;
  58761. CLEARCOAT_DEFAULTIOR: boolean;
  58762. CLEARCOAT_TEXTURE: boolean;
  58763. CLEARCOAT_TEXTUREDIRECTUV: number;
  58764. CLEARCOAT_BUMP: boolean;
  58765. CLEARCOAT_BUMPDIRECTUV: number;
  58766. CLEARCOAT_TINT: boolean;
  58767. CLEARCOAT_TINT_TEXTURE: boolean;
  58768. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58769. ANISOTROPIC: boolean;
  58770. ANISOTROPIC_TEXTURE: boolean;
  58771. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58772. BRDF_V_HEIGHT_CORRELATED: boolean;
  58773. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58774. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58775. SHEEN: boolean;
  58776. SHEEN_TEXTURE: boolean;
  58777. SHEEN_TEXTUREDIRECTUV: number;
  58778. SHEEN_LINKWITHALBEDO: boolean;
  58779. SHEEN_ROUGHNESS: boolean;
  58780. SHEEN_ALBEDOSCALING: boolean;
  58781. SUBSURFACE: boolean;
  58782. SS_REFRACTION: boolean;
  58783. SS_TRANSLUCENCY: boolean;
  58784. SS_SCATTERING: boolean;
  58785. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58786. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58787. SS_REFRACTIONMAP_3D: boolean;
  58788. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58789. SS_LODINREFRACTIONALPHA: boolean;
  58790. SS_GAMMAREFRACTION: boolean;
  58791. SS_RGBDREFRACTION: boolean;
  58792. SS_LINEARSPECULARREFRACTION: boolean;
  58793. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58794. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58795. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58796. UNLIT: boolean;
  58797. DEBUGMODE: number;
  58798. /**
  58799. * Initializes the PBR Material defines.
  58800. */
  58801. constructor();
  58802. /**
  58803. * Resets the PBR Material defines.
  58804. */
  58805. reset(): void;
  58806. }
  58807. /**
  58808. * The Physically based material base class of BJS.
  58809. *
  58810. * This offers the main features of a standard PBR material.
  58811. * For more information, please refer to the documentation :
  58812. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58813. */
  58814. export abstract class PBRBaseMaterial extends PushMaterial {
  58815. /**
  58816. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58817. */
  58818. static readonly PBRMATERIAL_OPAQUE: number;
  58819. /**
  58820. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58821. */
  58822. static readonly PBRMATERIAL_ALPHATEST: number;
  58823. /**
  58824. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58825. */
  58826. static readonly PBRMATERIAL_ALPHABLEND: number;
  58827. /**
  58828. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58829. * They are also discarded below the alpha cutoff threshold to improve performances.
  58830. */
  58831. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58832. /**
  58833. * Defines the default value of how much AO map is occluding the analytical lights
  58834. * (point spot...).
  58835. */
  58836. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58837. /**
  58838. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58839. */
  58840. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58841. /**
  58842. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58843. * to enhance interoperability with other engines.
  58844. */
  58845. static readonly LIGHTFALLOFF_GLTF: number;
  58846. /**
  58847. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58848. * to enhance interoperability with other materials.
  58849. */
  58850. static readonly LIGHTFALLOFF_STANDARD: number;
  58851. /**
  58852. * Intensity of the direct lights e.g. the four lights available in your scene.
  58853. * This impacts both the direct diffuse and specular highlights.
  58854. */
  58855. protected _directIntensity: number;
  58856. /**
  58857. * Intensity of the emissive part of the material.
  58858. * This helps controlling the emissive effect without modifying the emissive color.
  58859. */
  58860. protected _emissiveIntensity: number;
  58861. /**
  58862. * Intensity of the environment e.g. how much the environment will light the object
  58863. * either through harmonics for rough material or through the refelction for shiny ones.
  58864. */
  58865. protected _environmentIntensity: number;
  58866. /**
  58867. * This is a special control allowing the reduction of the specular highlights coming from the
  58868. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58869. */
  58870. protected _specularIntensity: number;
  58871. /**
  58872. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58873. */
  58874. private _lightingInfos;
  58875. /**
  58876. * Debug Control allowing disabling the bump map on this material.
  58877. */
  58878. protected _disableBumpMap: boolean;
  58879. /**
  58880. * AKA Diffuse Texture in standard nomenclature.
  58881. */
  58882. protected _albedoTexture: Nullable<BaseTexture>;
  58883. /**
  58884. * AKA Occlusion Texture in other nomenclature.
  58885. */
  58886. protected _ambientTexture: Nullable<BaseTexture>;
  58887. /**
  58888. * AKA Occlusion Texture Intensity in other nomenclature.
  58889. */
  58890. protected _ambientTextureStrength: number;
  58891. /**
  58892. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58893. * 1 means it completely occludes it
  58894. * 0 mean it has no impact
  58895. */
  58896. protected _ambientTextureImpactOnAnalyticalLights: number;
  58897. /**
  58898. * Stores the alpha values in a texture.
  58899. */
  58900. protected _opacityTexture: Nullable<BaseTexture>;
  58901. /**
  58902. * Stores the reflection values in a texture.
  58903. */
  58904. protected _reflectionTexture: Nullable<BaseTexture>;
  58905. /**
  58906. * Stores the emissive values in a texture.
  58907. */
  58908. protected _emissiveTexture: Nullable<BaseTexture>;
  58909. /**
  58910. * AKA Specular texture in other nomenclature.
  58911. */
  58912. protected _reflectivityTexture: Nullable<BaseTexture>;
  58913. /**
  58914. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58915. */
  58916. protected _metallicTexture: Nullable<BaseTexture>;
  58917. /**
  58918. * Specifies the metallic scalar of the metallic/roughness workflow.
  58919. * Can also be used to scale the metalness values of the metallic texture.
  58920. */
  58921. protected _metallic: Nullable<number>;
  58922. /**
  58923. * Specifies the roughness scalar of the metallic/roughness workflow.
  58924. * Can also be used to scale the roughness values of the metallic texture.
  58925. */
  58926. protected _roughness: Nullable<number>;
  58927. /**
  58928. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58929. * By default the indexOfrefraction is used to compute F0;
  58930. *
  58931. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58932. *
  58933. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58934. * F90 = metallicReflectanceColor;
  58935. */
  58936. protected _metallicF0Factor: number;
  58937. /**
  58938. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58939. * By default the F90 is always 1;
  58940. *
  58941. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58942. *
  58943. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58944. * F90 = metallicReflectanceColor;
  58945. */
  58946. protected _metallicReflectanceColor: Color3;
  58947. /**
  58948. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58949. * This is multiply against the scalar values defined in the material.
  58950. */
  58951. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58952. /**
  58953. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58954. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58955. */
  58956. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58957. /**
  58958. * Stores surface normal data used to displace a mesh in a texture.
  58959. */
  58960. protected _bumpTexture: Nullable<BaseTexture>;
  58961. /**
  58962. * Stores the pre-calculated light information of a mesh in a texture.
  58963. */
  58964. protected _lightmapTexture: Nullable<BaseTexture>;
  58965. /**
  58966. * The color of a material in ambient lighting.
  58967. */
  58968. protected _ambientColor: Color3;
  58969. /**
  58970. * AKA Diffuse Color in other nomenclature.
  58971. */
  58972. protected _albedoColor: Color3;
  58973. /**
  58974. * AKA Specular Color in other nomenclature.
  58975. */
  58976. protected _reflectivityColor: Color3;
  58977. /**
  58978. * The color applied when light is reflected from a material.
  58979. */
  58980. protected _reflectionColor: Color3;
  58981. /**
  58982. * The color applied when light is emitted from a material.
  58983. */
  58984. protected _emissiveColor: Color3;
  58985. /**
  58986. * AKA Glossiness in other nomenclature.
  58987. */
  58988. protected _microSurface: number;
  58989. /**
  58990. * Specifies that the material will use the light map as a show map.
  58991. */
  58992. protected _useLightmapAsShadowmap: boolean;
  58993. /**
  58994. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58995. * makes the reflect vector face the model (under horizon).
  58996. */
  58997. protected _useHorizonOcclusion: boolean;
  58998. /**
  58999. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59000. * too much the area relying on ambient texture to define their ambient occlusion.
  59001. */
  59002. protected _useRadianceOcclusion: boolean;
  59003. /**
  59004. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59005. */
  59006. protected _useAlphaFromAlbedoTexture: boolean;
  59007. /**
  59008. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59009. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59010. */
  59011. protected _useSpecularOverAlpha: boolean;
  59012. /**
  59013. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59014. */
  59015. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59016. /**
  59017. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59018. */
  59019. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59020. /**
  59021. * Specifies if the metallic texture contains the roughness information in its green channel.
  59022. */
  59023. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59024. /**
  59025. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59026. */
  59027. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59028. /**
  59029. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59030. */
  59031. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59032. /**
  59033. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59034. */
  59035. protected _useAmbientInGrayScale: boolean;
  59036. /**
  59037. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59038. * The material will try to infer what glossiness each pixel should be.
  59039. */
  59040. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59041. /**
  59042. * Defines the falloff type used in this material.
  59043. * It by default is Physical.
  59044. */
  59045. protected _lightFalloff: number;
  59046. /**
  59047. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59048. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59049. */
  59050. protected _useRadianceOverAlpha: boolean;
  59051. /**
  59052. * Allows using an object space normal map (instead of tangent space).
  59053. */
  59054. protected _useObjectSpaceNormalMap: boolean;
  59055. /**
  59056. * Allows using the bump map in parallax mode.
  59057. */
  59058. protected _useParallax: boolean;
  59059. /**
  59060. * Allows using the bump map in parallax occlusion mode.
  59061. */
  59062. protected _useParallaxOcclusion: boolean;
  59063. /**
  59064. * Controls the scale bias of the parallax mode.
  59065. */
  59066. protected _parallaxScaleBias: number;
  59067. /**
  59068. * If sets to true, disables all the lights affecting the material.
  59069. */
  59070. protected _disableLighting: boolean;
  59071. /**
  59072. * Number of Simultaneous lights allowed on the material.
  59073. */
  59074. protected _maxSimultaneousLights: number;
  59075. /**
  59076. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59077. */
  59078. protected _invertNormalMapX: boolean;
  59079. /**
  59080. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59081. */
  59082. protected _invertNormalMapY: boolean;
  59083. /**
  59084. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59085. */
  59086. protected _twoSidedLighting: boolean;
  59087. /**
  59088. * Defines the alpha limits in alpha test mode.
  59089. */
  59090. protected _alphaCutOff: number;
  59091. /**
  59092. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59093. */
  59094. protected _forceAlphaTest: boolean;
  59095. /**
  59096. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59097. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59098. */
  59099. protected _useAlphaFresnel: boolean;
  59100. /**
  59101. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59102. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59103. */
  59104. protected _useLinearAlphaFresnel: boolean;
  59105. /**
  59106. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59107. * from cos thetav and roughness:
  59108. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59109. */
  59110. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59111. /**
  59112. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59113. */
  59114. protected _forceIrradianceInFragment: boolean;
  59115. private _realTimeFiltering;
  59116. /**
  59117. * Enables realtime filtering on the texture.
  59118. */
  59119. get realTimeFiltering(): boolean;
  59120. set realTimeFiltering(b: boolean);
  59121. private _realTimeFilteringQuality;
  59122. /**
  59123. * Quality switch for realtime filtering
  59124. */
  59125. get realTimeFilteringQuality(): number;
  59126. set realTimeFilteringQuality(n: number);
  59127. /**
  59128. * Can this material render to several textures at once
  59129. */
  59130. get canRenderToMRT(): boolean;
  59131. /**
  59132. * Force normal to face away from face.
  59133. */
  59134. protected _forceNormalForward: boolean;
  59135. /**
  59136. * Enables specular anti aliasing in the PBR shader.
  59137. * It will both interacts on the Geometry for analytical and IBL lighting.
  59138. * It also prefilter the roughness map based on the bump values.
  59139. */
  59140. protected _enableSpecularAntiAliasing: boolean;
  59141. /**
  59142. * Default configuration related to image processing available in the PBR Material.
  59143. */
  59144. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59145. /**
  59146. * Keep track of the image processing observer to allow dispose and replace.
  59147. */
  59148. private _imageProcessingObserver;
  59149. /**
  59150. * Attaches a new image processing configuration to the PBR Material.
  59151. * @param configuration
  59152. */
  59153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59154. /**
  59155. * Stores the available render targets.
  59156. */
  59157. private _renderTargets;
  59158. /**
  59159. * Sets the global ambient color for the material used in lighting calculations.
  59160. */
  59161. private _globalAmbientColor;
  59162. /**
  59163. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59164. */
  59165. private _useLogarithmicDepth;
  59166. /**
  59167. * If set to true, no lighting calculations will be applied.
  59168. */
  59169. private _unlit;
  59170. private _debugMode;
  59171. /**
  59172. * @hidden
  59173. * This is reserved for the inspector.
  59174. * Defines the material debug mode.
  59175. * It helps seeing only some components of the material while troubleshooting.
  59176. */
  59177. debugMode: number;
  59178. /**
  59179. * @hidden
  59180. * This is reserved for the inspector.
  59181. * Specify from where on screen the debug mode should start.
  59182. * The value goes from -1 (full screen) to 1 (not visible)
  59183. * It helps with side by side comparison against the final render
  59184. * This defaults to -1
  59185. */
  59186. private debugLimit;
  59187. /**
  59188. * @hidden
  59189. * This is reserved for the inspector.
  59190. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59191. * You can use the factor to better multiply the final value.
  59192. */
  59193. private debugFactor;
  59194. /**
  59195. * Defines the clear coat layer parameters for the material.
  59196. */
  59197. readonly clearCoat: PBRClearCoatConfiguration;
  59198. /**
  59199. * Defines the anisotropic parameters for the material.
  59200. */
  59201. readonly anisotropy: PBRAnisotropicConfiguration;
  59202. /**
  59203. * Defines the BRDF parameters for the material.
  59204. */
  59205. readonly brdf: PBRBRDFConfiguration;
  59206. /**
  59207. * Defines the Sheen parameters for the material.
  59208. */
  59209. readonly sheen: PBRSheenConfiguration;
  59210. /**
  59211. * Defines the SubSurface parameters for the material.
  59212. */
  59213. readonly subSurface: PBRSubSurfaceConfiguration;
  59214. /**
  59215. * Defines the detail map parameters for the material.
  59216. */
  59217. readonly detailMap: DetailMapConfiguration;
  59218. protected _rebuildInParallel: boolean;
  59219. /**
  59220. * Instantiates a new PBRMaterial instance.
  59221. *
  59222. * @param name The material name
  59223. * @param scene The scene the material will be use in.
  59224. */
  59225. constructor(name: string, scene: Scene);
  59226. /**
  59227. * Gets a boolean indicating that current material needs to register RTT
  59228. */
  59229. get hasRenderTargetTextures(): boolean;
  59230. /**
  59231. * Gets the name of the material class.
  59232. */
  59233. getClassName(): string;
  59234. /**
  59235. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59236. */
  59237. get useLogarithmicDepth(): boolean;
  59238. /**
  59239. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59240. */
  59241. set useLogarithmicDepth(value: boolean);
  59242. /**
  59243. * Returns true if alpha blending should be disabled.
  59244. */
  59245. protected get _disableAlphaBlending(): boolean;
  59246. /**
  59247. * Specifies whether or not this material should be rendered in alpha blend mode.
  59248. */
  59249. needAlphaBlending(): boolean;
  59250. /**
  59251. * Specifies whether or not this material should be rendered in alpha test mode.
  59252. */
  59253. needAlphaTesting(): boolean;
  59254. /**
  59255. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59256. */
  59257. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59258. /**
  59259. * Gets the texture used for the alpha test.
  59260. */
  59261. getAlphaTestTexture(): Nullable<BaseTexture>;
  59262. /**
  59263. * Specifies that the submesh is ready to be used.
  59264. * @param mesh - BJS mesh.
  59265. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59266. * @param useInstances - Specifies that instances should be used.
  59267. * @returns - boolean indicating that the submesh is ready or not.
  59268. */
  59269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59270. /**
  59271. * Specifies if the material uses metallic roughness workflow.
  59272. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59273. */
  59274. isMetallicWorkflow(): boolean;
  59275. private _prepareEffect;
  59276. private _prepareDefines;
  59277. /**
  59278. * Force shader compilation
  59279. */
  59280. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59281. /**
  59282. * Initializes the uniform buffer layout for the shader.
  59283. */
  59284. buildUniformLayout(): void;
  59285. /**
  59286. * Unbinds the material from the mesh
  59287. */
  59288. unbind(): void;
  59289. /**
  59290. * Binds the submesh data.
  59291. * @param world - The world matrix.
  59292. * @param mesh - The BJS mesh.
  59293. * @param subMesh - A submesh of the BJS mesh.
  59294. */
  59295. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59296. /**
  59297. * Returns the animatable textures.
  59298. * @returns - Array of animatable textures.
  59299. */
  59300. getAnimatables(): IAnimatable[];
  59301. /**
  59302. * Returns the texture used for reflections.
  59303. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59304. */
  59305. private _getReflectionTexture;
  59306. /**
  59307. * Returns an array of the actively used textures.
  59308. * @returns - Array of BaseTextures
  59309. */
  59310. getActiveTextures(): BaseTexture[];
  59311. /**
  59312. * Checks to see if a texture is used in the material.
  59313. * @param texture - Base texture to use.
  59314. * @returns - Boolean specifying if a texture is used in the material.
  59315. */
  59316. hasTexture(texture: BaseTexture): boolean;
  59317. /**
  59318. * Sets the required values to the prepass renderer.
  59319. * @param prePassRenderer defines the prepass renderer to setup
  59320. */
  59321. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59322. /**
  59323. * Disposes the resources of the material.
  59324. * @param forceDisposeEffect - Forces the disposal of effects.
  59325. * @param forceDisposeTextures - Forces the disposal of all textures.
  59326. */
  59327. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59328. }
  59329. }
  59330. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59331. import { Nullable } from "babylonjs/types";
  59332. import { Scene } from "babylonjs/scene";
  59333. import { Color3 } from "babylonjs/Maths/math.color";
  59334. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59335. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59337. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59338. /**
  59339. * The Physically based material of BJS.
  59340. *
  59341. * This offers the main features of a standard PBR material.
  59342. * For more information, please refer to the documentation :
  59343. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59344. */
  59345. export class PBRMaterial extends PBRBaseMaterial {
  59346. /**
  59347. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59348. */
  59349. static readonly PBRMATERIAL_OPAQUE: number;
  59350. /**
  59351. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59352. */
  59353. static readonly PBRMATERIAL_ALPHATEST: number;
  59354. /**
  59355. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59356. */
  59357. static readonly PBRMATERIAL_ALPHABLEND: number;
  59358. /**
  59359. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59360. * They are also discarded below the alpha cutoff threshold to improve performances.
  59361. */
  59362. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59363. /**
  59364. * Defines the default value of how much AO map is occluding the analytical lights
  59365. * (point spot...).
  59366. */
  59367. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59368. /**
  59369. * Intensity of the direct lights e.g. the four lights available in your scene.
  59370. * This impacts both the direct diffuse and specular highlights.
  59371. */
  59372. directIntensity: number;
  59373. /**
  59374. * Intensity of the emissive part of the material.
  59375. * This helps controlling the emissive effect without modifying the emissive color.
  59376. */
  59377. emissiveIntensity: number;
  59378. /**
  59379. * Intensity of the environment e.g. how much the environment will light the object
  59380. * either through harmonics for rough material or through the refelction for shiny ones.
  59381. */
  59382. environmentIntensity: number;
  59383. /**
  59384. * This is a special control allowing the reduction of the specular highlights coming from the
  59385. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59386. */
  59387. specularIntensity: number;
  59388. /**
  59389. * Debug Control allowing disabling the bump map on this material.
  59390. */
  59391. disableBumpMap: boolean;
  59392. /**
  59393. * AKA Diffuse Texture in standard nomenclature.
  59394. */
  59395. albedoTexture: BaseTexture;
  59396. /**
  59397. * AKA Occlusion Texture in other nomenclature.
  59398. */
  59399. ambientTexture: BaseTexture;
  59400. /**
  59401. * AKA Occlusion Texture Intensity in other nomenclature.
  59402. */
  59403. ambientTextureStrength: number;
  59404. /**
  59405. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59406. * 1 means it completely occludes it
  59407. * 0 mean it has no impact
  59408. */
  59409. ambientTextureImpactOnAnalyticalLights: number;
  59410. /**
  59411. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59412. */
  59413. opacityTexture: BaseTexture;
  59414. /**
  59415. * Stores the reflection values in a texture.
  59416. */
  59417. reflectionTexture: Nullable<BaseTexture>;
  59418. /**
  59419. * Stores the emissive values in a texture.
  59420. */
  59421. emissiveTexture: BaseTexture;
  59422. /**
  59423. * AKA Specular texture in other nomenclature.
  59424. */
  59425. reflectivityTexture: BaseTexture;
  59426. /**
  59427. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59428. */
  59429. metallicTexture: BaseTexture;
  59430. /**
  59431. * Specifies the metallic scalar of the metallic/roughness workflow.
  59432. * Can also be used to scale the metalness values of the metallic texture.
  59433. */
  59434. metallic: Nullable<number>;
  59435. /**
  59436. * Specifies the roughness scalar of the metallic/roughness workflow.
  59437. * Can also be used to scale the roughness values of the metallic texture.
  59438. */
  59439. roughness: Nullable<number>;
  59440. /**
  59441. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59442. * By default the indexOfrefraction is used to compute F0;
  59443. *
  59444. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59445. *
  59446. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59447. * F90 = metallicReflectanceColor;
  59448. */
  59449. metallicF0Factor: number;
  59450. /**
  59451. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59452. * By default the F90 is always 1;
  59453. *
  59454. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59455. *
  59456. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59457. * F90 = metallicReflectanceColor;
  59458. */
  59459. metallicReflectanceColor: Color3;
  59460. /**
  59461. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59462. * This is multiply against the scalar values defined in the material.
  59463. */
  59464. metallicReflectanceTexture: Nullable<BaseTexture>;
  59465. /**
  59466. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59467. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59468. */
  59469. microSurfaceTexture: BaseTexture;
  59470. /**
  59471. * Stores surface normal data used to displace a mesh in a texture.
  59472. */
  59473. bumpTexture: BaseTexture;
  59474. /**
  59475. * Stores the pre-calculated light information of a mesh in a texture.
  59476. */
  59477. lightmapTexture: BaseTexture;
  59478. /**
  59479. * Stores the refracted light information in a texture.
  59480. */
  59481. get refractionTexture(): Nullable<BaseTexture>;
  59482. set refractionTexture(value: Nullable<BaseTexture>);
  59483. /**
  59484. * The color of a material in ambient lighting.
  59485. */
  59486. ambientColor: Color3;
  59487. /**
  59488. * AKA Diffuse Color in other nomenclature.
  59489. */
  59490. albedoColor: Color3;
  59491. /**
  59492. * AKA Specular Color in other nomenclature.
  59493. */
  59494. reflectivityColor: Color3;
  59495. /**
  59496. * The color reflected from the material.
  59497. */
  59498. reflectionColor: Color3;
  59499. /**
  59500. * The color emitted from the material.
  59501. */
  59502. emissiveColor: Color3;
  59503. /**
  59504. * AKA Glossiness in other nomenclature.
  59505. */
  59506. microSurface: number;
  59507. /**
  59508. * Index of refraction of the material base layer.
  59509. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59510. *
  59511. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59512. *
  59513. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59514. */
  59515. get indexOfRefraction(): number;
  59516. set indexOfRefraction(value: number);
  59517. /**
  59518. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59519. */
  59520. get invertRefractionY(): boolean;
  59521. set invertRefractionY(value: boolean);
  59522. /**
  59523. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59524. * Materials half opaque for instance using refraction could benefit from this control.
  59525. */
  59526. get linkRefractionWithTransparency(): boolean;
  59527. set linkRefractionWithTransparency(value: boolean);
  59528. /**
  59529. * If true, the light map contains occlusion information instead of lighting info.
  59530. */
  59531. useLightmapAsShadowmap: boolean;
  59532. /**
  59533. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59534. */
  59535. useAlphaFromAlbedoTexture: boolean;
  59536. /**
  59537. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59538. */
  59539. forceAlphaTest: boolean;
  59540. /**
  59541. * Defines the alpha limits in alpha test mode.
  59542. */
  59543. alphaCutOff: number;
  59544. /**
  59545. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59546. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59547. */
  59548. useSpecularOverAlpha: boolean;
  59549. /**
  59550. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59551. */
  59552. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59553. /**
  59554. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59555. */
  59556. useRoughnessFromMetallicTextureAlpha: boolean;
  59557. /**
  59558. * Specifies if the metallic texture contains the roughness information in its green channel.
  59559. */
  59560. useRoughnessFromMetallicTextureGreen: boolean;
  59561. /**
  59562. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59563. */
  59564. useMetallnessFromMetallicTextureBlue: boolean;
  59565. /**
  59566. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59567. */
  59568. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59569. /**
  59570. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59571. */
  59572. useAmbientInGrayScale: boolean;
  59573. /**
  59574. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59575. * The material will try to infer what glossiness each pixel should be.
  59576. */
  59577. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59578. /**
  59579. * BJS is using an harcoded light falloff based on a manually sets up range.
  59580. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59581. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59582. */
  59583. get usePhysicalLightFalloff(): boolean;
  59584. /**
  59585. * BJS is using an harcoded light falloff based on a manually sets up range.
  59586. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59587. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59588. */
  59589. set usePhysicalLightFalloff(value: boolean);
  59590. /**
  59591. * In order to support the falloff compatibility with gltf, a special mode has been added
  59592. * to reproduce the gltf light falloff.
  59593. */
  59594. get useGLTFLightFalloff(): boolean;
  59595. /**
  59596. * In order to support the falloff compatibility with gltf, a special mode has been added
  59597. * to reproduce the gltf light falloff.
  59598. */
  59599. set useGLTFLightFalloff(value: boolean);
  59600. /**
  59601. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59602. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59603. */
  59604. useRadianceOverAlpha: boolean;
  59605. /**
  59606. * Allows using an object space normal map (instead of tangent space).
  59607. */
  59608. useObjectSpaceNormalMap: boolean;
  59609. /**
  59610. * Allows using the bump map in parallax mode.
  59611. */
  59612. useParallax: boolean;
  59613. /**
  59614. * Allows using the bump map in parallax occlusion mode.
  59615. */
  59616. useParallaxOcclusion: boolean;
  59617. /**
  59618. * Controls the scale bias of the parallax mode.
  59619. */
  59620. parallaxScaleBias: number;
  59621. /**
  59622. * If sets to true, disables all the lights affecting the material.
  59623. */
  59624. disableLighting: boolean;
  59625. /**
  59626. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59627. */
  59628. forceIrradianceInFragment: boolean;
  59629. /**
  59630. * Number of Simultaneous lights allowed on the material.
  59631. */
  59632. maxSimultaneousLights: number;
  59633. /**
  59634. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59635. */
  59636. invertNormalMapX: boolean;
  59637. /**
  59638. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59639. */
  59640. invertNormalMapY: boolean;
  59641. /**
  59642. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59643. */
  59644. twoSidedLighting: boolean;
  59645. /**
  59646. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59647. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59648. */
  59649. useAlphaFresnel: boolean;
  59650. /**
  59651. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59652. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59653. */
  59654. useLinearAlphaFresnel: boolean;
  59655. /**
  59656. * Let user defines the brdf lookup texture used for IBL.
  59657. * A default 8bit version is embedded but you could point at :
  59658. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59659. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59660. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59661. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59662. */
  59663. environmentBRDFTexture: Nullable<BaseTexture>;
  59664. /**
  59665. * Force normal to face away from face.
  59666. */
  59667. forceNormalForward: boolean;
  59668. /**
  59669. * Enables specular anti aliasing in the PBR shader.
  59670. * It will both interacts on the Geometry for analytical and IBL lighting.
  59671. * It also prefilter the roughness map based on the bump values.
  59672. */
  59673. enableSpecularAntiAliasing: boolean;
  59674. /**
  59675. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59676. * makes the reflect vector face the model (under horizon).
  59677. */
  59678. useHorizonOcclusion: boolean;
  59679. /**
  59680. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59681. * too much the area relying on ambient texture to define their ambient occlusion.
  59682. */
  59683. useRadianceOcclusion: boolean;
  59684. /**
  59685. * If set to true, no lighting calculations will be applied.
  59686. */
  59687. unlit: boolean;
  59688. /**
  59689. * Gets the image processing configuration used either in this material.
  59690. */
  59691. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59692. /**
  59693. * Sets the Default image processing configuration used either in the this material.
  59694. *
  59695. * If sets to null, the scene one is in use.
  59696. */
  59697. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59698. /**
  59699. * Gets wether the color curves effect is enabled.
  59700. */
  59701. get cameraColorCurvesEnabled(): boolean;
  59702. /**
  59703. * Sets wether the color curves effect is enabled.
  59704. */
  59705. set cameraColorCurvesEnabled(value: boolean);
  59706. /**
  59707. * Gets wether the color grading effect is enabled.
  59708. */
  59709. get cameraColorGradingEnabled(): boolean;
  59710. /**
  59711. * Gets wether the color grading effect is enabled.
  59712. */
  59713. set cameraColorGradingEnabled(value: boolean);
  59714. /**
  59715. * Gets wether tonemapping is enabled or not.
  59716. */
  59717. get cameraToneMappingEnabled(): boolean;
  59718. /**
  59719. * Sets wether tonemapping is enabled or not
  59720. */
  59721. set cameraToneMappingEnabled(value: boolean);
  59722. /**
  59723. * The camera exposure used on this material.
  59724. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59725. * This corresponds to a photographic exposure.
  59726. */
  59727. get cameraExposure(): number;
  59728. /**
  59729. * The camera exposure used on this material.
  59730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59731. * This corresponds to a photographic exposure.
  59732. */
  59733. set cameraExposure(value: number);
  59734. /**
  59735. * Gets The camera contrast used on this material.
  59736. */
  59737. get cameraContrast(): number;
  59738. /**
  59739. * Sets The camera contrast used on this material.
  59740. */
  59741. set cameraContrast(value: number);
  59742. /**
  59743. * Gets the Color Grading 2D Lookup Texture.
  59744. */
  59745. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59746. /**
  59747. * Sets the Color Grading 2D Lookup Texture.
  59748. */
  59749. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59750. /**
  59751. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59752. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59753. * 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;
  59754. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59755. */
  59756. get cameraColorCurves(): Nullable<ColorCurves>;
  59757. /**
  59758. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59759. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59760. * 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;
  59761. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59762. */
  59763. set cameraColorCurves(value: Nullable<ColorCurves>);
  59764. /**
  59765. * Instantiates a new PBRMaterial instance.
  59766. *
  59767. * @param name The material name
  59768. * @param scene The scene the material will be use in.
  59769. */
  59770. constructor(name: string, scene: Scene);
  59771. /**
  59772. * Returns the name of this material class.
  59773. */
  59774. getClassName(): string;
  59775. /**
  59776. * Makes a duplicate of the current material.
  59777. * @param name - name to use for the new material.
  59778. */
  59779. clone(name: string): PBRMaterial;
  59780. /**
  59781. * Serializes this PBR Material.
  59782. * @returns - An object with the serialized material.
  59783. */
  59784. serialize(): any;
  59785. /**
  59786. * Parses a PBR Material from a serialized object.
  59787. * @param source - Serialized object.
  59788. * @param scene - BJS scene instance.
  59789. * @param rootUrl - url for the scene object
  59790. * @returns - PBRMaterial
  59791. */
  59792. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59793. }
  59794. }
  59795. declare module "babylonjs/Misc/dds" {
  59796. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59798. import { Nullable } from "babylonjs/types";
  59799. import { Scene } from "babylonjs/scene";
  59800. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59801. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59802. /**
  59803. * Direct draw surface info
  59804. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59805. */
  59806. export interface DDSInfo {
  59807. /**
  59808. * Width of the texture
  59809. */
  59810. width: number;
  59811. /**
  59812. * Width of the texture
  59813. */
  59814. height: number;
  59815. /**
  59816. * Number of Mipmaps for the texture
  59817. * @see https://en.wikipedia.org/wiki/Mipmap
  59818. */
  59819. mipmapCount: number;
  59820. /**
  59821. * If the textures format is a known fourCC format
  59822. * @see https://www.fourcc.org/
  59823. */
  59824. isFourCC: boolean;
  59825. /**
  59826. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59827. */
  59828. isRGB: boolean;
  59829. /**
  59830. * If the texture is a lumincance format
  59831. */
  59832. isLuminance: boolean;
  59833. /**
  59834. * If this is a cube texture
  59835. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59836. */
  59837. isCube: boolean;
  59838. /**
  59839. * If the texture is a compressed format eg. FOURCC_DXT1
  59840. */
  59841. isCompressed: boolean;
  59842. /**
  59843. * The dxgiFormat of the texture
  59844. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59845. */
  59846. dxgiFormat: number;
  59847. /**
  59848. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59849. */
  59850. textureType: number;
  59851. /**
  59852. * Sphericle polynomial created for the dds texture
  59853. */
  59854. sphericalPolynomial?: SphericalPolynomial;
  59855. }
  59856. /**
  59857. * Class used to provide DDS decompression tools
  59858. */
  59859. export class DDSTools {
  59860. /**
  59861. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59862. */
  59863. static StoreLODInAlphaChannel: boolean;
  59864. /**
  59865. * Gets DDS information from an array buffer
  59866. * @param data defines the array buffer view to read data from
  59867. * @returns the DDS information
  59868. */
  59869. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59870. private static _FloatView;
  59871. private static _Int32View;
  59872. private static _ToHalfFloat;
  59873. private static _FromHalfFloat;
  59874. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59875. private static _GetHalfFloatRGBAArrayBuffer;
  59876. private static _GetFloatRGBAArrayBuffer;
  59877. private static _GetFloatAsUIntRGBAArrayBuffer;
  59878. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59879. private static _GetRGBAArrayBuffer;
  59880. private static _ExtractLongWordOrder;
  59881. private static _GetRGBArrayBuffer;
  59882. private static _GetLuminanceArrayBuffer;
  59883. /**
  59884. * Uploads DDS Levels to a Babylon Texture
  59885. * @hidden
  59886. */
  59887. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59888. }
  59889. module "babylonjs/Engines/thinEngine" {
  59890. interface ThinEngine {
  59891. /**
  59892. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59893. * @param rootUrl defines the url where the file to load is located
  59894. * @param scene defines the current scene
  59895. * @param lodScale defines scale to apply to the mip map selection
  59896. * @param lodOffset defines offset to apply to the mip map selection
  59897. * @param onLoad defines an optional callback raised when the texture is loaded
  59898. * @param onError defines an optional callback raised if there is an issue to load the texture
  59899. * @param format defines the format of the data
  59900. * @param forcedExtension defines the extension to use to pick the right loader
  59901. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59902. * @returns the cube texture as an InternalTexture
  59903. */
  59904. 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;
  59905. }
  59906. }
  59907. }
  59908. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59909. import { Nullable } from "babylonjs/types";
  59910. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59911. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59912. /**
  59913. * Implementation of the DDS Texture Loader.
  59914. * @hidden
  59915. */
  59916. export class _DDSTextureLoader implements IInternalTextureLoader {
  59917. /**
  59918. * Defines wether the loader supports cascade loading the different faces.
  59919. */
  59920. readonly supportCascades: boolean;
  59921. /**
  59922. * This returns if the loader support the current file information.
  59923. * @param extension defines the file extension of the file being loaded
  59924. * @returns true if the loader can load the specified file
  59925. */
  59926. canLoad(extension: string): boolean;
  59927. /**
  59928. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59929. * @param data contains the texture data
  59930. * @param texture defines the BabylonJS internal texture
  59931. * @param createPolynomials will be true if polynomials have been requested
  59932. * @param onLoad defines the callback to trigger once the texture is ready
  59933. * @param onError defines the callback to trigger in case of error
  59934. */
  59935. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59936. /**
  59937. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59938. * @param data contains the texture data
  59939. * @param texture defines the BabylonJS internal texture
  59940. * @param callback defines the method to call once ready to upload
  59941. */
  59942. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59943. }
  59944. }
  59945. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59946. import { Nullable } from "babylonjs/types";
  59947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59948. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59949. /**
  59950. * Implementation of the ENV Texture Loader.
  59951. * @hidden
  59952. */
  59953. export class _ENVTextureLoader implements IInternalTextureLoader {
  59954. /**
  59955. * Defines wether the loader supports cascade loading the different faces.
  59956. */
  59957. readonly supportCascades: boolean;
  59958. /**
  59959. * This returns if the loader support the current file information.
  59960. * @param extension defines the file extension of the file being loaded
  59961. * @returns true if the loader can load the specified file
  59962. */
  59963. canLoad(extension: string): boolean;
  59964. /**
  59965. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59966. * @param data contains the texture data
  59967. * @param texture defines the BabylonJS internal texture
  59968. * @param createPolynomials will be true if polynomials have been requested
  59969. * @param onLoad defines the callback to trigger once the texture is ready
  59970. * @param onError defines the callback to trigger in case of error
  59971. */
  59972. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59973. /**
  59974. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59975. * @param data contains the texture data
  59976. * @param texture defines the BabylonJS internal texture
  59977. * @param callback defines the method to call once ready to upload
  59978. */
  59979. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59980. }
  59981. }
  59982. declare module "babylonjs/Misc/khronosTextureContainer" {
  59983. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59984. /**
  59985. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59986. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59987. */
  59988. export class KhronosTextureContainer {
  59989. /** contents of the KTX container file */
  59990. data: ArrayBufferView;
  59991. private static HEADER_LEN;
  59992. private static COMPRESSED_2D;
  59993. private static COMPRESSED_3D;
  59994. private static TEX_2D;
  59995. private static TEX_3D;
  59996. /**
  59997. * Gets the openGL type
  59998. */
  59999. glType: number;
  60000. /**
  60001. * Gets the openGL type size
  60002. */
  60003. glTypeSize: number;
  60004. /**
  60005. * Gets the openGL format
  60006. */
  60007. glFormat: number;
  60008. /**
  60009. * Gets the openGL internal format
  60010. */
  60011. glInternalFormat: number;
  60012. /**
  60013. * Gets the base internal format
  60014. */
  60015. glBaseInternalFormat: number;
  60016. /**
  60017. * Gets image width in pixel
  60018. */
  60019. pixelWidth: number;
  60020. /**
  60021. * Gets image height in pixel
  60022. */
  60023. pixelHeight: number;
  60024. /**
  60025. * Gets image depth in pixels
  60026. */
  60027. pixelDepth: number;
  60028. /**
  60029. * Gets the number of array elements
  60030. */
  60031. numberOfArrayElements: number;
  60032. /**
  60033. * Gets the number of faces
  60034. */
  60035. numberOfFaces: number;
  60036. /**
  60037. * Gets the number of mipmap levels
  60038. */
  60039. numberOfMipmapLevels: number;
  60040. /**
  60041. * Gets the bytes of key value data
  60042. */
  60043. bytesOfKeyValueData: number;
  60044. /**
  60045. * Gets the load type
  60046. */
  60047. loadType: number;
  60048. /**
  60049. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60050. */
  60051. isInvalid: boolean;
  60052. /**
  60053. * Creates a new KhronosTextureContainer
  60054. * @param data contents of the KTX container file
  60055. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60056. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60057. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60058. */
  60059. constructor(
  60060. /** contents of the KTX container file */
  60061. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60062. /**
  60063. * Uploads KTX content to a Babylon Texture.
  60064. * It is assumed that the texture has already been created & is currently bound
  60065. * @hidden
  60066. */
  60067. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60068. private _upload2DCompressedLevels;
  60069. /**
  60070. * Checks if the given data starts with a KTX file identifier.
  60071. * @param data the data to check
  60072. * @returns true if the data is a KTX file or false otherwise
  60073. */
  60074. static IsValid(data: ArrayBufferView): boolean;
  60075. }
  60076. }
  60077. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60078. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60079. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60080. /**
  60081. * Class for loading KTX2 files
  60082. * !!! Experimental Extension Subject to Changes !!!
  60083. * @hidden
  60084. */
  60085. export class KhronosTextureContainer2 {
  60086. private static _ModulePromise;
  60087. private static _TranscodeFormat;
  60088. constructor(engine: ThinEngine);
  60089. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60090. private _determineTranscodeFormat;
  60091. /**
  60092. * Checks if the given data starts with a KTX2 file identifier.
  60093. * @param data the data to check
  60094. * @returns true if the data is a KTX2 file or false otherwise
  60095. */
  60096. static IsValid(data: ArrayBufferView): boolean;
  60097. }
  60098. }
  60099. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60100. import { Nullable } from "babylonjs/types";
  60101. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60102. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60103. /**
  60104. * Implementation of the KTX Texture Loader.
  60105. * @hidden
  60106. */
  60107. export class _KTXTextureLoader implements IInternalTextureLoader {
  60108. /**
  60109. * Defines wether the loader supports cascade loading the different faces.
  60110. */
  60111. readonly supportCascades: boolean;
  60112. /**
  60113. * This returns if the loader support the current file information.
  60114. * @param extension defines the file extension of the file being loaded
  60115. * @param mimeType defines the optional mime type of the file being loaded
  60116. * @returns true if the loader can load the specified file
  60117. */
  60118. canLoad(extension: string, mimeType?: string): boolean;
  60119. /**
  60120. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60121. * @param data contains the texture data
  60122. * @param texture defines the BabylonJS internal texture
  60123. * @param createPolynomials will be true if polynomials have been requested
  60124. * @param onLoad defines the callback to trigger once the texture is ready
  60125. * @param onError defines the callback to trigger in case of error
  60126. */
  60127. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60128. /**
  60129. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60130. * @param data contains the texture data
  60131. * @param texture defines the BabylonJS internal texture
  60132. * @param callback defines the method to call once ready to upload
  60133. */
  60134. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60135. }
  60136. }
  60137. declare module "babylonjs/Helpers/sceneHelpers" {
  60138. import { Nullable } from "babylonjs/types";
  60139. import { Mesh } from "babylonjs/Meshes/mesh";
  60140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60141. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60142. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60143. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60144. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60145. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60146. import "babylonjs/Meshes/Builders/boxBuilder";
  60147. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60148. /** @hidden */
  60149. export var _forceSceneHelpersToBundle: boolean;
  60150. module "babylonjs/scene" {
  60151. interface Scene {
  60152. /**
  60153. * Creates a default light for the scene.
  60154. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60155. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60156. */
  60157. createDefaultLight(replace?: boolean): void;
  60158. /**
  60159. * Creates a default camera for the scene.
  60160. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60161. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60162. * @param replace has default false, when true replaces the active camera in the scene
  60163. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60164. */
  60165. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60166. /**
  60167. * Creates a default camera and a default light.
  60168. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60169. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60170. * @param replace has the default false, when true replaces the active camera/light in the scene
  60171. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60172. */
  60173. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60174. /**
  60175. * Creates a new sky box
  60176. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60177. * @param environmentTexture defines the texture to use as environment texture
  60178. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60179. * @param scale defines the overall scale of the skybox
  60180. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60181. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60182. * @returns a new mesh holding the sky box
  60183. */
  60184. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60185. /**
  60186. * Creates a new environment
  60187. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60188. * @param options defines the options you can use to configure the environment
  60189. * @returns the new EnvironmentHelper
  60190. */
  60191. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60192. /**
  60193. * Creates a new VREXperienceHelper
  60194. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60195. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60196. * @returns a new VREXperienceHelper
  60197. */
  60198. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60199. /**
  60200. * Creates a new WebXRDefaultExperience
  60201. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60202. * @param options experience options
  60203. * @returns a promise for a new WebXRDefaultExperience
  60204. */
  60205. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60206. }
  60207. }
  60208. }
  60209. declare module "babylonjs/Helpers/videoDome" {
  60210. import { Scene } from "babylonjs/scene";
  60211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60212. import { Mesh } from "babylonjs/Meshes/mesh";
  60213. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60214. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60215. import "babylonjs/Meshes/Builders/sphereBuilder";
  60216. /**
  60217. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60218. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60219. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60220. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60221. */
  60222. export class VideoDome extends TransformNode {
  60223. /**
  60224. * Define the video source as a Monoscopic panoramic 360 video.
  60225. */
  60226. static readonly MODE_MONOSCOPIC: number;
  60227. /**
  60228. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60229. */
  60230. static readonly MODE_TOPBOTTOM: number;
  60231. /**
  60232. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60233. */
  60234. static readonly MODE_SIDEBYSIDE: number;
  60235. private _halfDome;
  60236. private _useDirectMapping;
  60237. /**
  60238. * The video texture being displayed on the sphere
  60239. */
  60240. protected _videoTexture: VideoTexture;
  60241. /**
  60242. * Gets the video texture being displayed on the sphere
  60243. */
  60244. get videoTexture(): VideoTexture;
  60245. /**
  60246. * The skybox material
  60247. */
  60248. protected _material: BackgroundMaterial;
  60249. /**
  60250. * The surface used for the video dome
  60251. */
  60252. protected _mesh: Mesh;
  60253. /**
  60254. * Gets the mesh used for the video dome.
  60255. */
  60256. get mesh(): Mesh;
  60257. /**
  60258. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  60259. */
  60260. private _halfDomeMask;
  60261. /**
  60262. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60263. * Also see the options.resolution property.
  60264. */
  60265. get fovMultiplier(): number;
  60266. set fovMultiplier(value: number);
  60267. private _videoMode;
  60268. /**
  60269. * Gets or set the current video mode for the video. It can be:
  60270. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60271. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60272. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60273. */
  60274. get videoMode(): number;
  60275. set videoMode(value: number);
  60276. /**
  60277. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60278. *
  60279. */
  60280. get halfDome(): boolean;
  60281. /**
  60282. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60283. */
  60284. set halfDome(enabled: boolean);
  60285. /**
  60286. * Oberserver used in Stereoscopic VR Mode.
  60287. */
  60288. private _onBeforeCameraRenderObserver;
  60289. /**
  60290. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60291. * @param name Element's name, child elements will append suffixes for their own names.
  60292. * @param urlsOrVideo defines the url(s) or the video element to use
  60293. * @param options An object containing optional or exposed sub element properties
  60294. */
  60295. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60296. resolution?: number;
  60297. clickToPlay?: boolean;
  60298. autoPlay?: boolean;
  60299. loop?: boolean;
  60300. size?: number;
  60301. poster?: string;
  60302. faceForward?: boolean;
  60303. useDirectMapping?: boolean;
  60304. halfDomeMode?: boolean;
  60305. }, scene: Scene);
  60306. private _changeVideoMode;
  60307. /**
  60308. * Releases resources associated with this node.
  60309. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60310. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60311. */
  60312. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60313. }
  60314. }
  60315. declare module "babylonjs/Helpers/index" {
  60316. export * from "babylonjs/Helpers/environmentHelper";
  60317. export * from "babylonjs/Helpers/photoDome";
  60318. export * from "babylonjs/Helpers/sceneHelpers";
  60319. export * from "babylonjs/Helpers/videoDome";
  60320. }
  60321. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60322. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60323. import { IDisposable } from "babylonjs/scene";
  60324. import { Engine } from "babylonjs/Engines/engine";
  60325. /**
  60326. * This class can be used to get instrumentation data from a Babylon engine
  60327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60328. */
  60329. export class EngineInstrumentation implements IDisposable {
  60330. /**
  60331. * Define the instrumented engine.
  60332. */
  60333. engine: Engine;
  60334. private _captureGPUFrameTime;
  60335. private _gpuFrameTimeToken;
  60336. private _gpuFrameTime;
  60337. private _captureShaderCompilationTime;
  60338. private _shaderCompilationTime;
  60339. private _onBeginFrameObserver;
  60340. private _onEndFrameObserver;
  60341. private _onBeforeShaderCompilationObserver;
  60342. private _onAfterShaderCompilationObserver;
  60343. /**
  60344. * Gets the perf counter used for GPU frame time
  60345. */
  60346. get gpuFrameTimeCounter(): PerfCounter;
  60347. /**
  60348. * Gets the GPU frame time capture status
  60349. */
  60350. get captureGPUFrameTime(): boolean;
  60351. /**
  60352. * Enable or disable the GPU frame time capture
  60353. */
  60354. set captureGPUFrameTime(value: boolean);
  60355. /**
  60356. * Gets the perf counter used for shader compilation time
  60357. */
  60358. get shaderCompilationTimeCounter(): PerfCounter;
  60359. /**
  60360. * Gets the shader compilation time capture status
  60361. */
  60362. get captureShaderCompilationTime(): boolean;
  60363. /**
  60364. * Enable or disable the shader compilation time capture
  60365. */
  60366. set captureShaderCompilationTime(value: boolean);
  60367. /**
  60368. * Instantiates a new engine instrumentation.
  60369. * This class can be used to get instrumentation data from a Babylon engine
  60370. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60371. * @param engine Defines the engine to instrument
  60372. */
  60373. constructor(
  60374. /**
  60375. * Define the instrumented engine.
  60376. */
  60377. engine: Engine);
  60378. /**
  60379. * Dispose and release associated resources.
  60380. */
  60381. dispose(): void;
  60382. }
  60383. }
  60384. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60385. import { Scene, IDisposable } from "babylonjs/scene";
  60386. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60387. /**
  60388. * This class can be used to get instrumentation data from a Babylon engine
  60389. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60390. */
  60391. export class SceneInstrumentation implements IDisposable {
  60392. /**
  60393. * Defines the scene to instrument
  60394. */
  60395. scene: Scene;
  60396. private _captureActiveMeshesEvaluationTime;
  60397. private _activeMeshesEvaluationTime;
  60398. private _captureRenderTargetsRenderTime;
  60399. private _renderTargetsRenderTime;
  60400. private _captureFrameTime;
  60401. private _frameTime;
  60402. private _captureRenderTime;
  60403. private _renderTime;
  60404. private _captureInterFrameTime;
  60405. private _interFrameTime;
  60406. private _captureParticlesRenderTime;
  60407. private _particlesRenderTime;
  60408. private _captureSpritesRenderTime;
  60409. private _spritesRenderTime;
  60410. private _capturePhysicsTime;
  60411. private _physicsTime;
  60412. private _captureAnimationsTime;
  60413. private _animationsTime;
  60414. private _captureCameraRenderTime;
  60415. private _cameraRenderTime;
  60416. private _onBeforeActiveMeshesEvaluationObserver;
  60417. private _onAfterActiveMeshesEvaluationObserver;
  60418. private _onBeforeRenderTargetsRenderObserver;
  60419. private _onAfterRenderTargetsRenderObserver;
  60420. private _onAfterRenderObserver;
  60421. private _onBeforeDrawPhaseObserver;
  60422. private _onAfterDrawPhaseObserver;
  60423. private _onBeforeAnimationsObserver;
  60424. private _onBeforeParticlesRenderingObserver;
  60425. private _onAfterParticlesRenderingObserver;
  60426. private _onBeforeSpritesRenderingObserver;
  60427. private _onAfterSpritesRenderingObserver;
  60428. private _onBeforePhysicsObserver;
  60429. private _onAfterPhysicsObserver;
  60430. private _onAfterAnimationsObserver;
  60431. private _onBeforeCameraRenderObserver;
  60432. private _onAfterCameraRenderObserver;
  60433. /**
  60434. * Gets the perf counter used for active meshes evaluation time
  60435. */
  60436. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60437. /**
  60438. * Gets the active meshes evaluation time capture status
  60439. */
  60440. get captureActiveMeshesEvaluationTime(): boolean;
  60441. /**
  60442. * Enable or disable the active meshes evaluation time capture
  60443. */
  60444. set captureActiveMeshesEvaluationTime(value: boolean);
  60445. /**
  60446. * Gets the perf counter used for render targets render time
  60447. */
  60448. get renderTargetsRenderTimeCounter(): PerfCounter;
  60449. /**
  60450. * Gets the render targets render time capture status
  60451. */
  60452. get captureRenderTargetsRenderTime(): boolean;
  60453. /**
  60454. * Enable or disable the render targets render time capture
  60455. */
  60456. set captureRenderTargetsRenderTime(value: boolean);
  60457. /**
  60458. * Gets the perf counter used for particles render time
  60459. */
  60460. get particlesRenderTimeCounter(): PerfCounter;
  60461. /**
  60462. * Gets the particles render time capture status
  60463. */
  60464. get captureParticlesRenderTime(): boolean;
  60465. /**
  60466. * Enable or disable the particles render time capture
  60467. */
  60468. set captureParticlesRenderTime(value: boolean);
  60469. /**
  60470. * Gets the perf counter used for sprites render time
  60471. */
  60472. get spritesRenderTimeCounter(): PerfCounter;
  60473. /**
  60474. * Gets the sprites render time capture status
  60475. */
  60476. get captureSpritesRenderTime(): boolean;
  60477. /**
  60478. * Enable or disable the sprites render time capture
  60479. */
  60480. set captureSpritesRenderTime(value: boolean);
  60481. /**
  60482. * Gets the perf counter used for physics time
  60483. */
  60484. get physicsTimeCounter(): PerfCounter;
  60485. /**
  60486. * Gets the physics time capture status
  60487. */
  60488. get capturePhysicsTime(): boolean;
  60489. /**
  60490. * Enable or disable the physics time capture
  60491. */
  60492. set capturePhysicsTime(value: boolean);
  60493. /**
  60494. * Gets the perf counter used for animations time
  60495. */
  60496. get animationsTimeCounter(): PerfCounter;
  60497. /**
  60498. * Gets the animations time capture status
  60499. */
  60500. get captureAnimationsTime(): boolean;
  60501. /**
  60502. * Enable or disable the animations time capture
  60503. */
  60504. set captureAnimationsTime(value: boolean);
  60505. /**
  60506. * Gets the perf counter used for frame time capture
  60507. */
  60508. get frameTimeCounter(): PerfCounter;
  60509. /**
  60510. * Gets the frame time capture status
  60511. */
  60512. get captureFrameTime(): boolean;
  60513. /**
  60514. * Enable or disable the frame time capture
  60515. */
  60516. set captureFrameTime(value: boolean);
  60517. /**
  60518. * Gets the perf counter used for inter-frames time capture
  60519. */
  60520. get interFrameTimeCounter(): PerfCounter;
  60521. /**
  60522. * Gets the inter-frames time capture status
  60523. */
  60524. get captureInterFrameTime(): boolean;
  60525. /**
  60526. * Enable or disable the inter-frames time capture
  60527. */
  60528. set captureInterFrameTime(value: boolean);
  60529. /**
  60530. * Gets the perf counter used for render time capture
  60531. */
  60532. get renderTimeCounter(): PerfCounter;
  60533. /**
  60534. * Gets the render time capture status
  60535. */
  60536. get captureRenderTime(): boolean;
  60537. /**
  60538. * Enable or disable the render time capture
  60539. */
  60540. set captureRenderTime(value: boolean);
  60541. /**
  60542. * Gets the perf counter used for camera render time capture
  60543. */
  60544. get cameraRenderTimeCounter(): PerfCounter;
  60545. /**
  60546. * Gets the camera render time capture status
  60547. */
  60548. get captureCameraRenderTime(): boolean;
  60549. /**
  60550. * Enable or disable the camera render time capture
  60551. */
  60552. set captureCameraRenderTime(value: boolean);
  60553. /**
  60554. * Gets the perf counter used for draw calls
  60555. */
  60556. get drawCallsCounter(): PerfCounter;
  60557. /**
  60558. * Instantiates a new scene instrumentation.
  60559. * This class can be used to get instrumentation data from a Babylon engine
  60560. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60561. * @param scene Defines the scene to instrument
  60562. */
  60563. constructor(
  60564. /**
  60565. * Defines the scene to instrument
  60566. */
  60567. scene: Scene);
  60568. /**
  60569. * Dispose and release associated resources.
  60570. */
  60571. dispose(): void;
  60572. }
  60573. }
  60574. declare module "babylonjs/Instrumentation/index" {
  60575. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60576. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60577. export * from "babylonjs/Instrumentation/timeToken";
  60578. }
  60579. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60580. /** @hidden */
  60581. export var glowMapGenerationPixelShader: {
  60582. name: string;
  60583. shader: string;
  60584. };
  60585. }
  60586. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60587. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60590. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60591. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60592. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60593. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60594. /** @hidden */
  60595. export var glowMapGenerationVertexShader: {
  60596. name: string;
  60597. shader: string;
  60598. };
  60599. }
  60600. declare module "babylonjs/Layers/effectLayer" {
  60601. import { Observable } from "babylonjs/Misc/observable";
  60602. import { Nullable } from "babylonjs/types";
  60603. import { Camera } from "babylonjs/Cameras/camera";
  60604. import { Scene } from "babylonjs/scene";
  60605. import { ISize } from "babylonjs/Maths/math.size";
  60606. import { Color4 } from "babylonjs/Maths/math.color";
  60607. import { Engine } from "babylonjs/Engines/engine";
  60608. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60610. import { Mesh } from "babylonjs/Meshes/mesh";
  60611. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60614. import { Effect } from "babylonjs/Materials/effect";
  60615. import { Material } from "babylonjs/Materials/material";
  60616. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60617. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60618. /**
  60619. * Effect layer options. This helps customizing the behaviour
  60620. * of the effect layer.
  60621. */
  60622. export interface IEffectLayerOptions {
  60623. /**
  60624. * Multiplication factor apply to the canvas size to compute the render target size
  60625. * used to generated the objects (the smaller the faster).
  60626. */
  60627. mainTextureRatio: number;
  60628. /**
  60629. * Enforces a fixed size texture to ensure effect stability across devices.
  60630. */
  60631. mainTextureFixedSize?: number;
  60632. /**
  60633. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60634. */
  60635. alphaBlendingMode: number;
  60636. /**
  60637. * The camera attached to the layer.
  60638. */
  60639. camera: Nullable<Camera>;
  60640. /**
  60641. * The rendering group to draw the layer in.
  60642. */
  60643. renderingGroupId: number;
  60644. }
  60645. /**
  60646. * The effect layer Helps adding post process effect blended with the main pass.
  60647. *
  60648. * This can be for instance use to generate glow or higlight effects on the scene.
  60649. *
  60650. * The effect layer class can not be used directly and is intented to inherited from to be
  60651. * customized per effects.
  60652. */
  60653. export abstract class EffectLayer {
  60654. private _vertexBuffers;
  60655. private _indexBuffer;
  60656. private _cachedDefines;
  60657. private _effectLayerMapGenerationEffect;
  60658. private _effectLayerOptions;
  60659. private _mergeEffect;
  60660. protected _scene: Scene;
  60661. protected _engine: Engine;
  60662. protected _maxSize: number;
  60663. protected _mainTextureDesiredSize: ISize;
  60664. protected _mainTexture: RenderTargetTexture;
  60665. protected _shouldRender: boolean;
  60666. protected _postProcesses: PostProcess[];
  60667. protected _textures: BaseTexture[];
  60668. protected _emissiveTextureAndColor: {
  60669. texture: Nullable<BaseTexture>;
  60670. color: Color4;
  60671. };
  60672. /**
  60673. * The name of the layer
  60674. */
  60675. name: string;
  60676. /**
  60677. * The clear color of the texture used to generate the glow map.
  60678. */
  60679. neutralColor: Color4;
  60680. /**
  60681. * Specifies whether the highlight layer is enabled or not.
  60682. */
  60683. isEnabled: boolean;
  60684. /**
  60685. * Gets the camera attached to the layer.
  60686. */
  60687. get camera(): Nullable<Camera>;
  60688. /**
  60689. * Gets the rendering group id the layer should render in.
  60690. */
  60691. get renderingGroupId(): number;
  60692. set renderingGroupId(renderingGroupId: number);
  60693. /**
  60694. * An event triggered when the effect layer has been disposed.
  60695. */
  60696. onDisposeObservable: Observable<EffectLayer>;
  60697. /**
  60698. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60699. */
  60700. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60701. /**
  60702. * An event triggered when the generated texture is being merged in the scene.
  60703. */
  60704. onBeforeComposeObservable: Observable<EffectLayer>;
  60705. /**
  60706. * An event triggered when the mesh is rendered into the effect render target.
  60707. */
  60708. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60709. /**
  60710. * An event triggered after the mesh has been rendered into the effect render target.
  60711. */
  60712. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60713. /**
  60714. * An event triggered when the generated texture has been merged in the scene.
  60715. */
  60716. onAfterComposeObservable: Observable<EffectLayer>;
  60717. /**
  60718. * An event triggered when the efffect layer changes its size.
  60719. */
  60720. onSizeChangedObservable: Observable<EffectLayer>;
  60721. /** @hidden */
  60722. static _SceneComponentInitialization: (scene: Scene) => void;
  60723. /**
  60724. * Instantiates a new effect Layer and references it in the scene.
  60725. * @param name The name of the layer
  60726. * @param scene The scene to use the layer in
  60727. */
  60728. constructor(
  60729. /** The Friendly of the effect in the scene */
  60730. name: string, scene: Scene);
  60731. /**
  60732. * Get the effect name of the layer.
  60733. * @return The effect name
  60734. */
  60735. abstract getEffectName(): string;
  60736. /**
  60737. * Checks for the readiness of the element composing the layer.
  60738. * @param subMesh the mesh to check for
  60739. * @param useInstances specify whether or not to use instances to render the mesh
  60740. * @return true if ready otherwise, false
  60741. */
  60742. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60743. /**
  60744. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60745. * @returns true if the effect requires stencil during the main canvas render pass.
  60746. */
  60747. abstract needStencil(): boolean;
  60748. /**
  60749. * Create the merge effect. This is the shader use to blit the information back
  60750. * to the main canvas at the end of the scene rendering.
  60751. * @returns The effect containing the shader used to merge the effect on the main canvas
  60752. */
  60753. protected abstract _createMergeEffect(): Effect;
  60754. /**
  60755. * Creates the render target textures and post processes used in the effect layer.
  60756. */
  60757. protected abstract _createTextureAndPostProcesses(): void;
  60758. /**
  60759. * Implementation specific of rendering the generating effect on the main canvas.
  60760. * @param effect The effect used to render through
  60761. */
  60762. protected abstract _internalRender(effect: Effect): void;
  60763. /**
  60764. * Sets the required values for both the emissive texture and and the main color.
  60765. */
  60766. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60767. /**
  60768. * Free any resources and references associated to a mesh.
  60769. * Internal use
  60770. * @param mesh The mesh to free.
  60771. */
  60772. abstract _disposeMesh(mesh: Mesh): void;
  60773. /**
  60774. * Serializes this layer (Glow or Highlight for example)
  60775. * @returns a serialized layer object
  60776. */
  60777. abstract serialize?(): any;
  60778. /**
  60779. * Initializes the effect layer with the required options.
  60780. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60781. */
  60782. protected _init(options: Partial<IEffectLayerOptions>): void;
  60783. /**
  60784. * Generates the index buffer of the full screen quad blending to the main canvas.
  60785. */
  60786. private _generateIndexBuffer;
  60787. /**
  60788. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60789. */
  60790. private _generateVertexBuffer;
  60791. /**
  60792. * Sets the main texture desired size which is the closest power of two
  60793. * of the engine canvas size.
  60794. */
  60795. private _setMainTextureSize;
  60796. /**
  60797. * Creates the main texture for the effect layer.
  60798. */
  60799. protected _createMainTexture(): void;
  60800. /**
  60801. * Adds specific effects defines.
  60802. * @param defines The defines to add specifics to.
  60803. */
  60804. protected _addCustomEffectDefines(defines: string[]): void;
  60805. /**
  60806. * Checks for the readiness of the element composing the layer.
  60807. * @param subMesh the mesh to check for
  60808. * @param useInstances specify whether or not to use instances to render the mesh
  60809. * @param emissiveTexture the associated emissive texture used to generate the glow
  60810. * @return true if ready otherwise, false
  60811. */
  60812. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60813. /**
  60814. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60815. */
  60816. render(): void;
  60817. /**
  60818. * Determine if a given mesh will be used in the current effect.
  60819. * @param mesh mesh to test
  60820. * @returns true if the mesh will be used
  60821. */
  60822. hasMesh(mesh: AbstractMesh): boolean;
  60823. /**
  60824. * Returns true if the layer contains information to display, otherwise false.
  60825. * @returns true if the glow layer should be rendered
  60826. */
  60827. shouldRender(): boolean;
  60828. /**
  60829. * Returns true if the mesh should render, otherwise false.
  60830. * @param mesh The mesh to render
  60831. * @returns true if it should render otherwise false
  60832. */
  60833. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60834. /**
  60835. * Returns true if the mesh can be rendered, otherwise false.
  60836. * @param mesh The mesh to render
  60837. * @param material The material used on the mesh
  60838. * @returns true if it can be rendered otherwise false
  60839. */
  60840. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60841. /**
  60842. * Returns true if the mesh should render, otherwise false.
  60843. * @param mesh The mesh to render
  60844. * @returns true if it should render otherwise false
  60845. */
  60846. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60847. /**
  60848. * Renders the submesh passed in parameter to the generation map.
  60849. */
  60850. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60851. /**
  60852. * Defines whether the current material of the mesh should be use to render the effect.
  60853. * @param mesh defines the current mesh to render
  60854. */
  60855. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60856. /**
  60857. * Rebuild the required buffers.
  60858. * @hidden Internal use only.
  60859. */
  60860. _rebuild(): void;
  60861. /**
  60862. * Dispose only the render target textures and post process.
  60863. */
  60864. private _disposeTextureAndPostProcesses;
  60865. /**
  60866. * Dispose the highlight layer and free resources.
  60867. */
  60868. dispose(): void;
  60869. /**
  60870. * Gets the class name of the effect layer
  60871. * @returns the string with the class name of the effect layer
  60872. */
  60873. getClassName(): string;
  60874. /**
  60875. * Creates an effect layer from parsed effect layer data
  60876. * @param parsedEffectLayer defines effect layer data
  60877. * @param scene defines the current scene
  60878. * @param rootUrl defines the root URL containing the effect layer information
  60879. * @returns a parsed effect Layer
  60880. */
  60881. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60882. }
  60883. }
  60884. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60885. import { Scene } from "babylonjs/scene";
  60886. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60887. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60888. import { AbstractScene } from "babylonjs/abstractScene";
  60889. module "babylonjs/abstractScene" {
  60890. interface AbstractScene {
  60891. /**
  60892. * The list of effect layers (highlights/glow) added to the scene
  60893. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60894. * @see https://doc.babylonjs.com/how_to/glow_layer
  60895. */
  60896. effectLayers: Array<EffectLayer>;
  60897. /**
  60898. * Removes the given effect layer from this scene.
  60899. * @param toRemove defines the effect layer to remove
  60900. * @returns the index of the removed effect layer
  60901. */
  60902. removeEffectLayer(toRemove: EffectLayer): number;
  60903. /**
  60904. * Adds the given effect layer to this scene
  60905. * @param newEffectLayer defines the effect layer to add
  60906. */
  60907. addEffectLayer(newEffectLayer: EffectLayer): void;
  60908. }
  60909. }
  60910. /**
  60911. * Defines the layer scene component responsible to manage any effect layers
  60912. * in a given scene.
  60913. */
  60914. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60915. /**
  60916. * The component name helpfull to identify the component in the list of scene components.
  60917. */
  60918. readonly name: string;
  60919. /**
  60920. * The scene the component belongs to.
  60921. */
  60922. scene: Scene;
  60923. private _engine;
  60924. private _renderEffects;
  60925. private _needStencil;
  60926. private _previousStencilState;
  60927. /**
  60928. * Creates a new instance of the component for the given scene
  60929. * @param scene Defines the scene to register the component in
  60930. */
  60931. constructor(scene: Scene);
  60932. /**
  60933. * Registers the component in a given scene
  60934. */
  60935. register(): void;
  60936. /**
  60937. * Rebuilds the elements related to this component in case of
  60938. * context lost for instance.
  60939. */
  60940. rebuild(): void;
  60941. /**
  60942. * Serializes the component data to the specified json object
  60943. * @param serializationObject The object to serialize to
  60944. */
  60945. serialize(serializationObject: any): void;
  60946. /**
  60947. * Adds all the elements from the container to the scene
  60948. * @param container the container holding the elements
  60949. */
  60950. addFromContainer(container: AbstractScene): void;
  60951. /**
  60952. * Removes all the elements in the container from the scene
  60953. * @param container contains the elements to remove
  60954. * @param dispose if the removed element should be disposed (default: false)
  60955. */
  60956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60957. /**
  60958. * Disposes the component and the associated ressources.
  60959. */
  60960. dispose(): void;
  60961. private _isReadyForMesh;
  60962. private _renderMainTexture;
  60963. private _setStencil;
  60964. private _setStencilBack;
  60965. private _draw;
  60966. private _drawCamera;
  60967. private _drawRenderingGroup;
  60968. }
  60969. }
  60970. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60971. /** @hidden */
  60972. export var glowMapMergePixelShader: {
  60973. name: string;
  60974. shader: string;
  60975. };
  60976. }
  60977. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60978. /** @hidden */
  60979. export var glowMapMergeVertexShader: {
  60980. name: string;
  60981. shader: string;
  60982. };
  60983. }
  60984. declare module "babylonjs/Layers/glowLayer" {
  60985. import { Nullable } from "babylonjs/types";
  60986. import { Camera } from "babylonjs/Cameras/camera";
  60987. import { Scene } from "babylonjs/scene";
  60988. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60990. import { Mesh } from "babylonjs/Meshes/mesh";
  60991. import { Texture } from "babylonjs/Materials/Textures/texture";
  60992. import { Effect } from "babylonjs/Materials/effect";
  60993. import { Material } from "babylonjs/Materials/material";
  60994. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60995. import { Color4 } from "babylonjs/Maths/math.color";
  60996. import "babylonjs/Shaders/glowMapMerge.fragment";
  60997. import "babylonjs/Shaders/glowMapMerge.vertex";
  60998. import "babylonjs/Layers/effectLayerSceneComponent";
  60999. module "babylonjs/abstractScene" {
  61000. interface AbstractScene {
  61001. /**
  61002. * Return a the first highlight layer of the scene with a given name.
  61003. * @param name The name of the highlight layer to look for.
  61004. * @return The highlight layer if found otherwise null.
  61005. */
  61006. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61007. }
  61008. }
  61009. /**
  61010. * Glow layer options. This helps customizing the behaviour
  61011. * of the glow layer.
  61012. */
  61013. export interface IGlowLayerOptions {
  61014. /**
  61015. * Multiplication factor apply to the canvas size to compute the render target size
  61016. * used to generated the glowing objects (the smaller the faster).
  61017. */
  61018. mainTextureRatio: number;
  61019. /**
  61020. * Enforces a fixed size texture to ensure resize independant blur.
  61021. */
  61022. mainTextureFixedSize?: number;
  61023. /**
  61024. * How big is the kernel of the blur texture.
  61025. */
  61026. blurKernelSize: number;
  61027. /**
  61028. * The camera attached to the layer.
  61029. */
  61030. camera: Nullable<Camera>;
  61031. /**
  61032. * Enable MSAA by chosing the number of samples.
  61033. */
  61034. mainTextureSamples?: number;
  61035. /**
  61036. * The rendering group to draw the layer in.
  61037. */
  61038. renderingGroupId: number;
  61039. }
  61040. /**
  61041. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61042. *
  61043. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61044. *
  61045. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61046. */
  61047. export class GlowLayer extends EffectLayer {
  61048. /**
  61049. * Effect Name of the layer.
  61050. */
  61051. static readonly EffectName: string;
  61052. /**
  61053. * The default blur kernel size used for the glow.
  61054. */
  61055. static DefaultBlurKernelSize: number;
  61056. /**
  61057. * The default texture size ratio used for the glow.
  61058. */
  61059. static DefaultTextureRatio: number;
  61060. /**
  61061. * Sets the kernel size of the blur.
  61062. */
  61063. set blurKernelSize(value: number);
  61064. /**
  61065. * Gets the kernel size of the blur.
  61066. */
  61067. get blurKernelSize(): number;
  61068. /**
  61069. * Sets the glow intensity.
  61070. */
  61071. set intensity(value: number);
  61072. /**
  61073. * Gets the glow intensity.
  61074. */
  61075. get intensity(): number;
  61076. private _options;
  61077. private _intensity;
  61078. private _horizontalBlurPostprocess1;
  61079. private _verticalBlurPostprocess1;
  61080. private _horizontalBlurPostprocess2;
  61081. private _verticalBlurPostprocess2;
  61082. private _blurTexture1;
  61083. private _blurTexture2;
  61084. private _postProcesses1;
  61085. private _postProcesses2;
  61086. private _includedOnlyMeshes;
  61087. private _excludedMeshes;
  61088. private _meshesUsingTheirOwnMaterials;
  61089. /**
  61090. * Callback used to let the user override the color selection on a per mesh basis
  61091. */
  61092. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61093. /**
  61094. * Callback used to let the user override the texture selection on a per mesh basis
  61095. */
  61096. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61097. /**
  61098. * Instantiates a new glow Layer and references it to the scene.
  61099. * @param name The name of the layer
  61100. * @param scene The scene to use the layer in
  61101. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61102. */
  61103. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61104. /**
  61105. * Get the effect name of the layer.
  61106. * @return The effect name
  61107. */
  61108. getEffectName(): string;
  61109. /**
  61110. * Create the merge effect. This is the shader use to blit the information back
  61111. * to the main canvas at the end of the scene rendering.
  61112. */
  61113. protected _createMergeEffect(): Effect;
  61114. /**
  61115. * Creates the render target textures and post processes used in the glow layer.
  61116. */
  61117. protected _createTextureAndPostProcesses(): void;
  61118. /**
  61119. * Checks for the readiness of the element composing the layer.
  61120. * @param subMesh the mesh to check for
  61121. * @param useInstances specify wether or not to use instances to render the mesh
  61122. * @param emissiveTexture the associated emissive texture used to generate the glow
  61123. * @return true if ready otherwise, false
  61124. */
  61125. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61126. /**
  61127. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61128. */
  61129. needStencil(): boolean;
  61130. /**
  61131. * Returns true if the mesh can be rendered, otherwise false.
  61132. * @param mesh The mesh to render
  61133. * @param material The material used on the mesh
  61134. * @returns true if it can be rendered otherwise false
  61135. */
  61136. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61137. /**
  61138. * Implementation specific of rendering the generating effect on the main canvas.
  61139. * @param effect The effect used to render through
  61140. */
  61141. protected _internalRender(effect: Effect): void;
  61142. /**
  61143. * Sets the required values for both the emissive texture and and the main color.
  61144. */
  61145. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61146. /**
  61147. * Returns true if the mesh should render, otherwise false.
  61148. * @param mesh The mesh to render
  61149. * @returns true if it should render otherwise false
  61150. */
  61151. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61152. /**
  61153. * Adds specific effects defines.
  61154. * @param defines The defines to add specifics to.
  61155. */
  61156. protected _addCustomEffectDefines(defines: string[]): void;
  61157. /**
  61158. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61159. * @param mesh The mesh to exclude from the glow layer
  61160. */
  61161. addExcludedMesh(mesh: Mesh): void;
  61162. /**
  61163. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61164. * @param mesh The mesh to remove
  61165. */
  61166. removeExcludedMesh(mesh: Mesh): void;
  61167. /**
  61168. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61169. * @param mesh The mesh to include in the glow layer
  61170. */
  61171. addIncludedOnlyMesh(mesh: Mesh): void;
  61172. /**
  61173. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61174. * @param mesh The mesh to remove
  61175. */
  61176. removeIncludedOnlyMesh(mesh: Mesh): void;
  61177. /**
  61178. * Determine if a given mesh will be used in the glow layer
  61179. * @param mesh The mesh to test
  61180. * @returns true if the mesh will be highlighted by the current glow layer
  61181. */
  61182. hasMesh(mesh: AbstractMesh): boolean;
  61183. /**
  61184. * Defines whether the current material of the mesh should be use to render the effect.
  61185. * @param mesh defines the current mesh to render
  61186. */
  61187. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61188. /**
  61189. * Add a mesh to be rendered through its own material and not with emissive only.
  61190. * @param mesh The mesh for which we need to use its material
  61191. */
  61192. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61193. /**
  61194. * Remove a mesh from being rendered through its own material and not with emissive only.
  61195. * @param mesh The mesh for which we need to not use its material
  61196. */
  61197. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61198. /**
  61199. * Free any resources and references associated to a mesh.
  61200. * Internal use
  61201. * @param mesh The mesh to free.
  61202. * @hidden
  61203. */
  61204. _disposeMesh(mesh: Mesh): void;
  61205. /**
  61206. * Gets the class name of the effect layer
  61207. * @returns the string with the class name of the effect layer
  61208. */
  61209. getClassName(): string;
  61210. /**
  61211. * Serializes this glow layer
  61212. * @returns a serialized glow layer object
  61213. */
  61214. serialize(): any;
  61215. /**
  61216. * Creates a Glow Layer from parsed glow layer data
  61217. * @param parsedGlowLayer defines glow layer data
  61218. * @param scene defines the current scene
  61219. * @param rootUrl defines the root URL containing the glow layer information
  61220. * @returns a parsed Glow Layer
  61221. */
  61222. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61223. }
  61224. }
  61225. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61226. /** @hidden */
  61227. export var glowBlurPostProcessPixelShader: {
  61228. name: string;
  61229. shader: string;
  61230. };
  61231. }
  61232. declare module "babylonjs/Layers/highlightLayer" {
  61233. import { Observable } from "babylonjs/Misc/observable";
  61234. import { Nullable } from "babylonjs/types";
  61235. import { Camera } from "babylonjs/Cameras/camera";
  61236. import { Scene } from "babylonjs/scene";
  61237. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61239. import { Mesh } from "babylonjs/Meshes/mesh";
  61240. import { Effect } from "babylonjs/Materials/effect";
  61241. import { Material } from "babylonjs/Materials/material";
  61242. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61243. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61244. import "babylonjs/Shaders/glowMapMerge.fragment";
  61245. import "babylonjs/Shaders/glowMapMerge.vertex";
  61246. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61247. module "babylonjs/abstractScene" {
  61248. interface AbstractScene {
  61249. /**
  61250. * Return a the first highlight layer of the scene with a given name.
  61251. * @param name The name of the highlight layer to look for.
  61252. * @return The highlight layer if found otherwise null.
  61253. */
  61254. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61255. }
  61256. }
  61257. /**
  61258. * Highlight layer options. This helps customizing the behaviour
  61259. * of the highlight layer.
  61260. */
  61261. export interface IHighlightLayerOptions {
  61262. /**
  61263. * Multiplication factor apply to the canvas size to compute the render target size
  61264. * used to generated the glowing objects (the smaller the faster).
  61265. */
  61266. mainTextureRatio: number;
  61267. /**
  61268. * Enforces a fixed size texture to ensure resize independant blur.
  61269. */
  61270. mainTextureFixedSize?: number;
  61271. /**
  61272. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61273. * of the picture to blur (the smaller the faster).
  61274. */
  61275. blurTextureSizeRatio: number;
  61276. /**
  61277. * How big in texel of the blur texture is the vertical blur.
  61278. */
  61279. blurVerticalSize: number;
  61280. /**
  61281. * How big in texel of the blur texture is the horizontal blur.
  61282. */
  61283. blurHorizontalSize: number;
  61284. /**
  61285. * Alpha blending mode used to apply the blur. Default is combine.
  61286. */
  61287. alphaBlendingMode: number;
  61288. /**
  61289. * The camera attached to the layer.
  61290. */
  61291. camera: Nullable<Camera>;
  61292. /**
  61293. * Should we display highlight as a solid stroke?
  61294. */
  61295. isStroke?: boolean;
  61296. /**
  61297. * The rendering group to draw the layer in.
  61298. */
  61299. renderingGroupId: number;
  61300. }
  61301. /**
  61302. * The highlight layer Helps adding a glow effect around a mesh.
  61303. *
  61304. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61305. * glowy meshes to your scene.
  61306. *
  61307. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61308. */
  61309. export class HighlightLayer extends EffectLayer {
  61310. name: string;
  61311. /**
  61312. * Effect Name of the highlight layer.
  61313. */
  61314. static readonly EffectName: string;
  61315. /**
  61316. * The neutral color used during the preparation of the glow effect.
  61317. * This is black by default as the blend operation is a blend operation.
  61318. */
  61319. static NeutralColor: Color4;
  61320. /**
  61321. * Stencil value used for glowing meshes.
  61322. */
  61323. static GlowingMeshStencilReference: number;
  61324. /**
  61325. * Stencil value used for the other meshes in the scene.
  61326. */
  61327. static NormalMeshStencilReference: number;
  61328. /**
  61329. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61330. */
  61331. innerGlow: boolean;
  61332. /**
  61333. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61334. */
  61335. outerGlow: boolean;
  61336. /**
  61337. * Specifies the horizontal size of the blur.
  61338. */
  61339. set blurHorizontalSize(value: number);
  61340. /**
  61341. * Specifies the vertical size of the blur.
  61342. */
  61343. set blurVerticalSize(value: number);
  61344. /**
  61345. * Gets the horizontal size of the blur.
  61346. */
  61347. get blurHorizontalSize(): number;
  61348. /**
  61349. * Gets the vertical size of the blur.
  61350. */
  61351. get blurVerticalSize(): number;
  61352. /**
  61353. * An event triggered when the highlight layer is being blurred.
  61354. */
  61355. onBeforeBlurObservable: Observable<HighlightLayer>;
  61356. /**
  61357. * An event triggered when the highlight layer has been blurred.
  61358. */
  61359. onAfterBlurObservable: Observable<HighlightLayer>;
  61360. private _instanceGlowingMeshStencilReference;
  61361. private _options;
  61362. private _downSamplePostprocess;
  61363. private _horizontalBlurPostprocess;
  61364. private _verticalBlurPostprocess;
  61365. private _blurTexture;
  61366. private _meshes;
  61367. private _excludedMeshes;
  61368. /**
  61369. * Instantiates a new highlight Layer and references it to the scene..
  61370. * @param name The name of the layer
  61371. * @param scene The scene to use the layer in
  61372. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61373. */
  61374. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61375. /**
  61376. * Get the effect name of the layer.
  61377. * @return The effect name
  61378. */
  61379. getEffectName(): string;
  61380. /**
  61381. * Create the merge effect. This is the shader use to blit the information back
  61382. * to the main canvas at the end of the scene rendering.
  61383. */
  61384. protected _createMergeEffect(): Effect;
  61385. /**
  61386. * Creates the render target textures and post processes used in the highlight layer.
  61387. */
  61388. protected _createTextureAndPostProcesses(): void;
  61389. /**
  61390. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61391. */
  61392. needStencil(): boolean;
  61393. /**
  61394. * Checks for the readiness of the element composing the layer.
  61395. * @param subMesh the mesh to check for
  61396. * @param useInstances specify wether or not to use instances to render the mesh
  61397. * @param emissiveTexture the associated emissive texture used to generate the glow
  61398. * @return true if ready otherwise, false
  61399. */
  61400. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61401. /**
  61402. * Implementation specific of rendering the generating effect on the main canvas.
  61403. * @param effect The effect used to render through
  61404. */
  61405. protected _internalRender(effect: Effect): void;
  61406. /**
  61407. * Returns true if the layer contains information to display, otherwise false.
  61408. */
  61409. shouldRender(): boolean;
  61410. /**
  61411. * Returns true if the mesh should render, otherwise false.
  61412. * @param mesh The mesh to render
  61413. * @returns true if it should render otherwise false
  61414. */
  61415. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61416. /**
  61417. * Returns true if the mesh can be rendered, otherwise false.
  61418. * @param mesh The mesh to render
  61419. * @param material The material used on the mesh
  61420. * @returns true if it can be rendered otherwise false
  61421. */
  61422. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61423. /**
  61424. * Adds specific effects defines.
  61425. * @param defines The defines to add specifics to.
  61426. */
  61427. protected _addCustomEffectDefines(defines: string[]): void;
  61428. /**
  61429. * Sets the required values for both the emissive texture and and the main color.
  61430. */
  61431. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61432. /**
  61433. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61434. * @param mesh The mesh to exclude from the highlight layer
  61435. */
  61436. addExcludedMesh(mesh: Mesh): void;
  61437. /**
  61438. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61439. * @param mesh The mesh to highlight
  61440. */
  61441. removeExcludedMesh(mesh: Mesh): void;
  61442. /**
  61443. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61444. * @param mesh mesh to test
  61445. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61446. */
  61447. hasMesh(mesh: AbstractMesh): boolean;
  61448. /**
  61449. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61450. * @param mesh The mesh to highlight
  61451. * @param color The color of the highlight
  61452. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61453. */
  61454. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61455. /**
  61456. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61457. * @param mesh The mesh to highlight
  61458. */
  61459. removeMesh(mesh: Mesh): void;
  61460. /**
  61461. * Remove all the meshes currently referenced in the highlight layer
  61462. */
  61463. removeAllMeshes(): void;
  61464. /**
  61465. * Force the stencil to the normal expected value for none glowing parts
  61466. */
  61467. private _defaultStencilReference;
  61468. /**
  61469. * Free any resources and references associated to a mesh.
  61470. * Internal use
  61471. * @param mesh The mesh to free.
  61472. * @hidden
  61473. */
  61474. _disposeMesh(mesh: Mesh): void;
  61475. /**
  61476. * Dispose the highlight layer and free resources.
  61477. */
  61478. dispose(): void;
  61479. /**
  61480. * Gets the class name of the effect layer
  61481. * @returns the string with the class name of the effect layer
  61482. */
  61483. getClassName(): string;
  61484. /**
  61485. * Serializes this Highlight layer
  61486. * @returns a serialized Highlight layer object
  61487. */
  61488. serialize(): any;
  61489. /**
  61490. * Creates a Highlight layer from parsed Highlight layer data
  61491. * @param parsedHightlightLayer defines the Highlight layer data
  61492. * @param scene defines the current scene
  61493. * @param rootUrl defines the root URL containing the Highlight layer information
  61494. * @returns a parsed Highlight layer
  61495. */
  61496. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61497. }
  61498. }
  61499. declare module "babylonjs/Layers/layerSceneComponent" {
  61500. import { Scene } from "babylonjs/scene";
  61501. import { ISceneComponent } from "babylonjs/sceneComponent";
  61502. import { Layer } from "babylonjs/Layers/layer";
  61503. import { AbstractScene } from "babylonjs/abstractScene";
  61504. module "babylonjs/abstractScene" {
  61505. interface AbstractScene {
  61506. /**
  61507. * The list of layers (background and foreground) of the scene
  61508. */
  61509. layers: Array<Layer>;
  61510. }
  61511. }
  61512. /**
  61513. * Defines the layer scene component responsible to manage any layers
  61514. * in a given scene.
  61515. */
  61516. export class LayerSceneComponent implements ISceneComponent {
  61517. /**
  61518. * The component name helpfull to identify the component in the list of scene components.
  61519. */
  61520. readonly name: string;
  61521. /**
  61522. * The scene the component belongs to.
  61523. */
  61524. scene: Scene;
  61525. private _engine;
  61526. /**
  61527. * Creates a new instance of the component for the given scene
  61528. * @param scene Defines the scene to register the component in
  61529. */
  61530. constructor(scene: Scene);
  61531. /**
  61532. * Registers the component in a given scene
  61533. */
  61534. register(): void;
  61535. /**
  61536. * Rebuilds the elements related to this component in case of
  61537. * context lost for instance.
  61538. */
  61539. rebuild(): void;
  61540. /**
  61541. * Disposes the component and the associated ressources.
  61542. */
  61543. dispose(): void;
  61544. private _draw;
  61545. private _drawCameraPredicate;
  61546. private _drawCameraBackground;
  61547. private _drawCameraForeground;
  61548. private _drawRenderTargetPredicate;
  61549. private _drawRenderTargetBackground;
  61550. private _drawRenderTargetForeground;
  61551. /**
  61552. * Adds all the elements from the container to the scene
  61553. * @param container the container holding the elements
  61554. */
  61555. addFromContainer(container: AbstractScene): void;
  61556. /**
  61557. * Removes all the elements in the container from the scene
  61558. * @param container contains the elements to remove
  61559. * @param dispose if the removed element should be disposed (default: false)
  61560. */
  61561. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61562. }
  61563. }
  61564. declare module "babylonjs/Shaders/layer.fragment" {
  61565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61566. /** @hidden */
  61567. export var layerPixelShader: {
  61568. name: string;
  61569. shader: string;
  61570. };
  61571. }
  61572. declare module "babylonjs/Shaders/layer.vertex" {
  61573. /** @hidden */
  61574. export var layerVertexShader: {
  61575. name: string;
  61576. shader: string;
  61577. };
  61578. }
  61579. declare module "babylonjs/Layers/layer" {
  61580. import { Observable } from "babylonjs/Misc/observable";
  61581. import { Nullable } from "babylonjs/types";
  61582. import { Scene } from "babylonjs/scene";
  61583. import { Vector2 } from "babylonjs/Maths/math.vector";
  61584. import { Color4 } from "babylonjs/Maths/math.color";
  61585. import { Texture } from "babylonjs/Materials/Textures/texture";
  61586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61587. import "babylonjs/Shaders/layer.fragment";
  61588. import "babylonjs/Shaders/layer.vertex";
  61589. /**
  61590. * This represents a full screen 2d layer.
  61591. * This can be useful to display a picture in the background of your scene for instance.
  61592. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61593. */
  61594. export class Layer {
  61595. /**
  61596. * Define the name of the layer.
  61597. */
  61598. name: string;
  61599. /**
  61600. * Define the texture the layer should display.
  61601. */
  61602. texture: Nullable<Texture>;
  61603. /**
  61604. * Is the layer in background or foreground.
  61605. */
  61606. isBackground: boolean;
  61607. /**
  61608. * Define the color of the layer (instead of texture).
  61609. */
  61610. color: Color4;
  61611. /**
  61612. * Define the scale of the layer in order to zoom in out of the texture.
  61613. */
  61614. scale: Vector2;
  61615. /**
  61616. * Define an offset for the layer in order to shift the texture.
  61617. */
  61618. offset: Vector2;
  61619. /**
  61620. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61621. */
  61622. alphaBlendingMode: number;
  61623. /**
  61624. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61625. * Alpha test will not mix with the background color in case of transparency.
  61626. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61627. */
  61628. alphaTest: boolean;
  61629. /**
  61630. * Define a mask to restrict the layer to only some of the scene cameras.
  61631. */
  61632. layerMask: number;
  61633. /**
  61634. * Define the list of render target the layer is visible into.
  61635. */
  61636. renderTargetTextures: RenderTargetTexture[];
  61637. /**
  61638. * Define if the layer is only used in renderTarget or if it also
  61639. * renders in the main frame buffer of the canvas.
  61640. */
  61641. renderOnlyInRenderTargetTextures: boolean;
  61642. private _scene;
  61643. private _vertexBuffers;
  61644. private _indexBuffer;
  61645. private _effect;
  61646. private _previousDefines;
  61647. /**
  61648. * An event triggered when the layer is disposed.
  61649. */
  61650. onDisposeObservable: Observable<Layer>;
  61651. private _onDisposeObserver;
  61652. /**
  61653. * Back compatibility with callback before the onDisposeObservable existed.
  61654. * The set callback will be triggered when the layer has been disposed.
  61655. */
  61656. set onDispose(callback: () => void);
  61657. /**
  61658. * An event triggered before rendering the scene
  61659. */
  61660. onBeforeRenderObservable: Observable<Layer>;
  61661. private _onBeforeRenderObserver;
  61662. /**
  61663. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61664. * The set callback will be triggered just before rendering the layer.
  61665. */
  61666. set onBeforeRender(callback: () => void);
  61667. /**
  61668. * An event triggered after rendering the scene
  61669. */
  61670. onAfterRenderObservable: Observable<Layer>;
  61671. private _onAfterRenderObserver;
  61672. /**
  61673. * Back compatibility with callback before the onAfterRenderObservable existed.
  61674. * The set callback will be triggered just after rendering the layer.
  61675. */
  61676. set onAfterRender(callback: () => void);
  61677. /**
  61678. * Instantiates a new layer.
  61679. * This represents a full screen 2d layer.
  61680. * This can be useful to display a picture in the background of your scene for instance.
  61681. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61682. * @param name Define the name of the layer in the scene
  61683. * @param imgUrl Define the url of the texture to display in the layer
  61684. * @param scene Define the scene the layer belongs to
  61685. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61686. * @param color Defines a color for the layer
  61687. */
  61688. constructor(
  61689. /**
  61690. * Define the name of the layer.
  61691. */
  61692. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61693. private _createIndexBuffer;
  61694. /** @hidden */
  61695. _rebuild(): void;
  61696. /**
  61697. * Renders the layer in the scene.
  61698. */
  61699. render(): void;
  61700. /**
  61701. * Disposes and releases the associated ressources.
  61702. */
  61703. dispose(): void;
  61704. }
  61705. }
  61706. declare module "babylonjs/Layers/index" {
  61707. export * from "babylonjs/Layers/effectLayer";
  61708. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61709. export * from "babylonjs/Layers/glowLayer";
  61710. export * from "babylonjs/Layers/highlightLayer";
  61711. export * from "babylonjs/Layers/layer";
  61712. export * from "babylonjs/Layers/layerSceneComponent";
  61713. }
  61714. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61715. /** @hidden */
  61716. export var lensFlarePixelShader: {
  61717. name: string;
  61718. shader: string;
  61719. };
  61720. }
  61721. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61722. /** @hidden */
  61723. export var lensFlareVertexShader: {
  61724. name: string;
  61725. shader: string;
  61726. };
  61727. }
  61728. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61729. import { Scene } from "babylonjs/scene";
  61730. import { Vector3 } from "babylonjs/Maths/math.vector";
  61731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61732. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61733. import "babylonjs/Shaders/lensFlare.fragment";
  61734. import "babylonjs/Shaders/lensFlare.vertex";
  61735. import { Viewport } from "babylonjs/Maths/math.viewport";
  61736. /**
  61737. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61738. * It is usually composed of several `lensFlare`.
  61739. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61740. */
  61741. export class LensFlareSystem {
  61742. /**
  61743. * Define the name of the lens flare system
  61744. */
  61745. name: string;
  61746. /**
  61747. * List of lens flares used in this system.
  61748. */
  61749. lensFlares: LensFlare[];
  61750. /**
  61751. * Define a limit from the border the lens flare can be visible.
  61752. */
  61753. borderLimit: number;
  61754. /**
  61755. * Define a viewport border we do not want to see the lens flare in.
  61756. */
  61757. viewportBorder: number;
  61758. /**
  61759. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61760. */
  61761. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61762. /**
  61763. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61764. */
  61765. layerMask: number;
  61766. /**
  61767. * Define the id of the lens flare system in the scene.
  61768. * (equal to name by default)
  61769. */
  61770. id: string;
  61771. private _scene;
  61772. private _emitter;
  61773. private _vertexBuffers;
  61774. private _indexBuffer;
  61775. private _effect;
  61776. private _positionX;
  61777. private _positionY;
  61778. private _isEnabled;
  61779. /** @hidden */
  61780. static _SceneComponentInitialization: (scene: Scene) => void;
  61781. /**
  61782. * Instantiates a lens flare system.
  61783. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61784. * It is usually composed of several `lensFlare`.
  61785. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61786. * @param name Define the name of the lens flare system in the scene
  61787. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61788. * @param scene Define the scene the lens flare system belongs to
  61789. */
  61790. constructor(
  61791. /**
  61792. * Define the name of the lens flare system
  61793. */
  61794. name: string, emitter: any, scene: Scene);
  61795. /**
  61796. * Define if the lens flare system is enabled.
  61797. */
  61798. get isEnabled(): boolean;
  61799. set isEnabled(value: boolean);
  61800. /**
  61801. * Get the scene the effects belongs to.
  61802. * @returns the scene holding the lens flare system
  61803. */
  61804. getScene(): Scene;
  61805. /**
  61806. * Get the emitter of the lens flare system.
  61807. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61808. * @returns the emitter of the lens flare system
  61809. */
  61810. getEmitter(): any;
  61811. /**
  61812. * Set the emitter of the lens flare system.
  61813. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61814. * @param newEmitter Define the new emitter of the system
  61815. */
  61816. setEmitter(newEmitter: any): void;
  61817. /**
  61818. * Get the lens flare system emitter position.
  61819. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61820. * @returns the position
  61821. */
  61822. getEmitterPosition(): Vector3;
  61823. /**
  61824. * @hidden
  61825. */
  61826. computeEffectivePosition(globalViewport: Viewport): boolean;
  61827. /** @hidden */
  61828. _isVisible(): boolean;
  61829. /**
  61830. * @hidden
  61831. */
  61832. render(): boolean;
  61833. /**
  61834. * Dispose and release the lens flare with its associated resources.
  61835. */
  61836. dispose(): void;
  61837. /**
  61838. * Parse a lens flare system from a JSON repressentation
  61839. * @param parsedLensFlareSystem Define the JSON to parse
  61840. * @param scene Define the scene the parsed system should be instantiated in
  61841. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61842. * @returns the parsed system
  61843. */
  61844. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61845. /**
  61846. * Serialize the current Lens Flare System into a JSON representation.
  61847. * @returns the serialized JSON
  61848. */
  61849. serialize(): any;
  61850. }
  61851. }
  61852. declare module "babylonjs/LensFlares/lensFlare" {
  61853. import { Nullable } from "babylonjs/types";
  61854. import { Color3 } from "babylonjs/Maths/math.color";
  61855. import { Texture } from "babylonjs/Materials/Textures/texture";
  61856. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61857. /**
  61858. * This represents one of the lens effect in a `lensFlareSystem`.
  61859. * It controls one of the indiviual texture used in the effect.
  61860. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61861. */
  61862. export class LensFlare {
  61863. /**
  61864. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61865. */
  61866. size: number;
  61867. /**
  61868. * 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.
  61869. */
  61870. position: number;
  61871. /**
  61872. * Define the lens color.
  61873. */
  61874. color: Color3;
  61875. /**
  61876. * Define the lens texture.
  61877. */
  61878. texture: Nullable<Texture>;
  61879. /**
  61880. * Define the alpha mode to render this particular lens.
  61881. */
  61882. alphaMode: number;
  61883. private _system;
  61884. /**
  61885. * Creates a new Lens Flare.
  61886. * This represents one of the lens effect in a `lensFlareSystem`.
  61887. * It controls one of the indiviual texture used in the effect.
  61888. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61889. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61890. * @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.
  61891. * @param color Define the lens color
  61892. * @param imgUrl Define the lens texture url
  61893. * @param system Define the `lensFlareSystem` this flare is part of
  61894. * @returns The newly created Lens Flare
  61895. */
  61896. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61897. /**
  61898. * Instantiates a new Lens Flare.
  61899. * This represents one of the lens effect in a `lensFlareSystem`.
  61900. * It controls one of the indiviual texture used in the effect.
  61901. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61902. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61903. * @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.
  61904. * @param color Define the lens color
  61905. * @param imgUrl Define the lens texture url
  61906. * @param system Define the `lensFlareSystem` this flare is part of
  61907. */
  61908. constructor(
  61909. /**
  61910. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61911. */
  61912. size: number,
  61913. /**
  61914. * 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.
  61915. */
  61916. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61917. /**
  61918. * Dispose and release the lens flare with its associated resources.
  61919. */
  61920. dispose(): void;
  61921. }
  61922. }
  61923. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61924. import { Nullable } from "babylonjs/types";
  61925. import { Scene } from "babylonjs/scene";
  61926. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61927. import { AbstractScene } from "babylonjs/abstractScene";
  61928. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61929. module "babylonjs/abstractScene" {
  61930. interface AbstractScene {
  61931. /**
  61932. * The list of lens flare system added to the scene
  61933. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61934. */
  61935. lensFlareSystems: Array<LensFlareSystem>;
  61936. /**
  61937. * Removes the given lens flare system from this scene.
  61938. * @param toRemove The lens flare system to remove
  61939. * @returns The index of the removed lens flare system
  61940. */
  61941. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61942. /**
  61943. * Adds the given lens flare system to this scene
  61944. * @param newLensFlareSystem The lens flare system to add
  61945. */
  61946. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61947. /**
  61948. * Gets a lens flare system using its name
  61949. * @param name defines the name to look for
  61950. * @returns the lens flare system or null if not found
  61951. */
  61952. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61953. /**
  61954. * Gets a lens flare system using its id
  61955. * @param id defines the id to look for
  61956. * @returns the lens flare system or null if not found
  61957. */
  61958. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61959. }
  61960. }
  61961. /**
  61962. * Defines the lens flare scene component responsible to manage any lens flares
  61963. * in a given scene.
  61964. */
  61965. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61966. /**
  61967. * The component name helpfull to identify the component in the list of scene components.
  61968. */
  61969. readonly name: string;
  61970. /**
  61971. * The scene the component belongs to.
  61972. */
  61973. scene: Scene;
  61974. /**
  61975. * Creates a new instance of the component for the given scene
  61976. * @param scene Defines the scene to register the component in
  61977. */
  61978. constructor(scene: Scene);
  61979. /**
  61980. * Registers the component in a given scene
  61981. */
  61982. register(): void;
  61983. /**
  61984. * Rebuilds the elements related to this component in case of
  61985. * context lost for instance.
  61986. */
  61987. rebuild(): void;
  61988. /**
  61989. * Adds all the elements from the container to the scene
  61990. * @param container the container holding the elements
  61991. */
  61992. addFromContainer(container: AbstractScene): void;
  61993. /**
  61994. * Removes all the elements in the container from the scene
  61995. * @param container contains the elements to remove
  61996. * @param dispose if the removed element should be disposed (default: false)
  61997. */
  61998. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61999. /**
  62000. * Serializes the component data to the specified json object
  62001. * @param serializationObject The object to serialize to
  62002. */
  62003. serialize(serializationObject: any): void;
  62004. /**
  62005. * Disposes the component and the associated ressources.
  62006. */
  62007. dispose(): void;
  62008. private _draw;
  62009. }
  62010. }
  62011. declare module "babylonjs/LensFlares/index" {
  62012. export * from "babylonjs/LensFlares/lensFlare";
  62013. export * from "babylonjs/LensFlares/lensFlareSystem";
  62014. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62015. }
  62016. declare module "babylonjs/Shaders/depth.fragment" {
  62017. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62018. /** @hidden */
  62019. export var depthPixelShader: {
  62020. name: string;
  62021. shader: string;
  62022. };
  62023. }
  62024. declare module "babylonjs/Shaders/depth.vertex" {
  62025. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62026. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62027. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62028. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62029. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62030. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62031. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62032. /** @hidden */
  62033. export var depthVertexShader: {
  62034. name: string;
  62035. shader: string;
  62036. };
  62037. }
  62038. declare module "babylonjs/Rendering/depthRenderer" {
  62039. import { Nullable } from "babylonjs/types";
  62040. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62041. import { Scene } from "babylonjs/scene";
  62042. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62043. import { Camera } from "babylonjs/Cameras/camera";
  62044. import "babylonjs/Shaders/depth.fragment";
  62045. import "babylonjs/Shaders/depth.vertex";
  62046. /**
  62047. * This represents a depth renderer in Babylon.
  62048. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62049. */
  62050. export class DepthRenderer {
  62051. private _scene;
  62052. private _depthMap;
  62053. private _effect;
  62054. private readonly _storeNonLinearDepth;
  62055. private readonly _clearColor;
  62056. /** Get if the depth renderer is using packed depth or not */
  62057. readonly isPacked: boolean;
  62058. private _cachedDefines;
  62059. private _camera;
  62060. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62061. enabled: boolean;
  62062. /**
  62063. * Specifiess that the depth renderer will only be used within
  62064. * the camera it is created for.
  62065. * This can help forcing its rendering during the camera processing.
  62066. */
  62067. useOnlyInActiveCamera: boolean;
  62068. /** @hidden */
  62069. static _SceneComponentInitialization: (scene: Scene) => void;
  62070. /**
  62071. * Instantiates a depth renderer
  62072. * @param scene The scene the renderer belongs to
  62073. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62074. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62075. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62076. */
  62077. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62078. /**
  62079. * Creates the depth rendering effect and checks if the effect is ready.
  62080. * @param subMesh The submesh to be used to render the depth map of
  62081. * @param useInstances If multiple world instances should be used
  62082. * @returns if the depth renderer is ready to render the depth map
  62083. */
  62084. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62085. /**
  62086. * Gets the texture which the depth map will be written to.
  62087. * @returns The depth map texture
  62088. */
  62089. getDepthMap(): RenderTargetTexture;
  62090. /**
  62091. * Disposes of the depth renderer.
  62092. */
  62093. dispose(): void;
  62094. }
  62095. }
  62096. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62097. /** @hidden */
  62098. export var minmaxReduxPixelShader: {
  62099. name: string;
  62100. shader: string;
  62101. };
  62102. }
  62103. declare module "babylonjs/Misc/minMaxReducer" {
  62104. import { Nullable } from "babylonjs/types";
  62105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62106. import { Camera } from "babylonjs/Cameras/camera";
  62107. import { Observer } from "babylonjs/Misc/observable";
  62108. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62109. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62110. import { Observable } from "babylonjs/Misc/observable";
  62111. import "babylonjs/Shaders/minmaxRedux.fragment";
  62112. /**
  62113. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62114. * and maximum values from all values of the texture.
  62115. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62116. * The source values are read from the red channel of the texture.
  62117. */
  62118. export class MinMaxReducer {
  62119. /**
  62120. * Observable triggered when the computation has been performed
  62121. */
  62122. onAfterReductionPerformed: Observable<{
  62123. min: number;
  62124. max: number;
  62125. }>;
  62126. protected _camera: Camera;
  62127. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62128. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62129. protected _postProcessManager: PostProcessManager;
  62130. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62131. protected _forceFullscreenViewport: boolean;
  62132. /**
  62133. * Creates a min/max reducer
  62134. * @param camera The camera to use for the post processes
  62135. */
  62136. constructor(camera: Camera);
  62137. /**
  62138. * Gets the texture used to read the values from.
  62139. */
  62140. get sourceTexture(): Nullable<RenderTargetTexture>;
  62141. /**
  62142. * Sets the source texture to read the values from.
  62143. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62144. * because in such textures '1' value must not be taken into account to compute the maximum
  62145. * as this value is used to clear the texture.
  62146. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62147. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62148. * @param depthRedux Indicates if the texture is a depth texture or not
  62149. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62150. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62151. */
  62152. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62153. /**
  62154. * Defines the refresh rate of the computation.
  62155. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62156. */
  62157. get refreshRate(): number;
  62158. set refreshRate(value: number);
  62159. protected _activated: boolean;
  62160. /**
  62161. * Gets the activation status of the reducer
  62162. */
  62163. get activated(): boolean;
  62164. /**
  62165. * Activates the reduction computation.
  62166. * When activated, the observers registered in onAfterReductionPerformed are
  62167. * called after the compuation is performed
  62168. */
  62169. activate(): void;
  62170. /**
  62171. * Deactivates the reduction computation.
  62172. */
  62173. deactivate(): void;
  62174. /**
  62175. * Disposes the min/max reducer
  62176. * @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.
  62177. */
  62178. dispose(disposeAll?: boolean): void;
  62179. }
  62180. }
  62181. declare module "babylonjs/Misc/depthReducer" {
  62182. import { Nullable } from "babylonjs/types";
  62183. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62184. import { Camera } from "babylonjs/Cameras/camera";
  62185. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62186. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62187. /**
  62188. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62189. */
  62190. export class DepthReducer extends MinMaxReducer {
  62191. private _depthRenderer;
  62192. private _depthRendererId;
  62193. /**
  62194. * Gets the depth renderer used for the computation.
  62195. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62196. */
  62197. get depthRenderer(): Nullable<DepthRenderer>;
  62198. /**
  62199. * Creates a depth reducer
  62200. * @param camera The camera used to render the depth texture
  62201. */
  62202. constructor(camera: Camera);
  62203. /**
  62204. * Sets the depth renderer to use to generate the depth map
  62205. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62206. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62207. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62208. */
  62209. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62210. /** @hidden */
  62211. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62212. /**
  62213. * Activates the reduction computation.
  62214. * When activated, the observers registered in onAfterReductionPerformed are
  62215. * called after the compuation is performed
  62216. */
  62217. activate(): void;
  62218. /**
  62219. * Deactivates the reduction computation.
  62220. */
  62221. deactivate(): void;
  62222. /**
  62223. * Disposes the depth reducer
  62224. * @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.
  62225. */
  62226. dispose(disposeAll?: boolean): void;
  62227. }
  62228. }
  62229. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62230. import { Nullable } from "babylonjs/types";
  62231. import { Scene } from "babylonjs/scene";
  62232. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62235. import { Effect } from "babylonjs/Materials/effect";
  62236. import "babylonjs/Shaders/shadowMap.fragment";
  62237. import "babylonjs/Shaders/shadowMap.vertex";
  62238. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62239. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62240. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62241. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62242. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62243. /**
  62244. * A CSM implementation allowing casting shadows on large scenes.
  62245. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62246. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62247. */
  62248. export class CascadedShadowGenerator extends ShadowGenerator {
  62249. private static readonly frustumCornersNDCSpace;
  62250. /**
  62251. * Name of the CSM class
  62252. */
  62253. static CLASSNAME: string;
  62254. /**
  62255. * Defines the default number of cascades used by the CSM.
  62256. */
  62257. static readonly DEFAULT_CASCADES_COUNT: number;
  62258. /**
  62259. * Defines the minimum number of cascades used by the CSM.
  62260. */
  62261. static readonly MIN_CASCADES_COUNT: number;
  62262. /**
  62263. * Defines the maximum number of cascades used by the CSM.
  62264. */
  62265. static readonly MAX_CASCADES_COUNT: number;
  62266. protected _validateFilter(filter: number): number;
  62267. /**
  62268. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62269. */
  62270. penumbraDarkness: number;
  62271. private _numCascades;
  62272. /**
  62273. * Gets or set the number of cascades used by the CSM.
  62274. */
  62275. get numCascades(): number;
  62276. set numCascades(value: number);
  62277. /**
  62278. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62279. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62280. */
  62281. stabilizeCascades: boolean;
  62282. private _freezeShadowCastersBoundingInfo;
  62283. private _freezeShadowCastersBoundingInfoObservable;
  62284. /**
  62285. * Enables or disables the shadow casters bounding info computation.
  62286. * If your shadow casters don't move, you can disable this feature.
  62287. * If it is enabled, the bounding box computation is done every frame.
  62288. */
  62289. get freezeShadowCastersBoundingInfo(): boolean;
  62290. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62291. private _scbiMin;
  62292. private _scbiMax;
  62293. protected _computeShadowCastersBoundingInfo(): void;
  62294. protected _shadowCastersBoundingInfo: BoundingInfo;
  62295. /**
  62296. * Gets or sets the shadow casters bounding info.
  62297. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62298. * so that the system won't overwrite the bounds you provide
  62299. */
  62300. get shadowCastersBoundingInfo(): BoundingInfo;
  62301. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62302. protected _breaksAreDirty: boolean;
  62303. protected _minDistance: number;
  62304. protected _maxDistance: number;
  62305. /**
  62306. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62307. *
  62308. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62309. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62310. * @param min minimal distance for the breaks (default to 0.)
  62311. * @param max maximal distance for the breaks (default to 1.)
  62312. */
  62313. setMinMaxDistance(min: number, max: number): void;
  62314. /** Gets the minimal distance used in the cascade break computation */
  62315. get minDistance(): number;
  62316. /** Gets the maximal distance used in the cascade break computation */
  62317. get maxDistance(): number;
  62318. /**
  62319. * Gets the class name of that object
  62320. * @returns "CascadedShadowGenerator"
  62321. */
  62322. getClassName(): string;
  62323. private _cascadeMinExtents;
  62324. private _cascadeMaxExtents;
  62325. /**
  62326. * Gets a cascade minimum extents
  62327. * @param cascadeIndex index of the cascade
  62328. * @returns the minimum cascade extents
  62329. */
  62330. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62331. /**
  62332. * Gets a cascade maximum extents
  62333. * @param cascadeIndex index of the cascade
  62334. * @returns the maximum cascade extents
  62335. */
  62336. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62337. private _cascades;
  62338. private _currentLayer;
  62339. private _viewSpaceFrustumsZ;
  62340. private _viewMatrices;
  62341. private _projectionMatrices;
  62342. private _transformMatrices;
  62343. private _transformMatricesAsArray;
  62344. private _frustumLengths;
  62345. private _lightSizeUVCorrection;
  62346. private _depthCorrection;
  62347. private _frustumCornersWorldSpace;
  62348. private _frustumCenter;
  62349. private _shadowCameraPos;
  62350. private _shadowMaxZ;
  62351. /**
  62352. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62353. * It defaults to camera.maxZ
  62354. */
  62355. get shadowMaxZ(): number;
  62356. /**
  62357. * Sets the shadow max z distance.
  62358. */
  62359. set shadowMaxZ(value: number);
  62360. protected _debug: boolean;
  62361. /**
  62362. * Gets or sets the debug flag.
  62363. * When enabled, the cascades are materialized by different colors on the screen.
  62364. */
  62365. get debug(): boolean;
  62366. set debug(dbg: boolean);
  62367. private _depthClamp;
  62368. /**
  62369. * Gets or sets the depth clamping value.
  62370. *
  62371. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62372. * to account for the shadow casters far away.
  62373. *
  62374. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62375. */
  62376. get depthClamp(): boolean;
  62377. set depthClamp(value: boolean);
  62378. private _cascadeBlendPercentage;
  62379. /**
  62380. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62381. * It defaults to 0.1 (10% blending).
  62382. */
  62383. get cascadeBlendPercentage(): number;
  62384. set cascadeBlendPercentage(value: number);
  62385. private _lambda;
  62386. /**
  62387. * Gets or set the lambda parameter.
  62388. * This parameter is used to split the camera frustum and create the cascades.
  62389. * 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.
  62390. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62391. */
  62392. get lambda(): number;
  62393. set lambda(value: number);
  62394. /**
  62395. * Gets the view matrix corresponding to a given cascade
  62396. * @param cascadeNum cascade to retrieve the view matrix from
  62397. * @returns the cascade view matrix
  62398. */
  62399. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62400. /**
  62401. * Gets the projection matrix corresponding to a given cascade
  62402. * @param cascadeNum cascade to retrieve the projection matrix from
  62403. * @returns the cascade projection matrix
  62404. */
  62405. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62406. /**
  62407. * Gets the transformation matrix corresponding to a given cascade
  62408. * @param cascadeNum cascade to retrieve the transformation matrix from
  62409. * @returns the cascade transformation matrix
  62410. */
  62411. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62412. private _depthRenderer;
  62413. /**
  62414. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62415. *
  62416. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62417. *
  62418. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62419. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62420. * @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
  62421. */
  62422. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62423. private _depthReducer;
  62424. private _autoCalcDepthBounds;
  62425. /**
  62426. * Gets or sets the autoCalcDepthBounds property.
  62427. *
  62428. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62429. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62430. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62431. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62432. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62433. */
  62434. get autoCalcDepthBounds(): boolean;
  62435. set autoCalcDepthBounds(value: boolean);
  62436. /**
  62437. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62438. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62439. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62440. * for setting the refresh rate on the renderer yourself!
  62441. */
  62442. get autoCalcDepthBoundsRefreshRate(): number;
  62443. set autoCalcDepthBoundsRefreshRate(value: number);
  62444. /**
  62445. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62446. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62447. * you change the camera near/far planes!
  62448. */
  62449. splitFrustum(): void;
  62450. private _splitFrustum;
  62451. private _computeMatrices;
  62452. private _computeFrustumInWorldSpace;
  62453. private _computeCascadeFrustum;
  62454. /**
  62455. * Support test.
  62456. */
  62457. static get IsSupported(): boolean;
  62458. /** @hidden */
  62459. static _SceneComponentInitialization: (scene: Scene) => void;
  62460. /**
  62461. * Creates a Cascaded Shadow Generator object.
  62462. * A ShadowGenerator is the required tool to use the shadows.
  62463. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62464. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62465. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62466. * @param light The directional light object generating the shadows.
  62467. * @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.
  62468. */
  62469. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62470. protected _initializeGenerator(): void;
  62471. protected _createTargetRenderTexture(): void;
  62472. protected _initializeShadowMap(): void;
  62473. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62474. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62475. /**
  62476. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62477. * @param defines Defines of the material we want to update
  62478. * @param lightIndex Index of the light in the enabled light list of the material
  62479. */
  62480. prepareDefines(defines: any, lightIndex: number): void;
  62481. /**
  62482. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62483. * defined in the generator but impacting the effect).
  62484. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62485. * @param effect The effect we are binfing the information for
  62486. */
  62487. bindShadowLight(lightIndex: string, effect: Effect): void;
  62488. /**
  62489. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62490. * (eq to view projection * shadow projection matrices)
  62491. * @returns The transform matrix used to create the shadow map
  62492. */
  62493. getTransformMatrix(): Matrix;
  62494. /**
  62495. * Disposes the ShadowGenerator.
  62496. * Returns nothing.
  62497. */
  62498. dispose(): void;
  62499. /**
  62500. * Serializes the shadow generator setup to a json object.
  62501. * @returns The serialized JSON object
  62502. */
  62503. serialize(): any;
  62504. /**
  62505. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62506. * @param parsedShadowGenerator The JSON object to parse
  62507. * @param scene The scene to create the shadow map for
  62508. * @returns The parsed shadow generator
  62509. */
  62510. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62511. }
  62512. }
  62513. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62514. import { Scene } from "babylonjs/scene";
  62515. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62516. import { AbstractScene } from "babylonjs/abstractScene";
  62517. /**
  62518. * Defines the shadow generator component responsible to manage any shadow generators
  62519. * in a given scene.
  62520. */
  62521. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62522. /**
  62523. * The component name helpfull to identify the component in the list of scene components.
  62524. */
  62525. readonly name: string;
  62526. /**
  62527. * The scene the component belongs to.
  62528. */
  62529. scene: Scene;
  62530. /**
  62531. * Creates a new instance of the component for the given scene
  62532. * @param scene Defines the scene to register the component in
  62533. */
  62534. constructor(scene: Scene);
  62535. /**
  62536. * Registers the component in a given scene
  62537. */
  62538. register(): void;
  62539. /**
  62540. * Rebuilds the elements related to this component in case of
  62541. * context lost for instance.
  62542. */
  62543. rebuild(): void;
  62544. /**
  62545. * Serializes the component data to the specified json object
  62546. * @param serializationObject The object to serialize to
  62547. */
  62548. serialize(serializationObject: any): void;
  62549. /**
  62550. * Adds all the elements from the container to the scene
  62551. * @param container the container holding the elements
  62552. */
  62553. addFromContainer(container: AbstractScene): void;
  62554. /**
  62555. * Removes all the elements in the container from the scene
  62556. * @param container contains the elements to remove
  62557. * @param dispose if the removed element should be disposed (default: false)
  62558. */
  62559. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62560. /**
  62561. * Rebuilds the elements related to this component in case of
  62562. * context lost for instance.
  62563. */
  62564. dispose(): void;
  62565. private _gatherRenderTargets;
  62566. }
  62567. }
  62568. declare module "babylonjs/Lights/Shadows/index" {
  62569. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62570. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62571. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62572. }
  62573. declare module "babylonjs/Lights/pointLight" {
  62574. import { Scene } from "babylonjs/scene";
  62575. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62577. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62578. import { Effect } from "babylonjs/Materials/effect";
  62579. /**
  62580. * A point light is a light defined by an unique point in world space.
  62581. * The light is emitted in every direction from this point.
  62582. * A good example of a point light is a standard light bulb.
  62583. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62584. */
  62585. export class PointLight extends ShadowLight {
  62586. private _shadowAngle;
  62587. /**
  62588. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62589. * This specifies what angle the shadow will use to be created.
  62590. *
  62591. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62592. */
  62593. get shadowAngle(): number;
  62594. /**
  62595. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62596. * This specifies what angle the shadow will use to be created.
  62597. *
  62598. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62599. */
  62600. set shadowAngle(value: number);
  62601. /**
  62602. * Gets the direction if it has been set.
  62603. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62604. */
  62605. get direction(): Vector3;
  62606. /**
  62607. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62608. */
  62609. set direction(value: Vector3);
  62610. /**
  62611. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62612. * A PointLight emits the light in every direction.
  62613. * It can cast shadows.
  62614. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62615. * ```javascript
  62616. * var pointLight = new PointLight("pl", camera.position, scene);
  62617. * ```
  62618. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62619. * @param name The light friendly name
  62620. * @param position The position of the point light in the scene
  62621. * @param scene The scene the lights belongs to
  62622. */
  62623. constructor(name: string, position: Vector3, scene: Scene);
  62624. /**
  62625. * Returns the string "PointLight"
  62626. * @returns the class name
  62627. */
  62628. getClassName(): string;
  62629. /**
  62630. * Returns the integer 0.
  62631. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62632. */
  62633. getTypeID(): number;
  62634. /**
  62635. * Specifies wether or not the shadowmap should be a cube texture.
  62636. * @returns true if the shadowmap needs to be a cube texture.
  62637. */
  62638. needCube(): boolean;
  62639. /**
  62640. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62641. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62642. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62643. */
  62644. getShadowDirection(faceIndex?: number): Vector3;
  62645. /**
  62646. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62647. * - fov = PI / 2
  62648. * - aspect ratio : 1.0
  62649. * - z-near and far equal to the active camera minZ and maxZ.
  62650. * Returns the PointLight.
  62651. */
  62652. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62653. protected _buildUniformLayout(): void;
  62654. /**
  62655. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62656. * @param effect The effect to update
  62657. * @param lightIndex The index of the light in the effect to update
  62658. * @returns The point light
  62659. */
  62660. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62661. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62662. /**
  62663. * Prepares the list of defines specific to the light type.
  62664. * @param defines the list of defines
  62665. * @param lightIndex defines the index of the light for the effect
  62666. */
  62667. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62668. }
  62669. }
  62670. declare module "babylonjs/Lights/index" {
  62671. export * from "babylonjs/Lights/light";
  62672. export * from "babylonjs/Lights/shadowLight";
  62673. export * from "babylonjs/Lights/Shadows/index";
  62674. export * from "babylonjs/Lights/directionalLight";
  62675. export * from "babylonjs/Lights/hemisphericLight";
  62676. export * from "babylonjs/Lights/pointLight";
  62677. export * from "babylonjs/Lights/spotLight";
  62678. }
  62679. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62680. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62681. /**
  62682. * Header information of HDR texture files.
  62683. */
  62684. export interface HDRInfo {
  62685. /**
  62686. * The height of the texture in pixels.
  62687. */
  62688. height: number;
  62689. /**
  62690. * The width of the texture in pixels.
  62691. */
  62692. width: number;
  62693. /**
  62694. * The index of the beginning of the data in the binary file.
  62695. */
  62696. dataPosition: number;
  62697. }
  62698. /**
  62699. * This groups tools to convert HDR texture to native colors array.
  62700. */
  62701. export class HDRTools {
  62702. private static Ldexp;
  62703. private static Rgbe2float;
  62704. private static readStringLine;
  62705. /**
  62706. * Reads header information from an RGBE texture stored in a native array.
  62707. * More information on this format are available here:
  62708. * https://en.wikipedia.org/wiki/RGBE_image_format
  62709. *
  62710. * @param uint8array The binary file stored in native array.
  62711. * @return The header information.
  62712. */
  62713. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62714. /**
  62715. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62716. * This RGBE texture needs to store the information as a panorama.
  62717. *
  62718. * More information on this format are available here:
  62719. * https://en.wikipedia.org/wiki/RGBE_image_format
  62720. *
  62721. * @param buffer The binary file stored in an array buffer.
  62722. * @param size The expected size of the extracted cubemap.
  62723. * @return The Cube Map information.
  62724. */
  62725. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62726. /**
  62727. * Returns the pixels data extracted from an RGBE texture.
  62728. * This pixels will be stored left to right up to down in the R G B order in one array.
  62729. *
  62730. * More information on this format are available here:
  62731. * https://en.wikipedia.org/wiki/RGBE_image_format
  62732. *
  62733. * @param uint8array The binary file stored in an array buffer.
  62734. * @param hdrInfo The header information of the file.
  62735. * @return The pixels data in RGB right to left up to down order.
  62736. */
  62737. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62738. private static RGBE_ReadPixels_RLE;
  62739. private static RGBE_ReadPixels_NOT_RLE;
  62740. }
  62741. }
  62742. declare module "babylonjs/Materials/effectRenderer" {
  62743. import { Nullable } from "babylonjs/types";
  62744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62746. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62747. import { Viewport } from "babylonjs/Maths/math.viewport";
  62748. import { Observable } from "babylonjs/Misc/observable";
  62749. import { Effect } from "babylonjs/Materials/effect";
  62750. import "babylonjs/Shaders/postprocess.vertex";
  62751. /**
  62752. * Effect Render Options
  62753. */
  62754. export interface IEffectRendererOptions {
  62755. /**
  62756. * Defines the vertices positions.
  62757. */
  62758. positions?: number[];
  62759. /**
  62760. * Defines the indices.
  62761. */
  62762. indices?: number[];
  62763. }
  62764. /**
  62765. * Helper class to render one or more effects.
  62766. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62767. */
  62768. export class EffectRenderer {
  62769. private engine;
  62770. private static _DefaultOptions;
  62771. private _vertexBuffers;
  62772. private _indexBuffer;
  62773. private _fullscreenViewport;
  62774. /**
  62775. * Creates an effect renderer
  62776. * @param engine the engine to use for rendering
  62777. * @param options defines the options of the effect renderer
  62778. */
  62779. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62780. /**
  62781. * Sets the current viewport in normalized coordinates 0-1
  62782. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62783. */
  62784. setViewport(viewport?: Viewport): void;
  62785. /**
  62786. * Binds the embedded attributes buffer to the effect.
  62787. * @param effect Defines the effect to bind the attributes for
  62788. */
  62789. bindBuffers(effect: Effect): void;
  62790. /**
  62791. * Sets the current effect wrapper to use during draw.
  62792. * The effect needs to be ready before calling this api.
  62793. * This also sets the default full screen position attribute.
  62794. * @param effectWrapper Defines the effect to draw with
  62795. */
  62796. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62797. /**
  62798. * Restores engine states
  62799. */
  62800. restoreStates(): void;
  62801. /**
  62802. * Draws a full screen quad.
  62803. */
  62804. draw(): void;
  62805. private isRenderTargetTexture;
  62806. /**
  62807. * renders one or more effects to a specified texture
  62808. * @param effectWrapper the effect to renderer
  62809. * @param outputTexture texture to draw to, if null it will render to the screen.
  62810. */
  62811. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62812. /**
  62813. * Disposes of the effect renderer
  62814. */
  62815. dispose(): void;
  62816. }
  62817. /**
  62818. * Options to create an EffectWrapper
  62819. */
  62820. interface EffectWrapperCreationOptions {
  62821. /**
  62822. * Engine to use to create the effect
  62823. */
  62824. engine: ThinEngine;
  62825. /**
  62826. * Fragment shader for the effect
  62827. */
  62828. fragmentShader: string;
  62829. /**
  62830. * Use the shader store instead of direct source code
  62831. */
  62832. useShaderStore?: boolean;
  62833. /**
  62834. * Vertex shader for the effect
  62835. */
  62836. vertexShader?: string;
  62837. /**
  62838. * Attributes to use in the shader
  62839. */
  62840. attributeNames?: Array<string>;
  62841. /**
  62842. * Uniforms to use in the shader
  62843. */
  62844. uniformNames?: Array<string>;
  62845. /**
  62846. * Texture sampler names to use in the shader
  62847. */
  62848. samplerNames?: Array<string>;
  62849. /**
  62850. * Defines to use in the shader
  62851. */
  62852. defines?: Array<string>;
  62853. /**
  62854. * Callback when effect is compiled
  62855. */
  62856. onCompiled?: Nullable<(effect: Effect) => void>;
  62857. /**
  62858. * The friendly name of the effect displayed in Spector.
  62859. */
  62860. name?: string;
  62861. }
  62862. /**
  62863. * Wraps an effect to be used for rendering
  62864. */
  62865. export class EffectWrapper {
  62866. /**
  62867. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62868. */
  62869. onApplyObservable: Observable<{}>;
  62870. /**
  62871. * The underlying effect
  62872. */
  62873. effect: Effect;
  62874. /**
  62875. * Creates an effect to be renderer
  62876. * @param creationOptions options to create the effect
  62877. */
  62878. constructor(creationOptions: EffectWrapperCreationOptions);
  62879. /**
  62880. * Disposes of the effect wrapper
  62881. */
  62882. dispose(): void;
  62883. }
  62884. }
  62885. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62886. /** @hidden */
  62887. export var hdrFilteringVertexShader: {
  62888. name: string;
  62889. shader: string;
  62890. };
  62891. }
  62892. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62893. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62894. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62895. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62896. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62897. /** @hidden */
  62898. export var hdrFilteringPixelShader: {
  62899. name: string;
  62900. shader: string;
  62901. };
  62902. }
  62903. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62905. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62906. import { Nullable } from "babylonjs/types";
  62907. import "babylonjs/Shaders/hdrFiltering.vertex";
  62908. import "babylonjs/Shaders/hdrFiltering.fragment";
  62909. /**
  62910. * Options for texture filtering
  62911. */
  62912. interface IHDRFilteringOptions {
  62913. /**
  62914. * Scales pixel intensity for the input HDR map.
  62915. */
  62916. hdrScale?: number;
  62917. /**
  62918. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62919. */
  62920. quality?: number;
  62921. }
  62922. /**
  62923. * Filters HDR maps to get correct renderings of PBR reflections
  62924. */
  62925. export class HDRFiltering {
  62926. private _engine;
  62927. private _effectRenderer;
  62928. private _effectWrapper;
  62929. private _lodGenerationOffset;
  62930. private _lodGenerationScale;
  62931. /**
  62932. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62933. * you care about baking speed.
  62934. */
  62935. quality: number;
  62936. /**
  62937. * Scales pixel intensity for the input HDR map.
  62938. */
  62939. hdrScale: number;
  62940. /**
  62941. * Instantiates HDR filter for reflection maps
  62942. *
  62943. * @param engine Thin engine
  62944. * @param options Options
  62945. */
  62946. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62947. private _createRenderTarget;
  62948. private _prefilterInternal;
  62949. private _createEffect;
  62950. /**
  62951. * Get a value indicating if the filter is ready to be used
  62952. * @param texture Texture to filter
  62953. * @returns true if the filter is ready
  62954. */
  62955. isReady(texture: BaseTexture): boolean;
  62956. /**
  62957. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62958. * Prefiltering will be invoked at the end of next rendering pass.
  62959. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62960. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62961. * @param texture Texture to filter
  62962. * @param onFinished Callback when filtering is done
  62963. * @return Promise called when prefiltering is done
  62964. */
  62965. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62966. }
  62967. }
  62968. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62969. import { Nullable } from "babylonjs/types";
  62970. import { Scene } from "babylonjs/scene";
  62971. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62973. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62974. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62975. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62976. /**
  62977. * This represents a texture coming from an HDR input.
  62978. *
  62979. * The only supported format is currently panorama picture stored in RGBE format.
  62980. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62981. */
  62982. export class HDRCubeTexture extends BaseTexture {
  62983. private static _facesMapping;
  62984. private _generateHarmonics;
  62985. private _noMipmap;
  62986. private _prefilterOnLoad;
  62987. private _textureMatrix;
  62988. private _size;
  62989. private _onLoad;
  62990. private _onError;
  62991. /**
  62992. * The texture URL.
  62993. */
  62994. url: string;
  62995. /**
  62996. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62997. */
  62998. coordinatesMode: number;
  62999. protected _isBlocking: boolean;
  63000. /**
  63001. * Sets wether or not the texture is blocking during loading.
  63002. */
  63003. set isBlocking(value: boolean);
  63004. /**
  63005. * Gets wether or not the texture is blocking during loading.
  63006. */
  63007. get isBlocking(): boolean;
  63008. protected _rotationY: number;
  63009. /**
  63010. * Sets texture matrix rotation angle around Y axis in radians.
  63011. */
  63012. set rotationY(value: number);
  63013. /**
  63014. * Gets texture matrix rotation angle around Y axis radians.
  63015. */
  63016. get rotationY(): number;
  63017. /**
  63018. * Gets or sets the center of the bounding box associated with the cube texture
  63019. * It must define where the camera used to render the texture was set
  63020. */
  63021. boundingBoxPosition: Vector3;
  63022. private _boundingBoxSize;
  63023. /**
  63024. * Gets or sets the size of the bounding box associated with the cube texture
  63025. * When defined, the cubemap will switch to local mode
  63026. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63027. * @example https://www.babylonjs-playground.com/#RNASML
  63028. */
  63029. set boundingBoxSize(value: Vector3);
  63030. get boundingBoxSize(): Vector3;
  63031. /**
  63032. * Instantiates an HDRTexture from the following parameters.
  63033. *
  63034. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63035. * @param sceneOrEngine The scene or engine the texture will be used in
  63036. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63037. * @param noMipmap Forces to not generate the mipmap if true
  63038. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63039. * @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)
  63040. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63041. */
  63042. 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>);
  63043. /**
  63044. * Get the current class name of the texture useful for serialization or dynamic coding.
  63045. * @returns "HDRCubeTexture"
  63046. */
  63047. getClassName(): string;
  63048. /**
  63049. * Occurs when the file is raw .hdr file.
  63050. */
  63051. private loadTexture;
  63052. clone(): HDRCubeTexture;
  63053. delayLoad(): void;
  63054. /**
  63055. * Get the texture reflection matrix used to rotate/transform the reflection.
  63056. * @returns the reflection matrix
  63057. */
  63058. getReflectionTextureMatrix(): Matrix;
  63059. /**
  63060. * Set the texture reflection matrix used to rotate/transform the reflection.
  63061. * @param value Define the reflection matrix to set
  63062. */
  63063. setReflectionTextureMatrix(value: Matrix): void;
  63064. /**
  63065. * Parses a JSON representation of an HDR Texture in order to create the texture
  63066. * @param parsedTexture Define the JSON representation
  63067. * @param scene Define the scene the texture should be created in
  63068. * @param rootUrl Define the root url in case we need to load relative dependencies
  63069. * @returns the newly created texture after parsing
  63070. */
  63071. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63072. serialize(): any;
  63073. }
  63074. }
  63075. declare module "babylonjs/Physics/physicsEngine" {
  63076. import { Nullable } from "babylonjs/types";
  63077. import { Vector3 } from "babylonjs/Maths/math.vector";
  63078. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63079. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63080. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63081. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63082. /**
  63083. * Class used to control physics engine
  63084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63085. */
  63086. export class PhysicsEngine implements IPhysicsEngine {
  63087. private _physicsPlugin;
  63088. /**
  63089. * Global value used to control the smallest number supported by the simulation
  63090. */
  63091. static Epsilon: number;
  63092. private _impostors;
  63093. private _joints;
  63094. private _subTimeStep;
  63095. /**
  63096. * Gets the gravity vector used by the simulation
  63097. */
  63098. gravity: Vector3;
  63099. /**
  63100. * Factory used to create the default physics plugin.
  63101. * @returns The default physics plugin
  63102. */
  63103. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63104. /**
  63105. * Creates a new Physics Engine
  63106. * @param gravity defines the gravity vector used by the simulation
  63107. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63108. */
  63109. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63110. /**
  63111. * Sets the gravity vector used by the simulation
  63112. * @param gravity defines the gravity vector to use
  63113. */
  63114. setGravity(gravity: Vector3): void;
  63115. /**
  63116. * Set the time step of the physics engine.
  63117. * Default is 1/60.
  63118. * To slow it down, enter 1/600 for example.
  63119. * To speed it up, 1/30
  63120. * @param newTimeStep defines the new timestep to apply to this world.
  63121. */
  63122. setTimeStep(newTimeStep?: number): void;
  63123. /**
  63124. * Get the time step of the physics engine.
  63125. * @returns the current time step
  63126. */
  63127. getTimeStep(): number;
  63128. /**
  63129. * Set the sub time step of the physics engine.
  63130. * Default is 0 meaning there is no sub steps
  63131. * To increase physics resolution precision, set a small value (like 1 ms)
  63132. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63133. */
  63134. setSubTimeStep(subTimeStep?: number): void;
  63135. /**
  63136. * Get the sub time step of the physics engine.
  63137. * @returns the current sub time step
  63138. */
  63139. getSubTimeStep(): number;
  63140. /**
  63141. * Release all resources
  63142. */
  63143. dispose(): void;
  63144. /**
  63145. * Gets the name of the current physics plugin
  63146. * @returns the name of the plugin
  63147. */
  63148. getPhysicsPluginName(): string;
  63149. /**
  63150. * Adding a new impostor for the impostor tracking.
  63151. * This will be done by the impostor itself.
  63152. * @param impostor the impostor to add
  63153. */
  63154. addImpostor(impostor: PhysicsImpostor): void;
  63155. /**
  63156. * Remove an impostor from the engine.
  63157. * This impostor and its mesh will not longer be updated by the physics engine.
  63158. * @param impostor the impostor to remove
  63159. */
  63160. removeImpostor(impostor: PhysicsImpostor): void;
  63161. /**
  63162. * Add a joint to the physics engine
  63163. * @param mainImpostor defines the main impostor to which the joint is added.
  63164. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63165. * @param joint defines the joint that will connect both impostors.
  63166. */
  63167. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63168. /**
  63169. * Removes a joint from the simulation
  63170. * @param mainImpostor defines the impostor used with the joint
  63171. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63172. * @param joint defines the joint to remove
  63173. */
  63174. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63175. /**
  63176. * Called by the scene. No need to call it.
  63177. * @param delta defines the timespam between frames
  63178. */
  63179. _step(delta: number): void;
  63180. /**
  63181. * Gets the current plugin used to run the simulation
  63182. * @returns current plugin
  63183. */
  63184. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63185. /**
  63186. * Gets the list of physic impostors
  63187. * @returns an array of PhysicsImpostor
  63188. */
  63189. getImpostors(): Array<PhysicsImpostor>;
  63190. /**
  63191. * Gets the impostor for a physics enabled object
  63192. * @param object defines the object impersonated by the impostor
  63193. * @returns the PhysicsImpostor or null if not found
  63194. */
  63195. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63196. /**
  63197. * Gets the impostor for a physics body object
  63198. * @param body defines physics body used by the impostor
  63199. * @returns the PhysicsImpostor or null if not found
  63200. */
  63201. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63202. /**
  63203. * Does a raycast in the physics world
  63204. * @param from when should the ray start?
  63205. * @param to when should the ray end?
  63206. * @returns PhysicsRaycastResult
  63207. */
  63208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63209. }
  63210. }
  63211. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63212. import { Nullable } from "babylonjs/types";
  63213. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63215. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63216. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63217. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63218. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63219. /** @hidden */
  63220. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63221. private _useDeltaForWorldStep;
  63222. world: any;
  63223. name: string;
  63224. private _physicsMaterials;
  63225. private _fixedTimeStep;
  63226. private _cannonRaycastResult;
  63227. private _raycastResult;
  63228. private _physicsBodysToRemoveAfterStep;
  63229. private _firstFrame;
  63230. BJSCANNON: any;
  63231. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63232. setGravity(gravity: Vector3): void;
  63233. setTimeStep(timeStep: number): void;
  63234. getTimeStep(): number;
  63235. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63236. private _removeMarkedPhysicsBodiesFromWorld;
  63237. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63238. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63239. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63240. private _processChildMeshes;
  63241. removePhysicsBody(impostor: PhysicsImpostor): void;
  63242. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63243. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63244. private _addMaterial;
  63245. private _checkWithEpsilon;
  63246. private _createShape;
  63247. private _createHeightmap;
  63248. private _minus90X;
  63249. private _plus90X;
  63250. private _tmpPosition;
  63251. private _tmpDeltaPosition;
  63252. private _tmpUnityRotation;
  63253. private _updatePhysicsBodyTransformation;
  63254. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63255. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63256. isSupported(): boolean;
  63257. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63258. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63259. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63260. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63261. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63262. getBodyMass(impostor: PhysicsImpostor): number;
  63263. getBodyFriction(impostor: PhysicsImpostor): number;
  63264. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63265. getBodyRestitution(impostor: PhysicsImpostor): number;
  63266. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63267. sleepBody(impostor: PhysicsImpostor): void;
  63268. wakeUpBody(impostor: PhysicsImpostor): void;
  63269. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63270. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63271. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63272. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63273. getRadius(impostor: PhysicsImpostor): number;
  63274. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63275. dispose(): void;
  63276. private _extendNamespace;
  63277. /**
  63278. * Does a raycast in the physics world
  63279. * @param from when should the ray start?
  63280. * @param to when should the ray end?
  63281. * @returns PhysicsRaycastResult
  63282. */
  63283. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63284. }
  63285. }
  63286. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63287. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63288. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63289. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63291. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63292. import { Nullable } from "babylonjs/types";
  63293. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63294. /** @hidden */
  63295. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63296. private _useDeltaForWorldStep;
  63297. world: any;
  63298. name: string;
  63299. BJSOIMO: any;
  63300. private _raycastResult;
  63301. private _fixedTimeStep;
  63302. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63303. setGravity(gravity: Vector3): void;
  63304. setTimeStep(timeStep: number): void;
  63305. getTimeStep(): number;
  63306. private _tmpImpostorsArray;
  63307. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63308. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63309. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63310. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63311. private _tmpPositionVector;
  63312. removePhysicsBody(impostor: PhysicsImpostor): void;
  63313. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63314. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63315. isSupported(): boolean;
  63316. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63317. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63318. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63319. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63320. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63321. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63322. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63323. getBodyMass(impostor: PhysicsImpostor): number;
  63324. getBodyFriction(impostor: PhysicsImpostor): number;
  63325. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63326. getBodyRestitution(impostor: PhysicsImpostor): number;
  63327. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63328. sleepBody(impostor: PhysicsImpostor): void;
  63329. wakeUpBody(impostor: PhysicsImpostor): void;
  63330. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63331. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63332. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63333. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63334. getRadius(impostor: PhysicsImpostor): number;
  63335. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63336. dispose(): void;
  63337. /**
  63338. * Does a raycast in the physics world
  63339. * @param from when should the ray start?
  63340. * @param to when should the ray end?
  63341. * @returns PhysicsRaycastResult
  63342. */
  63343. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63344. }
  63345. }
  63346. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63347. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63348. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63349. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63350. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63351. import { Nullable } from "babylonjs/types";
  63352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63353. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63354. /**
  63355. * AmmoJS Physics plugin
  63356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63357. * @see https://github.com/kripken/ammo.js/
  63358. */
  63359. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63360. private _useDeltaForWorldStep;
  63361. /**
  63362. * Reference to the Ammo library
  63363. */
  63364. bjsAMMO: any;
  63365. /**
  63366. * Created ammoJS world which physics bodies are added to
  63367. */
  63368. world: any;
  63369. /**
  63370. * Name of the plugin
  63371. */
  63372. name: string;
  63373. private _timeStep;
  63374. private _fixedTimeStep;
  63375. private _maxSteps;
  63376. private _tmpQuaternion;
  63377. private _tmpAmmoTransform;
  63378. private _tmpAmmoQuaternion;
  63379. private _tmpAmmoConcreteContactResultCallback;
  63380. private _collisionConfiguration;
  63381. private _dispatcher;
  63382. private _overlappingPairCache;
  63383. private _solver;
  63384. private _softBodySolver;
  63385. private _tmpAmmoVectorA;
  63386. private _tmpAmmoVectorB;
  63387. private _tmpAmmoVectorC;
  63388. private _tmpAmmoVectorD;
  63389. private _tmpContactCallbackResult;
  63390. private _tmpAmmoVectorRCA;
  63391. private _tmpAmmoVectorRCB;
  63392. private _raycastResult;
  63393. private static readonly DISABLE_COLLISION_FLAG;
  63394. private static readonly KINEMATIC_FLAG;
  63395. private static readonly DISABLE_DEACTIVATION_FLAG;
  63396. /**
  63397. * Initializes the ammoJS plugin
  63398. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63399. * @param ammoInjection can be used to inject your own ammo reference
  63400. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63401. */
  63402. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63403. /**
  63404. * Sets the gravity of the physics world (m/(s^2))
  63405. * @param gravity Gravity to set
  63406. */
  63407. setGravity(gravity: Vector3): void;
  63408. /**
  63409. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63410. * @param timeStep timestep to use in seconds
  63411. */
  63412. setTimeStep(timeStep: number): void;
  63413. /**
  63414. * 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)
  63415. * @param fixedTimeStep fixedTimeStep to use in seconds
  63416. */
  63417. setFixedTimeStep(fixedTimeStep: number): void;
  63418. /**
  63419. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63420. * @param maxSteps the maximum number of steps by the physics engine per frame
  63421. */
  63422. setMaxSteps(maxSteps: number): void;
  63423. /**
  63424. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63425. * @returns the current timestep in seconds
  63426. */
  63427. getTimeStep(): number;
  63428. /**
  63429. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63430. */
  63431. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63432. private _isImpostorInContact;
  63433. private _isImpostorPairInContact;
  63434. private _stepSimulation;
  63435. /**
  63436. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63437. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63438. * After the step the babylon meshes are set to the position of the physics imposters
  63439. * @param delta amount of time to step forward
  63440. * @param impostors array of imposters to update before/after the step
  63441. */
  63442. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63443. /**
  63444. * Update babylon mesh to match physics world object
  63445. * @param impostor imposter to match
  63446. */
  63447. private _afterSoftStep;
  63448. /**
  63449. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63450. * @param impostor imposter to match
  63451. */
  63452. private _ropeStep;
  63453. /**
  63454. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63455. * @param impostor imposter to match
  63456. */
  63457. private _softbodyOrClothStep;
  63458. private _tmpMatrix;
  63459. /**
  63460. * Applies an impulse on the imposter
  63461. * @param impostor imposter to apply impulse to
  63462. * @param force amount of force to be applied to the imposter
  63463. * @param contactPoint the location to apply the impulse on the imposter
  63464. */
  63465. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63466. /**
  63467. * Applies a force on the imposter
  63468. * @param impostor imposter to apply force
  63469. * @param force amount of force to be applied to the imposter
  63470. * @param contactPoint the location to apply the force on the imposter
  63471. */
  63472. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63473. /**
  63474. * Creates a physics body using the plugin
  63475. * @param impostor the imposter to create the physics body on
  63476. */
  63477. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63478. /**
  63479. * Removes the physics body from the imposter and disposes of the body's memory
  63480. * @param impostor imposter to remove the physics body from
  63481. */
  63482. removePhysicsBody(impostor: PhysicsImpostor): void;
  63483. /**
  63484. * Generates a joint
  63485. * @param impostorJoint the imposter joint to create the joint with
  63486. */
  63487. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63488. /**
  63489. * Removes a joint
  63490. * @param impostorJoint the imposter joint to remove the joint from
  63491. */
  63492. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63493. private _addMeshVerts;
  63494. /**
  63495. * Initialise the soft body vertices to match its object's (mesh) vertices
  63496. * Softbody vertices (nodes) are in world space and to match this
  63497. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63498. * @param impostor to create the softbody for
  63499. */
  63500. private _softVertexData;
  63501. /**
  63502. * Create an impostor's soft body
  63503. * @param impostor to create the softbody for
  63504. */
  63505. private _createSoftbody;
  63506. /**
  63507. * Create cloth for an impostor
  63508. * @param impostor to create the softbody for
  63509. */
  63510. private _createCloth;
  63511. /**
  63512. * Create rope for an impostor
  63513. * @param impostor to create the softbody for
  63514. */
  63515. private _createRope;
  63516. /**
  63517. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63518. * @param impostor to create the custom physics shape for
  63519. */
  63520. private _createCustom;
  63521. private _addHullVerts;
  63522. private _createShape;
  63523. /**
  63524. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63525. * @param impostor imposter containing the physics body and babylon object
  63526. */
  63527. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63528. /**
  63529. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63530. * @param impostor imposter containing the physics body and babylon object
  63531. * @param newPosition new position
  63532. * @param newRotation new rotation
  63533. */
  63534. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63535. /**
  63536. * If this plugin is supported
  63537. * @returns true if its supported
  63538. */
  63539. isSupported(): boolean;
  63540. /**
  63541. * Sets the linear velocity of the physics body
  63542. * @param impostor imposter to set the velocity on
  63543. * @param velocity velocity to set
  63544. */
  63545. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63546. /**
  63547. * Sets the angular velocity of the physics body
  63548. * @param impostor imposter to set the velocity on
  63549. * @param velocity velocity to set
  63550. */
  63551. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63552. /**
  63553. * gets the linear velocity
  63554. * @param impostor imposter to get linear velocity from
  63555. * @returns linear velocity
  63556. */
  63557. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63558. /**
  63559. * gets the angular velocity
  63560. * @param impostor imposter to get angular velocity from
  63561. * @returns angular velocity
  63562. */
  63563. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63564. /**
  63565. * Sets the mass of physics body
  63566. * @param impostor imposter to set the mass on
  63567. * @param mass mass to set
  63568. */
  63569. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63570. /**
  63571. * Gets the mass of the physics body
  63572. * @param impostor imposter to get the mass from
  63573. * @returns mass
  63574. */
  63575. getBodyMass(impostor: PhysicsImpostor): number;
  63576. /**
  63577. * Gets friction of the impostor
  63578. * @param impostor impostor to get friction from
  63579. * @returns friction value
  63580. */
  63581. getBodyFriction(impostor: PhysicsImpostor): number;
  63582. /**
  63583. * Sets friction of the impostor
  63584. * @param impostor impostor to set friction on
  63585. * @param friction friction value
  63586. */
  63587. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63588. /**
  63589. * Gets restitution of the impostor
  63590. * @param impostor impostor to get restitution from
  63591. * @returns restitution value
  63592. */
  63593. getBodyRestitution(impostor: PhysicsImpostor): number;
  63594. /**
  63595. * Sets resitution of the impostor
  63596. * @param impostor impostor to set resitution on
  63597. * @param restitution resitution value
  63598. */
  63599. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63600. /**
  63601. * Gets pressure inside the impostor
  63602. * @param impostor impostor to get pressure from
  63603. * @returns pressure value
  63604. */
  63605. getBodyPressure(impostor: PhysicsImpostor): number;
  63606. /**
  63607. * Sets pressure inside a soft body impostor
  63608. * Cloth and rope must remain 0 pressure
  63609. * @param impostor impostor to set pressure on
  63610. * @param pressure pressure value
  63611. */
  63612. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63613. /**
  63614. * Gets stiffness of the impostor
  63615. * @param impostor impostor to get stiffness from
  63616. * @returns pressure value
  63617. */
  63618. getBodyStiffness(impostor: PhysicsImpostor): number;
  63619. /**
  63620. * Sets stiffness of the impostor
  63621. * @param impostor impostor to set stiffness on
  63622. * @param stiffness stiffness value from 0 to 1
  63623. */
  63624. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63625. /**
  63626. * Gets velocityIterations of the impostor
  63627. * @param impostor impostor to get velocity iterations from
  63628. * @returns velocityIterations value
  63629. */
  63630. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63631. /**
  63632. * Sets velocityIterations of the impostor
  63633. * @param impostor impostor to set velocity iterations on
  63634. * @param velocityIterations velocityIterations value
  63635. */
  63636. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63637. /**
  63638. * Gets positionIterations of the impostor
  63639. * @param impostor impostor to get position iterations from
  63640. * @returns positionIterations value
  63641. */
  63642. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63643. /**
  63644. * Sets positionIterations of the impostor
  63645. * @param impostor impostor to set position on
  63646. * @param positionIterations positionIterations value
  63647. */
  63648. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63649. /**
  63650. * Append an anchor to a cloth object
  63651. * @param impostor is the cloth impostor to add anchor to
  63652. * @param otherImpostor is the rigid impostor to anchor to
  63653. * @param width ratio across width from 0 to 1
  63654. * @param height ratio up height from 0 to 1
  63655. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63656. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63657. */
  63658. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63659. /**
  63660. * Append an hook to a rope object
  63661. * @param impostor is the rope impostor to add hook to
  63662. * @param otherImpostor is the rigid impostor to hook to
  63663. * @param length ratio along the rope from 0 to 1
  63664. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63665. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63666. */
  63667. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63668. /**
  63669. * Sleeps the physics body and stops it from being active
  63670. * @param impostor impostor to sleep
  63671. */
  63672. sleepBody(impostor: PhysicsImpostor): void;
  63673. /**
  63674. * Activates the physics body
  63675. * @param impostor impostor to activate
  63676. */
  63677. wakeUpBody(impostor: PhysicsImpostor): void;
  63678. /**
  63679. * Updates the distance parameters of the joint
  63680. * @param joint joint to update
  63681. * @param maxDistance maximum distance of the joint
  63682. * @param minDistance minimum distance of the joint
  63683. */
  63684. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63685. /**
  63686. * Sets a motor on the joint
  63687. * @param joint joint to set motor on
  63688. * @param speed speed of the motor
  63689. * @param maxForce maximum force of the motor
  63690. * @param motorIndex index of the motor
  63691. */
  63692. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63693. /**
  63694. * Sets the motors limit
  63695. * @param joint joint to set limit on
  63696. * @param upperLimit upper limit
  63697. * @param lowerLimit lower limit
  63698. */
  63699. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63700. /**
  63701. * Syncs the position and rotation of a mesh with the impostor
  63702. * @param mesh mesh to sync
  63703. * @param impostor impostor to update the mesh with
  63704. */
  63705. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63706. /**
  63707. * Gets the radius of the impostor
  63708. * @param impostor impostor to get radius from
  63709. * @returns the radius
  63710. */
  63711. getRadius(impostor: PhysicsImpostor): number;
  63712. /**
  63713. * Gets the box size of the impostor
  63714. * @param impostor impostor to get box size from
  63715. * @param result the resulting box size
  63716. */
  63717. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63718. /**
  63719. * Disposes of the impostor
  63720. */
  63721. dispose(): void;
  63722. /**
  63723. * Does a raycast in the physics world
  63724. * @param from when should the ray start?
  63725. * @param to when should the ray end?
  63726. * @returns PhysicsRaycastResult
  63727. */
  63728. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63729. }
  63730. }
  63731. declare module "babylonjs/Probes/reflectionProbe" {
  63732. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63733. import { Vector3 } from "babylonjs/Maths/math.vector";
  63734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63735. import { Nullable } from "babylonjs/types";
  63736. import { Scene } from "babylonjs/scene";
  63737. module "babylonjs/abstractScene" {
  63738. interface AbstractScene {
  63739. /**
  63740. * The list of reflection probes added to the scene
  63741. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63742. */
  63743. reflectionProbes: Array<ReflectionProbe>;
  63744. /**
  63745. * Removes the given reflection probe from this scene.
  63746. * @param toRemove The reflection probe to remove
  63747. * @returns The index of the removed reflection probe
  63748. */
  63749. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63750. /**
  63751. * Adds the given reflection probe to this scene.
  63752. * @param newReflectionProbe The reflection probe to add
  63753. */
  63754. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63755. }
  63756. }
  63757. /**
  63758. * Class used to generate realtime reflection / refraction cube textures
  63759. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63760. */
  63761. export class ReflectionProbe {
  63762. /** defines the name of the probe */
  63763. name: string;
  63764. private _scene;
  63765. private _renderTargetTexture;
  63766. private _projectionMatrix;
  63767. private _viewMatrix;
  63768. private _target;
  63769. private _add;
  63770. private _attachedMesh;
  63771. private _invertYAxis;
  63772. /** Gets or sets probe position (center of the cube map) */
  63773. position: Vector3;
  63774. /**
  63775. * Creates a new reflection probe
  63776. * @param name defines the name of the probe
  63777. * @param size defines the texture resolution (for each face)
  63778. * @param scene defines the hosting scene
  63779. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63780. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63781. */
  63782. constructor(
  63783. /** defines the name of the probe */
  63784. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63785. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63786. get samples(): number;
  63787. set samples(value: number);
  63788. /** Gets or sets the refresh rate to use (on every frame by default) */
  63789. get refreshRate(): number;
  63790. set refreshRate(value: number);
  63791. /**
  63792. * Gets the hosting scene
  63793. * @returns a Scene
  63794. */
  63795. getScene(): Scene;
  63796. /** Gets the internal CubeTexture used to render to */
  63797. get cubeTexture(): RenderTargetTexture;
  63798. /** Gets the list of meshes to render */
  63799. get renderList(): Nullable<AbstractMesh[]>;
  63800. /**
  63801. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63802. * @param mesh defines the mesh to attach to
  63803. */
  63804. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63805. /**
  63806. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63807. * @param renderingGroupId The rendering group id corresponding to its index
  63808. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63809. */
  63810. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63811. /**
  63812. * Clean all associated resources
  63813. */
  63814. dispose(): void;
  63815. /**
  63816. * Converts the reflection probe information to a readable string for debug purpose.
  63817. * @param fullDetails Supports for multiple levels of logging within scene loading
  63818. * @returns the human readable reflection probe info
  63819. */
  63820. toString(fullDetails?: boolean): string;
  63821. /**
  63822. * Get the class name of the relfection probe.
  63823. * @returns "ReflectionProbe"
  63824. */
  63825. getClassName(): string;
  63826. /**
  63827. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63828. * @returns The JSON representation of the texture
  63829. */
  63830. serialize(): any;
  63831. /**
  63832. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63833. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63834. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63835. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63836. * @returns The parsed reflection probe if successful
  63837. */
  63838. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63839. }
  63840. }
  63841. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63842. /** @hidden */
  63843. export var _BabylonLoaderRegistered: boolean;
  63844. /**
  63845. * Helps setting up some configuration for the babylon file loader.
  63846. */
  63847. export class BabylonFileLoaderConfiguration {
  63848. /**
  63849. * The loader does not allow injecting custom physix engine into the plugins.
  63850. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63851. * So you could set this variable to your engine import to make it work.
  63852. */
  63853. static LoaderInjectedPhysicsEngine: any;
  63854. }
  63855. }
  63856. declare module "babylonjs/Loading/Plugins/index" {
  63857. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63858. }
  63859. declare module "babylonjs/Loading/index" {
  63860. export * from "babylonjs/Loading/loadingScreen";
  63861. export * from "babylonjs/Loading/Plugins/index";
  63862. export * from "babylonjs/Loading/sceneLoader";
  63863. export * from "babylonjs/Loading/sceneLoaderFlags";
  63864. }
  63865. declare module "babylonjs/Materials/Background/index" {
  63866. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63867. }
  63868. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63869. import { Scene } from "babylonjs/scene";
  63870. import { Color3 } from "babylonjs/Maths/math.color";
  63871. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63873. /**
  63874. * The Physically based simple base material of BJS.
  63875. *
  63876. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63877. * It is used as the base class for both the specGloss and metalRough conventions.
  63878. */
  63879. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63880. /**
  63881. * Number of Simultaneous lights allowed on the material.
  63882. */
  63883. maxSimultaneousLights: number;
  63884. /**
  63885. * If sets to true, disables all the lights affecting the material.
  63886. */
  63887. disableLighting: boolean;
  63888. /**
  63889. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63890. */
  63891. environmentTexture: BaseTexture;
  63892. /**
  63893. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63894. */
  63895. invertNormalMapX: boolean;
  63896. /**
  63897. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63898. */
  63899. invertNormalMapY: boolean;
  63900. /**
  63901. * Normal map used in the model.
  63902. */
  63903. normalTexture: BaseTexture;
  63904. /**
  63905. * Emissivie color used to self-illuminate the model.
  63906. */
  63907. emissiveColor: Color3;
  63908. /**
  63909. * Emissivie texture used to self-illuminate the model.
  63910. */
  63911. emissiveTexture: BaseTexture;
  63912. /**
  63913. * Occlusion Channel Strenght.
  63914. */
  63915. occlusionStrength: number;
  63916. /**
  63917. * Occlusion Texture of the material (adding extra occlusion effects).
  63918. */
  63919. occlusionTexture: BaseTexture;
  63920. /**
  63921. * Defines the alpha limits in alpha test mode.
  63922. */
  63923. alphaCutOff: number;
  63924. /**
  63925. * Gets the current double sided mode.
  63926. */
  63927. get doubleSided(): boolean;
  63928. /**
  63929. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63930. */
  63931. set doubleSided(value: boolean);
  63932. /**
  63933. * Stores the pre-calculated light information of a mesh in a texture.
  63934. */
  63935. lightmapTexture: BaseTexture;
  63936. /**
  63937. * If true, the light map contains occlusion information instead of lighting info.
  63938. */
  63939. useLightmapAsShadowmap: boolean;
  63940. /**
  63941. * Instantiates a new PBRMaterial instance.
  63942. *
  63943. * @param name The material name
  63944. * @param scene The scene the material will be use in.
  63945. */
  63946. constructor(name: string, scene: Scene);
  63947. getClassName(): string;
  63948. }
  63949. }
  63950. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63951. import { Scene } from "babylonjs/scene";
  63952. import { Color3 } from "babylonjs/Maths/math.color";
  63953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63954. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63955. /**
  63956. * The PBR material of BJS following the metal roughness convention.
  63957. *
  63958. * This fits to the PBR convention in the GLTF definition:
  63959. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63960. */
  63961. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63962. /**
  63963. * The base color has two different interpretations depending on the value of metalness.
  63964. * When the material is a metal, the base color is the specific measured reflectance value
  63965. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63966. * of the material.
  63967. */
  63968. baseColor: Color3;
  63969. /**
  63970. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63971. * well as opacity information in the alpha channel.
  63972. */
  63973. baseTexture: BaseTexture;
  63974. /**
  63975. * Specifies the metallic scalar value of the material.
  63976. * Can also be used to scale the metalness values of the metallic texture.
  63977. */
  63978. metallic: number;
  63979. /**
  63980. * Specifies the roughness scalar value of the material.
  63981. * Can also be used to scale the roughness values of the metallic texture.
  63982. */
  63983. roughness: number;
  63984. /**
  63985. * Texture containing both the metallic value in the B channel and the
  63986. * roughness value in the G channel to keep better precision.
  63987. */
  63988. metallicRoughnessTexture: BaseTexture;
  63989. /**
  63990. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63991. *
  63992. * @param name The material name
  63993. * @param scene The scene the material will be use in.
  63994. */
  63995. constructor(name: string, scene: Scene);
  63996. /**
  63997. * Return the currrent class name of the material.
  63998. */
  63999. getClassName(): string;
  64000. /**
  64001. * Makes a duplicate of the current material.
  64002. * @param name - name to use for the new material.
  64003. */
  64004. clone(name: string): PBRMetallicRoughnessMaterial;
  64005. /**
  64006. * Serialize the material to a parsable JSON object.
  64007. */
  64008. serialize(): any;
  64009. /**
  64010. * Parses a JSON object correponding to the serialize function.
  64011. */
  64012. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64013. }
  64014. }
  64015. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64016. import { Scene } from "babylonjs/scene";
  64017. import { Color3 } from "babylonjs/Maths/math.color";
  64018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64019. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64020. /**
  64021. * The PBR material of BJS following the specular glossiness convention.
  64022. *
  64023. * This fits to the PBR convention in the GLTF definition:
  64024. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64025. */
  64026. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64027. /**
  64028. * Specifies the diffuse color of the material.
  64029. */
  64030. diffuseColor: Color3;
  64031. /**
  64032. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64033. * channel.
  64034. */
  64035. diffuseTexture: BaseTexture;
  64036. /**
  64037. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64038. */
  64039. specularColor: Color3;
  64040. /**
  64041. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64042. */
  64043. glossiness: number;
  64044. /**
  64045. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64046. */
  64047. specularGlossinessTexture: BaseTexture;
  64048. /**
  64049. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64050. *
  64051. * @param name The material name
  64052. * @param scene The scene the material will be use in.
  64053. */
  64054. constructor(name: string, scene: Scene);
  64055. /**
  64056. * Return the currrent class name of the material.
  64057. */
  64058. getClassName(): string;
  64059. /**
  64060. * Makes a duplicate of the current material.
  64061. * @param name - name to use for the new material.
  64062. */
  64063. clone(name: string): PBRSpecularGlossinessMaterial;
  64064. /**
  64065. * Serialize the material to a parsable JSON object.
  64066. */
  64067. serialize(): any;
  64068. /**
  64069. * Parses a JSON object correponding to the serialize function.
  64070. */
  64071. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64072. }
  64073. }
  64074. declare module "babylonjs/Materials/PBR/index" {
  64075. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64076. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64077. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64078. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64079. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64080. }
  64081. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64082. import { Nullable } from "babylonjs/types";
  64083. import { Scene } from "babylonjs/scene";
  64084. import { Matrix } from "babylonjs/Maths/math.vector";
  64085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64086. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64087. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64088. /**
  64089. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64090. * It can help converting any input color in a desired output one. This can then be used to create effects
  64091. * from sepia, black and white to sixties or futuristic rendering...
  64092. *
  64093. * The only supported format is currently 3dl.
  64094. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64095. */
  64096. export class ColorGradingTexture extends BaseTexture {
  64097. /**
  64098. * The texture URL.
  64099. */
  64100. url: string;
  64101. /**
  64102. * Empty line regex stored for GC.
  64103. */
  64104. private static _noneEmptyLineRegex;
  64105. private _textureMatrix;
  64106. private _onLoad;
  64107. /**
  64108. * Instantiates a ColorGradingTexture from the following parameters.
  64109. *
  64110. * @param url The location of the color gradind data (currently only supporting 3dl)
  64111. * @param sceneOrEngine The scene or engine the texture will be used in
  64112. * @param onLoad defines a callback triggered when the texture has been loaded
  64113. */
  64114. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64115. /**
  64116. * Fires the onload event from the constructor if requested.
  64117. */
  64118. private _triggerOnLoad;
  64119. /**
  64120. * Returns the texture matrix used in most of the material.
  64121. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64122. */
  64123. getTextureMatrix(): Matrix;
  64124. /**
  64125. * Occurs when the file being loaded is a .3dl LUT file.
  64126. */
  64127. private load3dlTexture;
  64128. /**
  64129. * Starts the loading process of the texture.
  64130. */
  64131. private loadTexture;
  64132. /**
  64133. * Clones the color gradind texture.
  64134. */
  64135. clone(): ColorGradingTexture;
  64136. /**
  64137. * Called during delayed load for textures.
  64138. */
  64139. delayLoad(): void;
  64140. /**
  64141. * Parses a color grading texture serialized by Babylon.
  64142. * @param parsedTexture The texture information being parsedTexture
  64143. * @param scene The scene to load the texture in
  64144. * @param rootUrl The root url of the data assets to load
  64145. * @return A color gradind texture
  64146. */
  64147. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64148. /**
  64149. * Serializes the LUT texture to json format.
  64150. */
  64151. serialize(): any;
  64152. }
  64153. }
  64154. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64156. import { Scene } from "babylonjs/scene";
  64157. import { Nullable } from "babylonjs/types";
  64158. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64159. /**
  64160. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64161. */
  64162. export class EquiRectangularCubeTexture extends BaseTexture {
  64163. /** The six faces of the cube. */
  64164. private static _FacesMapping;
  64165. private _noMipmap;
  64166. private _onLoad;
  64167. private _onError;
  64168. /** The size of the cubemap. */
  64169. private _size;
  64170. /** The buffer of the image. */
  64171. private _buffer;
  64172. /** The width of the input image. */
  64173. private _width;
  64174. /** The height of the input image. */
  64175. private _height;
  64176. /** The URL to the image. */
  64177. url: string;
  64178. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  64179. coordinatesMode: number;
  64180. /**
  64181. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64182. * @param url The location of the image
  64183. * @param scene The scene the texture will be used in
  64184. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64185. * @param noMipmap Forces to not generate the mipmap if true
  64186. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64187. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64188. * @param onLoad — defines a callback called when texture is loaded
  64189. * @param onError — defines a callback called if there is an error
  64190. */
  64191. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64192. /**
  64193. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64194. */
  64195. private loadImage;
  64196. /**
  64197. * Convert the image buffer into a cubemap and create a CubeTexture.
  64198. */
  64199. private loadTexture;
  64200. /**
  64201. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64202. * @param buffer The ArrayBuffer that should be converted.
  64203. * @returns The buffer as Float32Array.
  64204. */
  64205. private getFloat32ArrayFromArrayBuffer;
  64206. /**
  64207. * Get the current class name of the texture useful for serialization or dynamic coding.
  64208. * @returns "EquiRectangularCubeTexture"
  64209. */
  64210. getClassName(): string;
  64211. /**
  64212. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64213. * @returns A clone of the current EquiRectangularCubeTexture.
  64214. */
  64215. clone(): EquiRectangularCubeTexture;
  64216. }
  64217. }
  64218. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64219. import { Nullable } from "babylonjs/types";
  64220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64221. import { Matrix } from "babylonjs/Maths/math.vector";
  64222. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64223. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64224. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64225. import { Scene } from "babylonjs/scene";
  64226. /**
  64227. * Defines the options related to the creation of an HtmlElementTexture
  64228. */
  64229. export interface IHtmlElementTextureOptions {
  64230. /**
  64231. * Defines wether mip maps should be created or not.
  64232. */
  64233. generateMipMaps?: boolean;
  64234. /**
  64235. * Defines the sampling mode of the texture.
  64236. */
  64237. samplingMode?: number;
  64238. /**
  64239. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64240. */
  64241. engine: Nullable<ThinEngine>;
  64242. /**
  64243. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64244. */
  64245. scene: Nullable<Scene>;
  64246. }
  64247. /**
  64248. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64249. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64250. * is automatically managed.
  64251. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64252. * in your application.
  64253. *
  64254. * As the update is not automatic, you need to call them manually.
  64255. */
  64256. export class HtmlElementTexture extends BaseTexture {
  64257. /**
  64258. * The texture URL.
  64259. */
  64260. element: HTMLVideoElement | HTMLCanvasElement;
  64261. private static readonly DefaultOptions;
  64262. private _textureMatrix;
  64263. private _isVideo;
  64264. private _generateMipMaps;
  64265. private _samplingMode;
  64266. /**
  64267. * Instantiates a HtmlElementTexture from the following parameters.
  64268. *
  64269. * @param name Defines the name of the texture
  64270. * @param element Defines the video or canvas the texture is filled with
  64271. * @param options Defines the other none mandatory texture creation options
  64272. */
  64273. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64274. private _createInternalTexture;
  64275. /**
  64276. * Returns the texture matrix used in most of the material.
  64277. */
  64278. getTextureMatrix(): Matrix;
  64279. /**
  64280. * Updates the content of the texture.
  64281. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64282. */
  64283. update(invertY?: Nullable<boolean>): void;
  64284. }
  64285. }
  64286. declare module "babylonjs/Misc/tga" {
  64287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64288. /**
  64289. * Based on jsTGALoader - Javascript loader for TGA file
  64290. * By Vincent Thibault
  64291. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64292. */
  64293. export class TGATools {
  64294. private static _TYPE_INDEXED;
  64295. private static _TYPE_RGB;
  64296. private static _TYPE_GREY;
  64297. private static _TYPE_RLE_INDEXED;
  64298. private static _TYPE_RLE_RGB;
  64299. private static _TYPE_RLE_GREY;
  64300. private static _ORIGIN_MASK;
  64301. private static _ORIGIN_SHIFT;
  64302. private static _ORIGIN_BL;
  64303. private static _ORIGIN_BR;
  64304. private static _ORIGIN_UL;
  64305. private static _ORIGIN_UR;
  64306. /**
  64307. * Gets the header of a TGA file
  64308. * @param data defines the TGA data
  64309. * @returns the header
  64310. */
  64311. static GetTGAHeader(data: Uint8Array): any;
  64312. /**
  64313. * Uploads TGA content to a Babylon Texture
  64314. * @hidden
  64315. */
  64316. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64317. /** @hidden */
  64318. 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;
  64319. /** @hidden */
  64320. 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;
  64321. /** @hidden */
  64322. 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;
  64323. /** @hidden */
  64324. 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;
  64325. /** @hidden */
  64326. 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;
  64327. /** @hidden */
  64328. 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;
  64329. }
  64330. }
  64331. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64332. import { Nullable } from "babylonjs/types";
  64333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64334. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64335. /**
  64336. * Implementation of the TGA Texture Loader.
  64337. * @hidden
  64338. */
  64339. export class _TGATextureLoader implements IInternalTextureLoader {
  64340. /**
  64341. * Defines wether the loader supports cascade loading the different faces.
  64342. */
  64343. readonly supportCascades: boolean;
  64344. /**
  64345. * This returns if the loader support the current file information.
  64346. * @param extension defines the file extension of the file being loaded
  64347. * @returns true if the loader can load the specified file
  64348. */
  64349. canLoad(extension: string): boolean;
  64350. /**
  64351. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64352. * @param data contains the texture data
  64353. * @param texture defines the BabylonJS internal texture
  64354. * @param createPolynomials will be true if polynomials have been requested
  64355. * @param onLoad defines the callback to trigger once the texture is ready
  64356. * @param onError defines the callback to trigger in case of error
  64357. */
  64358. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64359. /**
  64360. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64361. * @param data contains the texture data
  64362. * @param texture defines the BabylonJS internal texture
  64363. * @param callback defines the method to call once ready to upload
  64364. */
  64365. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64366. }
  64367. }
  64368. declare module "babylonjs/Misc/basis" {
  64369. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64370. /**
  64371. * Info about the .basis files
  64372. */
  64373. class BasisFileInfo {
  64374. /**
  64375. * If the file has alpha
  64376. */
  64377. hasAlpha: boolean;
  64378. /**
  64379. * Info about each image of the basis file
  64380. */
  64381. images: Array<{
  64382. levels: Array<{
  64383. width: number;
  64384. height: number;
  64385. transcodedPixels: ArrayBufferView;
  64386. }>;
  64387. }>;
  64388. }
  64389. /**
  64390. * Result of transcoding a basis file
  64391. */
  64392. class TranscodeResult {
  64393. /**
  64394. * Info about the .basis file
  64395. */
  64396. fileInfo: BasisFileInfo;
  64397. /**
  64398. * Format to use when loading the file
  64399. */
  64400. format: number;
  64401. }
  64402. /**
  64403. * Configuration options for the Basis transcoder
  64404. */
  64405. export class BasisTranscodeConfiguration {
  64406. /**
  64407. * Supported compression formats used to determine the supported output format of the transcoder
  64408. */
  64409. supportedCompressionFormats?: {
  64410. /**
  64411. * etc1 compression format
  64412. */
  64413. etc1?: boolean;
  64414. /**
  64415. * s3tc compression format
  64416. */
  64417. s3tc?: boolean;
  64418. /**
  64419. * pvrtc compression format
  64420. */
  64421. pvrtc?: boolean;
  64422. /**
  64423. * etc2 compression format
  64424. */
  64425. etc2?: boolean;
  64426. };
  64427. /**
  64428. * If mipmap levels should be loaded for transcoded images (Default: true)
  64429. */
  64430. loadMipmapLevels?: boolean;
  64431. /**
  64432. * Index of a single image to load (Default: all images)
  64433. */
  64434. loadSingleImage?: number;
  64435. }
  64436. /**
  64437. * Used to load .Basis files
  64438. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64439. */
  64440. export class BasisTools {
  64441. private static _IgnoreSupportedFormats;
  64442. /**
  64443. * URL to use when loading the basis transcoder
  64444. */
  64445. static JSModuleURL: string;
  64446. /**
  64447. * URL to use when loading the wasm module for the transcoder
  64448. */
  64449. static WasmModuleURL: string;
  64450. /**
  64451. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64452. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64453. * @returns internal format corresponding to the Basis format
  64454. */
  64455. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64456. private static _WorkerPromise;
  64457. private static _Worker;
  64458. private static _actionId;
  64459. private static _CreateWorkerAsync;
  64460. /**
  64461. * Transcodes a loaded image file to compressed pixel data
  64462. * @param data image data to transcode
  64463. * @param config configuration options for the transcoding
  64464. * @returns a promise resulting in the transcoded image
  64465. */
  64466. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64467. /**
  64468. * Loads a texture from the transcode result
  64469. * @param texture texture load to
  64470. * @param transcodeResult the result of transcoding the basis file to load from
  64471. */
  64472. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64473. }
  64474. }
  64475. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64476. import { Nullable } from "babylonjs/types";
  64477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64478. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64479. /**
  64480. * Loader for .basis file format
  64481. */
  64482. export class _BasisTextureLoader implements IInternalTextureLoader {
  64483. /**
  64484. * Defines whether the loader supports cascade loading the different faces.
  64485. */
  64486. readonly supportCascades: boolean;
  64487. /**
  64488. * This returns if the loader support the current file information.
  64489. * @param extension defines the file extension of the file being loaded
  64490. * @returns true if the loader can load the specified file
  64491. */
  64492. canLoad(extension: string): boolean;
  64493. /**
  64494. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64495. * @param data contains the texture data
  64496. * @param texture defines the BabylonJS internal texture
  64497. * @param createPolynomials will be true if polynomials have been requested
  64498. * @param onLoad defines the callback to trigger once the texture is ready
  64499. * @param onError defines the callback to trigger in case of error
  64500. */
  64501. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64502. /**
  64503. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64504. * @param data contains the texture data
  64505. * @param texture defines the BabylonJS internal texture
  64506. * @param callback defines the method to call once ready to upload
  64507. */
  64508. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64509. }
  64510. }
  64511. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64512. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64513. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64514. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64515. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64516. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64517. }
  64518. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64519. import { Vector2 } from "babylonjs/Maths/math.vector";
  64520. /**
  64521. * Defines the basic options interface of a TexturePacker Frame
  64522. */
  64523. export interface ITexturePackerFrame {
  64524. /**
  64525. * The frame ID
  64526. */
  64527. id: number;
  64528. /**
  64529. * The frames Scale
  64530. */
  64531. scale: Vector2;
  64532. /**
  64533. * The Frames offset
  64534. */
  64535. offset: Vector2;
  64536. }
  64537. /**
  64538. * This is a support class for frame Data on texture packer sets.
  64539. */
  64540. export class TexturePackerFrame implements ITexturePackerFrame {
  64541. /**
  64542. * The frame ID
  64543. */
  64544. id: number;
  64545. /**
  64546. * The frames Scale
  64547. */
  64548. scale: Vector2;
  64549. /**
  64550. * The Frames offset
  64551. */
  64552. offset: Vector2;
  64553. /**
  64554. * Initializes a texture package frame.
  64555. * @param id The numerical frame identifier
  64556. * @param scale Scalar Vector2 for UV frame
  64557. * @param offset Vector2 for the frame position in UV units.
  64558. * @returns TexturePackerFrame
  64559. */
  64560. constructor(id: number, scale: Vector2, offset: Vector2);
  64561. }
  64562. }
  64563. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64565. import { Scene } from "babylonjs/scene";
  64566. import { Nullable } from "babylonjs/types";
  64567. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64568. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64569. /**
  64570. * Defines the basic options interface of a TexturePacker
  64571. */
  64572. export interface ITexturePackerOptions {
  64573. /**
  64574. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64575. */
  64576. map?: string[];
  64577. /**
  64578. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64579. */
  64580. uvsIn?: string;
  64581. /**
  64582. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64583. */
  64584. uvsOut?: string;
  64585. /**
  64586. * number representing the layout style. Defaults to LAYOUT_STRIP
  64587. */
  64588. layout?: number;
  64589. /**
  64590. * number of columns if using custom column count layout(2). This defaults to 4.
  64591. */
  64592. colnum?: number;
  64593. /**
  64594. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64595. */
  64596. updateInputMeshes?: boolean;
  64597. /**
  64598. * boolean flag to dispose all the source textures. Defaults to true.
  64599. */
  64600. disposeSources?: boolean;
  64601. /**
  64602. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64603. */
  64604. fillBlanks?: boolean;
  64605. /**
  64606. * string value representing the context fill style color. Defaults to 'black'.
  64607. */
  64608. customFillColor?: string;
  64609. /**
  64610. * Width and Height Value of each Frame in the TexturePacker Sets
  64611. */
  64612. frameSize?: number;
  64613. /**
  64614. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64615. */
  64616. paddingRatio?: number;
  64617. /**
  64618. * Number that declares the fill method for the padding gutter.
  64619. */
  64620. paddingMode?: number;
  64621. /**
  64622. * If in SUBUV_COLOR padding mode what color to use.
  64623. */
  64624. paddingColor?: Color3 | Color4;
  64625. }
  64626. /**
  64627. * Defines the basic interface of a TexturePacker JSON File
  64628. */
  64629. export interface ITexturePackerJSON {
  64630. /**
  64631. * The frame ID
  64632. */
  64633. name: string;
  64634. /**
  64635. * The base64 channel data
  64636. */
  64637. sets: any;
  64638. /**
  64639. * The options of the Packer
  64640. */
  64641. options: ITexturePackerOptions;
  64642. /**
  64643. * The frame data of the Packer
  64644. */
  64645. frames: Array<number>;
  64646. }
  64647. /**
  64648. * This is a support class that generates a series of packed texture sets.
  64649. * @see https://doc.babylonjs.com/babylon101/materials
  64650. */
  64651. export class TexturePacker {
  64652. /** Packer Layout Constant 0 */
  64653. static readonly LAYOUT_STRIP: number;
  64654. /** Packer Layout Constant 1 */
  64655. static readonly LAYOUT_POWER2: number;
  64656. /** Packer Layout Constant 2 */
  64657. static readonly LAYOUT_COLNUM: number;
  64658. /** Packer Layout Constant 0 */
  64659. static readonly SUBUV_WRAP: number;
  64660. /** Packer Layout Constant 1 */
  64661. static readonly SUBUV_EXTEND: number;
  64662. /** Packer Layout Constant 2 */
  64663. static readonly SUBUV_COLOR: number;
  64664. /** The Name of the Texture Package */
  64665. name: string;
  64666. /** The scene scope of the TexturePacker */
  64667. scene: Scene;
  64668. /** The Meshes to target */
  64669. meshes: AbstractMesh[];
  64670. /** Arguments passed with the Constructor */
  64671. options: ITexturePackerOptions;
  64672. /** The promise that is started upon initialization */
  64673. promise: Nullable<Promise<TexturePacker | string>>;
  64674. /** The Container object for the channel sets that are generated */
  64675. sets: object;
  64676. /** The Container array for the frames that are generated */
  64677. frames: TexturePackerFrame[];
  64678. /** The expected number of textures the system is parsing. */
  64679. private _expecting;
  64680. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64681. private _paddingValue;
  64682. /**
  64683. * Initializes a texture package series from an array of meshes or a single mesh.
  64684. * @param name The name of the package
  64685. * @param meshes The target meshes to compose the package from
  64686. * @param options The arguments that texture packer should follow while building.
  64687. * @param scene The scene which the textures are scoped to.
  64688. * @returns TexturePacker
  64689. */
  64690. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64691. /**
  64692. * Starts the package process
  64693. * @param resolve The promises resolution function
  64694. * @returns TexturePacker
  64695. */
  64696. private _createFrames;
  64697. /**
  64698. * Calculates the Size of the Channel Sets
  64699. * @returns Vector2
  64700. */
  64701. private _calculateSize;
  64702. /**
  64703. * Calculates the UV data for the frames.
  64704. * @param baseSize the base frameSize
  64705. * @param padding the base frame padding
  64706. * @param dtSize size of the Dynamic Texture for that channel
  64707. * @param dtUnits is 1/dtSize
  64708. * @param update flag to update the input meshes
  64709. */
  64710. private _calculateMeshUVFrames;
  64711. /**
  64712. * Calculates the frames Offset.
  64713. * @param index of the frame
  64714. * @returns Vector2
  64715. */
  64716. private _getFrameOffset;
  64717. /**
  64718. * Updates a Mesh to the frame data
  64719. * @param mesh that is the target
  64720. * @param frameID or the frame index
  64721. */
  64722. private _updateMeshUV;
  64723. /**
  64724. * Updates a Meshes materials to use the texture packer channels
  64725. * @param m is the mesh to target
  64726. * @param force all channels on the packer to be set.
  64727. */
  64728. private _updateTextureReferences;
  64729. /**
  64730. * Public method to set a Mesh to a frame
  64731. * @param m that is the target
  64732. * @param frameID or the frame index
  64733. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64734. */
  64735. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64736. /**
  64737. * Starts the async promise to compile the texture packer.
  64738. * @returns Promise<void>
  64739. */
  64740. processAsync(): Promise<void>;
  64741. /**
  64742. * Disposes all textures associated with this packer
  64743. */
  64744. dispose(): void;
  64745. /**
  64746. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64747. * @param imageType is the image type to use.
  64748. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64749. */
  64750. download(imageType?: string, quality?: number): void;
  64751. /**
  64752. * Public method to load a texturePacker JSON file.
  64753. * @param data of the JSON file in string format.
  64754. */
  64755. updateFromJSON(data: string): void;
  64756. }
  64757. }
  64758. declare module "babylonjs/Materials/Textures/Packer/index" {
  64759. export * from "babylonjs/Materials/Textures/Packer/packer";
  64760. export * from "babylonjs/Materials/Textures/Packer/frame";
  64761. }
  64762. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64763. import { Scene } from "babylonjs/scene";
  64764. import { Texture } from "babylonjs/Materials/Textures/texture";
  64765. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64766. /**
  64767. * 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.
  64768. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64769. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64770. */
  64771. export class CustomProceduralTexture extends ProceduralTexture {
  64772. private _animate;
  64773. private _time;
  64774. private _config;
  64775. private _texturePath;
  64776. /**
  64777. * Instantiates a new Custom Procedural Texture.
  64778. * 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.
  64779. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64780. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64781. * @param name Define the name of the texture
  64782. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64783. * @param size Define the size of the texture to create
  64784. * @param scene Define the scene the texture belongs to
  64785. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64786. * @param generateMipMaps Define if the texture should creates mip maps or not
  64787. */
  64788. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64789. private _loadJson;
  64790. /**
  64791. * Is the texture ready to be used ? (rendered at least once)
  64792. * @returns true if ready, otherwise, false.
  64793. */
  64794. isReady(): boolean;
  64795. /**
  64796. * Render the texture to its associated render target.
  64797. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64798. */
  64799. render(useCameraPostProcess?: boolean): void;
  64800. /**
  64801. * Update the list of dependant textures samplers in the shader.
  64802. */
  64803. updateTextures(): void;
  64804. /**
  64805. * Update the uniform values of the procedural texture in the shader.
  64806. */
  64807. updateShaderUniforms(): void;
  64808. /**
  64809. * Define if the texture animates or not.
  64810. */
  64811. get animate(): boolean;
  64812. set animate(value: boolean);
  64813. }
  64814. }
  64815. declare module "babylonjs/Shaders/noise.fragment" {
  64816. /** @hidden */
  64817. export var noisePixelShader: {
  64818. name: string;
  64819. shader: string;
  64820. };
  64821. }
  64822. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64823. import { Nullable } from "babylonjs/types";
  64824. import { Scene } from "babylonjs/scene";
  64825. import { Texture } from "babylonjs/Materials/Textures/texture";
  64826. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64827. import "babylonjs/Shaders/noise.fragment";
  64828. /**
  64829. * Class used to generate noise procedural textures
  64830. */
  64831. export class NoiseProceduralTexture extends ProceduralTexture {
  64832. private _time;
  64833. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64834. brightness: number;
  64835. /** Defines the number of octaves to process */
  64836. octaves: number;
  64837. /** Defines the level of persistence (0.8 by default) */
  64838. persistence: number;
  64839. /** Gets or sets animation speed factor (default is 1) */
  64840. animationSpeedFactor: number;
  64841. /**
  64842. * Creates a new NoiseProceduralTexture
  64843. * @param name defines the name fo the texture
  64844. * @param size defines the size of the texture (default is 256)
  64845. * @param scene defines the hosting scene
  64846. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64847. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64848. */
  64849. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64850. private _updateShaderUniforms;
  64851. protected _getDefines(): string;
  64852. /** Generate the current state of the procedural texture */
  64853. render(useCameraPostProcess?: boolean): void;
  64854. /**
  64855. * Serializes this noise procedural texture
  64856. * @returns a serialized noise procedural texture object
  64857. */
  64858. serialize(): any;
  64859. /**
  64860. * Clone the texture.
  64861. * @returns the cloned texture
  64862. */
  64863. clone(): NoiseProceduralTexture;
  64864. /**
  64865. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64866. * @param parsedTexture defines parsed texture data
  64867. * @param scene defines the current scene
  64868. * @param rootUrl defines the root URL containing noise procedural texture information
  64869. * @returns a parsed NoiseProceduralTexture
  64870. */
  64871. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64872. }
  64873. }
  64874. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64875. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64876. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64877. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64878. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64879. }
  64880. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64881. import { Nullable } from "babylonjs/types";
  64882. import { Scene } from "babylonjs/scene";
  64883. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64885. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64886. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64887. /**
  64888. * Raw cube texture where the raw buffers are passed in
  64889. */
  64890. export class RawCubeTexture extends CubeTexture {
  64891. /**
  64892. * Creates a cube texture where the raw buffers are passed in.
  64893. * @param scene defines the scene the texture is attached to
  64894. * @param data defines the array of data to use to create each face
  64895. * @param size defines the size of the textures
  64896. * @param format defines the format of the data
  64897. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64898. * @param generateMipMaps defines if the engine should generate the mip levels
  64899. * @param invertY defines if data must be stored with Y axis inverted
  64900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64901. * @param compression defines the compression used (null by default)
  64902. */
  64903. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64904. /**
  64905. * Updates the raw cube texture.
  64906. * @param data defines the data to store
  64907. * @param format defines the data format
  64908. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64909. * @param invertY defines if data must be stored with Y axis inverted
  64910. * @param compression defines the compression used (null by default)
  64911. * @param level defines which level of the texture to update
  64912. */
  64913. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64914. /**
  64915. * Updates a raw cube texture with RGBD encoded data.
  64916. * @param data defines the array of data [mipmap][face] to use to create each face
  64917. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64918. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64919. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64920. * @returns a promsie that resolves when the operation is complete
  64921. */
  64922. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64923. /**
  64924. * Clones the raw cube texture.
  64925. * @return a new cube texture
  64926. */
  64927. clone(): CubeTexture;
  64928. /** @hidden */
  64929. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64930. }
  64931. }
  64932. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64933. import { Scene } from "babylonjs/scene";
  64934. import { Texture } from "babylonjs/Materials/Textures/texture";
  64935. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64936. /**
  64937. * Class used to store 2D array textures containing user data
  64938. */
  64939. export class RawTexture2DArray extends Texture {
  64940. /** Gets or sets the texture format to use */
  64941. format: number;
  64942. /**
  64943. * Create a new RawTexture2DArray
  64944. * @param data defines the data of the texture
  64945. * @param width defines the width of the texture
  64946. * @param height defines the height of the texture
  64947. * @param depth defines the number of layers of the texture
  64948. * @param format defines the texture format to use
  64949. * @param scene defines the hosting scene
  64950. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64951. * @param invertY defines if texture must be stored with Y axis inverted
  64952. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64953. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64954. */
  64955. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64956. /** Gets or sets the texture format to use */
  64957. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64958. /**
  64959. * Update the texture with new data
  64960. * @param data defines the data to store in the texture
  64961. */
  64962. update(data: ArrayBufferView): void;
  64963. }
  64964. }
  64965. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64966. import { Scene } from "babylonjs/scene";
  64967. import { Texture } from "babylonjs/Materials/Textures/texture";
  64968. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64969. /**
  64970. * Class used to store 3D textures containing user data
  64971. */
  64972. export class RawTexture3D extends Texture {
  64973. /** Gets or sets the texture format to use */
  64974. format: number;
  64975. /**
  64976. * Create a new RawTexture3D
  64977. * @param data defines the data of the texture
  64978. * @param width defines the width of the texture
  64979. * @param height defines the height of the texture
  64980. * @param depth defines the depth of the texture
  64981. * @param format defines the texture format to use
  64982. * @param scene defines the hosting scene
  64983. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64984. * @param invertY defines if texture must be stored with Y axis inverted
  64985. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64986. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64987. */
  64988. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64989. /** Gets or sets the texture format to use */
  64990. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64991. /**
  64992. * Update the texture with new data
  64993. * @param data defines the data to store in the texture
  64994. */
  64995. update(data: ArrayBufferView): void;
  64996. }
  64997. }
  64998. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64999. import { Scene } from "babylonjs/scene";
  65000. import { Plane } from "babylonjs/Maths/math.plane";
  65001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65002. /**
  65003. * Creates a refraction texture used by refraction channel of the standard material.
  65004. * It is like a mirror but to see through a material.
  65005. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65006. */
  65007. export class RefractionTexture extends RenderTargetTexture {
  65008. /**
  65009. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65010. * 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.
  65011. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65012. */
  65013. refractionPlane: Plane;
  65014. /**
  65015. * Define how deep under the surface we should see.
  65016. */
  65017. depth: number;
  65018. /**
  65019. * Creates a refraction texture used by refraction channel of the standard material.
  65020. * It is like a mirror but to see through a material.
  65021. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65022. * @param name Define the texture name
  65023. * @param size Define the size of the underlying texture
  65024. * @param scene Define the scene the refraction belongs to
  65025. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65026. */
  65027. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65028. /**
  65029. * Clone the refraction texture.
  65030. * @returns the cloned texture
  65031. */
  65032. clone(): RefractionTexture;
  65033. /**
  65034. * Serialize the texture to a JSON representation you could use in Parse later on
  65035. * @returns the serialized JSON representation
  65036. */
  65037. serialize(): any;
  65038. }
  65039. }
  65040. declare module "babylonjs/Materials/Textures/index" {
  65041. export * from "babylonjs/Materials/Textures/baseTexture";
  65042. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65043. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65044. export * from "babylonjs/Materials/Textures/cubeTexture";
  65045. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65046. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65047. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65048. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65049. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65050. export * from "babylonjs/Materials/Textures/internalTexture";
  65051. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65052. export * from "babylonjs/Materials/Textures/Loaders/index";
  65053. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65054. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65055. export * from "babylonjs/Materials/Textures/Packer/index";
  65056. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65057. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65058. export * from "babylonjs/Materials/Textures/rawTexture";
  65059. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65060. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65061. export * from "babylonjs/Materials/Textures/refractionTexture";
  65062. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65063. export * from "babylonjs/Materials/Textures/texture";
  65064. export * from "babylonjs/Materials/Textures/videoTexture";
  65065. }
  65066. declare module "babylonjs/Materials/Node/Enums/index" {
  65067. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65068. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65069. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65070. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65071. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65072. }
  65073. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65077. import { Mesh } from "babylonjs/Meshes/mesh";
  65078. import { Effect } from "babylonjs/Materials/effect";
  65079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65080. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65081. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65082. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65083. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65084. /**
  65085. * Block used to add support for vertex skinning (bones)
  65086. */
  65087. export class BonesBlock extends NodeMaterialBlock {
  65088. /**
  65089. * Creates a new BonesBlock
  65090. * @param name defines the block name
  65091. */
  65092. constructor(name: string);
  65093. /**
  65094. * Initialize the block and prepare the context for build
  65095. * @param state defines the state that will be used for the build
  65096. */
  65097. initialize(state: NodeMaterialBuildState): void;
  65098. /**
  65099. * Gets the current class name
  65100. * @returns the class name
  65101. */
  65102. getClassName(): string;
  65103. /**
  65104. * Gets the matrix indices input component
  65105. */
  65106. get matricesIndices(): NodeMaterialConnectionPoint;
  65107. /**
  65108. * Gets the matrix weights input component
  65109. */
  65110. get matricesWeights(): NodeMaterialConnectionPoint;
  65111. /**
  65112. * Gets the extra matrix indices input component
  65113. */
  65114. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65115. /**
  65116. * Gets the extra matrix weights input component
  65117. */
  65118. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65119. /**
  65120. * Gets the world input component
  65121. */
  65122. get world(): NodeMaterialConnectionPoint;
  65123. /**
  65124. * Gets the output component
  65125. */
  65126. get output(): NodeMaterialConnectionPoint;
  65127. autoConfigure(material: NodeMaterial): void;
  65128. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65129. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65131. protected _buildBlock(state: NodeMaterialBuildState): this;
  65132. }
  65133. }
  65134. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65139. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65140. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65141. /**
  65142. * Block used to add support for instances
  65143. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65144. */
  65145. export class InstancesBlock extends NodeMaterialBlock {
  65146. /**
  65147. * Creates a new InstancesBlock
  65148. * @param name defines the block name
  65149. */
  65150. constructor(name: string);
  65151. /**
  65152. * Gets the current class name
  65153. * @returns the class name
  65154. */
  65155. getClassName(): string;
  65156. /**
  65157. * Gets the first world row input component
  65158. */
  65159. get world0(): NodeMaterialConnectionPoint;
  65160. /**
  65161. * Gets the second world row input component
  65162. */
  65163. get world1(): NodeMaterialConnectionPoint;
  65164. /**
  65165. * Gets the third world row input component
  65166. */
  65167. get world2(): NodeMaterialConnectionPoint;
  65168. /**
  65169. * Gets the forth world row input component
  65170. */
  65171. get world3(): NodeMaterialConnectionPoint;
  65172. /**
  65173. * Gets the world input component
  65174. */
  65175. get world(): NodeMaterialConnectionPoint;
  65176. /**
  65177. * Gets the output component
  65178. */
  65179. get output(): NodeMaterialConnectionPoint;
  65180. /**
  65181. * Gets the isntanceID component
  65182. */
  65183. get instanceID(): NodeMaterialConnectionPoint;
  65184. autoConfigure(material: NodeMaterial): void;
  65185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65186. protected _buildBlock(state: NodeMaterialBuildState): this;
  65187. }
  65188. }
  65189. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65195. import { Effect } from "babylonjs/Materials/effect";
  65196. import { Mesh } from "babylonjs/Meshes/mesh";
  65197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65199. /**
  65200. * Block used to add morph targets support to vertex shader
  65201. */
  65202. export class MorphTargetsBlock extends NodeMaterialBlock {
  65203. private _repeatableContentAnchor;
  65204. /**
  65205. * Create a new MorphTargetsBlock
  65206. * @param name defines the block name
  65207. */
  65208. constructor(name: string);
  65209. /**
  65210. * Gets the current class name
  65211. * @returns the class name
  65212. */
  65213. getClassName(): string;
  65214. /**
  65215. * Gets the position input component
  65216. */
  65217. get position(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the normal input component
  65220. */
  65221. get normal(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the tangent input component
  65224. */
  65225. get tangent(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the tangent input component
  65228. */
  65229. get uv(): NodeMaterialConnectionPoint;
  65230. /**
  65231. * Gets the position output component
  65232. */
  65233. get positionOutput(): NodeMaterialConnectionPoint;
  65234. /**
  65235. * Gets the normal output component
  65236. */
  65237. get normalOutput(): NodeMaterialConnectionPoint;
  65238. /**
  65239. * Gets the tangent output component
  65240. */
  65241. get tangentOutput(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the tangent output component
  65244. */
  65245. get uvOutput(): NodeMaterialConnectionPoint;
  65246. initialize(state: NodeMaterialBuildState): void;
  65247. autoConfigure(material: NodeMaterial): void;
  65248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65250. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65251. protected _buildBlock(state: NodeMaterialBuildState): this;
  65252. }
  65253. }
  65254. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65258. import { Nullable } from "babylonjs/types";
  65259. import { Scene } from "babylonjs/scene";
  65260. import { Effect } from "babylonjs/Materials/effect";
  65261. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65262. import { Mesh } from "babylonjs/Meshes/mesh";
  65263. import { Light } from "babylonjs/Lights/light";
  65264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65265. /**
  65266. * Block used to get data information from a light
  65267. */
  65268. export class LightInformationBlock extends NodeMaterialBlock {
  65269. private _lightDataUniformName;
  65270. private _lightColorUniformName;
  65271. private _lightTypeDefineName;
  65272. /**
  65273. * Gets or sets the light associated with this block
  65274. */
  65275. light: Nullable<Light>;
  65276. /**
  65277. * Creates a new LightInformationBlock
  65278. * @param name defines the block name
  65279. */
  65280. constructor(name: string);
  65281. /**
  65282. * Gets the current class name
  65283. * @returns the class name
  65284. */
  65285. getClassName(): string;
  65286. /**
  65287. * Gets the world position input component
  65288. */
  65289. get worldPosition(): NodeMaterialConnectionPoint;
  65290. /**
  65291. * Gets the direction output component
  65292. */
  65293. get direction(): NodeMaterialConnectionPoint;
  65294. /**
  65295. * Gets the direction output component
  65296. */
  65297. get color(): NodeMaterialConnectionPoint;
  65298. /**
  65299. * Gets the direction output component
  65300. */
  65301. get intensity(): NodeMaterialConnectionPoint;
  65302. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65304. protected _buildBlock(state: NodeMaterialBuildState): this;
  65305. serialize(): any;
  65306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65307. }
  65308. }
  65309. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65310. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65311. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65312. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65313. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65314. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65315. }
  65316. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65319. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65321. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65322. import { Effect } from "babylonjs/Materials/effect";
  65323. import { Mesh } from "babylonjs/Meshes/mesh";
  65324. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65325. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65326. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65327. /**
  65328. * Block used to add image processing support to fragment shader
  65329. */
  65330. export class ImageProcessingBlock extends NodeMaterialBlock {
  65331. /**
  65332. * Create a new ImageProcessingBlock
  65333. * @param name defines the block name
  65334. */
  65335. constructor(name: string);
  65336. /**
  65337. * Gets the current class name
  65338. * @returns the class name
  65339. */
  65340. getClassName(): string;
  65341. /**
  65342. * Gets the color input component
  65343. */
  65344. get color(): NodeMaterialConnectionPoint;
  65345. /**
  65346. * Gets the output component
  65347. */
  65348. get output(): NodeMaterialConnectionPoint;
  65349. /**
  65350. * Initialize the block and prepare the context for build
  65351. * @param state defines the state that will be used for the build
  65352. */
  65353. initialize(state: NodeMaterialBuildState): void;
  65354. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65357. protected _buildBlock(state: NodeMaterialBuildState): this;
  65358. }
  65359. }
  65360. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65364. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65366. import { Effect } from "babylonjs/Materials/effect";
  65367. import { Mesh } from "babylonjs/Meshes/mesh";
  65368. import { Scene } from "babylonjs/scene";
  65369. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65370. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65371. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65372. /**
  65373. * Block used to pertub normals based on a normal map
  65374. */
  65375. export class PerturbNormalBlock extends NodeMaterialBlock {
  65376. private _tangentSpaceParameterName;
  65377. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65378. invertX: boolean;
  65379. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65380. invertY: boolean;
  65381. /**
  65382. * Create a new PerturbNormalBlock
  65383. * @param name defines the block name
  65384. */
  65385. constructor(name: string);
  65386. /**
  65387. * Gets the current class name
  65388. * @returns the class name
  65389. */
  65390. getClassName(): string;
  65391. /**
  65392. * Gets the world position input component
  65393. */
  65394. get worldPosition(): NodeMaterialConnectionPoint;
  65395. /**
  65396. * Gets the world normal input component
  65397. */
  65398. get worldNormal(): NodeMaterialConnectionPoint;
  65399. /**
  65400. * Gets the world tangent input component
  65401. */
  65402. get worldTangent(): NodeMaterialConnectionPoint;
  65403. /**
  65404. * Gets the uv input component
  65405. */
  65406. get uv(): NodeMaterialConnectionPoint;
  65407. /**
  65408. * Gets the normal map color input component
  65409. */
  65410. get normalMapColor(): NodeMaterialConnectionPoint;
  65411. /**
  65412. * Gets the strength input component
  65413. */
  65414. get strength(): NodeMaterialConnectionPoint;
  65415. /**
  65416. * Gets the output component
  65417. */
  65418. get output(): NodeMaterialConnectionPoint;
  65419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65421. autoConfigure(material: NodeMaterial): void;
  65422. protected _buildBlock(state: NodeMaterialBuildState): this;
  65423. protected _dumpPropertiesCode(): string;
  65424. serialize(): any;
  65425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65426. }
  65427. }
  65428. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65432. /**
  65433. * Block used to discard a pixel if a value is smaller than a cutoff
  65434. */
  65435. export class DiscardBlock extends NodeMaterialBlock {
  65436. /**
  65437. * Create a new DiscardBlock
  65438. * @param name defines the block name
  65439. */
  65440. constructor(name: string);
  65441. /**
  65442. * Gets the current class name
  65443. * @returns the class name
  65444. */
  65445. getClassName(): string;
  65446. /**
  65447. * Gets the color input component
  65448. */
  65449. get value(): NodeMaterialConnectionPoint;
  65450. /**
  65451. * Gets the cutoff input component
  65452. */
  65453. get cutoff(): NodeMaterialConnectionPoint;
  65454. protected _buildBlock(state: NodeMaterialBuildState): this;
  65455. }
  65456. }
  65457. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65458. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65459. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65460. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65461. /**
  65462. * Block used to test if the fragment shader is front facing
  65463. */
  65464. export class FrontFacingBlock extends NodeMaterialBlock {
  65465. /**
  65466. * Creates a new FrontFacingBlock
  65467. * @param name defines the block name
  65468. */
  65469. constructor(name: string);
  65470. /**
  65471. * Gets the current class name
  65472. * @returns the class name
  65473. */
  65474. getClassName(): string;
  65475. /**
  65476. * Gets the output component
  65477. */
  65478. get output(): NodeMaterialConnectionPoint;
  65479. protected _buildBlock(state: NodeMaterialBuildState): this;
  65480. }
  65481. }
  65482. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65486. /**
  65487. * Block used to get the derivative value on x and y of a given input
  65488. */
  65489. export class DerivativeBlock extends NodeMaterialBlock {
  65490. /**
  65491. * Create a new DerivativeBlock
  65492. * @param name defines the block name
  65493. */
  65494. constructor(name: string);
  65495. /**
  65496. * Gets the current class name
  65497. * @returns the class name
  65498. */
  65499. getClassName(): string;
  65500. /**
  65501. * Gets the input component
  65502. */
  65503. get input(): NodeMaterialConnectionPoint;
  65504. /**
  65505. * Gets the derivative output on x
  65506. */
  65507. get dx(): NodeMaterialConnectionPoint;
  65508. /**
  65509. * Gets the derivative output on y
  65510. */
  65511. get dy(): NodeMaterialConnectionPoint;
  65512. protected _buildBlock(state: NodeMaterialBuildState): this;
  65513. }
  65514. }
  65515. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65519. /**
  65520. * Block used to make gl_FragCoord available
  65521. */
  65522. export class FragCoordBlock extends NodeMaterialBlock {
  65523. /**
  65524. * Creates a new FragCoordBlock
  65525. * @param name defines the block name
  65526. */
  65527. constructor(name: string);
  65528. /**
  65529. * Gets the current class name
  65530. * @returns the class name
  65531. */
  65532. getClassName(): string;
  65533. /**
  65534. * Gets the xy component
  65535. */
  65536. get xy(): NodeMaterialConnectionPoint;
  65537. /**
  65538. * Gets the xyz component
  65539. */
  65540. get xyz(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the xyzw component
  65543. */
  65544. get xyzw(): NodeMaterialConnectionPoint;
  65545. /**
  65546. * Gets the x component
  65547. */
  65548. get x(): NodeMaterialConnectionPoint;
  65549. /**
  65550. * Gets the y component
  65551. */
  65552. get y(): NodeMaterialConnectionPoint;
  65553. /**
  65554. * Gets the z component
  65555. */
  65556. get z(): NodeMaterialConnectionPoint;
  65557. /**
  65558. * Gets the w component
  65559. */
  65560. get output(): NodeMaterialConnectionPoint;
  65561. protected writeOutputs(state: NodeMaterialBuildState): string;
  65562. protected _buildBlock(state: NodeMaterialBuildState): this;
  65563. }
  65564. }
  65565. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65569. import { Effect } from "babylonjs/Materials/effect";
  65570. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65571. import { Mesh } from "babylonjs/Meshes/mesh";
  65572. /**
  65573. * Block used to get the screen sizes
  65574. */
  65575. export class ScreenSizeBlock extends NodeMaterialBlock {
  65576. private _varName;
  65577. private _scene;
  65578. /**
  65579. * Creates a new ScreenSizeBlock
  65580. * @param name defines the block name
  65581. */
  65582. constructor(name: string);
  65583. /**
  65584. * Gets the current class name
  65585. * @returns the class name
  65586. */
  65587. getClassName(): string;
  65588. /**
  65589. * Gets the xy component
  65590. */
  65591. get xy(): NodeMaterialConnectionPoint;
  65592. /**
  65593. * Gets the x component
  65594. */
  65595. get x(): NodeMaterialConnectionPoint;
  65596. /**
  65597. * Gets the y component
  65598. */
  65599. get y(): NodeMaterialConnectionPoint;
  65600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65601. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65602. protected _buildBlock(state: NodeMaterialBuildState): this;
  65603. }
  65604. }
  65605. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65606. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65607. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65608. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65609. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65610. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65611. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65612. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65613. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65614. }
  65615. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65618. import { Mesh } from "babylonjs/Meshes/mesh";
  65619. import { Effect } from "babylonjs/Materials/effect";
  65620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65622. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65623. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65624. /**
  65625. * Block used to add support for scene fog
  65626. */
  65627. export class FogBlock extends NodeMaterialBlock {
  65628. private _fogDistanceName;
  65629. private _fogParameters;
  65630. /**
  65631. * Create a new FogBlock
  65632. * @param name defines the block name
  65633. */
  65634. constructor(name: string);
  65635. /**
  65636. * Gets the current class name
  65637. * @returns the class name
  65638. */
  65639. getClassName(): string;
  65640. /**
  65641. * Gets the world position input component
  65642. */
  65643. get worldPosition(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Gets the view input component
  65646. */
  65647. get view(): NodeMaterialConnectionPoint;
  65648. /**
  65649. * Gets the color input component
  65650. */
  65651. get input(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the fog color input component
  65654. */
  65655. get fogColor(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the output component
  65658. */
  65659. get output(): NodeMaterialConnectionPoint;
  65660. autoConfigure(material: NodeMaterial): void;
  65661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65663. protected _buildBlock(state: NodeMaterialBuildState): this;
  65664. }
  65665. }
  65666. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65671. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65672. import { Effect } from "babylonjs/Materials/effect";
  65673. import { Mesh } from "babylonjs/Meshes/mesh";
  65674. import { Light } from "babylonjs/Lights/light";
  65675. import { Nullable } from "babylonjs/types";
  65676. import { Scene } from "babylonjs/scene";
  65677. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65678. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65679. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65680. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65681. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65682. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65683. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65684. /**
  65685. * Block used to add light in the fragment shader
  65686. */
  65687. export class LightBlock extends NodeMaterialBlock {
  65688. private _lightId;
  65689. /**
  65690. * Gets or sets the light associated with this block
  65691. */
  65692. light: Nullable<Light>;
  65693. /**
  65694. * Create a new LightBlock
  65695. * @param name defines the block name
  65696. */
  65697. constructor(name: string);
  65698. /**
  65699. * Gets the current class name
  65700. * @returns the class name
  65701. */
  65702. getClassName(): string;
  65703. /**
  65704. * Gets the world position input component
  65705. */
  65706. get worldPosition(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the world normal input component
  65709. */
  65710. get worldNormal(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Gets the camera (or eye) position component
  65713. */
  65714. get cameraPosition(): NodeMaterialConnectionPoint;
  65715. /**
  65716. * Gets the glossiness component
  65717. */
  65718. get glossiness(): NodeMaterialConnectionPoint;
  65719. /**
  65720. * Gets the glossinness power component
  65721. */
  65722. get glossPower(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the diffuse color component
  65725. */
  65726. get diffuseColor(): NodeMaterialConnectionPoint;
  65727. /**
  65728. * Gets the specular color component
  65729. */
  65730. get specularColor(): NodeMaterialConnectionPoint;
  65731. /**
  65732. * Gets the diffuse output component
  65733. */
  65734. get diffuseOutput(): NodeMaterialConnectionPoint;
  65735. /**
  65736. * Gets the specular output component
  65737. */
  65738. get specularOutput(): NodeMaterialConnectionPoint;
  65739. /**
  65740. * Gets the shadow output component
  65741. */
  65742. get shadow(): NodeMaterialConnectionPoint;
  65743. autoConfigure(material: NodeMaterial): void;
  65744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65745. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65747. private _injectVertexCode;
  65748. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65749. serialize(): any;
  65750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65751. }
  65752. }
  65753. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65756. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65757. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65758. /**
  65759. * Block used to read a reflection texture from a sampler
  65760. */
  65761. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65762. /**
  65763. * Create a new ReflectionTextureBlock
  65764. * @param name defines the block name
  65765. */
  65766. constructor(name: string);
  65767. /**
  65768. * Gets the current class name
  65769. * @returns the class name
  65770. */
  65771. getClassName(): string;
  65772. /**
  65773. * Gets the world position input component
  65774. */
  65775. get position(): NodeMaterialConnectionPoint;
  65776. /**
  65777. * Gets the world position input component
  65778. */
  65779. get worldPosition(): NodeMaterialConnectionPoint;
  65780. /**
  65781. * Gets the world normal input component
  65782. */
  65783. get worldNormal(): NodeMaterialConnectionPoint;
  65784. /**
  65785. * Gets the world input component
  65786. */
  65787. get world(): NodeMaterialConnectionPoint;
  65788. /**
  65789. * Gets the camera (or eye) position component
  65790. */
  65791. get cameraPosition(): NodeMaterialConnectionPoint;
  65792. /**
  65793. * Gets the view input component
  65794. */
  65795. get view(): NodeMaterialConnectionPoint;
  65796. /**
  65797. * Gets the rgb output component
  65798. */
  65799. get rgb(): NodeMaterialConnectionPoint;
  65800. /**
  65801. * Gets the rgba output component
  65802. */
  65803. get rgba(): NodeMaterialConnectionPoint;
  65804. /**
  65805. * Gets the r output component
  65806. */
  65807. get r(): NodeMaterialConnectionPoint;
  65808. /**
  65809. * Gets the g output component
  65810. */
  65811. get g(): NodeMaterialConnectionPoint;
  65812. /**
  65813. * Gets the b output component
  65814. */
  65815. get b(): NodeMaterialConnectionPoint;
  65816. /**
  65817. * Gets the a output component
  65818. */
  65819. get a(): NodeMaterialConnectionPoint;
  65820. autoConfigure(material: NodeMaterial): void;
  65821. protected _buildBlock(state: NodeMaterialBuildState): this;
  65822. }
  65823. }
  65824. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65825. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65826. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65827. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65828. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65829. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65830. }
  65831. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65832. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65833. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65834. }
  65835. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65839. /**
  65840. * Block used to add 2 vectors
  65841. */
  65842. export class AddBlock extends NodeMaterialBlock {
  65843. /**
  65844. * Creates a new AddBlock
  65845. * @param name defines the block name
  65846. */
  65847. constructor(name: string);
  65848. /**
  65849. * Gets the current class name
  65850. * @returns the class name
  65851. */
  65852. getClassName(): string;
  65853. /**
  65854. * Gets the left operand input component
  65855. */
  65856. get left(): NodeMaterialConnectionPoint;
  65857. /**
  65858. * Gets the right operand input component
  65859. */
  65860. get right(): NodeMaterialConnectionPoint;
  65861. /**
  65862. * Gets the output component
  65863. */
  65864. get output(): NodeMaterialConnectionPoint;
  65865. protected _buildBlock(state: NodeMaterialBuildState): this;
  65866. }
  65867. }
  65868. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65872. /**
  65873. * Block used to scale a vector by a float
  65874. */
  65875. export class ScaleBlock extends NodeMaterialBlock {
  65876. /**
  65877. * Creates a new ScaleBlock
  65878. * @param name defines the block name
  65879. */
  65880. constructor(name: string);
  65881. /**
  65882. * Gets the current class name
  65883. * @returns the class name
  65884. */
  65885. getClassName(): string;
  65886. /**
  65887. * Gets the input component
  65888. */
  65889. get input(): NodeMaterialConnectionPoint;
  65890. /**
  65891. * Gets the factor input component
  65892. */
  65893. get factor(): NodeMaterialConnectionPoint;
  65894. /**
  65895. * Gets the output component
  65896. */
  65897. get output(): NodeMaterialConnectionPoint;
  65898. protected _buildBlock(state: NodeMaterialBuildState): this;
  65899. }
  65900. }
  65901. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65905. import { Scene } from "babylonjs/scene";
  65906. /**
  65907. * Block used to clamp a float
  65908. */
  65909. export class ClampBlock extends NodeMaterialBlock {
  65910. /** Gets or sets the minimum range */
  65911. minimum: number;
  65912. /** Gets or sets the maximum range */
  65913. maximum: number;
  65914. /**
  65915. * Creates a new ClampBlock
  65916. * @param name defines the block name
  65917. */
  65918. constructor(name: string);
  65919. /**
  65920. * Gets the current class name
  65921. * @returns the class name
  65922. */
  65923. getClassName(): string;
  65924. /**
  65925. * Gets the value input component
  65926. */
  65927. get value(): NodeMaterialConnectionPoint;
  65928. /**
  65929. * Gets the output component
  65930. */
  65931. get output(): NodeMaterialConnectionPoint;
  65932. protected _buildBlock(state: NodeMaterialBuildState): this;
  65933. protected _dumpPropertiesCode(): string;
  65934. serialize(): any;
  65935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65936. }
  65937. }
  65938. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65942. /**
  65943. * Block used to apply a cross product between 2 vectors
  65944. */
  65945. export class CrossBlock extends NodeMaterialBlock {
  65946. /**
  65947. * Creates a new CrossBlock
  65948. * @param name defines the block name
  65949. */
  65950. constructor(name: string);
  65951. /**
  65952. * Gets the current class name
  65953. * @returns the class name
  65954. */
  65955. getClassName(): string;
  65956. /**
  65957. * Gets the left operand input component
  65958. */
  65959. get left(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the right operand input component
  65962. */
  65963. get right(): NodeMaterialConnectionPoint;
  65964. /**
  65965. * Gets the output component
  65966. */
  65967. get output(): NodeMaterialConnectionPoint;
  65968. protected _buildBlock(state: NodeMaterialBuildState): this;
  65969. }
  65970. }
  65971. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65975. /**
  65976. * Block used to apply a dot product between 2 vectors
  65977. */
  65978. export class DotBlock extends NodeMaterialBlock {
  65979. /**
  65980. * Creates a new DotBlock
  65981. * @param name defines the block name
  65982. */
  65983. constructor(name: string);
  65984. /**
  65985. * Gets the current class name
  65986. * @returns the class name
  65987. */
  65988. getClassName(): string;
  65989. /**
  65990. * Gets the left operand input component
  65991. */
  65992. get left(): NodeMaterialConnectionPoint;
  65993. /**
  65994. * Gets the right operand input component
  65995. */
  65996. get right(): NodeMaterialConnectionPoint;
  65997. /**
  65998. * Gets the output component
  65999. */
  66000. get output(): NodeMaterialConnectionPoint;
  66001. protected _buildBlock(state: NodeMaterialBuildState): this;
  66002. }
  66003. }
  66004. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66008. /**
  66009. * Block used to normalize a vector
  66010. */
  66011. export class NormalizeBlock extends NodeMaterialBlock {
  66012. /**
  66013. * Creates a new NormalizeBlock
  66014. * @param name defines the block name
  66015. */
  66016. constructor(name: string);
  66017. /**
  66018. * Gets the current class name
  66019. * @returns the class name
  66020. */
  66021. getClassName(): string;
  66022. /**
  66023. * Gets the input component
  66024. */
  66025. get input(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the output component
  66028. */
  66029. get output(): NodeMaterialConnectionPoint;
  66030. protected _buildBlock(state: NodeMaterialBuildState): this;
  66031. }
  66032. }
  66033. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  66034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66037. import { Scene } from "babylonjs/scene";
  66038. /**
  66039. * Operations supported by the Trigonometry block
  66040. */
  66041. export enum TrigonometryBlockOperations {
  66042. /** Cos */
  66043. Cos = 0,
  66044. /** Sin */
  66045. Sin = 1,
  66046. /** Abs */
  66047. Abs = 2,
  66048. /** Exp */
  66049. Exp = 3,
  66050. /** Exp2 */
  66051. Exp2 = 4,
  66052. /** Round */
  66053. Round = 5,
  66054. /** Floor */
  66055. Floor = 6,
  66056. /** Ceiling */
  66057. Ceiling = 7,
  66058. /** Square root */
  66059. Sqrt = 8,
  66060. /** Log */
  66061. Log = 9,
  66062. /** Tangent */
  66063. Tan = 10,
  66064. /** Arc tangent */
  66065. ArcTan = 11,
  66066. /** Arc cosinus */
  66067. ArcCos = 12,
  66068. /** Arc sinus */
  66069. ArcSin = 13,
  66070. /** Fraction */
  66071. Fract = 14,
  66072. /** Sign */
  66073. Sign = 15,
  66074. /** To radians (from degrees) */
  66075. Radians = 16,
  66076. /** To degrees (from radians) */
  66077. Degrees = 17
  66078. }
  66079. /**
  66080. * Block used to apply trigonometry operation to floats
  66081. */
  66082. export class TrigonometryBlock extends NodeMaterialBlock {
  66083. /**
  66084. * Gets or sets the operation applied by the block
  66085. */
  66086. operation: TrigonometryBlockOperations;
  66087. /**
  66088. * Creates a new TrigonometryBlock
  66089. * @param name defines the block name
  66090. */
  66091. constructor(name: string);
  66092. /**
  66093. * Gets the current class name
  66094. * @returns the class name
  66095. */
  66096. getClassName(): string;
  66097. /**
  66098. * Gets the input component
  66099. */
  66100. get input(): NodeMaterialConnectionPoint;
  66101. /**
  66102. * Gets the output component
  66103. */
  66104. get output(): NodeMaterialConnectionPoint;
  66105. protected _buildBlock(state: NodeMaterialBuildState): this;
  66106. serialize(): any;
  66107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66108. protected _dumpPropertiesCode(): string;
  66109. }
  66110. }
  66111. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66115. /**
  66116. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66117. */
  66118. export class ColorMergerBlock extends NodeMaterialBlock {
  66119. /**
  66120. * Create a new ColorMergerBlock
  66121. * @param name defines the block name
  66122. */
  66123. constructor(name: string);
  66124. /**
  66125. * Gets the current class name
  66126. * @returns the class name
  66127. */
  66128. getClassName(): string;
  66129. /**
  66130. * Gets the rgb component (input)
  66131. */
  66132. get rgbIn(): NodeMaterialConnectionPoint;
  66133. /**
  66134. * Gets the r component (input)
  66135. */
  66136. get r(): NodeMaterialConnectionPoint;
  66137. /**
  66138. * Gets the g component (input)
  66139. */
  66140. get g(): NodeMaterialConnectionPoint;
  66141. /**
  66142. * Gets the b component (input)
  66143. */
  66144. get b(): NodeMaterialConnectionPoint;
  66145. /**
  66146. * Gets the a component (input)
  66147. */
  66148. get a(): NodeMaterialConnectionPoint;
  66149. /**
  66150. * Gets the rgba component (output)
  66151. */
  66152. get rgba(): NodeMaterialConnectionPoint;
  66153. /**
  66154. * Gets the rgb component (output)
  66155. */
  66156. get rgbOut(): NodeMaterialConnectionPoint;
  66157. /**
  66158. * Gets the rgb component (output)
  66159. * @deprecated Please use rgbOut instead.
  66160. */
  66161. get rgb(): NodeMaterialConnectionPoint;
  66162. protected _buildBlock(state: NodeMaterialBuildState): this;
  66163. }
  66164. }
  66165. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66167. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66169. /**
  66170. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66171. */
  66172. export class VectorSplitterBlock extends NodeMaterialBlock {
  66173. /**
  66174. * Create a new VectorSplitterBlock
  66175. * @param name defines the block name
  66176. */
  66177. constructor(name: string);
  66178. /**
  66179. * Gets the current class name
  66180. * @returns the class name
  66181. */
  66182. getClassName(): string;
  66183. /**
  66184. * Gets the xyzw component (input)
  66185. */
  66186. get xyzw(): NodeMaterialConnectionPoint;
  66187. /**
  66188. * Gets the xyz component (input)
  66189. */
  66190. get xyzIn(): NodeMaterialConnectionPoint;
  66191. /**
  66192. * Gets the xy component (input)
  66193. */
  66194. get xyIn(): NodeMaterialConnectionPoint;
  66195. /**
  66196. * Gets the xyz component (output)
  66197. */
  66198. get xyzOut(): NodeMaterialConnectionPoint;
  66199. /**
  66200. * Gets the xy component (output)
  66201. */
  66202. get xyOut(): NodeMaterialConnectionPoint;
  66203. /**
  66204. * Gets the x component (output)
  66205. */
  66206. get x(): NodeMaterialConnectionPoint;
  66207. /**
  66208. * Gets the y component (output)
  66209. */
  66210. get y(): NodeMaterialConnectionPoint;
  66211. /**
  66212. * Gets the z component (output)
  66213. */
  66214. get z(): NodeMaterialConnectionPoint;
  66215. /**
  66216. * Gets the w component (output)
  66217. */
  66218. get w(): NodeMaterialConnectionPoint;
  66219. protected _inputRename(name: string): string;
  66220. protected _outputRename(name: string): string;
  66221. protected _buildBlock(state: NodeMaterialBuildState): this;
  66222. }
  66223. }
  66224. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66228. /**
  66229. * Block used to lerp between 2 values
  66230. */
  66231. export class LerpBlock extends NodeMaterialBlock {
  66232. /**
  66233. * Creates a new LerpBlock
  66234. * @param name defines the block name
  66235. */
  66236. constructor(name: string);
  66237. /**
  66238. * Gets the current class name
  66239. * @returns the class name
  66240. */
  66241. getClassName(): string;
  66242. /**
  66243. * Gets the left operand input component
  66244. */
  66245. get left(): NodeMaterialConnectionPoint;
  66246. /**
  66247. * Gets the right operand input component
  66248. */
  66249. get right(): NodeMaterialConnectionPoint;
  66250. /**
  66251. * Gets the gradient operand input component
  66252. */
  66253. get gradient(): NodeMaterialConnectionPoint;
  66254. /**
  66255. * Gets the output component
  66256. */
  66257. get output(): NodeMaterialConnectionPoint;
  66258. protected _buildBlock(state: NodeMaterialBuildState): this;
  66259. }
  66260. }
  66261. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66265. /**
  66266. * Block used to divide 2 vectors
  66267. */
  66268. export class DivideBlock extends NodeMaterialBlock {
  66269. /**
  66270. * Creates a new DivideBlock
  66271. * @param name defines the block name
  66272. */
  66273. constructor(name: string);
  66274. /**
  66275. * Gets the current class name
  66276. * @returns the class name
  66277. */
  66278. getClassName(): string;
  66279. /**
  66280. * Gets the left operand input component
  66281. */
  66282. get left(): NodeMaterialConnectionPoint;
  66283. /**
  66284. * Gets the right operand input component
  66285. */
  66286. get right(): NodeMaterialConnectionPoint;
  66287. /**
  66288. * Gets the output component
  66289. */
  66290. get output(): NodeMaterialConnectionPoint;
  66291. protected _buildBlock(state: NodeMaterialBuildState): this;
  66292. }
  66293. }
  66294. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66298. /**
  66299. * Block used to subtract 2 vectors
  66300. */
  66301. export class SubtractBlock extends NodeMaterialBlock {
  66302. /**
  66303. * Creates a new SubtractBlock
  66304. * @param name defines the block name
  66305. */
  66306. constructor(name: string);
  66307. /**
  66308. * Gets the current class name
  66309. * @returns the class name
  66310. */
  66311. getClassName(): string;
  66312. /**
  66313. * Gets the left operand input component
  66314. */
  66315. get left(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the right operand input component
  66318. */
  66319. get right(): NodeMaterialConnectionPoint;
  66320. /**
  66321. * Gets the output component
  66322. */
  66323. get output(): NodeMaterialConnectionPoint;
  66324. protected _buildBlock(state: NodeMaterialBuildState): this;
  66325. }
  66326. }
  66327. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66331. /**
  66332. * Block used to step a value
  66333. */
  66334. export class StepBlock extends NodeMaterialBlock {
  66335. /**
  66336. * Creates a new StepBlock
  66337. * @param name defines the block name
  66338. */
  66339. constructor(name: string);
  66340. /**
  66341. * Gets the current class name
  66342. * @returns the class name
  66343. */
  66344. getClassName(): string;
  66345. /**
  66346. * Gets the value operand input component
  66347. */
  66348. get value(): NodeMaterialConnectionPoint;
  66349. /**
  66350. * Gets the edge operand input component
  66351. */
  66352. get edge(): NodeMaterialConnectionPoint;
  66353. /**
  66354. * Gets the output component
  66355. */
  66356. get output(): NodeMaterialConnectionPoint;
  66357. protected _buildBlock(state: NodeMaterialBuildState): this;
  66358. }
  66359. }
  66360. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66364. /**
  66365. * Block used to get the opposite (1 - x) of a value
  66366. */
  66367. export class OneMinusBlock extends NodeMaterialBlock {
  66368. /**
  66369. * Creates a new OneMinusBlock
  66370. * @param name defines the block name
  66371. */
  66372. constructor(name: string);
  66373. /**
  66374. * Gets the current class name
  66375. * @returns the class name
  66376. */
  66377. getClassName(): string;
  66378. /**
  66379. * Gets the input component
  66380. */
  66381. get input(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the output component
  66384. */
  66385. get output(): NodeMaterialConnectionPoint;
  66386. protected _buildBlock(state: NodeMaterialBuildState): this;
  66387. }
  66388. }
  66389. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66393. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66394. /**
  66395. * Block used to get the view direction
  66396. */
  66397. export class ViewDirectionBlock extends NodeMaterialBlock {
  66398. /**
  66399. * Creates a new ViewDirectionBlock
  66400. * @param name defines the block name
  66401. */
  66402. constructor(name: string);
  66403. /**
  66404. * Gets the current class name
  66405. * @returns the class name
  66406. */
  66407. getClassName(): string;
  66408. /**
  66409. * Gets the world position component
  66410. */
  66411. get worldPosition(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the camera position component
  66414. */
  66415. get cameraPosition(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the output component
  66418. */
  66419. get output(): NodeMaterialConnectionPoint;
  66420. autoConfigure(material: NodeMaterial): void;
  66421. protected _buildBlock(state: NodeMaterialBuildState): this;
  66422. }
  66423. }
  66424. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66428. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66429. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66430. /**
  66431. * Block used to compute fresnel value
  66432. */
  66433. export class FresnelBlock extends NodeMaterialBlock {
  66434. /**
  66435. * Create a new FresnelBlock
  66436. * @param name defines the block name
  66437. */
  66438. constructor(name: string);
  66439. /**
  66440. * Gets the current class name
  66441. * @returns the class name
  66442. */
  66443. getClassName(): string;
  66444. /**
  66445. * Gets the world normal input component
  66446. */
  66447. get worldNormal(): NodeMaterialConnectionPoint;
  66448. /**
  66449. * Gets the view direction input component
  66450. */
  66451. get viewDirection(): NodeMaterialConnectionPoint;
  66452. /**
  66453. * Gets the bias input component
  66454. */
  66455. get bias(): NodeMaterialConnectionPoint;
  66456. /**
  66457. * Gets the camera (or eye) position component
  66458. */
  66459. get power(): NodeMaterialConnectionPoint;
  66460. /**
  66461. * Gets the fresnel output component
  66462. */
  66463. get fresnel(): NodeMaterialConnectionPoint;
  66464. autoConfigure(material: NodeMaterial): void;
  66465. protected _buildBlock(state: NodeMaterialBuildState): this;
  66466. }
  66467. }
  66468. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66472. /**
  66473. * Block used to get the max of 2 values
  66474. */
  66475. export class MaxBlock extends NodeMaterialBlock {
  66476. /**
  66477. * Creates a new MaxBlock
  66478. * @param name defines the block name
  66479. */
  66480. constructor(name: string);
  66481. /**
  66482. * Gets the current class name
  66483. * @returns the class name
  66484. */
  66485. getClassName(): string;
  66486. /**
  66487. * Gets the left operand input component
  66488. */
  66489. get left(): NodeMaterialConnectionPoint;
  66490. /**
  66491. * Gets the right operand input component
  66492. */
  66493. get right(): NodeMaterialConnectionPoint;
  66494. /**
  66495. * Gets the output component
  66496. */
  66497. get output(): NodeMaterialConnectionPoint;
  66498. protected _buildBlock(state: NodeMaterialBuildState): this;
  66499. }
  66500. }
  66501. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66505. /**
  66506. * Block used to get the min of 2 values
  66507. */
  66508. export class MinBlock extends NodeMaterialBlock {
  66509. /**
  66510. * Creates a new MinBlock
  66511. * @param name defines the block name
  66512. */
  66513. constructor(name: string);
  66514. /**
  66515. * Gets the current class name
  66516. * @returns the class name
  66517. */
  66518. getClassName(): string;
  66519. /**
  66520. * Gets the left operand input component
  66521. */
  66522. get left(): NodeMaterialConnectionPoint;
  66523. /**
  66524. * Gets the right operand input component
  66525. */
  66526. get right(): NodeMaterialConnectionPoint;
  66527. /**
  66528. * Gets the output component
  66529. */
  66530. get output(): NodeMaterialConnectionPoint;
  66531. protected _buildBlock(state: NodeMaterialBuildState): this;
  66532. }
  66533. }
  66534. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66538. /**
  66539. * Block used to get the distance between 2 values
  66540. */
  66541. export class DistanceBlock extends NodeMaterialBlock {
  66542. /**
  66543. * Creates a new DistanceBlock
  66544. * @param name defines the block name
  66545. */
  66546. constructor(name: string);
  66547. /**
  66548. * Gets the current class name
  66549. * @returns the class name
  66550. */
  66551. getClassName(): string;
  66552. /**
  66553. * Gets the left operand input component
  66554. */
  66555. get left(): NodeMaterialConnectionPoint;
  66556. /**
  66557. * Gets the right operand input component
  66558. */
  66559. get right(): NodeMaterialConnectionPoint;
  66560. /**
  66561. * Gets the output component
  66562. */
  66563. get output(): NodeMaterialConnectionPoint;
  66564. protected _buildBlock(state: NodeMaterialBuildState): this;
  66565. }
  66566. }
  66567. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66571. /**
  66572. * Block used to get the length of a vector
  66573. */
  66574. export class LengthBlock extends NodeMaterialBlock {
  66575. /**
  66576. * Creates a new LengthBlock
  66577. * @param name defines the block name
  66578. */
  66579. constructor(name: string);
  66580. /**
  66581. * Gets the current class name
  66582. * @returns the class name
  66583. */
  66584. getClassName(): string;
  66585. /**
  66586. * Gets the value input component
  66587. */
  66588. get value(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the output component
  66591. */
  66592. get output(): NodeMaterialConnectionPoint;
  66593. protected _buildBlock(state: NodeMaterialBuildState): this;
  66594. }
  66595. }
  66596. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66600. /**
  66601. * Block used to get negative version of a value (i.e. x * -1)
  66602. */
  66603. export class NegateBlock extends NodeMaterialBlock {
  66604. /**
  66605. * Creates a new NegateBlock
  66606. * @param name defines the block name
  66607. */
  66608. constructor(name: string);
  66609. /**
  66610. * Gets the current class name
  66611. * @returns the class name
  66612. */
  66613. getClassName(): string;
  66614. /**
  66615. * Gets the value input component
  66616. */
  66617. get value(): NodeMaterialConnectionPoint;
  66618. /**
  66619. * Gets the output component
  66620. */
  66621. get output(): NodeMaterialConnectionPoint;
  66622. protected _buildBlock(state: NodeMaterialBuildState): this;
  66623. }
  66624. }
  66625. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66629. /**
  66630. * Block used to get the value of the first parameter raised to the power of the second
  66631. */
  66632. export class PowBlock extends NodeMaterialBlock {
  66633. /**
  66634. * Creates a new PowBlock
  66635. * @param name defines the block name
  66636. */
  66637. constructor(name: string);
  66638. /**
  66639. * Gets the current class name
  66640. * @returns the class name
  66641. */
  66642. getClassName(): string;
  66643. /**
  66644. * Gets the value operand input component
  66645. */
  66646. get value(): NodeMaterialConnectionPoint;
  66647. /**
  66648. * Gets the power operand input component
  66649. */
  66650. get power(): NodeMaterialConnectionPoint;
  66651. /**
  66652. * Gets the output component
  66653. */
  66654. get output(): NodeMaterialConnectionPoint;
  66655. protected _buildBlock(state: NodeMaterialBuildState): this;
  66656. }
  66657. }
  66658. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66662. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66663. /**
  66664. * Block used to get a random number
  66665. */
  66666. export class RandomNumberBlock extends NodeMaterialBlock {
  66667. /**
  66668. * Creates a new RandomNumberBlock
  66669. * @param name defines the block name
  66670. */
  66671. constructor(name: string);
  66672. /**
  66673. * Gets the current class name
  66674. * @returns the class name
  66675. */
  66676. getClassName(): string;
  66677. /**
  66678. * Gets the seed input component
  66679. */
  66680. get seed(): NodeMaterialConnectionPoint;
  66681. /**
  66682. * Gets the output component
  66683. */
  66684. get output(): NodeMaterialConnectionPoint;
  66685. protected _buildBlock(state: NodeMaterialBuildState): this;
  66686. }
  66687. }
  66688. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66692. /**
  66693. * Block used to compute arc tangent of 2 values
  66694. */
  66695. export class ArcTan2Block extends NodeMaterialBlock {
  66696. /**
  66697. * Creates a new ArcTan2Block
  66698. * @param name defines the block name
  66699. */
  66700. constructor(name: string);
  66701. /**
  66702. * Gets the current class name
  66703. * @returns the class name
  66704. */
  66705. getClassName(): string;
  66706. /**
  66707. * Gets the x operand input component
  66708. */
  66709. get x(): NodeMaterialConnectionPoint;
  66710. /**
  66711. * Gets the y operand input component
  66712. */
  66713. get y(): NodeMaterialConnectionPoint;
  66714. /**
  66715. * Gets the output component
  66716. */
  66717. get output(): NodeMaterialConnectionPoint;
  66718. protected _buildBlock(state: NodeMaterialBuildState): this;
  66719. }
  66720. }
  66721. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66724. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66725. /**
  66726. * Block used to smooth step a value
  66727. */
  66728. export class SmoothStepBlock extends NodeMaterialBlock {
  66729. /**
  66730. * Creates a new SmoothStepBlock
  66731. * @param name defines the block name
  66732. */
  66733. constructor(name: string);
  66734. /**
  66735. * Gets the current class name
  66736. * @returns the class name
  66737. */
  66738. getClassName(): string;
  66739. /**
  66740. * Gets the value operand input component
  66741. */
  66742. get value(): NodeMaterialConnectionPoint;
  66743. /**
  66744. * Gets the first edge operand input component
  66745. */
  66746. get edge0(): NodeMaterialConnectionPoint;
  66747. /**
  66748. * Gets the second edge operand input component
  66749. */
  66750. get edge1(): NodeMaterialConnectionPoint;
  66751. /**
  66752. * Gets the output component
  66753. */
  66754. get output(): NodeMaterialConnectionPoint;
  66755. protected _buildBlock(state: NodeMaterialBuildState): this;
  66756. }
  66757. }
  66758. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66762. /**
  66763. * Block used to get the reciprocal (1 / x) of a value
  66764. */
  66765. export class ReciprocalBlock extends NodeMaterialBlock {
  66766. /**
  66767. * Creates a new ReciprocalBlock
  66768. * @param name defines the block name
  66769. */
  66770. constructor(name: string);
  66771. /**
  66772. * Gets the current class name
  66773. * @returns the class name
  66774. */
  66775. getClassName(): string;
  66776. /**
  66777. * Gets the input component
  66778. */
  66779. get input(): NodeMaterialConnectionPoint;
  66780. /**
  66781. * Gets the output component
  66782. */
  66783. get output(): NodeMaterialConnectionPoint;
  66784. protected _buildBlock(state: NodeMaterialBuildState): this;
  66785. }
  66786. }
  66787. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66791. /**
  66792. * Block used to replace a color by another one
  66793. */
  66794. export class ReplaceColorBlock extends NodeMaterialBlock {
  66795. /**
  66796. * Creates a new ReplaceColorBlock
  66797. * @param name defines the block name
  66798. */
  66799. constructor(name: string);
  66800. /**
  66801. * Gets the current class name
  66802. * @returns the class name
  66803. */
  66804. getClassName(): string;
  66805. /**
  66806. * Gets the value input component
  66807. */
  66808. get value(): NodeMaterialConnectionPoint;
  66809. /**
  66810. * Gets the reference input component
  66811. */
  66812. get reference(): NodeMaterialConnectionPoint;
  66813. /**
  66814. * Gets the distance input component
  66815. */
  66816. get distance(): NodeMaterialConnectionPoint;
  66817. /**
  66818. * Gets the replacement input component
  66819. */
  66820. get replacement(): NodeMaterialConnectionPoint;
  66821. /**
  66822. * Gets the output component
  66823. */
  66824. get output(): NodeMaterialConnectionPoint;
  66825. protected _buildBlock(state: NodeMaterialBuildState): this;
  66826. }
  66827. }
  66828. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66830. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66832. /**
  66833. * Block used to posterize a value
  66834. * @see https://en.wikipedia.org/wiki/Posterization
  66835. */
  66836. export class PosterizeBlock extends NodeMaterialBlock {
  66837. /**
  66838. * Creates a new PosterizeBlock
  66839. * @param name defines the block name
  66840. */
  66841. constructor(name: string);
  66842. /**
  66843. * Gets the current class name
  66844. * @returns the class name
  66845. */
  66846. getClassName(): string;
  66847. /**
  66848. * Gets the value input component
  66849. */
  66850. get value(): NodeMaterialConnectionPoint;
  66851. /**
  66852. * Gets the steps input component
  66853. */
  66854. get steps(): NodeMaterialConnectionPoint;
  66855. /**
  66856. * Gets the output component
  66857. */
  66858. get output(): NodeMaterialConnectionPoint;
  66859. protected _buildBlock(state: NodeMaterialBuildState): this;
  66860. }
  66861. }
  66862. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66866. import { Scene } from "babylonjs/scene";
  66867. /**
  66868. * Operations supported by the Wave block
  66869. */
  66870. export enum WaveBlockKind {
  66871. /** SawTooth */
  66872. SawTooth = 0,
  66873. /** Square */
  66874. Square = 1,
  66875. /** Triangle */
  66876. Triangle = 2
  66877. }
  66878. /**
  66879. * Block used to apply wave operation to floats
  66880. */
  66881. export class WaveBlock extends NodeMaterialBlock {
  66882. /**
  66883. * Gets or sets the kibnd of wave to be applied by the block
  66884. */
  66885. kind: WaveBlockKind;
  66886. /**
  66887. * Creates a new WaveBlock
  66888. * @param name defines the block name
  66889. */
  66890. constructor(name: string);
  66891. /**
  66892. * Gets the current class name
  66893. * @returns the class name
  66894. */
  66895. getClassName(): string;
  66896. /**
  66897. * Gets the input component
  66898. */
  66899. get input(): NodeMaterialConnectionPoint;
  66900. /**
  66901. * Gets the output component
  66902. */
  66903. get output(): NodeMaterialConnectionPoint;
  66904. protected _buildBlock(state: NodeMaterialBuildState): this;
  66905. serialize(): any;
  66906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66907. }
  66908. }
  66909. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66913. import { Color3 } from "babylonjs/Maths/math.color";
  66914. import { Scene } from "babylonjs/scene";
  66915. /**
  66916. * Class used to store a color step for the GradientBlock
  66917. */
  66918. export class GradientBlockColorStep {
  66919. /**
  66920. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66921. */
  66922. step: number;
  66923. /**
  66924. * Gets or sets the color associated with this step
  66925. */
  66926. color: Color3;
  66927. /**
  66928. * Creates a new GradientBlockColorStep
  66929. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66930. * @param color defines the color associated with this step
  66931. */
  66932. constructor(
  66933. /**
  66934. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66935. */
  66936. step: number,
  66937. /**
  66938. * Gets or sets the color associated with this step
  66939. */
  66940. color: Color3);
  66941. }
  66942. /**
  66943. * Block used to return a color from a gradient based on an input value between 0 and 1
  66944. */
  66945. export class GradientBlock extends NodeMaterialBlock {
  66946. /**
  66947. * Gets or sets the list of color steps
  66948. */
  66949. colorSteps: GradientBlockColorStep[];
  66950. /**
  66951. * Creates a new GradientBlock
  66952. * @param name defines the block name
  66953. */
  66954. constructor(name: string);
  66955. /**
  66956. * Gets the current class name
  66957. * @returns the class name
  66958. */
  66959. getClassName(): string;
  66960. /**
  66961. * Gets the gradient input component
  66962. */
  66963. get gradient(): NodeMaterialConnectionPoint;
  66964. /**
  66965. * Gets the output component
  66966. */
  66967. get output(): NodeMaterialConnectionPoint;
  66968. private _writeColorConstant;
  66969. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66970. serialize(): any;
  66971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66972. protected _dumpPropertiesCode(): string;
  66973. }
  66974. }
  66975. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66979. /**
  66980. * Block used to normalize lerp between 2 values
  66981. */
  66982. export class NLerpBlock extends NodeMaterialBlock {
  66983. /**
  66984. * Creates a new NLerpBlock
  66985. * @param name defines the block name
  66986. */
  66987. constructor(name: string);
  66988. /**
  66989. * Gets the current class name
  66990. * @returns the class name
  66991. */
  66992. getClassName(): string;
  66993. /**
  66994. * Gets the left operand input component
  66995. */
  66996. get left(): NodeMaterialConnectionPoint;
  66997. /**
  66998. * Gets the right operand input component
  66999. */
  67000. get right(): NodeMaterialConnectionPoint;
  67001. /**
  67002. * Gets the gradient operand input component
  67003. */
  67004. get gradient(): NodeMaterialConnectionPoint;
  67005. /**
  67006. * Gets the output component
  67007. */
  67008. get output(): NodeMaterialConnectionPoint;
  67009. protected _buildBlock(state: NodeMaterialBuildState): this;
  67010. }
  67011. }
  67012. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67016. import { Scene } from "babylonjs/scene";
  67017. /**
  67018. * block used to Generate a Worley Noise 3D Noise Pattern
  67019. */
  67020. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67021. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67022. manhattanDistance: boolean;
  67023. /**
  67024. * Creates a new WorleyNoise3DBlock
  67025. * @param name defines the block name
  67026. */
  67027. constructor(name: string);
  67028. /**
  67029. * Gets the current class name
  67030. * @returns the class name
  67031. */
  67032. getClassName(): string;
  67033. /**
  67034. * Gets the seed input component
  67035. */
  67036. get seed(): NodeMaterialConnectionPoint;
  67037. /**
  67038. * Gets the jitter input component
  67039. */
  67040. get jitter(): NodeMaterialConnectionPoint;
  67041. /**
  67042. * Gets the output component
  67043. */
  67044. get output(): NodeMaterialConnectionPoint;
  67045. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67046. /**
  67047. * Exposes the properties to the UI?
  67048. */
  67049. protected _dumpPropertiesCode(): string;
  67050. /**
  67051. * Exposes the properties to the Seralize?
  67052. */
  67053. serialize(): any;
  67054. /**
  67055. * Exposes the properties to the deseralize?
  67056. */
  67057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67058. }
  67059. }
  67060. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67064. /**
  67065. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67066. */
  67067. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67068. /**
  67069. * Creates a new SimplexPerlin3DBlock
  67070. * @param name defines the block name
  67071. */
  67072. constructor(name: string);
  67073. /**
  67074. * Gets the current class name
  67075. * @returns the class name
  67076. */
  67077. getClassName(): string;
  67078. /**
  67079. * Gets the seed operand input component
  67080. */
  67081. get seed(): NodeMaterialConnectionPoint;
  67082. /**
  67083. * Gets the output component
  67084. */
  67085. get output(): NodeMaterialConnectionPoint;
  67086. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67087. }
  67088. }
  67089. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67093. /**
  67094. * Block used to blend normals
  67095. */
  67096. export class NormalBlendBlock extends NodeMaterialBlock {
  67097. /**
  67098. * Creates a new NormalBlendBlock
  67099. * @param name defines the block name
  67100. */
  67101. constructor(name: string);
  67102. /**
  67103. * Gets the current class name
  67104. * @returns the class name
  67105. */
  67106. getClassName(): string;
  67107. /**
  67108. * Gets the first input component
  67109. */
  67110. get normalMap0(): NodeMaterialConnectionPoint;
  67111. /**
  67112. * Gets the second input component
  67113. */
  67114. get normalMap1(): NodeMaterialConnectionPoint;
  67115. /**
  67116. * Gets the output component
  67117. */
  67118. get output(): NodeMaterialConnectionPoint;
  67119. protected _buildBlock(state: NodeMaterialBuildState): this;
  67120. }
  67121. }
  67122. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67126. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67127. /**
  67128. * Block used to rotate a 2d vector by a given angle
  67129. */
  67130. export class Rotate2dBlock extends NodeMaterialBlock {
  67131. /**
  67132. * Creates a new Rotate2dBlock
  67133. * @param name defines the block name
  67134. */
  67135. constructor(name: string);
  67136. /**
  67137. * Gets the current class name
  67138. * @returns the class name
  67139. */
  67140. getClassName(): string;
  67141. /**
  67142. * Gets the input vector
  67143. */
  67144. get input(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Gets the input angle
  67147. */
  67148. get angle(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the output component
  67151. */
  67152. get output(): NodeMaterialConnectionPoint;
  67153. autoConfigure(material: NodeMaterial): void;
  67154. protected _buildBlock(state: NodeMaterialBuildState): this;
  67155. }
  67156. }
  67157. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67161. /**
  67162. * Block used to get the reflected vector from a direction and a normal
  67163. */
  67164. export class ReflectBlock extends NodeMaterialBlock {
  67165. /**
  67166. * Creates a new ReflectBlock
  67167. * @param name defines the block name
  67168. */
  67169. constructor(name: string);
  67170. /**
  67171. * Gets the current class name
  67172. * @returns the class name
  67173. */
  67174. getClassName(): string;
  67175. /**
  67176. * Gets the incident component
  67177. */
  67178. get incident(): NodeMaterialConnectionPoint;
  67179. /**
  67180. * Gets the normal component
  67181. */
  67182. get normal(): NodeMaterialConnectionPoint;
  67183. /**
  67184. * Gets the output component
  67185. */
  67186. get output(): NodeMaterialConnectionPoint;
  67187. protected _buildBlock(state: NodeMaterialBuildState): this;
  67188. }
  67189. }
  67190. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67194. /**
  67195. * Block used to get the refracted vector from a direction and a normal
  67196. */
  67197. export class RefractBlock extends NodeMaterialBlock {
  67198. /**
  67199. * Creates a new RefractBlock
  67200. * @param name defines the block name
  67201. */
  67202. constructor(name: string);
  67203. /**
  67204. * Gets the current class name
  67205. * @returns the class name
  67206. */
  67207. getClassName(): string;
  67208. /**
  67209. * Gets the incident component
  67210. */
  67211. get incident(): NodeMaterialConnectionPoint;
  67212. /**
  67213. * Gets the normal component
  67214. */
  67215. get normal(): NodeMaterialConnectionPoint;
  67216. /**
  67217. * Gets the index of refraction component
  67218. */
  67219. get ior(): NodeMaterialConnectionPoint;
  67220. /**
  67221. * Gets the output component
  67222. */
  67223. get output(): NodeMaterialConnectionPoint;
  67224. protected _buildBlock(state: NodeMaterialBuildState): this;
  67225. }
  67226. }
  67227. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67231. /**
  67232. * Block used to desaturate a color
  67233. */
  67234. export class DesaturateBlock extends NodeMaterialBlock {
  67235. /**
  67236. * Creates a new DesaturateBlock
  67237. * @param name defines the block name
  67238. */
  67239. constructor(name: string);
  67240. /**
  67241. * Gets the current class name
  67242. * @returns the class name
  67243. */
  67244. getClassName(): string;
  67245. /**
  67246. * Gets the color operand input component
  67247. */
  67248. get color(): NodeMaterialConnectionPoint;
  67249. /**
  67250. * Gets the level operand input component
  67251. */
  67252. get level(): NodeMaterialConnectionPoint;
  67253. /**
  67254. * Gets the output component
  67255. */
  67256. get output(): NodeMaterialConnectionPoint;
  67257. protected _buildBlock(state: NodeMaterialBuildState): this;
  67258. }
  67259. }
  67260. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67264. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67265. import { Nullable } from "babylonjs/types";
  67266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67267. import { Scene } from "babylonjs/scene";
  67268. /**
  67269. * Block used to implement the ambient occlusion module of the PBR material
  67270. */
  67271. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67272. /**
  67273. * Create a new AmbientOcclusionBlock
  67274. * @param name defines the block name
  67275. */
  67276. constructor(name: string);
  67277. /**
  67278. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67279. */
  67280. useAmbientInGrayScale: boolean;
  67281. /**
  67282. * Initialize the block and prepare the context for build
  67283. * @param state defines the state that will be used for the build
  67284. */
  67285. initialize(state: NodeMaterialBuildState): void;
  67286. /**
  67287. * Gets the current class name
  67288. * @returns the class name
  67289. */
  67290. getClassName(): string;
  67291. /**
  67292. * Gets the texture input component
  67293. */
  67294. get texture(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the texture intensity component
  67297. */
  67298. get intensity(): NodeMaterialConnectionPoint;
  67299. /**
  67300. * Gets the direct light intensity input component
  67301. */
  67302. get directLightIntensity(): NodeMaterialConnectionPoint;
  67303. /**
  67304. * Gets the ambient occlusion object output component
  67305. */
  67306. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67307. /**
  67308. * Gets the main code of the block (fragment side)
  67309. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67310. * @returns the shader code
  67311. */
  67312. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67314. protected _buildBlock(state: NodeMaterialBuildState): this;
  67315. protected _dumpPropertiesCode(): string;
  67316. serialize(): any;
  67317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67318. }
  67319. }
  67320. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67323. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67324. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67326. import { Nullable } from "babylonjs/types";
  67327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67328. import { Mesh } from "babylonjs/Meshes/mesh";
  67329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67330. import { Effect } from "babylonjs/Materials/effect";
  67331. import { Scene } from "babylonjs/scene";
  67332. /**
  67333. * Block used to implement the reflection module of the PBR material
  67334. */
  67335. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67336. /** @hidden */
  67337. _defineLODReflectionAlpha: string;
  67338. /** @hidden */
  67339. _defineLinearSpecularReflection: string;
  67340. private _vEnvironmentIrradianceName;
  67341. /** @hidden */
  67342. _vReflectionMicrosurfaceInfosName: string;
  67343. /** @hidden */
  67344. _vReflectionInfosName: string;
  67345. /** @hidden */
  67346. _vReflectionFilteringInfoName: string;
  67347. private _scene;
  67348. /**
  67349. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67350. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67351. * It's less burden on the user side in the editor part.
  67352. */
  67353. /** @hidden */
  67354. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67355. /** @hidden */
  67356. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67357. /** @hidden */
  67358. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67359. /**
  67360. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67361. * diffuse part of the IBL.
  67362. */
  67363. useSphericalHarmonics: boolean;
  67364. /**
  67365. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67366. */
  67367. forceIrradianceInFragment: boolean;
  67368. /**
  67369. * Create a new ReflectionBlock
  67370. * @param name defines the block name
  67371. */
  67372. constructor(name: string);
  67373. /**
  67374. * Gets the current class name
  67375. * @returns the class name
  67376. */
  67377. getClassName(): string;
  67378. /**
  67379. * Gets the position input component
  67380. */
  67381. get position(): NodeMaterialConnectionPoint;
  67382. /**
  67383. * Gets the world position input component
  67384. */
  67385. get worldPosition(): NodeMaterialConnectionPoint;
  67386. /**
  67387. * Gets the world normal input component
  67388. */
  67389. get worldNormal(): NodeMaterialConnectionPoint;
  67390. /**
  67391. * Gets the world input component
  67392. */
  67393. get world(): NodeMaterialConnectionPoint;
  67394. /**
  67395. * Gets the camera (or eye) position component
  67396. */
  67397. get cameraPosition(): NodeMaterialConnectionPoint;
  67398. /**
  67399. * Gets the view input component
  67400. */
  67401. get view(): NodeMaterialConnectionPoint;
  67402. /**
  67403. * Gets the color input component
  67404. */
  67405. get color(): NodeMaterialConnectionPoint;
  67406. /**
  67407. * Gets the reflection object output component
  67408. */
  67409. get reflection(): NodeMaterialConnectionPoint;
  67410. /**
  67411. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67412. */
  67413. get hasTexture(): boolean;
  67414. /**
  67415. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67416. */
  67417. get reflectionColor(): string;
  67418. protected _getTexture(): Nullable<BaseTexture>;
  67419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67421. /**
  67422. * Gets the code to inject in the vertex shader
  67423. * @param state current state of the node material building
  67424. * @returns the shader code
  67425. */
  67426. handleVertexSide(state: NodeMaterialBuildState): string;
  67427. /**
  67428. * Gets the main code of the block (fragment side)
  67429. * @param state current state of the node material building
  67430. * @param normalVarName name of the existing variable corresponding to the normal
  67431. * @returns the shader code
  67432. */
  67433. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67434. protected _buildBlock(state: NodeMaterialBuildState): this;
  67435. protected _dumpPropertiesCode(): string;
  67436. serialize(): any;
  67437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67438. }
  67439. }
  67440. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67444. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67446. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67447. import { Scene } from "babylonjs/scene";
  67448. import { Nullable } from "babylonjs/types";
  67449. /**
  67450. * Block used to implement the sheen module of the PBR material
  67451. */
  67452. export class SheenBlock extends NodeMaterialBlock {
  67453. /**
  67454. * Create a new SheenBlock
  67455. * @param name defines the block name
  67456. */
  67457. constructor(name: string);
  67458. /**
  67459. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67460. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67461. * making it easier to setup and tweak the effect
  67462. */
  67463. albedoScaling: boolean;
  67464. /**
  67465. * Defines if the sheen is linked to the sheen color.
  67466. */
  67467. linkSheenWithAlbedo: boolean;
  67468. /**
  67469. * Initialize the block and prepare the context for build
  67470. * @param state defines the state that will be used for the build
  67471. */
  67472. initialize(state: NodeMaterialBuildState): void;
  67473. /**
  67474. * Gets the current class name
  67475. * @returns the class name
  67476. */
  67477. getClassName(): string;
  67478. /**
  67479. * Gets the intensity input component
  67480. */
  67481. get intensity(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the color input component
  67484. */
  67485. get color(): NodeMaterialConnectionPoint;
  67486. /**
  67487. * Gets the roughness input component
  67488. */
  67489. get roughness(): NodeMaterialConnectionPoint;
  67490. /**
  67491. * Gets the sheen object output component
  67492. */
  67493. get sheen(): NodeMaterialConnectionPoint;
  67494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67495. /**
  67496. * Gets the main code of the block (fragment side)
  67497. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67498. * @returns the shader code
  67499. */
  67500. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67501. protected _buildBlock(state: NodeMaterialBuildState): this;
  67502. protected _dumpPropertiesCode(): string;
  67503. serialize(): any;
  67504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67505. }
  67506. }
  67507. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67508. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67513. import { Scene } from "babylonjs/scene";
  67514. import { Nullable } from "babylonjs/types";
  67515. import { Mesh } from "babylonjs/Meshes/mesh";
  67516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67517. import { Effect } from "babylonjs/Materials/effect";
  67518. /**
  67519. * Block used to implement the reflectivity module of the PBR material
  67520. */
  67521. export class ReflectivityBlock extends NodeMaterialBlock {
  67522. private _metallicReflectanceColor;
  67523. private _metallicF0Factor;
  67524. /** @hidden */
  67525. _vMetallicReflectanceFactorsName: string;
  67526. /**
  67527. * The property below is set by the main PBR block prior to calling methods of this class.
  67528. */
  67529. /** @hidden */
  67530. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67531. /**
  67532. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67533. */
  67534. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67535. /**
  67536. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67537. */
  67538. useMetallnessFromMetallicTextureBlue: boolean;
  67539. /**
  67540. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67541. */
  67542. useRoughnessFromMetallicTextureAlpha: boolean;
  67543. /**
  67544. * Specifies if the metallic texture contains the roughness information in its green channel.
  67545. */
  67546. useRoughnessFromMetallicTextureGreen: boolean;
  67547. /**
  67548. * Create a new ReflectivityBlock
  67549. * @param name defines the block name
  67550. */
  67551. constructor(name: string);
  67552. /**
  67553. * Initialize the block and prepare the context for build
  67554. * @param state defines the state that will be used for the build
  67555. */
  67556. initialize(state: NodeMaterialBuildState): void;
  67557. /**
  67558. * Gets the current class name
  67559. * @returns the class name
  67560. */
  67561. getClassName(): string;
  67562. /**
  67563. * Gets the metallic input component
  67564. */
  67565. get metallic(): NodeMaterialConnectionPoint;
  67566. /**
  67567. * Gets the roughness input component
  67568. */
  67569. get roughness(): NodeMaterialConnectionPoint;
  67570. /**
  67571. * Gets the texture input component
  67572. */
  67573. get texture(): NodeMaterialConnectionPoint;
  67574. /**
  67575. * Gets the reflectivity object output component
  67576. */
  67577. get reflectivity(): NodeMaterialConnectionPoint;
  67578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67579. /**
  67580. * Gets the main code of the block (fragment side)
  67581. * @param state current state of the node material building
  67582. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67583. * @returns the shader code
  67584. */
  67585. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67587. protected _buildBlock(state: NodeMaterialBuildState): this;
  67588. protected _dumpPropertiesCode(): string;
  67589. serialize(): any;
  67590. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67591. }
  67592. }
  67593. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67594. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67599. /**
  67600. * Block used to implement the anisotropy module of the PBR material
  67601. */
  67602. export class AnisotropyBlock extends NodeMaterialBlock {
  67603. /**
  67604. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67605. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67606. * It's less burden on the user side in the editor part.
  67607. */
  67608. /** @hidden */
  67609. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67610. /** @hidden */
  67611. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67612. /**
  67613. * Create a new AnisotropyBlock
  67614. * @param name defines the block name
  67615. */
  67616. constructor(name: string);
  67617. /**
  67618. * Initialize the block and prepare the context for build
  67619. * @param state defines the state that will be used for the build
  67620. */
  67621. initialize(state: NodeMaterialBuildState): void;
  67622. /**
  67623. * Gets the current class name
  67624. * @returns the class name
  67625. */
  67626. getClassName(): string;
  67627. /**
  67628. * Gets the intensity input component
  67629. */
  67630. get intensity(): NodeMaterialConnectionPoint;
  67631. /**
  67632. * Gets the direction input component
  67633. */
  67634. get direction(): NodeMaterialConnectionPoint;
  67635. /**
  67636. * Gets the texture input component
  67637. */
  67638. get texture(): NodeMaterialConnectionPoint;
  67639. /**
  67640. * Gets the uv input component
  67641. */
  67642. get uv(): NodeMaterialConnectionPoint;
  67643. /**
  67644. * Gets the worldTangent input component
  67645. */
  67646. get worldTangent(): NodeMaterialConnectionPoint;
  67647. /**
  67648. * Gets the anisotropy object output component
  67649. */
  67650. get anisotropy(): NodeMaterialConnectionPoint;
  67651. private _generateTBNSpace;
  67652. /**
  67653. * Gets the main code of the block (fragment side)
  67654. * @param state current state of the node material building
  67655. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67656. * @returns the shader code
  67657. */
  67658. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67660. protected _buildBlock(state: NodeMaterialBuildState): this;
  67661. }
  67662. }
  67663. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67667. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67669. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67670. import { Nullable } from "babylonjs/types";
  67671. import { Mesh } from "babylonjs/Meshes/mesh";
  67672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67673. import { Effect } from "babylonjs/Materials/effect";
  67674. /**
  67675. * Block used to implement the clear coat module of the PBR material
  67676. */
  67677. export class ClearCoatBlock extends NodeMaterialBlock {
  67678. private _scene;
  67679. /**
  67680. * Create a new ClearCoatBlock
  67681. * @param name defines the block name
  67682. */
  67683. constructor(name: string);
  67684. /**
  67685. * Initialize the block and prepare the context for build
  67686. * @param state defines the state that will be used for the build
  67687. */
  67688. initialize(state: NodeMaterialBuildState): void;
  67689. /**
  67690. * Gets the current class name
  67691. * @returns the class name
  67692. */
  67693. getClassName(): string;
  67694. /**
  67695. * Gets the intensity input component
  67696. */
  67697. get intensity(): NodeMaterialConnectionPoint;
  67698. /**
  67699. * Gets the roughness input component
  67700. */
  67701. get roughness(): NodeMaterialConnectionPoint;
  67702. /**
  67703. * Gets the ior input component
  67704. */
  67705. get ior(): NodeMaterialConnectionPoint;
  67706. /**
  67707. * Gets the texture input component
  67708. */
  67709. get texture(): NodeMaterialConnectionPoint;
  67710. /**
  67711. * Gets the bump texture input component
  67712. */
  67713. get bumpTexture(): NodeMaterialConnectionPoint;
  67714. /**
  67715. * Gets the uv input component
  67716. */
  67717. get uv(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the tint color input component
  67720. */
  67721. get tintColor(): NodeMaterialConnectionPoint;
  67722. /**
  67723. * Gets the tint "at distance" input component
  67724. */
  67725. get tintAtDistance(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Gets the tint thickness input component
  67728. */
  67729. get tintThickness(): NodeMaterialConnectionPoint;
  67730. /**
  67731. * Gets the world tangent input component
  67732. */
  67733. get worldTangent(): NodeMaterialConnectionPoint;
  67734. /**
  67735. * Gets the clear coat object output component
  67736. */
  67737. get clearcoat(): NodeMaterialConnectionPoint;
  67738. autoConfigure(material: NodeMaterial): void;
  67739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67741. private _generateTBNSpace;
  67742. /**
  67743. * Gets the main code of the block (fragment side)
  67744. * @param state current state of the node material building
  67745. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67746. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67747. * @param worldPosVarName name of the variable holding the world position
  67748. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67749. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67750. * @param worldNormalVarName name of the variable holding the world normal
  67751. * @returns the shader code
  67752. */
  67753. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67754. protected _buildBlock(state: NodeMaterialBuildState): this;
  67755. }
  67756. }
  67757. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67761. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67763. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67764. import { Nullable } from "babylonjs/types";
  67765. /**
  67766. * Block used to implement the sub surface module of the PBR material
  67767. */
  67768. export class SubSurfaceBlock extends NodeMaterialBlock {
  67769. /**
  67770. * Create a new SubSurfaceBlock
  67771. * @param name defines the block name
  67772. */
  67773. constructor(name: string);
  67774. /**
  67775. * Stores the intensity of the different subsurface effects in the thickness texture.
  67776. * * the green channel is the translucency intensity.
  67777. * * the blue channel is the scattering intensity.
  67778. * * the alpha channel is the refraction intensity.
  67779. */
  67780. useMaskFromThicknessTexture: boolean;
  67781. /**
  67782. * Initialize the block and prepare the context for build
  67783. * @param state defines the state that will be used for the build
  67784. */
  67785. initialize(state: NodeMaterialBuildState): void;
  67786. /**
  67787. * Gets the current class name
  67788. * @returns the class name
  67789. */
  67790. getClassName(): string;
  67791. /**
  67792. * Gets the min thickness input component
  67793. */
  67794. get minThickness(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the max thickness input component
  67797. */
  67798. get maxThickness(): NodeMaterialConnectionPoint;
  67799. /**
  67800. * Gets the thickness texture component
  67801. */
  67802. get thicknessTexture(): NodeMaterialConnectionPoint;
  67803. /**
  67804. * Gets the tint color input component
  67805. */
  67806. get tintColor(): NodeMaterialConnectionPoint;
  67807. /**
  67808. * Gets the translucency intensity input component
  67809. */
  67810. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67811. /**
  67812. * Gets the translucency diffusion distance input component
  67813. */
  67814. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67815. /**
  67816. * Gets the refraction object parameters
  67817. */
  67818. get refraction(): NodeMaterialConnectionPoint;
  67819. /**
  67820. * Gets the sub surface object output component
  67821. */
  67822. get subsurface(): NodeMaterialConnectionPoint;
  67823. autoConfigure(material: NodeMaterial): void;
  67824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67825. /**
  67826. * Gets the main code of the block (fragment side)
  67827. * @param state current state of the node material building
  67828. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67829. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67830. * @param worldPosVarName name of the variable holding the world position
  67831. * @returns the shader code
  67832. */
  67833. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67834. protected _buildBlock(state: NodeMaterialBuildState): this;
  67835. }
  67836. }
  67837. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67841. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67842. import { Light } from "babylonjs/Lights/light";
  67843. import { Nullable } from "babylonjs/types";
  67844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67845. import { Effect } from "babylonjs/Materials/effect";
  67846. import { Mesh } from "babylonjs/Meshes/mesh";
  67847. import { Scene } from "babylonjs/scene";
  67848. /**
  67849. * Block used to implement the PBR metallic/roughness model
  67850. */
  67851. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67852. /**
  67853. * Gets or sets the light associated with this block
  67854. */
  67855. light: Nullable<Light>;
  67856. private _lightId;
  67857. private _scene;
  67858. private _environmentBRDFTexture;
  67859. private _environmentBrdfSamplerName;
  67860. private _vNormalWName;
  67861. private _invertNormalName;
  67862. /**
  67863. * Create a new ReflectionBlock
  67864. * @param name defines the block name
  67865. */
  67866. constructor(name: string);
  67867. /**
  67868. * Intensity of the direct lights e.g. the four lights available in your scene.
  67869. * This impacts both the direct diffuse and specular highlights.
  67870. */
  67871. directIntensity: number;
  67872. /**
  67873. * Intensity of the environment e.g. how much the environment will light the object
  67874. * either through harmonics for rough material or through the refelction for shiny ones.
  67875. */
  67876. environmentIntensity: number;
  67877. /**
  67878. * This is a special control allowing the reduction of the specular highlights coming from the
  67879. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67880. */
  67881. specularIntensity: number;
  67882. /**
  67883. * Defines the falloff type used in this material.
  67884. * It by default is Physical.
  67885. */
  67886. lightFalloff: number;
  67887. /**
  67888. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67889. */
  67890. useAlphaFromAlbedoTexture: boolean;
  67891. /**
  67892. * Specifies that alpha test should be used
  67893. */
  67894. useAlphaTest: boolean;
  67895. /**
  67896. * Defines the alpha limits in alpha test mode.
  67897. */
  67898. alphaTestCutoff: number;
  67899. /**
  67900. * Specifies that alpha blending should be used
  67901. */
  67902. useAlphaBlending: boolean;
  67903. /**
  67904. * Defines if the alpha value should be determined via the rgb values.
  67905. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67906. */
  67907. opacityRGB: boolean;
  67908. /**
  67909. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67910. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67911. */
  67912. useRadianceOverAlpha: boolean;
  67913. /**
  67914. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67915. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67916. */
  67917. useSpecularOverAlpha: boolean;
  67918. /**
  67919. * Enables specular anti aliasing in the PBR shader.
  67920. * It will both interacts on the Geometry for analytical and IBL lighting.
  67921. * It also prefilter the roughness map based on the bump values.
  67922. */
  67923. enableSpecularAntiAliasing: boolean;
  67924. /**
  67925. * Enables realtime filtering on the texture.
  67926. */
  67927. realTimeFiltering: boolean;
  67928. /**
  67929. * Quality switch for realtime filtering
  67930. */
  67931. realTimeFilteringQuality: number;
  67932. /**
  67933. * Defines if the material uses energy conservation.
  67934. */
  67935. useEnergyConservation: boolean;
  67936. /**
  67937. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67938. * too much the area relying on ambient texture to define their ambient occlusion.
  67939. */
  67940. useRadianceOcclusion: boolean;
  67941. /**
  67942. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67943. * makes the reflect vector face the model (under horizon).
  67944. */
  67945. useHorizonOcclusion: boolean;
  67946. /**
  67947. * If set to true, no lighting calculations will be applied.
  67948. */
  67949. unlit: boolean;
  67950. /**
  67951. * Force normal to face away from face.
  67952. */
  67953. forceNormalForward: boolean;
  67954. /**
  67955. * Defines the material debug mode.
  67956. * It helps seeing only some components of the material while troubleshooting.
  67957. */
  67958. debugMode: number;
  67959. /**
  67960. * Specify from where on screen the debug mode should start.
  67961. * The value goes from -1 (full screen) to 1 (not visible)
  67962. * It helps with side by side comparison against the final render
  67963. * This defaults to 0
  67964. */
  67965. debugLimit: number;
  67966. /**
  67967. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67968. * You can use the factor to better multiply the final value.
  67969. */
  67970. debugFactor: number;
  67971. /**
  67972. * Initialize the block and prepare the context for build
  67973. * @param state defines the state that will be used for the build
  67974. */
  67975. initialize(state: NodeMaterialBuildState): void;
  67976. /**
  67977. * Gets the current class name
  67978. * @returns the class name
  67979. */
  67980. getClassName(): string;
  67981. /**
  67982. * Gets the world position input component
  67983. */
  67984. get worldPosition(): NodeMaterialConnectionPoint;
  67985. /**
  67986. * Gets the world normal input component
  67987. */
  67988. get worldNormal(): NodeMaterialConnectionPoint;
  67989. /**
  67990. * Gets the perturbed normal input component
  67991. */
  67992. get perturbedNormal(): NodeMaterialConnectionPoint;
  67993. /**
  67994. * Gets the camera position input component
  67995. */
  67996. get cameraPosition(): NodeMaterialConnectionPoint;
  67997. /**
  67998. * Gets the base color input component
  67999. */
  68000. get baseColor(): NodeMaterialConnectionPoint;
  68001. /**
  68002. * Gets the opacity texture input component
  68003. */
  68004. get opacityTexture(): NodeMaterialConnectionPoint;
  68005. /**
  68006. * Gets the ambient color input component
  68007. */
  68008. get ambientColor(): NodeMaterialConnectionPoint;
  68009. /**
  68010. * Gets the reflectivity object parameters
  68011. */
  68012. get reflectivity(): NodeMaterialConnectionPoint;
  68013. /**
  68014. * Gets the ambient occlusion object parameters
  68015. */
  68016. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68017. /**
  68018. * Gets the reflection object parameters
  68019. */
  68020. get reflection(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the sheen object parameters
  68023. */
  68024. get sheen(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the clear coat object parameters
  68027. */
  68028. get clearcoat(): NodeMaterialConnectionPoint;
  68029. /**
  68030. * Gets the sub surface object parameters
  68031. */
  68032. get subsurface(): NodeMaterialConnectionPoint;
  68033. /**
  68034. * Gets the anisotropy object parameters
  68035. */
  68036. get anisotropy(): NodeMaterialConnectionPoint;
  68037. /**
  68038. * Gets the ambient output component
  68039. */
  68040. get ambient(): NodeMaterialConnectionPoint;
  68041. /**
  68042. * Gets the diffuse output component
  68043. */
  68044. get diffuse(): NodeMaterialConnectionPoint;
  68045. /**
  68046. * Gets the specular output component
  68047. */
  68048. get specular(): NodeMaterialConnectionPoint;
  68049. /**
  68050. * Gets the sheen output component
  68051. */
  68052. get sheenDir(): NodeMaterialConnectionPoint;
  68053. /**
  68054. * Gets the clear coat output component
  68055. */
  68056. get clearcoatDir(): NodeMaterialConnectionPoint;
  68057. /**
  68058. * Gets the indirect diffuse output component
  68059. */
  68060. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68061. /**
  68062. * Gets the indirect specular output component
  68063. */
  68064. get specularIndirect(): NodeMaterialConnectionPoint;
  68065. /**
  68066. * Gets the indirect sheen output component
  68067. */
  68068. get sheenIndirect(): NodeMaterialConnectionPoint;
  68069. /**
  68070. * Gets the indirect clear coat output component
  68071. */
  68072. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68073. /**
  68074. * Gets the refraction output component
  68075. */
  68076. get refraction(): NodeMaterialConnectionPoint;
  68077. /**
  68078. * Gets the global lighting output component
  68079. */
  68080. get lighting(): NodeMaterialConnectionPoint;
  68081. /**
  68082. * Gets the shadow output component
  68083. */
  68084. get shadow(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the alpha output component
  68087. */
  68088. get alpha(): NodeMaterialConnectionPoint;
  68089. autoConfigure(material: NodeMaterial): void;
  68090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68091. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68092. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68093. private _injectVertexCode;
  68094. /**
  68095. * Gets the code corresponding to the albedo/opacity module
  68096. * @returns the shader code
  68097. */
  68098. getAlbedoOpacityCode(): string;
  68099. protected _buildBlock(state: NodeMaterialBuildState): this;
  68100. protected _dumpPropertiesCode(): string;
  68101. serialize(): any;
  68102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68103. }
  68104. }
  68105. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68106. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68107. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68108. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68109. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68110. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68111. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68112. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68113. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68114. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68115. }
  68116. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68117. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68118. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68119. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68120. }
  68121. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68125. /**
  68126. * Block used to compute value of one parameter modulo another
  68127. */
  68128. export class ModBlock extends NodeMaterialBlock {
  68129. /**
  68130. * Creates a new ModBlock
  68131. * @param name defines the block name
  68132. */
  68133. constructor(name: string);
  68134. /**
  68135. * Gets the current class name
  68136. * @returns the class name
  68137. */
  68138. getClassName(): string;
  68139. /**
  68140. * Gets the left operand input component
  68141. */
  68142. get left(): NodeMaterialConnectionPoint;
  68143. /**
  68144. * Gets the right operand input component
  68145. */
  68146. get right(): NodeMaterialConnectionPoint;
  68147. /**
  68148. * Gets the output component
  68149. */
  68150. get output(): NodeMaterialConnectionPoint;
  68151. protected _buildBlock(state: NodeMaterialBuildState): this;
  68152. }
  68153. }
  68154. declare module "babylonjs/Materials/Node/Blocks/index" {
  68155. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68156. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68157. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68158. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68159. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68160. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68161. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68162. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68163. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68164. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68165. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68166. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68167. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68168. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68169. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68170. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68171. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68172. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68173. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68174. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68175. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68176. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68177. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68178. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68179. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68180. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68181. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68182. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68183. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68184. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68185. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68186. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68187. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68188. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68189. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68190. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68191. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68192. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68193. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68194. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68195. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68196. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68197. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68198. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68199. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68200. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68201. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68202. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68203. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68204. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68205. }
  68206. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68207. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68208. }
  68209. declare module "babylonjs/Materials/Node/index" {
  68210. export * from "babylonjs/Materials/Node/Enums/index";
  68211. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68212. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68213. export * from "babylonjs/Materials/Node/nodeMaterial";
  68214. export * from "babylonjs/Materials/Node/Blocks/index";
  68215. export * from "babylonjs/Materials/Node/Optimizers/index";
  68216. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68217. }
  68218. declare module "babylonjs/Materials/index" {
  68219. export * from "babylonjs/Materials/Background/index";
  68220. export * from "babylonjs/Materials/colorCurves";
  68221. export * from "babylonjs/Materials/iEffectFallbacks";
  68222. export * from "babylonjs/Materials/effectFallbacks";
  68223. export * from "babylonjs/Materials/effect";
  68224. export * from "babylonjs/Materials/fresnelParameters";
  68225. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68226. export * from "babylonjs/Materials/material";
  68227. export * from "babylonjs/Materials/materialDefines";
  68228. export * from "babylonjs/Materials/thinMaterialHelper";
  68229. export * from "babylonjs/Materials/materialHelper";
  68230. export * from "babylonjs/Materials/multiMaterial";
  68231. export * from "babylonjs/Materials/PBR/index";
  68232. export * from "babylonjs/Materials/pushMaterial";
  68233. export * from "babylonjs/Materials/shaderMaterial";
  68234. export * from "babylonjs/Materials/standardMaterial";
  68235. export * from "babylonjs/Materials/Textures/index";
  68236. export * from "babylonjs/Materials/uniformBuffer";
  68237. export * from "babylonjs/Materials/materialFlags";
  68238. export * from "babylonjs/Materials/Node/index";
  68239. export * from "babylonjs/Materials/effectRenderer";
  68240. export * from "babylonjs/Materials/shadowDepthWrapper";
  68241. }
  68242. declare module "babylonjs/Maths/index" {
  68243. export * from "babylonjs/Maths/math.scalar";
  68244. export * from "babylonjs/Maths/math";
  68245. export * from "babylonjs/Maths/sphericalPolynomial";
  68246. }
  68247. declare module "babylonjs/Misc/workerPool" {
  68248. import { IDisposable } from "babylonjs/scene";
  68249. /**
  68250. * Helper class to push actions to a pool of workers.
  68251. */
  68252. export class WorkerPool implements IDisposable {
  68253. private _workerInfos;
  68254. private _pendingActions;
  68255. /**
  68256. * Constructor
  68257. * @param workers Array of workers to use for actions
  68258. */
  68259. constructor(workers: Array<Worker>);
  68260. /**
  68261. * Terminates all workers and clears any pending actions.
  68262. */
  68263. dispose(): void;
  68264. /**
  68265. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68266. * pended until a worker has completed its action.
  68267. * @param action The action to perform. Call onComplete when the action is complete.
  68268. */
  68269. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68270. private _execute;
  68271. }
  68272. }
  68273. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68274. import { IDisposable } from "babylonjs/scene";
  68275. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68276. /**
  68277. * Configuration for Draco compression
  68278. */
  68279. export interface IDracoCompressionConfiguration {
  68280. /**
  68281. * Configuration for the decoder.
  68282. */
  68283. decoder: {
  68284. /**
  68285. * The url to the WebAssembly module.
  68286. */
  68287. wasmUrl?: string;
  68288. /**
  68289. * The url to the WebAssembly binary.
  68290. */
  68291. wasmBinaryUrl?: string;
  68292. /**
  68293. * The url to the fallback JavaScript module.
  68294. */
  68295. fallbackUrl?: string;
  68296. };
  68297. }
  68298. /**
  68299. * Draco compression (https://google.github.io/draco/)
  68300. *
  68301. * This class wraps the Draco module.
  68302. *
  68303. * **Encoder**
  68304. *
  68305. * The encoder is not currently implemented.
  68306. *
  68307. * **Decoder**
  68308. *
  68309. * 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.
  68310. *
  68311. * To update the configuration, use the following code:
  68312. * ```javascript
  68313. * DracoCompression.Configuration = {
  68314. * decoder: {
  68315. * wasmUrl: "<url to the WebAssembly library>",
  68316. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68317. * fallbackUrl: "<url to the fallback JavaScript library>",
  68318. * }
  68319. * };
  68320. * ```
  68321. *
  68322. * 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.
  68323. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68324. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68325. *
  68326. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68327. * ```javascript
  68328. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68329. * ```
  68330. *
  68331. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68332. */
  68333. export class DracoCompression implements IDisposable {
  68334. private _workerPoolPromise?;
  68335. private _decoderModulePromise?;
  68336. /**
  68337. * The configuration. Defaults to the following urls:
  68338. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68339. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68340. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68341. */
  68342. static Configuration: IDracoCompressionConfiguration;
  68343. /**
  68344. * Returns true if the decoder configuration is available.
  68345. */
  68346. static get DecoderAvailable(): boolean;
  68347. /**
  68348. * Default number of workers to create when creating the draco compression object.
  68349. */
  68350. static DefaultNumWorkers: number;
  68351. private static GetDefaultNumWorkers;
  68352. private static _Default;
  68353. /**
  68354. * Default instance for the draco compression object.
  68355. */
  68356. static get Default(): DracoCompression;
  68357. /**
  68358. * Constructor
  68359. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68360. */
  68361. constructor(numWorkers?: number);
  68362. /**
  68363. * Stop all async operations and release resources.
  68364. */
  68365. dispose(): void;
  68366. /**
  68367. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68368. * @returns a promise that resolves when ready
  68369. */
  68370. whenReadyAsync(): Promise<void>;
  68371. /**
  68372. * Decode Draco compressed mesh data to vertex data.
  68373. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68374. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68375. * @returns A promise that resolves with the decoded vertex data
  68376. */
  68377. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68378. [kind: string]: number;
  68379. }): Promise<VertexData>;
  68380. }
  68381. }
  68382. declare module "babylonjs/Meshes/Compression/index" {
  68383. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68384. }
  68385. declare module "babylonjs/Meshes/csg" {
  68386. import { Nullable } from "babylonjs/types";
  68387. import { Scene } from "babylonjs/scene";
  68388. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68389. import { Mesh } from "babylonjs/Meshes/mesh";
  68390. import { Material } from "babylonjs/Materials/material";
  68391. /**
  68392. * Class for building Constructive Solid Geometry
  68393. */
  68394. export class CSG {
  68395. private polygons;
  68396. /**
  68397. * The world matrix
  68398. */
  68399. matrix: Matrix;
  68400. /**
  68401. * Stores the position
  68402. */
  68403. position: Vector3;
  68404. /**
  68405. * Stores the rotation
  68406. */
  68407. rotation: Vector3;
  68408. /**
  68409. * Stores the rotation quaternion
  68410. */
  68411. rotationQuaternion: Nullable<Quaternion>;
  68412. /**
  68413. * Stores the scaling vector
  68414. */
  68415. scaling: Vector3;
  68416. /**
  68417. * Convert the Mesh to CSG
  68418. * @param mesh The Mesh to convert to CSG
  68419. * @returns A new CSG from the Mesh
  68420. */
  68421. static FromMesh(mesh: Mesh): CSG;
  68422. /**
  68423. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68424. * @param polygons Polygons used to construct a CSG solid
  68425. */
  68426. private static FromPolygons;
  68427. /**
  68428. * Clones, or makes a deep copy, of the CSG
  68429. * @returns A new CSG
  68430. */
  68431. clone(): CSG;
  68432. /**
  68433. * Unions this CSG with another CSG
  68434. * @param csg The CSG to union against this CSG
  68435. * @returns The unioned CSG
  68436. */
  68437. union(csg: CSG): CSG;
  68438. /**
  68439. * Unions this CSG with another CSG in place
  68440. * @param csg The CSG to union against this CSG
  68441. */
  68442. unionInPlace(csg: CSG): void;
  68443. /**
  68444. * Subtracts this CSG with another CSG
  68445. * @param csg The CSG to subtract against this CSG
  68446. * @returns A new CSG
  68447. */
  68448. subtract(csg: CSG): CSG;
  68449. /**
  68450. * Subtracts this CSG with another CSG in place
  68451. * @param csg The CSG to subtact against this CSG
  68452. */
  68453. subtractInPlace(csg: CSG): void;
  68454. /**
  68455. * Intersect this CSG with another CSG
  68456. * @param csg The CSG to intersect against this CSG
  68457. * @returns A new CSG
  68458. */
  68459. intersect(csg: CSG): CSG;
  68460. /**
  68461. * Intersects this CSG with another CSG in place
  68462. * @param csg The CSG to intersect against this CSG
  68463. */
  68464. intersectInPlace(csg: CSG): void;
  68465. /**
  68466. * Return a new CSG solid with solid and empty space switched. This solid is
  68467. * not modified.
  68468. * @returns A new CSG solid with solid and empty space switched
  68469. */
  68470. inverse(): CSG;
  68471. /**
  68472. * Inverses the CSG in place
  68473. */
  68474. inverseInPlace(): void;
  68475. /**
  68476. * This is used to keep meshes transformations so they can be restored
  68477. * when we build back a Babylon Mesh
  68478. * NB : All CSG operations are performed in world coordinates
  68479. * @param csg The CSG to copy the transform attributes from
  68480. * @returns This CSG
  68481. */
  68482. copyTransformAttributes(csg: CSG): CSG;
  68483. /**
  68484. * Build Raw mesh from CSG
  68485. * Coordinates here are in world space
  68486. * @param name The name of the mesh geometry
  68487. * @param scene The Scene
  68488. * @param keepSubMeshes Specifies if the submeshes should be kept
  68489. * @returns A new Mesh
  68490. */
  68491. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68492. /**
  68493. * Build Mesh from CSG taking material and transforms into account
  68494. * @param name The name of the Mesh
  68495. * @param material The material of the Mesh
  68496. * @param scene The Scene
  68497. * @param keepSubMeshes Specifies if submeshes should be kept
  68498. * @returns The new Mesh
  68499. */
  68500. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68501. }
  68502. }
  68503. declare module "babylonjs/Meshes/trailMesh" {
  68504. import { Mesh } from "babylonjs/Meshes/mesh";
  68505. import { Scene } from "babylonjs/scene";
  68506. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68507. /**
  68508. * Class used to create a trail following a mesh
  68509. */
  68510. export class TrailMesh extends Mesh {
  68511. private _generator;
  68512. private _autoStart;
  68513. private _running;
  68514. private _diameter;
  68515. private _length;
  68516. private _sectionPolygonPointsCount;
  68517. private _sectionVectors;
  68518. private _sectionNormalVectors;
  68519. private _beforeRenderObserver;
  68520. /**
  68521. * @constructor
  68522. * @param name The value used by scene.getMeshByName() to do a lookup.
  68523. * @param generator The mesh or transform node to generate a trail.
  68524. * @param scene The scene to add this mesh to.
  68525. * @param diameter Diameter of trailing mesh. Default is 1.
  68526. * @param length Length of trailing mesh. Default is 60.
  68527. * @param autoStart Automatically start trailing mesh. Default true.
  68528. */
  68529. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68530. /**
  68531. * "TrailMesh"
  68532. * @returns "TrailMesh"
  68533. */
  68534. getClassName(): string;
  68535. private _createMesh;
  68536. /**
  68537. * Start trailing mesh.
  68538. */
  68539. start(): void;
  68540. /**
  68541. * Stop trailing mesh.
  68542. */
  68543. stop(): void;
  68544. /**
  68545. * Update trailing mesh geometry.
  68546. */
  68547. update(): void;
  68548. /**
  68549. * Returns a new TrailMesh object.
  68550. * @param name is a string, the name given to the new mesh
  68551. * @param newGenerator use new generator object for cloned trail mesh
  68552. * @returns a new mesh
  68553. */
  68554. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68555. /**
  68556. * Serializes this trail mesh
  68557. * @param serializationObject object to write serialization to
  68558. */
  68559. serialize(serializationObject: any): void;
  68560. /**
  68561. * Parses a serialized trail mesh
  68562. * @param parsedMesh the serialized mesh
  68563. * @param scene the scene to create the trail mesh in
  68564. * @returns the created trail mesh
  68565. */
  68566. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68567. }
  68568. }
  68569. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68570. import { Nullable } from "babylonjs/types";
  68571. import { Scene } from "babylonjs/scene";
  68572. import { Vector4 } from "babylonjs/Maths/math.vector";
  68573. import { Color4 } from "babylonjs/Maths/math.color";
  68574. import { Mesh } from "babylonjs/Meshes/mesh";
  68575. /**
  68576. * Class containing static functions to help procedurally build meshes
  68577. */
  68578. export class TiledBoxBuilder {
  68579. /**
  68580. * Creates a box mesh
  68581. * 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)
  68582. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68586. * @param name defines the name of the mesh
  68587. * @param options defines the options used to create the mesh
  68588. * @param scene defines the hosting scene
  68589. * @returns the box mesh
  68590. */
  68591. static CreateTiledBox(name: string, options: {
  68592. pattern?: number;
  68593. width?: number;
  68594. height?: number;
  68595. depth?: number;
  68596. tileSize?: number;
  68597. tileWidth?: number;
  68598. tileHeight?: number;
  68599. alignHorizontal?: number;
  68600. alignVertical?: number;
  68601. faceUV?: Vector4[];
  68602. faceColors?: Color4[];
  68603. sideOrientation?: number;
  68604. updatable?: boolean;
  68605. }, scene?: Nullable<Scene>): Mesh;
  68606. }
  68607. }
  68608. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68609. import { Vector4 } from "babylonjs/Maths/math.vector";
  68610. import { Mesh } from "babylonjs/Meshes/mesh";
  68611. /**
  68612. * Class containing static functions to help procedurally build meshes
  68613. */
  68614. export class TorusKnotBuilder {
  68615. /**
  68616. * Creates a torus knot mesh
  68617. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68618. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68619. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68620. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68624. * @param name defines the name of the mesh
  68625. * @param options defines the options used to create the mesh
  68626. * @param scene defines the hosting scene
  68627. * @returns the torus knot mesh
  68628. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68629. */
  68630. static CreateTorusKnot(name: string, options: {
  68631. radius?: number;
  68632. tube?: number;
  68633. radialSegments?: number;
  68634. tubularSegments?: number;
  68635. p?: number;
  68636. q?: number;
  68637. updatable?: boolean;
  68638. sideOrientation?: number;
  68639. frontUVs?: Vector4;
  68640. backUVs?: Vector4;
  68641. }, scene: any): Mesh;
  68642. }
  68643. }
  68644. declare module "babylonjs/Meshes/polygonMesh" {
  68645. import { Scene } from "babylonjs/scene";
  68646. import { Vector2 } from "babylonjs/Maths/math.vector";
  68647. import { Mesh } from "babylonjs/Meshes/mesh";
  68648. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68649. import { Path2 } from "babylonjs/Maths/math.path";
  68650. /**
  68651. * Polygon
  68652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68653. */
  68654. export class Polygon {
  68655. /**
  68656. * Creates a rectangle
  68657. * @param xmin bottom X coord
  68658. * @param ymin bottom Y coord
  68659. * @param xmax top X coord
  68660. * @param ymax top Y coord
  68661. * @returns points that make the resulting rectation
  68662. */
  68663. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68664. /**
  68665. * Creates a circle
  68666. * @param radius radius of circle
  68667. * @param cx scale in x
  68668. * @param cy scale in y
  68669. * @param numberOfSides number of sides that make up the circle
  68670. * @returns points that make the resulting circle
  68671. */
  68672. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68673. /**
  68674. * Creates a polygon from input string
  68675. * @param input Input polygon data
  68676. * @returns the parsed points
  68677. */
  68678. static Parse(input: string): Vector2[];
  68679. /**
  68680. * Starts building a polygon from x and y coordinates
  68681. * @param x x coordinate
  68682. * @param y y coordinate
  68683. * @returns the started path2
  68684. */
  68685. static StartingAt(x: number, y: number): Path2;
  68686. }
  68687. /**
  68688. * Builds a polygon
  68689. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68690. */
  68691. export class PolygonMeshBuilder {
  68692. private _points;
  68693. private _outlinepoints;
  68694. private _holes;
  68695. private _name;
  68696. private _scene;
  68697. private _epoints;
  68698. private _eholes;
  68699. private _addToepoint;
  68700. /**
  68701. * Babylon reference to the earcut plugin.
  68702. */
  68703. bjsEarcut: any;
  68704. /**
  68705. * Creates a PolygonMeshBuilder
  68706. * @param name name of the builder
  68707. * @param contours Path of the polygon
  68708. * @param scene scene to add to when creating the mesh
  68709. * @param earcutInjection can be used to inject your own earcut reference
  68710. */
  68711. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68712. /**
  68713. * Adds a whole within the polygon
  68714. * @param hole Array of points defining the hole
  68715. * @returns this
  68716. */
  68717. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68718. /**
  68719. * Creates the polygon
  68720. * @param updatable If the mesh should be updatable
  68721. * @param depth The depth of the mesh created
  68722. * @returns the created mesh
  68723. */
  68724. build(updatable?: boolean, depth?: number): Mesh;
  68725. /**
  68726. * Creates the polygon
  68727. * @param depth The depth of the mesh created
  68728. * @returns the created VertexData
  68729. */
  68730. buildVertexData(depth?: number): VertexData;
  68731. /**
  68732. * Adds a side to the polygon
  68733. * @param positions points that make the polygon
  68734. * @param normals normals of the polygon
  68735. * @param uvs uvs of the polygon
  68736. * @param indices indices of the polygon
  68737. * @param bounds bounds of the polygon
  68738. * @param points points of the polygon
  68739. * @param depth depth of the polygon
  68740. * @param flip flip of the polygon
  68741. */
  68742. private addSide;
  68743. }
  68744. }
  68745. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68746. import { Scene } from "babylonjs/scene";
  68747. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68748. import { Color4 } from "babylonjs/Maths/math.color";
  68749. import { Mesh } from "babylonjs/Meshes/mesh";
  68750. import { Nullable } from "babylonjs/types";
  68751. /**
  68752. * Class containing static functions to help procedurally build meshes
  68753. */
  68754. export class PolygonBuilder {
  68755. /**
  68756. * Creates a polygon mesh
  68757. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68758. * * 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
  68759. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68762. * * Remember you can only change the shape positions, not their number when updating a polygon
  68763. * @param name defines the name of the mesh
  68764. * @param options defines the options used to create the mesh
  68765. * @param scene defines the hosting scene
  68766. * @param earcutInjection can be used to inject your own earcut reference
  68767. * @returns the polygon mesh
  68768. */
  68769. static CreatePolygon(name: string, options: {
  68770. shape: Vector3[];
  68771. holes?: Vector3[][];
  68772. depth?: number;
  68773. faceUV?: Vector4[];
  68774. faceColors?: Color4[];
  68775. updatable?: boolean;
  68776. sideOrientation?: number;
  68777. frontUVs?: Vector4;
  68778. backUVs?: Vector4;
  68779. wrap?: boolean;
  68780. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68781. /**
  68782. * Creates an extruded polygon mesh, with depth in the Y direction.
  68783. * * 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)
  68784. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68785. * @param name defines the name of the mesh
  68786. * @param options defines the options used to create the mesh
  68787. * @param scene defines the hosting scene
  68788. * @param earcutInjection can be used to inject your own earcut reference
  68789. * @returns the polygon mesh
  68790. */
  68791. static ExtrudePolygon(name: string, options: {
  68792. shape: Vector3[];
  68793. holes?: Vector3[][];
  68794. depth?: number;
  68795. faceUV?: Vector4[];
  68796. faceColors?: Color4[];
  68797. updatable?: boolean;
  68798. sideOrientation?: number;
  68799. frontUVs?: Vector4;
  68800. backUVs?: Vector4;
  68801. wrap?: boolean;
  68802. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68803. }
  68804. }
  68805. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68806. import { Scene } from "babylonjs/scene";
  68807. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68808. import { Mesh } from "babylonjs/Meshes/mesh";
  68809. import { Nullable } from "babylonjs/types";
  68810. /**
  68811. * Class containing static functions to help procedurally build meshes
  68812. */
  68813. export class LatheBuilder {
  68814. /**
  68815. * Creates lathe mesh.
  68816. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68817. * * 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
  68818. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68819. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68820. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68821. * * 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
  68822. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68823. * * 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
  68824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68826. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68828. * @param name defines the name of the mesh
  68829. * @param options defines the options used to create the mesh
  68830. * @param scene defines the hosting scene
  68831. * @returns the lathe mesh
  68832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68833. */
  68834. static CreateLathe(name: string, options: {
  68835. shape: Vector3[];
  68836. radius?: number;
  68837. tessellation?: number;
  68838. clip?: number;
  68839. arc?: number;
  68840. closed?: boolean;
  68841. updatable?: boolean;
  68842. sideOrientation?: number;
  68843. frontUVs?: Vector4;
  68844. backUVs?: Vector4;
  68845. cap?: number;
  68846. invertUV?: boolean;
  68847. }, scene?: Nullable<Scene>): Mesh;
  68848. }
  68849. }
  68850. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68851. import { Nullable } from "babylonjs/types";
  68852. import { Scene } from "babylonjs/scene";
  68853. import { Vector4 } from "babylonjs/Maths/math.vector";
  68854. import { Mesh } from "babylonjs/Meshes/mesh";
  68855. /**
  68856. * Class containing static functions to help procedurally build meshes
  68857. */
  68858. export class TiledPlaneBuilder {
  68859. /**
  68860. * Creates a tiled plane mesh
  68861. * * The parameter `pattern` will, depending on value, do nothing or
  68862. * * * flip (reflect about central vertical) alternate tiles across and up
  68863. * * * flip every tile on alternate rows
  68864. * * * rotate (180 degs) alternate tiles across and up
  68865. * * * rotate every tile on alternate rows
  68866. * * * flip and rotate alternate tiles across and up
  68867. * * * flip and rotate every tile on alternate rows
  68868. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68869. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68871. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68872. * * 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)
  68873. * * 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)
  68874. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68875. * @param name defines the name of the mesh
  68876. * @param options defines the options used to create the mesh
  68877. * @param scene defines the hosting scene
  68878. * @returns the box mesh
  68879. */
  68880. static CreateTiledPlane(name: string, options: {
  68881. pattern?: number;
  68882. tileSize?: number;
  68883. tileWidth?: number;
  68884. tileHeight?: number;
  68885. size?: number;
  68886. width?: number;
  68887. height?: number;
  68888. alignHorizontal?: number;
  68889. alignVertical?: number;
  68890. sideOrientation?: number;
  68891. frontUVs?: Vector4;
  68892. backUVs?: Vector4;
  68893. updatable?: boolean;
  68894. }, scene?: Nullable<Scene>): Mesh;
  68895. }
  68896. }
  68897. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68898. import { Nullable } from "babylonjs/types";
  68899. import { Scene } from "babylonjs/scene";
  68900. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68901. import { Mesh } from "babylonjs/Meshes/mesh";
  68902. /**
  68903. * Class containing static functions to help procedurally build meshes
  68904. */
  68905. export class TubeBuilder {
  68906. /**
  68907. * Creates a tube mesh.
  68908. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68909. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68910. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68911. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68912. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68913. * * 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)
  68914. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68915. * * 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
  68916. * * 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
  68917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68921. * @param name defines the name of the mesh
  68922. * @param options defines the options used to create the mesh
  68923. * @param scene defines the hosting scene
  68924. * @returns the tube mesh
  68925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68926. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68927. */
  68928. static CreateTube(name: string, options: {
  68929. path: Vector3[];
  68930. radius?: number;
  68931. tessellation?: number;
  68932. radiusFunction?: {
  68933. (i: number, distance: number): number;
  68934. };
  68935. cap?: number;
  68936. arc?: number;
  68937. updatable?: boolean;
  68938. sideOrientation?: number;
  68939. frontUVs?: Vector4;
  68940. backUVs?: Vector4;
  68941. instance?: Mesh;
  68942. invertUV?: boolean;
  68943. }, scene?: Nullable<Scene>): Mesh;
  68944. }
  68945. }
  68946. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68947. import { Scene } from "babylonjs/scene";
  68948. import { Vector4 } from "babylonjs/Maths/math.vector";
  68949. import { Mesh } from "babylonjs/Meshes/mesh";
  68950. import { Nullable } from "babylonjs/types";
  68951. /**
  68952. * Class containing static functions to help procedurally build meshes
  68953. */
  68954. export class IcoSphereBuilder {
  68955. /**
  68956. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68957. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68958. * * 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`)
  68959. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68960. * * 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
  68961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68964. * @param name defines the name of the mesh
  68965. * @param options defines the options used to create the mesh
  68966. * @param scene defines the hosting scene
  68967. * @returns the icosahedron mesh
  68968. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68969. */
  68970. static CreateIcoSphere(name: string, options: {
  68971. radius?: number;
  68972. radiusX?: number;
  68973. radiusY?: number;
  68974. radiusZ?: number;
  68975. flat?: boolean;
  68976. subdivisions?: number;
  68977. sideOrientation?: number;
  68978. frontUVs?: Vector4;
  68979. backUVs?: Vector4;
  68980. updatable?: boolean;
  68981. }, scene?: Nullable<Scene>): Mesh;
  68982. }
  68983. }
  68984. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68985. import { Vector3 } from "babylonjs/Maths/math.vector";
  68986. import { Mesh } from "babylonjs/Meshes/mesh";
  68987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68988. /**
  68989. * Class containing static functions to help procedurally build meshes
  68990. */
  68991. export class DecalBuilder {
  68992. /**
  68993. * Creates a decal mesh.
  68994. * 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
  68995. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68996. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68997. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68998. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68999. * @param name defines the name of the mesh
  69000. * @param sourceMesh defines the mesh where the decal must be applied
  69001. * @param options defines the options used to create the mesh
  69002. * @param scene defines the hosting scene
  69003. * @returns the decal mesh
  69004. * @see https://doc.babylonjs.com/how_to/decals
  69005. */
  69006. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69007. position?: Vector3;
  69008. normal?: Vector3;
  69009. size?: Vector3;
  69010. angle?: number;
  69011. }): Mesh;
  69012. }
  69013. }
  69014. declare module "babylonjs/Meshes/meshBuilder" {
  69015. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69016. import { Nullable } from "babylonjs/types";
  69017. import { Scene } from "babylonjs/scene";
  69018. import { Mesh } from "babylonjs/Meshes/mesh";
  69019. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69020. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69022. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69023. import { Plane } from "babylonjs/Maths/math.plane";
  69024. /**
  69025. * Class containing static functions to help procedurally build meshes
  69026. */
  69027. export class MeshBuilder {
  69028. /**
  69029. * Creates a box mesh
  69030. * * The parameter `size` sets the size (float) of each box side (default 1)
  69031. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69032. * * 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)
  69033. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69037. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69038. * @param name defines the name of the mesh
  69039. * @param options defines the options used to create the mesh
  69040. * @param scene defines the hosting scene
  69041. * @returns the box mesh
  69042. */
  69043. static CreateBox(name: string, options: {
  69044. size?: number;
  69045. width?: number;
  69046. height?: number;
  69047. depth?: number;
  69048. faceUV?: Vector4[];
  69049. faceColors?: Color4[];
  69050. sideOrientation?: number;
  69051. frontUVs?: Vector4;
  69052. backUVs?: Vector4;
  69053. wrap?: boolean;
  69054. topBaseAt?: number;
  69055. bottomBaseAt?: number;
  69056. updatable?: boolean;
  69057. }, scene?: Nullable<Scene>): Mesh;
  69058. /**
  69059. * Creates a tiled box mesh
  69060. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69062. * @param name defines the name of the mesh
  69063. * @param options defines the options used to create the mesh
  69064. * @param scene defines the hosting scene
  69065. * @returns the tiled box mesh
  69066. */
  69067. static CreateTiledBox(name: string, options: {
  69068. pattern?: number;
  69069. size?: number;
  69070. width?: number;
  69071. height?: number;
  69072. depth: number;
  69073. tileSize?: number;
  69074. tileWidth?: number;
  69075. tileHeight?: number;
  69076. faceUV?: Vector4[];
  69077. faceColors?: Color4[];
  69078. alignHorizontal?: number;
  69079. alignVertical?: number;
  69080. sideOrientation?: number;
  69081. updatable?: boolean;
  69082. }, scene?: Nullable<Scene>): Mesh;
  69083. /**
  69084. * Creates a sphere mesh
  69085. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69086. * * 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`)
  69087. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69088. * * 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
  69089. * * 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)
  69090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69093. * @param name defines the name of the mesh
  69094. * @param options defines the options used to create the mesh
  69095. * @param scene defines the hosting scene
  69096. * @returns the sphere mesh
  69097. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69098. */
  69099. static CreateSphere(name: string, options: {
  69100. segments?: number;
  69101. diameter?: number;
  69102. diameterX?: number;
  69103. diameterY?: number;
  69104. diameterZ?: number;
  69105. arc?: number;
  69106. slice?: number;
  69107. sideOrientation?: number;
  69108. frontUVs?: Vector4;
  69109. backUVs?: Vector4;
  69110. updatable?: boolean;
  69111. }, scene?: Nullable<Scene>): Mesh;
  69112. /**
  69113. * Creates a plane polygonal mesh. By default, this is a disc
  69114. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69115. * * 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
  69116. * * 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
  69117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69120. * @param name defines the name of the mesh
  69121. * @param options defines the options used to create the mesh
  69122. * @param scene defines the hosting scene
  69123. * @returns the plane polygonal mesh
  69124. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69125. */
  69126. static CreateDisc(name: string, options: {
  69127. radius?: number;
  69128. tessellation?: number;
  69129. arc?: number;
  69130. updatable?: boolean;
  69131. sideOrientation?: number;
  69132. frontUVs?: Vector4;
  69133. backUVs?: Vector4;
  69134. }, scene?: Nullable<Scene>): Mesh;
  69135. /**
  69136. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69137. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69138. * * 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`)
  69139. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69140. * * 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
  69141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69144. * @param name defines the name of the mesh
  69145. * @param options defines the options used to create the mesh
  69146. * @param scene defines the hosting scene
  69147. * @returns the icosahedron mesh
  69148. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69149. */
  69150. static CreateIcoSphere(name: string, options: {
  69151. radius?: number;
  69152. radiusX?: number;
  69153. radiusY?: number;
  69154. radiusZ?: number;
  69155. flat?: boolean;
  69156. subdivisions?: number;
  69157. sideOrientation?: number;
  69158. frontUVs?: Vector4;
  69159. backUVs?: Vector4;
  69160. updatable?: boolean;
  69161. }, scene?: Nullable<Scene>): Mesh;
  69162. /**
  69163. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69164. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69165. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69166. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69167. * * 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
  69168. * * 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
  69169. * * 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
  69170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69173. * * 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
  69174. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69175. * * 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
  69176. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69178. * @param name defines the name of the mesh
  69179. * @param options defines the options used to create the mesh
  69180. * @param scene defines the hosting scene
  69181. * @returns the ribbon mesh
  69182. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69183. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69184. */
  69185. static CreateRibbon(name: string, options: {
  69186. pathArray: Vector3[][];
  69187. closeArray?: boolean;
  69188. closePath?: boolean;
  69189. offset?: number;
  69190. updatable?: boolean;
  69191. sideOrientation?: number;
  69192. frontUVs?: Vector4;
  69193. backUVs?: Vector4;
  69194. instance?: Mesh;
  69195. invertUV?: boolean;
  69196. uvs?: Vector2[];
  69197. colors?: Color4[];
  69198. }, scene?: Nullable<Scene>): Mesh;
  69199. /**
  69200. * Creates a cylinder or a cone mesh
  69201. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69202. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69203. * * 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.
  69204. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69205. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69206. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69207. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69208. * * 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).
  69209. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69210. * * 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).
  69211. * * 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
  69212. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69213. * * 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
  69214. * * 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.
  69215. * * If `enclose` is false, a ring surface is one element.
  69216. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69217. * * 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
  69218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69221. * @param name defines the name of the mesh
  69222. * @param options defines the options used to create the mesh
  69223. * @param scene defines the hosting scene
  69224. * @returns the cylinder mesh
  69225. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69226. */
  69227. static CreateCylinder(name: string, options: {
  69228. height?: number;
  69229. diameterTop?: number;
  69230. diameterBottom?: number;
  69231. diameter?: number;
  69232. tessellation?: number;
  69233. subdivisions?: number;
  69234. arc?: number;
  69235. faceColors?: Color4[];
  69236. faceUV?: Vector4[];
  69237. updatable?: boolean;
  69238. hasRings?: boolean;
  69239. enclose?: boolean;
  69240. cap?: number;
  69241. sideOrientation?: number;
  69242. frontUVs?: Vector4;
  69243. backUVs?: Vector4;
  69244. }, scene?: Nullable<Scene>): Mesh;
  69245. /**
  69246. * Creates a torus mesh
  69247. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69248. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69249. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69253. * @param name defines the name of the mesh
  69254. * @param options defines the options used to create the mesh
  69255. * @param scene defines the hosting scene
  69256. * @returns the torus mesh
  69257. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69258. */
  69259. static CreateTorus(name: string, options: {
  69260. diameter?: number;
  69261. thickness?: number;
  69262. tessellation?: number;
  69263. updatable?: boolean;
  69264. sideOrientation?: number;
  69265. frontUVs?: Vector4;
  69266. backUVs?: Vector4;
  69267. }, scene?: Nullable<Scene>): Mesh;
  69268. /**
  69269. * Creates a torus knot mesh
  69270. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69271. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69272. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69273. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69277. * @param name defines the name of the mesh
  69278. * @param options defines the options used to create the mesh
  69279. * @param scene defines the hosting scene
  69280. * @returns the torus knot mesh
  69281. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69282. */
  69283. static CreateTorusKnot(name: string, options: {
  69284. radius?: number;
  69285. tube?: number;
  69286. radialSegments?: number;
  69287. tubularSegments?: number;
  69288. p?: number;
  69289. q?: number;
  69290. updatable?: boolean;
  69291. sideOrientation?: number;
  69292. frontUVs?: Vector4;
  69293. backUVs?: Vector4;
  69294. }, scene?: Nullable<Scene>): Mesh;
  69295. /**
  69296. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69297. * * 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
  69298. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69299. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69300. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69301. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69302. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69303. * * 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
  69304. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69307. * @param name defines the name of the new line system
  69308. * @param options defines the options used to create the line system
  69309. * @param scene defines the hosting scene
  69310. * @returns a new line system mesh
  69311. */
  69312. static CreateLineSystem(name: string, options: {
  69313. lines: Vector3[][];
  69314. updatable?: boolean;
  69315. instance?: Nullable<LinesMesh>;
  69316. colors?: Nullable<Color4[][]>;
  69317. useVertexAlpha?: boolean;
  69318. }, scene: Nullable<Scene>): LinesMesh;
  69319. /**
  69320. * Creates a line mesh
  69321. * 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
  69322. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69323. * * The parameter `points` is an array successive Vector3
  69324. * * 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
  69325. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69326. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69327. * * When updating an instance, remember that only point positions can change, not the number of points
  69328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69330. * @param name defines the name of the new line system
  69331. * @param options defines the options used to create the line system
  69332. * @param scene defines the hosting scene
  69333. * @returns a new line mesh
  69334. */
  69335. static CreateLines(name: string, options: {
  69336. points: Vector3[];
  69337. updatable?: boolean;
  69338. instance?: Nullable<LinesMesh>;
  69339. colors?: Color4[];
  69340. useVertexAlpha?: boolean;
  69341. }, scene?: Nullable<Scene>): LinesMesh;
  69342. /**
  69343. * Creates a dashed line mesh
  69344. * * 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
  69345. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69346. * * The parameter `points` is an array successive Vector3
  69347. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69348. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69349. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69350. * * 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
  69351. * * When updating an instance, remember that only point positions can change, not the number of points
  69352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69353. * @param name defines the name of the mesh
  69354. * @param options defines the options used to create the mesh
  69355. * @param scene defines the hosting scene
  69356. * @returns the dashed line mesh
  69357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69358. */
  69359. static CreateDashedLines(name: string, options: {
  69360. points: Vector3[];
  69361. dashSize?: number;
  69362. gapSize?: number;
  69363. dashNb?: number;
  69364. updatable?: boolean;
  69365. instance?: LinesMesh;
  69366. }, scene?: Nullable<Scene>): LinesMesh;
  69367. /**
  69368. * 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.
  69369. * * 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.
  69370. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69371. * * 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.
  69372. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69373. * * 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
  69374. * * 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
  69375. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69378. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69380. * @param name defines the name of the mesh
  69381. * @param options defines the options used to create the mesh
  69382. * @param scene defines the hosting scene
  69383. * @returns the extruded shape mesh
  69384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69386. */
  69387. static ExtrudeShape(name: string, options: {
  69388. shape: Vector3[];
  69389. path: Vector3[];
  69390. scale?: number;
  69391. rotation?: number;
  69392. cap?: number;
  69393. updatable?: boolean;
  69394. sideOrientation?: number;
  69395. frontUVs?: Vector4;
  69396. backUVs?: Vector4;
  69397. instance?: Mesh;
  69398. invertUV?: boolean;
  69399. }, scene?: Nullable<Scene>): Mesh;
  69400. /**
  69401. * Creates an custom extruded shape mesh.
  69402. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69403. * * 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.
  69404. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69405. * * 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
  69406. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69407. * * 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
  69408. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69409. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69410. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69411. * * 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
  69412. * * 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
  69413. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69418. * @param name defines the name of the mesh
  69419. * @param options defines the options used to create the mesh
  69420. * @param scene defines the hosting scene
  69421. * @returns the custom extruded shape mesh
  69422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69425. */
  69426. static ExtrudeShapeCustom(name: string, options: {
  69427. shape: Vector3[];
  69428. path: Vector3[];
  69429. scaleFunction?: any;
  69430. rotationFunction?: any;
  69431. ribbonCloseArray?: boolean;
  69432. ribbonClosePath?: boolean;
  69433. cap?: number;
  69434. updatable?: boolean;
  69435. sideOrientation?: number;
  69436. frontUVs?: Vector4;
  69437. backUVs?: Vector4;
  69438. instance?: Mesh;
  69439. invertUV?: boolean;
  69440. }, scene?: Nullable<Scene>): Mesh;
  69441. /**
  69442. * Creates lathe mesh.
  69443. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69444. * * 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
  69445. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69446. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69447. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69448. * * 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
  69449. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69450. * * 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
  69451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69455. * @param name defines the name of the mesh
  69456. * @param options defines the options used to create the mesh
  69457. * @param scene defines the hosting scene
  69458. * @returns the lathe mesh
  69459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69460. */
  69461. static CreateLathe(name: string, options: {
  69462. shape: Vector3[];
  69463. radius?: number;
  69464. tessellation?: number;
  69465. clip?: number;
  69466. arc?: number;
  69467. closed?: boolean;
  69468. updatable?: boolean;
  69469. sideOrientation?: number;
  69470. frontUVs?: Vector4;
  69471. backUVs?: Vector4;
  69472. cap?: number;
  69473. invertUV?: boolean;
  69474. }, scene?: Nullable<Scene>): Mesh;
  69475. /**
  69476. * Creates a tiled plane mesh
  69477. * * You can set a limited pattern arrangement with the tiles
  69478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69481. * @param name defines the name of the mesh
  69482. * @param options defines the options used to create the mesh
  69483. * @param scene defines the hosting scene
  69484. * @returns the plane mesh
  69485. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69486. */
  69487. static CreateTiledPlane(name: string, options: {
  69488. pattern?: number;
  69489. tileSize?: number;
  69490. tileWidth?: number;
  69491. tileHeight?: number;
  69492. size?: number;
  69493. width?: number;
  69494. height?: number;
  69495. alignHorizontal?: number;
  69496. alignVertical?: number;
  69497. sideOrientation?: number;
  69498. frontUVs?: Vector4;
  69499. backUVs?: Vector4;
  69500. updatable?: boolean;
  69501. }, scene?: Nullable<Scene>): Mesh;
  69502. /**
  69503. * Creates a plane mesh
  69504. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69505. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69506. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69510. * @param name defines the name of the mesh
  69511. * @param options defines the options used to create the mesh
  69512. * @param scene defines the hosting scene
  69513. * @returns the plane mesh
  69514. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69515. */
  69516. static CreatePlane(name: string, options: {
  69517. size?: number;
  69518. width?: number;
  69519. height?: number;
  69520. sideOrientation?: number;
  69521. frontUVs?: Vector4;
  69522. backUVs?: Vector4;
  69523. updatable?: boolean;
  69524. sourcePlane?: Plane;
  69525. }, scene?: Nullable<Scene>): Mesh;
  69526. /**
  69527. * Creates a ground mesh
  69528. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69529. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69531. * @param name defines the name of the mesh
  69532. * @param options defines the options used to create the mesh
  69533. * @param scene defines the hosting scene
  69534. * @returns the ground mesh
  69535. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69536. */
  69537. static CreateGround(name: string, options: {
  69538. width?: number;
  69539. height?: number;
  69540. subdivisions?: number;
  69541. subdivisionsX?: number;
  69542. subdivisionsY?: number;
  69543. updatable?: boolean;
  69544. }, scene?: Nullable<Scene>): Mesh;
  69545. /**
  69546. * Creates a tiled ground mesh
  69547. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69548. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69549. * * 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
  69550. * * 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
  69551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69552. * @param name defines the name of the mesh
  69553. * @param options defines the options used to create the mesh
  69554. * @param scene defines the hosting scene
  69555. * @returns the tiled ground mesh
  69556. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69557. */
  69558. static CreateTiledGround(name: string, options: {
  69559. xmin: number;
  69560. zmin: number;
  69561. xmax: number;
  69562. zmax: number;
  69563. subdivisions?: {
  69564. w: number;
  69565. h: number;
  69566. };
  69567. precision?: {
  69568. w: number;
  69569. h: number;
  69570. };
  69571. updatable?: boolean;
  69572. }, scene?: Nullable<Scene>): Mesh;
  69573. /**
  69574. * Creates a ground mesh from a height map
  69575. * * The parameter `url` sets the URL of the height map image resource.
  69576. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69577. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69578. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69579. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69580. * * 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.
  69581. * * 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).
  69582. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69584. * @param name defines the name of the mesh
  69585. * @param url defines the url to the height map
  69586. * @param options defines the options used to create the mesh
  69587. * @param scene defines the hosting scene
  69588. * @returns the ground mesh
  69589. * @see https://doc.babylonjs.com/babylon101/height_map
  69590. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69591. */
  69592. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69593. width?: number;
  69594. height?: number;
  69595. subdivisions?: number;
  69596. minHeight?: number;
  69597. maxHeight?: number;
  69598. colorFilter?: Color3;
  69599. alphaFilter?: number;
  69600. updatable?: boolean;
  69601. onReady?: (mesh: GroundMesh) => void;
  69602. }, scene?: Nullable<Scene>): GroundMesh;
  69603. /**
  69604. * Creates a polygon mesh
  69605. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69606. * * 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
  69607. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69610. * * Remember you can only change the shape positions, not their number when updating a polygon
  69611. * @param name defines the name of the mesh
  69612. * @param options defines the options used to create the mesh
  69613. * @param scene defines the hosting scene
  69614. * @param earcutInjection can be used to inject your own earcut reference
  69615. * @returns the polygon mesh
  69616. */
  69617. static CreatePolygon(name: string, options: {
  69618. shape: Vector3[];
  69619. holes?: Vector3[][];
  69620. depth?: number;
  69621. faceUV?: Vector4[];
  69622. faceColors?: Color4[];
  69623. updatable?: boolean;
  69624. sideOrientation?: number;
  69625. frontUVs?: Vector4;
  69626. backUVs?: Vector4;
  69627. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69628. /**
  69629. * Creates an extruded polygon mesh, with depth in the Y direction.
  69630. * * 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)
  69631. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69632. * @param name defines the name of the mesh
  69633. * @param options defines the options used to create the mesh
  69634. * @param scene defines the hosting scene
  69635. * @param earcutInjection can be used to inject your own earcut reference
  69636. * @returns the polygon mesh
  69637. */
  69638. static ExtrudePolygon(name: string, options: {
  69639. shape: Vector3[];
  69640. holes?: Vector3[][];
  69641. depth?: number;
  69642. faceUV?: Vector4[];
  69643. faceColors?: Color4[];
  69644. updatable?: boolean;
  69645. sideOrientation?: number;
  69646. frontUVs?: Vector4;
  69647. backUVs?: Vector4;
  69648. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69649. /**
  69650. * Creates a tube mesh.
  69651. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69652. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69653. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69654. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69655. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69656. * * 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)
  69657. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69658. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  69659. * * 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
  69660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69664. * @param name defines the name of the mesh
  69665. * @param options defines the options used to create the mesh
  69666. * @param scene defines the hosting scene
  69667. * @returns the tube mesh
  69668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69669. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69670. */
  69671. static CreateTube(name: string, options: {
  69672. path: Vector3[];
  69673. radius?: number;
  69674. tessellation?: number;
  69675. radiusFunction?: {
  69676. (i: number, distance: number): number;
  69677. };
  69678. cap?: number;
  69679. arc?: number;
  69680. updatable?: boolean;
  69681. sideOrientation?: number;
  69682. frontUVs?: Vector4;
  69683. backUVs?: Vector4;
  69684. instance?: Mesh;
  69685. invertUV?: boolean;
  69686. }, scene?: Nullable<Scene>): Mesh;
  69687. /**
  69688. * Creates a polyhedron mesh
  69689. * * 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
  69690. * * The parameter `size` (positive float, default 1) sets the polygon size
  69691. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69692. * * 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`
  69693. * * 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
  69694. * * 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)`)
  69695. * * 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
  69696. * * 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
  69697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69700. * @param name defines the name of the mesh
  69701. * @param options defines the options used to create the mesh
  69702. * @param scene defines the hosting scene
  69703. * @returns the polyhedron mesh
  69704. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69705. */
  69706. static CreatePolyhedron(name: string, options: {
  69707. type?: number;
  69708. size?: number;
  69709. sizeX?: number;
  69710. sizeY?: number;
  69711. sizeZ?: number;
  69712. custom?: any;
  69713. faceUV?: Vector4[];
  69714. faceColors?: Color4[];
  69715. flat?: boolean;
  69716. updatable?: boolean;
  69717. sideOrientation?: number;
  69718. frontUVs?: Vector4;
  69719. backUVs?: Vector4;
  69720. }, scene?: Nullable<Scene>): Mesh;
  69721. /**
  69722. * Creates a decal mesh.
  69723. * 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
  69724. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69725. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69726. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69727. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69728. * @param name defines the name of the mesh
  69729. * @param sourceMesh defines the mesh where the decal must be applied
  69730. * @param options defines the options used to create the mesh
  69731. * @param scene defines the hosting scene
  69732. * @returns the decal mesh
  69733. * @see https://doc.babylonjs.com/how_to/decals
  69734. */
  69735. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69736. position?: Vector3;
  69737. normal?: Vector3;
  69738. size?: Vector3;
  69739. angle?: number;
  69740. }): Mesh;
  69741. }
  69742. }
  69743. declare module "babylonjs/Meshes/meshSimplification" {
  69744. import { Mesh } from "babylonjs/Meshes/mesh";
  69745. /**
  69746. * A simplifier interface for future simplification implementations
  69747. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69748. */
  69749. export interface ISimplifier {
  69750. /**
  69751. * Simplification of a given mesh according to the given settings.
  69752. * Since this requires computation, it is assumed that the function runs async.
  69753. * @param settings The settings of the simplification, including quality and distance
  69754. * @param successCallback A callback that will be called after the mesh was simplified.
  69755. * @param errorCallback in case of an error, this callback will be called. optional.
  69756. */
  69757. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69758. }
  69759. /**
  69760. * Expected simplification settings.
  69761. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69762. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69763. */
  69764. export interface ISimplificationSettings {
  69765. /**
  69766. * Gets or sets the expected quality
  69767. */
  69768. quality: number;
  69769. /**
  69770. * Gets or sets the distance when this optimized version should be used
  69771. */
  69772. distance: number;
  69773. /**
  69774. * Gets an already optimized mesh
  69775. */
  69776. optimizeMesh?: boolean;
  69777. }
  69778. /**
  69779. * Class used to specify simplification options
  69780. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69781. */
  69782. export class SimplificationSettings implements ISimplificationSettings {
  69783. /** expected quality */
  69784. quality: number;
  69785. /** distance when this optimized version should be used */
  69786. distance: number;
  69787. /** already optimized mesh */
  69788. optimizeMesh?: boolean | undefined;
  69789. /**
  69790. * Creates a SimplificationSettings
  69791. * @param quality expected quality
  69792. * @param distance distance when this optimized version should be used
  69793. * @param optimizeMesh already optimized mesh
  69794. */
  69795. constructor(
  69796. /** expected quality */
  69797. quality: number,
  69798. /** distance when this optimized version should be used */
  69799. distance: number,
  69800. /** already optimized mesh */
  69801. optimizeMesh?: boolean | undefined);
  69802. }
  69803. /**
  69804. * Interface used to define a simplification task
  69805. */
  69806. export interface ISimplificationTask {
  69807. /**
  69808. * Array of settings
  69809. */
  69810. settings: Array<ISimplificationSettings>;
  69811. /**
  69812. * Simplification type
  69813. */
  69814. simplificationType: SimplificationType;
  69815. /**
  69816. * Mesh to simplify
  69817. */
  69818. mesh: Mesh;
  69819. /**
  69820. * Callback called on success
  69821. */
  69822. successCallback?: () => void;
  69823. /**
  69824. * Defines if parallel processing can be used
  69825. */
  69826. parallelProcessing: boolean;
  69827. }
  69828. /**
  69829. * Queue used to order the simplification tasks
  69830. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69831. */
  69832. export class SimplificationQueue {
  69833. private _simplificationArray;
  69834. /**
  69835. * Gets a boolean indicating that the process is still running
  69836. */
  69837. running: boolean;
  69838. /**
  69839. * Creates a new queue
  69840. */
  69841. constructor();
  69842. /**
  69843. * Adds a new simplification task
  69844. * @param task defines a task to add
  69845. */
  69846. addTask(task: ISimplificationTask): void;
  69847. /**
  69848. * Execute next task
  69849. */
  69850. executeNext(): void;
  69851. /**
  69852. * Execute a simplification task
  69853. * @param task defines the task to run
  69854. */
  69855. runSimplification(task: ISimplificationTask): void;
  69856. private getSimplifier;
  69857. }
  69858. /**
  69859. * The implemented types of simplification
  69860. * At the moment only Quadratic Error Decimation is implemented
  69861. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69862. */
  69863. export enum SimplificationType {
  69864. /** Quadratic error decimation */
  69865. QUADRATIC = 0
  69866. }
  69867. /**
  69868. * An implementation of the Quadratic Error simplification algorithm.
  69869. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69870. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69871. * @author RaananW
  69872. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69873. */
  69874. export class QuadraticErrorSimplification implements ISimplifier {
  69875. private _mesh;
  69876. private triangles;
  69877. private vertices;
  69878. private references;
  69879. private _reconstructedMesh;
  69880. /** Gets or sets the number pf sync interations */
  69881. syncIterations: number;
  69882. /** Gets or sets the aggressiveness of the simplifier */
  69883. aggressiveness: number;
  69884. /** Gets or sets the number of allowed iterations for decimation */
  69885. decimationIterations: number;
  69886. /** Gets or sets the espilon to use for bounding box computation */
  69887. boundingBoxEpsilon: number;
  69888. /**
  69889. * Creates a new QuadraticErrorSimplification
  69890. * @param _mesh defines the target mesh
  69891. */
  69892. constructor(_mesh: Mesh);
  69893. /**
  69894. * Simplification of a given mesh according to the given settings.
  69895. * Since this requires computation, it is assumed that the function runs async.
  69896. * @param settings The settings of the simplification, including quality and distance
  69897. * @param successCallback A callback that will be called after the mesh was simplified.
  69898. */
  69899. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69900. private runDecimation;
  69901. private initWithMesh;
  69902. private init;
  69903. private reconstructMesh;
  69904. private initDecimatedMesh;
  69905. private isFlipped;
  69906. private updateTriangles;
  69907. private identifyBorder;
  69908. private updateMesh;
  69909. private vertexError;
  69910. private calculateError;
  69911. }
  69912. }
  69913. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69914. import { Scene } from "babylonjs/scene";
  69915. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69916. import { ISceneComponent } from "babylonjs/sceneComponent";
  69917. module "babylonjs/scene" {
  69918. interface Scene {
  69919. /** @hidden (Backing field) */
  69920. _simplificationQueue: SimplificationQueue;
  69921. /**
  69922. * Gets or sets the simplification queue attached to the scene
  69923. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69924. */
  69925. simplificationQueue: SimplificationQueue;
  69926. }
  69927. }
  69928. module "babylonjs/Meshes/mesh" {
  69929. interface Mesh {
  69930. /**
  69931. * Simplify the mesh according to the given array of settings.
  69932. * Function will return immediately and will simplify async
  69933. * @param settings a collection of simplification settings
  69934. * @param parallelProcessing should all levels calculate parallel or one after the other
  69935. * @param simplificationType the type of simplification to run
  69936. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69937. * @returns the current mesh
  69938. */
  69939. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69940. }
  69941. }
  69942. /**
  69943. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69944. * created in a scene
  69945. */
  69946. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69947. /**
  69948. * The component name helpfull to identify the component in the list of scene components.
  69949. */
  69950. readonly name: string;
  69951. /**
  69952. * The scene the component belongs to.
  69953. */
  69954. scene: Scene;
  69955. /**
  69956. * Creates a new instance of the component for the given scene
  69957. * @param scene Defines the scene to register the component in
  69958. */
  69959. constructor(scene: Scene);
  69960. /**
  69961. * Registers the component in a given scene
  69962. */
  69963. register(): void;
  69964. /**
  69965. * Rebuilds the elements related to this component in case of
  69966. * context lost for instance.
  69967. */
  69968. rebuild(): void;
  69969. /**
  69970. * Disposes the component and the associated ressources
  69971. */
  69972. dispose(): void;
  69973. private _beforeCameraUpdate;
  69974. }
  69975. }
  69976. declare module "babylonjs/Meshes/Builders/index" {
  69977. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69978. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69979. export * from "babylonjs/Meshes/Builders/discBuilder";
  69980. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69981. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69982. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69983. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69984. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69985. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69986. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69987. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69988. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69989. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69990. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69991. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69992. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69993. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69994. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69995. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69996. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69997. }
  69998. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69999. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70000. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70001. import { Matrix } from "babylonjs/Maths/math.vector";
  70002. module "babylonjs/Meshes/mesh" {
  70003. interface Mesh {
  70004. /**
  70005. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70006. */
  70007. thinInstanceEnablePicking: boolean;
  70008. /**
  70009. * Creates a new thin instance
  70010. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70011. * @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
  70012. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70013. */
  70014. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70015. /**
  70016. * Adds the transformation (matrix) of the current mesh as a thin instance
  70017. * @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
  70018. * @returns the thin instance index number
  70019. */
  70020. thinInstanceAddSelf(refresh: boolean): number;
  70021. /**
  70022. * Registers a custom attribute to be used with thin instances
  70023. * @param kind name of the attribute
  70024. * @param stride size in floats of the attribute
  70025. */
  70026. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70027. /**
  70028. * Sets the matrix of a thin instance
  70029. * @param index index of the thin instance
  70030. * @param matrix matrix to set
  70031. * @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
  70032. */
  70033. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70034. /**
  70035. * Sets the value of a custom attribute for a thin instance
  70036. * @param kind name of the attribute
  70037. * @param index index of the thin instance
  70038. * @param value value to set
  70039. * @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
  70040. */
  70041. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70042. /**
  70043. * 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.
  70044. */
  70045. thinInstanceCount: number;
  70046. /**
  70047. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70048. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70049. * @param buffer buffer to set
  70050. * @param stride size in floats of each value of the buffer
  70051. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70052. */
  70053. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70054. /**
  70055. * Gets the list of world matrices
  70056. * @return an array containing all the world matrices from the thin instances
  70057. */
  70058. thinInstanceGetWorldMatrices(): Matrix[];
  70059. /**
  70060. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70061. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70062. */
  70063. thinInstanceBufferUpdated(kind: string): void;
  70064. /**
  70065. * Refreshes the bounding info, taking into account all the thin instances defined
  70066. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70067. */
  70068. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70069. /** @hidden */
  70070. _thinInstanceInitializeUserStorage(): void;
  70071. /** @hidden */
  70072. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70073. /** @hidden */
  70074. _userThinInstanceBuffersStorage: {
  70075. data: {
  70076. [key: string]: Float32Array;
  70077. };
  70078. sizes: {
  70079. [key: string]: number;
  70080. };
  70081. vertexBuffers: {
  70082. [key: string]: Nullable<VertexBuffer>;
  70083. };
  70084. strides: {
  70085. [key: string]: number;
  70086. };
  70087. };
  70088. }
  70089. }
  70090. }
  70091. declare module "babylonjs/Meshes/index" {
  70092. export * from "babylonjs/Meshes/abstractMesh";
  70093. export * from "babylonjs/Meshes/buffer";
  70094. export * from "babylonjs/Meshes/Compression/index";
  70095. export * from "babylonjs/Meshes/csg";
  70096. export * from "babylonjs/Meshes/geometry";
  70097. export * from "babylonjs/Meshes/groundMesh";
  70098. export * from "babylonjs/Meshes/trailMesh";
  70099. export * from "babylonjs/Meshes/instancedMesh";
  70100. export * from "babylonjs/Meshes/linesMesh";
  70101. export * from "babylonjs/Meshes/mesh";
  70102. export * from "babylonjs/Meshes/mesh.vertexData";
  70103. export * from "babylonjs/Meshes/meshBuilder";
  70104. export * from "babylonjs/Meshes/meshSimplification";
  70105. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70106. export * from "babylonjs/Meshes/polygonMesh";
  70107. export * from "babylonjs/Meshes/subMesh";
  70108. export * from "babylonjs/Meshes/meshLODLevel";
  70109. export * from "babylonjs/Meshes/transformNode";
  70110. export * from "babylonjs/Meshes/Builders/index";
  70111. export * from "babylonjs/Meshes/dataBuffer";
  70112. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70113. import "babylonjs/Meshes/thinInstanceMesh";
  70114. export * from "babylonjs/Meshes/thinInstanceMesh";
  70115. }
  70116. declare module "babylonjs/Morph/index" {
  70117. export * from "babylonjs/Morph/morphTarget";
  70118. export * from "babylonjs/Morph/morphTargetManager";
  70119. }
  70120. declare module "babylonjs/Navigation/INavigationEngine" {
  70121. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70122. import { Vector3 } from "babylonjs/Maths/math";
  70123. import { Mesh } from "babylonjs/Meshes/mesh";
  70124. import { Scene } from "babylonjs/scene";
  70125. /**
  70126. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70127. */
  70128. export interface INavigationEnginePlugin {
  70129. /**
  70130. * plugin name
  70131. */
  70132. name: string;
  70133. /**
  70134. * Creates a navigation mesh
  70135. * @param meshes array of all the geometry used to compute the navigatio mesh
  70136. * @param parameters bunch of parameters used to filter geometry
  70137. */
  70138. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70139. /**
  70140. * Create a navigation mesh debug mesh
  70141. * @param scene is where the mesh will be added
  70142. * @returns debug display mesh
  70143. */
  70144. createDebugNavMesh(scene: Scene): Mesh;
  70145. /**
  70146. * Get a navigation mesh constrained position, closest to the parameter position
  70147. * @param position world position
  70148. * @returns the closest point to position constrained by the navigation mesh
  70149. */
  70150. getClosestPoint(position: Vector3): Vector3;
  70151. /**
  70152. * Get a navigation mesh constrained position, closest to the parameter position
  70153. * @param position world position
  70154. * @param result output the closest point to position constrained by the navigation mesh
  70155. */
  70156. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70157. /**
  70158. * Get a navigation mesh constrained position, within a particular radius
  70159. * @param position world position
  70160. * @param maxRadius the maximum distance to the constrained world position
  70161. * @returns the closest point to position constrained by the navigation mesh
  70162. */
  70163. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70164. /**
  70165. * Get a navigation mesh constrained position, within a particular radius
  70166. * @param position world position
  70167. * @param maxRadius the maximum distance to the constrained world position
  70168. * @param result output the closest point to position constrained by the navigation mesh
  70169. */
  70170. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70171. /**
  70172. * Compute the final position from a segment made of destination-position
  70173. * @param position world position
  70174. * @param destination world position
  70175. * @returns the resulting point along the navmesh
  70176. */
  70177. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70178. /**
  70179. * Compute the final position from a segment made of destination-position
  70180. * @param position world position
  70181. * @param destination world position
  70182. * @param result output the resulting point along the navmesh
  70183. */
  70184. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70185. /**
  70186. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70187. * @param start world position
  70188. * @param end world position
  70189. * @returns array containing world position composing the path
  70190. */
  70191. computePath(start: Vector3, end: Vector3): Vector3[];
  70192. /**
  70193. * If this plugin is supported
  70194. * @returns true if plugin is supported
  70195. */
  70196. isSupported(): boolean;
  70197. /**
  70198. * Create a new Crowd so you can add agents
  70199. * @param maxAgents the maximum agent count in the crowd
  70200. * @param maxAgentRadius the maximum radius an agent can have
  70201. * @param scene to attach the crowd to
  70202. * @returns the crowd you can add agents to
  70203. */
  70204. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70205. /**
  70206. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70207. * The queries will try to find a solution within those bounds
  70208. * default is (1,1,1)
  70209. * @param extent x,y,z value that define the extent around the queries point of reference
  70210. */
  70211. setDefaultQueryExtent(extent: Vector3): void;
  70212. /**
  70213. * Get the Bounding box extent specified by setDefaultQueryExtent
  70214. * @returns the box extent values
  70215. */
  70216. getDefaultQueryExtent(): Vector3;
  70217. /**
  70218. * build the navmesh from a previously saved state using getNavmeshData
  70219. * @param data the Uint8Array returned by getNavmeshData
  70220. */
  70221. buildFromNavmeshData(data: Uint8Array): void;
  70222. /**
  70223. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70224. * @returns data the Uint8Array that can be saved and reused
  70225. */
  70226. getNavmeshData(): Uint8Array;
  70227. /**
  70228. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70229. * @param result output the box extent values
  70230. */
  70231. getDefaultQueryExtentToRef(result: Vector3): void;
  70232. /**
  70233. * Release all resources
  70234. */
  70235. dispose(): void;
  70236. }
  70237. /**
  70238. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70239. */
  70240. export interface ICrowd {
  70241. /**
  70242. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70243. * You can attach anything to that node. The node position is updated in the scene update tick.
  70244. * @param pos world position that will be constrained by the navigation mesh
  70245. * @param parameters agent parameters
  70246. * @param transform hooked to the agent that will be update by the scene
  70247. * @returns agent index
  70248. */
  70249. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70250. /**
  70251. * Returns the agent position in world space
  70252. * @param index agent index returned by addAgent
  70253. * @returns world space position
  70254. */
  70255. getAgentPosition(index: number): Vector3;
  70256. /**
  70257. * Gets the agent position result in world space
  70258. * @param index agent index returned by addAgent
  70259. * @param result output world space position
  70260. */
  70261. getAgentPositionToRef(index: number, result: Vector3): void;
  70262. /**
  70263. * Gets the agent velocity in world space
  70264. * @param index agent index returned by addAgent
  70265. * @returns world space velocity
  70266. */
  70267. getAgentVelocity(index: number): Vector3;
  70268. /**
  70269. * Gets the agent velocity result in world space
  70270. * @param index agent index returned by addAgent
  70271. * @param result output world space velocity
  70272. */
  70273. getAgentVelocityToRef(index: number, result: Vector3): void;
  70274. /**
  70275. * remove a particular agent previously created
  70276. * @param index agent index returned by addAgent
  70277. */
  70278. removeAgent(index: number): void;
  70279. /**
  70280. * get the list of all agents attached to this crowd
  70281. * @returns list of agent indices
  70282. */
  70283. getAgents(): number[];
  70284. /**
  70285. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70286. * @param deltaTime in seconds
  70287. */
  70288. update(deltaTime: number): void;
  70289. /**
  70290. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70291. * @param index agent index returned by addAgent
  70292. * @param destination targeted world position
  70293. */
  70294. agentGoto(index: number, destination: Vector3): void;
  70295. /**
  70296. * Teleport the agent to a new position
  70297. * @param index agent index returned by addAgent
  70298. * @param destination targeted world position
  70299. */
  70300. agentTeleport(index: number, destination: Vector3): void;
  70301. /**
  70302. * Update agent parameters
  70303. * @param index agent index returned by addAgent
  70304. * @param parameters agent parameters
  70305. */
  70306. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70307. /**
  70308. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70309. * The queries will try to find a solution within those bounds
  70310. * default is (1,1,1)
  70311. * @param extent x,y,z value that define the extent around the queries point of reference
  70312. */
  70313. setDefaultQueryExtent(extent: Vector3): void;
  70314. /**
  70315. * Get the Bounding box extent specified by setDefaultQueryExtent
  70316. * @returns the box extent values
  70317. */
  70318. getDefaultQueryExtent(): Vector3;
  70319. /**
  70320. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70321. * @param result output the box extent values
  70322. */
  70323. getDefaultQueryExtentToRef(result: Vector3): void;
  70324. /**
  70325. * Release all resources
  70326. */
  70327. dispose(): void;
  70328. }
  70329. /**
  70330. * Configures an agent
  70331. */
  70332. export interface IAgentParameters {
  70333. /**
  70334. * Agent radius. [Limit: >= 0]
  70335. */
  70336. radius: number;
  70337. /**
  70338. * Agent height. [Limit: > 0]
  70339. */
  70340. height: number;
  70341. /**
  70342. * Maximum allowed acceleration. [Limit: >= 0]
  70343. */
  70344. maxAcceleration: number;
  70345. /**
  70346. * Maximum allowed speed. [Limit: >= 0]
  70347. */
  70348. maxSpeed: number;
  70349. /**
  70350. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70351. */
  70352. collisionQueryRange: number;
  70353. /**
  70354. * The path visibility optimization range. [Limit: > 0]
  70355. */
  70356. pathOptimizationRange: number;
  70357. /**
  70358. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70359. */
  70360. separationWeight: number;
  70361. }
  70362. /**
  70363. * Configures the navigation mesh creation
  70364. */
  70365. export interface INavMeshParameters {
  70366. /**
  70367. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70368. */
  70369. cs: number;
  70370. /**
  70371. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70372. */
  70373. ch: number;
  70374. /**
  70375. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70376. */
  70377. walkableSlopeAngle: number;
  70378. /**
  70379. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70380. * be considered walkable. [Limit: >= 3] [Units: vx]
  70381. */
  70382. walkableHeight: number;
  70383. /**
  70384. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70385. */
  70386. walkableClimb: number;
  70387. /**
  70388. * The distance to erode/shrink the walkable area of the heightfield away from
  70389. * obstructions. [Limit: >=0] [Units: vx]
  70390. */
  70391. walkableRadius: number;
  70392. /**
  70393. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70394. */
  70395. maxEdgeLen: number;
  70396. /**
  70397. * The maximum distance a simplfied contour's border edges should deviate
  70398. * the original raw contour. [Limit: >=0] [Units: vx]
  70399. */
  70400. maxSimplificationError: number;
  70401. /**
  70402. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70403. */
  70404. minRegionArea: number;
  70405. /**
  70406. * Any regions with a span count smaller than this value will, if possible,
  70407. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70408. */
  70409. mergeRegionArea: number;
  70410. /**
  70411. * The maximum number of vertices allowed for polygons generated during the
  70412. * contour to polygon conversion process. [Limit: >= 3]
  70413. */
  70414. maxVertsPerPoly: number;
  70415. /**
  70416. * Sets the sampling distance to use when generating the detail mesh.
  70417. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70418. */
  70419. detailSampleDist: number;
  70420. /**
  70421. * The maximum distance the detail mesh surface should deviate from heightfield
  70422. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70423. */
  70424. detailSampleMaxError: number;
  70425. }
  70426. }
  70427. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70428. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70429. import { Mesh } from "babylonjs/Meshes/mesh";
  70430. import { Scene } from "babylonjs/scene";
  70431. import { Vector3 } from "babylonjs/Maths/math";
  70432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70433. /**
  70434. * RecastJS navigation plugin
  70435. */
  70436. export class RecastJSPlugin implements INavigationEnginePlugin {
  70437. /**
  70438. * Reference to the Recast library
  70439. */
  70440. bjsRECAST: any;
  70441. /**
  70442. * plugin name
  70443. */
  70444. name: string;
  70445. /**
  70446. * the first navmesh created. We might extend this to support multiple navmeshes
  70447. */
  70448. navMesh: any;
  70449. /**
  70450. * Initializes the recastJS plugin
  70451. * @param recastInjection can be used to inject your own recast reference
  70452. */
  70453. constructor(recastInjection?: any);
  70454. /**
  70455. * Creates a navigation mesh
  70456. * @param meshes array of all the geometry used to compute the navigatio mesh
  70457. * @param parameters bunch of parameters used to filter geometry
  70458. */
  70459. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70460. /**
  70461. * Create a navigation mesh debug mesh
  70462. * @param scene is where the mesh will be added
  70463. * @returns debug display mesh
  70464. */
  70465. createDebugNavMesh(scene: Scene): Mesh;
  70466. /**
  70467. * Get a navigation mesh constrained position, closest to the parameter position
  70468. * @param position world position
  70469. * @returns the closest point to position constrained by the navigation mesh
  70470. */
  70471. getClosestPoint(position: Vector3): Vector3;
  70472. /**
  70473. * Get a navigation mesh constrained position, closest to the parameter position
  70474. * @param position world position
  70475. * @param result output the closest point to position constrained by the navigation mesh
  70476. */
  70477. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70478. /**
  70479. * Get a navigation mesh constrained position, within a particular radius
  70480. * @param position world position
  70481. * @param maxRadius the maximum distance to the constrained world position
  70482. * @returns the closest point to position constrained by the navigation mesh
  70483. */
  70484. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70485. /**
  70486. * Get a navigation mesh constrained position, within a particular radius
  70487. * @param position world position
  70488. * @param maxRadius the maximum distance to the constrained world position
  70489. * @param result output the closest point to position constrained by the navigation mesh
  70490. */
  70491. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70492. /**
  70493. * Compute the final position from a segment made of destination-position
  70494. * @param position world position
  70495. * @param destination world position
  70496. * @returns the resulting point along the navmesh
  70497. */
  70498. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70499. /**
  70500. * Compute the final position from a segment made of destination-position
  70501. * @param position world position
  70502. * @param destination world position
  70503. * @param result output the resulting point along the navmesh
  70504. */
  70505. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70506. /**
  70507. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70508. * @param start world position
  70509. * @param end world position
  70510. * @returns array containing world position composing the path
  70511. */
  70512. computePath(start: Vector3, end: Vector3): Vector3[];
  70513. /**
  70514. * Create a new Crowd so you can add agents
  70515. * @param maxAgents the maximum agent count in the crowd
  70516. * @param maxAgentRadius the maximum radius an agent can have
  70517. * @param scene to attach the crowd to
  70518. * @returns the crowd you can add agents to
  70519. */
  70520. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70521. /**
  70522. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70523. * The queries will try to find a solution within those bounds
  70524. * default is (1,1,1)
  70525. * @param extent x,y,z value that define the extent around the queries point of reference
  70526. */
  70527. setDefaultQueryExtent(extent: Vector3): void;
  70528. /**
  70529. * Get the Bounding box extent specified by setDefaultQueryExtent
  70530. * @returns the box extent values
  70531. */
  70532. getDefaultQueryExtent(): Vector3;
  70533. /**
  70534. * build the navmesh from a previously saved state using getNavmeshData
  70535. * @param data the Uint8Array returned by getNavmeshData
  70536. */
  70537. buildFromNavmeshData(data: Uint8Array): void;
  70538. /**
  70539. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70540. * @returns data the Uint8Array that can be saved and reused
  70541. */
  70542. getNavmeshData(): Uint8Array;
  70543. /**
  70544. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70545. * @param result output the box extent values
  70546. */
  70547. getDefaultQueryExtentToRef(result: Vector3): void;
  70548. /**
  70549. * Disposes
  70550. */
  70551. dispose(): void;
  70552. /**
  70553. * If this plugin is supported
  70554. * @returns true if plugin is supported
  70555. */
  70556. isSupported(): boolean;
  70557. }
  70558. /**
  70559. * Recast detour crowd implementation
  70560. */
  70561. export class RecastJSCrowd implements ICrowd {
  70562. /**
  70563. * Recast/detour plugin
  70564. */
  70565. bjsRECASTPlugin: RecastJSPlugin;
  70566. /**
  70567. * Link to the detour crowd
  70568. */
  70569. recastCrowd: any;
  70570. /**
  70571. * One transform per agent
  70572. */
  70573. transforms: TransformNode[];
  70574. /**
  70575. * All agents created
  70576. */
  70577. agents: number[];
  70578. /**
  70579. * Link to the scene is kept to unregister the crowd from the scene
  70580. */
  70581. private _scene;
  70582. /**
  70583. * Observer for crowd updates
  70584. */
  70585. private _onBeforeAnimationsObserver;
  70586. /**
  70587. * Constructor
  70588. * @param plugin recastJS plugin
  70589. * @param maxAgents the maximum agent count in the crowd
  70590. * @param maxAgentRadius the maximum radius an agent can have
  70591. * @param scene to attach the crowd to
  70592. * @returns the crowd you can add agents to
  70593. */
  70594. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70595. /**
  70596. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70597. * You can attach anything to that node. The node position is updated in the scene update tick.
  70598. * @param pos world position that will be constrained by the navigation mesh
  70599. * @param parameters agent parameters
  70600. * @param transform hooked to the agent that will be update by the scene
  70601. * @returns agent index
  70602. */
  70603. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70604. /**
  70605. * Returns the agent position in world space
  70606. * @param index agent index returned by addAgent
  70607. * @returns world space position
  70608. */
  70609. getAgentPosition(index: number): Vector3;
  70610. /**
  70611. * Returns the agent position result in world space
  70612. * @param index agent index returned by addAgent
  70613. * @param result output world space position
  70614. */
  70615. getAgentPositionToRef(index: number, result: Vector3): void;
  70616. /**
  70617. * Returns the agent velocity in world space
  70618. * @param index agent index returned by addAgent
  70619. * @returns world space velocity
  70620. */
  70621. getAgentVelocity(index: number): Vector3;
  70622. /**
  70623. * Returns the agent velocity result in world space
  70624. * @param index agent index returned by addAgent
  70625. * @param result output world space velocity
  70626. */
  70627. getAgentVelocityToRef(index: number, result: Vector3): void;
  70628. /**
  70629. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70630. * @param index agent index returned by addAgent
  70631. * @param destination targeted world position
  70632. */
  70633. agentGoto(index: number, destination: Vector3): void;
  70634. /**
  70635. * Teleport the agent to a new position
  70636. * @param index agent index returned by addAgent
  70637. * @param destination targeted world position
  70638. */
  70639. agentTeleport(index: number, destination: Vector3): void;
  70640. /**
  70641. * Update agent parameters
  70642. * @param index agent index returned by addAgent
  70643. * @param parameters agent parameters
  70644. */
  70645. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70646. /**
  70647. * remove a particular agent previously created
  70648. * @param index agent index returned by addAgent
  70649. */
  70650. removeAgent(index: number): void;
  70651. /**
  70652. * get the list of all agents attached to this crowd
  70653. * @returns list of agent indices
  70654. */
  70655. getAgents(): number[];
  70656. /**
  70657. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70658. * @param deltaTime in seconds
  70659. */
  70660. update(deltaTime: number): void;
  70661. /**
  70662. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70663. * The queries will try to find a solution within those bounds
  70664. * default is (1,1,1)
  70665. * @param extent x,y,z value that define the extent around the queries point of reference
  70666. */
  70667. setDefaultQueryExtent(extent: Vector3): void;
  70668. /**
  70669. * Get the Bounding box extent specified by setDefaultQueryExtent
  70670. * @returns the box extent values
  70671. */
  70672. getDefaultQueryExtent(): Vector3;
  70673. /**
  70674. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70675. * @param result output the box extent values
  70676. */
  70677. getDefaultQueryExtentToRef(result: Vector3): void;
  70678. /**
  70679. * Release all resources
  70680. */
  70681. dispose(): void;
  70682. }
  70683. }
  70684. declare module "babylonjs/Navigation/Plugins/index" {
  70685. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70686. }
  70687. declare module "babylonjs/Navigation/index" {
  70688. export * from "babylonjs/Navigation/INavigationEngine";
  70689. export * from "babylonjs/Navigation/Plugins/index";
  70690. }
  70691. declare module "babylonjs/Offline/database" {
  70692. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70693. /**
  70694. * Class used to enable access to IndexedDB
  70695. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70696. */
  70697. export class Database implements IOfflineProvider {
  70698. private _callbackManifestChecked;
  70699. private _currentSceneUrl;
  70700. private _db;
  70701. private _enableSceneOffline;
  70702. private _enableTexturesOffline;
  70703. private _manifestVersionFound;
  70704. private _mustUpdateRessources;
  70705. private _hasReachedQuota;
  70706. private _isSupported;
  70707. private _idbFactory;
  70708. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70709. private static IsUASupportingBlobStorage;
  70710. /**
  70711. * Gets a boolean indicating if Database storate is enabled (off by default)
  70712. */
  70713. static IDBStorageEnabled: boolean;
  70714. /**
  70715. * Gets a boolean indicating if scene must be saved in the database
  70716. */
  70717. get enableSceneOffline(): boolean;
  70718. /**
  70719. * Gets a boolean indicating if textures must be saved in the database
  70720. */
  70721. get enableTexturesOffline(): boolean;
  70722. /**
  70723. * Creates a new Database
  70724. * @param urlToScene defines the url to load the scene
  70725. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70726. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70727. */
  70728. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70729. private static _ParseURL;
  70730. private static _ReturnFullUrlLocation;
  70731. private _checkManifestFile;
  70732. /**
  70733. * Open the database and make it available
  70734. * @param successCallback defines the callback to call on success
  70735. * @param errorCallback defines the callback to call on error
  70736. */
  70737. open(successCallback: () => void, errorCallback: () => void): void;
  70738. /**
  70739. * Loads an image from the database
  70740. * @param url defines the url to load from
  70741. * @param image defines the target DOM image
  70742. */
  70743. loadImage(url: string, image: HTMLImageElement): void;
  70744. private _loadImageFromDBAsync;
  70745. private _saveImageIntoDBAsync;
  70746. private _checkVersionFromDB;
  70747. private _loadVersionFromDBAsync;
  70748. private _saveVersionIntoDBAsync;
  70749. /**
  70750. * Loads a file from database
  70751. * @param url defines the URL to load from
  70752. * @param sceneLoaded defines a callback to call on success
  70753. * @param progressCallBack defines a callback to call when progress changed
  70754. * @param errorCallback defines a callback to call on error
  70755. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70756. */
  70757. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70758. private _loadFileAsync;
  70759. private _saveFileAsync;
  70760. /**
  70761. * Validates if xhr data is correct
  70762. * @param xhr defines the request to validate
  70763. * @param dataType defines the expected data type
  70764. * @returns true if data is correct
  70765. */
  70766. private static _ValidateXHRData;
  70767. }
  70768. }
  70769. declare module "babylonjs/Offline/index" {
  70770. export * from "babylonjs/Offline/database";
  70771. export * from "babylonjs/Offline/IOfflineProvider";
  70772. }
  70773. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70774. /** @hidden */
  70775. export var gpuUpdateParticlesPixelShader: {
  70776. name: string;
  70777. shader: string;
  70778. };
  70779. }
  70780. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70781. /** @hidden */
  70782. export var gpuUpdateParticlesVertexShader: {
  70783. name: string;
  70784. shader: string;
  70785. };
  70786. }
  70787. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70788. /** @hidden */
  70789. export var clipPlaneFragmentDeclaration2: {
  70790. name: string;
  70791. shader: string;
  70792. };
  70793. }
  70794. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70795. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70796. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70797. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70798. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70799. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70800. /** @hidden */
  70801. export var gpuRenderParticlesPixelShader: {
  70802. name: string;
  70803. shader: string;
  70804. };
  70805. }
  70806. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70807. /** @hidden */
  70808. export var clipPlaneVertexDeclaration2: {
  70809. name: string;
  70810. shader: string;
  70811. };
  70812. }
  70813. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70814. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70816. /** @hidden */
  70817. export var gpuRenderParticlesVertexShader: {
  70818. name: string;
  70819. shader: string;
  70820. };
  70821. }
  70822. declare module "babylonjs/Particles/gpuParticleSystem" {
  70823. import { Nullable } from "babylonjs/types";
  70824. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70825. import { Observable } from "babylonjs/Misc/observable";
  70826. import { Matrix } from "babylonjs/Maths/math.vector";
  70827. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70828. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70829. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70830. import { IDisposable } from "babylonjs/scene";
  70831. import { Effect } from "babylonjs/Materials/effect";
  70832. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70833. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  70835. import { Scene } from "babylonjs/scene";
  70836. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70837. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70838. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70839. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70840. /**
  70841. * This represents a GPU particle system in Babylon
  70842. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70843. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70844. */
  70845. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70846. /**
  70847. * The layer mask we are rendering the particles through.
  70848. */
  70849. layerMask: number;
  70850. private _capacity;
  70851. private _activeCount;
  70852. private _currentActiveCount;
  70853. private _accumulatedCount;
  70854. private _renderEffect;
  70855. private _updateEffect;
  70856. private _buffer0;
  70857. private _buffer1;
  70858. private _spriteBuffer;
  70859. private _updateVAO;
  70860. private _renderVAO;
  70861. private _targetIndex;
  70862. private _sourceBuffer;
  70863. private _targetBuffer;
  70864. private _currentRenderId;
  70865. private _started;
  70866. private _stopped;
  70867. private _timeDelta;
  70868. private _randomTexture;
  70869. private _randomTexture2;
  70870. private _attributesStrideSize;
  70871. private _updateEffectOptions;
  70872. private _randomTextureSize;
  70873. private _actualFrame;
  70874. private _customEffect;
  70875. private readonly _rawTextureWidth;
  70876. /**
  70877. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70878. */
  70879. static get IsSupported(): boolean;
  70880. /**
  70881. * An event triggered when the system is disposed.
  70882. */
  70883. onDisposeObservable: Observable<IParticleSystem>;
  70884. /**
  70885. * Gets the maximum number of particles active at the same time.
  70886. * @returns The max number of active particles.
  70887. */
  70888. getCapacity(): number;
  70889. /**
  70890. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70891. * to override the particles.
  70892. */
  70893. forceDepthWrite: boolean;
  70894. /**
  70895. * Gets or set the number of active particles
  70896. */
  70897. get activeParticleCount(): number;
  70898. set activeParticleCount(value: number);
  70899. private _preWarmDone;
  70900. /**
  70901. * Specifies if the particles are updated in emitter local space or world space.
  70902. */
  70903. isLocal: boolean;
  70904. /** Gets or sets a matrix to use to compute projection */
  70905. defaultProjectionMatrix: Matrix;
  70906. /**
  70907. * Is this system ready to be used/rendered
  70908. * @return true if the system is ready
  70909. */
  70910. isReady(): boolean;
  70911. /**
  70912. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70913. * @returns True if it has been started, otherwise false.
  70914. */
  70915. isStarted(): boolean;
  70916. /**
  70917. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70918. * @returns True if it has been stopped, otherwise false.
  70919. */
  70920. isStopped(): boolean;
  70921. /**
  70922. * Gets a boolean indicating that the system is stopping
  70923. * @returns true if the system is currently stopping
  70924. */
  70925. isStopping(): boolean;
  70926. /**
  70927. * Gets the number of particles active at the same time.
  70928. * @returns The number of active particles.
  70929. */
  70930. getActiveCount(): number;
  70931. /**
  70932. * Starts the particle system and begins to emit
  70933. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70934. */
  70935. start(delay?: number): void;
  70936. /**
  70937. * Stops the particle system.
  70938. */
  70939. stop(): void;
  70940. /**
  70941. * Remove all active particles
  70942. */
  70943. reset(): void;
  70944. /**
  70945. * Returns the string "GPUParticleSystem"
  70946. * @returns a string containing the class name
  70947. */
  70948. getClassName(): string;
  70949. /**
  70950. * Gets the custom effect used to render the particles
  70951. * @param blendMode Blend mode for which the effect should be retrieved
  70952. * @returns The effect
  70953. */
  70954. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70955. /**
  70956. * Sets the custom effect used to render the particles
  70957. * @param effect The effect to set
  70958. * @param blendMode Blend mode for which the effect should be set
  70959. */
  70960. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70961. /** @hidden */
  70962. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70963. /**
  70964. * Observable that will be called just before the particles are drawn
  70965. */
  70966. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70967. /**
  70968. * Gets the name of the particle vertex shader
  70969. */
  70970. get vertexShaderName(): string;
  70971. private _colorGradientsTexture;
  70972. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70973. /**
  70974. * Adds a new color gradient
  70975. * @param gradient defines the gradient to use (between 0 and 1)
  70976. * @param color1 defines the color to affect to the specified gradient
  70977. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70978. * @returns the current particle system
  70979. */
  70980. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70981. private _refreshColorGradient;
  70982. /** Force the system to rebuild all gradients that need to be resync */
  70983. forceRefreshGradients(): void;
  70984. /**
  70985. * Remove a specific color gradient
  70986. * @param gradient defines the gradient to remove
  70987. * @returns the current particle system
  70988. */
  70989. removeColorGradient(gradient: number): GPUParticleSystem;
  70990. private _angularSpeedGradientsTexture;
  70991. private _sizeGradientsTexture;
  70992. private _velocityGradientsTexture;
  70993. private _limitVelocityGradientsTexture;
  70994. private _dragGradientsTexture;
  70995. private _addFactorGradient;
  70996. /**
  70997. * Adds a new size gradient
  70998. * @param gradient defines the gradient to use (between 0 and 1)
  70999. * @param factor defines the size factor to affect to the specified gradient
  71000. * @returns the current particle system
  71001. */
  71002. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71003. /**
  71004. * Remove a specific size gradient
  71005. * @param gradient defines the gradient to remove
  71006. * @returns the current particle system
  71007. */
  71008. removeSizeGradient(gradient: number): GPUParticleSystem;
  71009. private _refreshFactorGradient;
  71010. /**
  71011. * Adds a new angular speed gradient
  71012. * @param gradient defines the gradient to use (between 0 and 1)
  71013. * @param factor defines the angular speed to affect to the specified gradient
  71014. * @returns the current particle system
  71015. */
  71016. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71017. /**
  71018. * Remove a specific angular speed gradient
  71019. * @param gradient defines the gradient to remove
  71020. * @returns the current particle system
  71021. */
  71022. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71023. /**
  71024. * Adds a new velocity gradient
  71025. * @param gradient defines the gradient to use (between 0 and 1)
  71026. * @param factor defines the velocity to affect to the specified gradient
  71027. * @returns the current particle system
  71028. */
  71029. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71030. /**
  71031. * Remove a specific velocity gradient
  71032. * @param gradient defines the gradient to remove
  71033. * @returns the current particle system
  71034. */
  71035. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71036. /**
  71037. * Adds a new limit velocity gradient
  71038. * @param gradient defines the gradient to use (between 0 and 1)
  71039. * @param factor defines the limit velocity value to affect to the specified gradient
  71040. * @returns the current particle system
  71041. */
  71042. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71043. /**
  71044. * Remove a specific limit velocity gradient
  71045. * @param gradient defines the gradient to remove
  71046. * @returns the current particle system
  71047. */
  71048. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71049. /**
  71050. * Adds a new drag gradient
  71051. * @param gradient defines the gradient to use (between 0 and 1)
  71052. * @param factor defines the drag value to affect to the specified gradient
  71053. * @returns the current particle system
  71054. */
  71055. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71056. /**
  71057. * Remove a specific drag gradient
  71058. * @param gradient defines the gradient to remove
  71059. * @returns the current particle system
  71060. */
  71061. removeDragGradient(gradient: number): GPUParticleSystem;
  71062. /**
  71063. * Not supported by GPUParticleSystem
  71064. * @param gradient defines the gradient to use (between 0 and 1)
  71065. * @param factor defines the emit rate value to affect to the specified gradient
  71066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71067. * @returns the current particle system
  71068. */
  71069. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71070. /**
  71071. * Not supported by GPUParticleSystem
  71072. * @param gradient defines the gradient to remove
  71073. * @returns the current particle system
  71074. */
  71075. removeEmitRateGradient(gradient: number): IParticleSystem;
  71076. /**
  71077. * Not supported by GPUParticleSystem
  71078. * @param gradient defines the gradient to use (between 0 and 1)
  71079. * @param factor defines the start size value to affect to the specified gradient
  71080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71081. * @returns the current particle system
  71082. */
  71083. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71084. /**
  71085. * Not supported by GPUParticleSystem
  71086. * @param gradient defines the gradient to remove
  71087. * @returns the current particle system
  71088. */
  71089. removeStartSizeGradient(gradient: number): IParticleSystem;
  71090. /**
  71091. * Not supported by GPUParticleSystem
  71092. * @param gradient defines the gradient to use (between 0 and 1)
  71093. * @param min defines the color remap minimal range
  71094. * @param max defines the color remap maximal range
  71095. * @returns the current particle system
  71096. */
  71097. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71098. /**
  71099. * Not supported by GPUParticleSystem
  71100. * @param gradient defines the gradient to remove
  71101. * @returns the current particle system
  71102. */
  71103. removeColorRemapGradient(): IParticleSystem;
  71104. /**
  71105. * Not supported by GPUParticleSystem
  71106. * @param gradient defines the gradient to use (between 0 and 1)
  71107. * @param min defines the alpha remap minimal range
  71108. * @param max defines the alpha remap maximal range
  71109. * @returns the current particle system
  71110. */
  71111. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71112. /**
  71113. * Not supported by GPUParticleSystem
  71114. * @param gradient defines the gradient to remove
  71115. * @returns the current particle system
  71116. */
  71117. removeAlphaRemapGradient(): IParticleSystem;
  71118. /**
  71119. * Not supported by GPUParticleSystem
  71120. * @param gradient defines the gradient to use (between 0 and 1)
  71121. * @param color defines the color to affect to the specified gradient
  71122. * @returns the current particle system
  71123. */
  71124. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71125. /**
  71126. * Not supported by GPUParticleSystem
  71127. * @param gradient defines the gradient to remove
  71128. * @returns the current particle system
  71129. */
  71130. removeRampGradient(): IParticleSystem;
  71131. /**
  71132. * Not supported by GPUParticleSystem
  71133. * @returns the list of ramp gradients
  71134. */
  71135. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71136. /**
  71137. * Not supported by GPUParticleSystem
  71138. * Gets or sets a boolean indicating that ramp gradients must be used
  71139. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71140. */
  71141. get useRampGradients(): boolean;
  71142. set useRampGradients(value: boolean);
  71143. /**
  71144. * Not supported by GPUParticleSystem
  71145. * @param gradient defines the gradient to use (between 0 and 1)
  71146. * @param factor defines the life time factor to affect to the specified gradient
  71147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71148. * @returns the current particle system
  71149. */
  71150. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71151. /**
  71152. * Not supported by GPUParticleSystem
  71153. * @param gradient defines the gradient to remove
  71154. * @returns the current particle system
  71155. */
  71156. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71157. /**
  71158. * Instantiates a GPU particle system.
  71159. * 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.
  71160. * @param name The name of the particle system
  71161. * @param options The options used to create the system
  71162. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71163. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71164. * @param customEffect a custom effect used to change the way particles are rendered by default
  71165. */
  71166. constructor(name: string, options: Partial<{
  71167. capacity: number;
  71168. randomTextureSize: number;
  71169. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71170. protected _reset(): void;
  71171. private _createUpdateVAO;
  71172. private _createRenderVAO;
  71173. private _initialize;
  71174. /** @hidden */
  71175. _recreateUpdateEffect(): void;
  71176. private _getEffect;
  71177. /**
  71178. * Fill the defines array according to the current settings of the particle system
  71179. * @param defines Array to be updated
  71180. * @param blendMode blend mode to take into account when updating the array
  71181. */
  71182. fillDefines(defines: Array<string>, blendMode?: number): void;
  71183. /**
  71184. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71185. * @param uniforms Uniforms array to fill
  71186. * @param attributes Attributes array to fill
  71187. * @param samplers Samplers array to fill
  71188. */
  71189. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71190. /** @hidden */
  71191. _recreateRenderEffect(): Effect;
  71192. /**
  71193. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71194. * @param preWarm defines if we are in the pre-warmimg phase
  71195. */
  71196. animate(preWarm?: boolean): void;
  71197. private _createFactorGradientTexture;
  71198. private _createSizeGradientTexture;
  71199. private _createAngularSpeedGradientTexture;
  71200. private _createVelocityGradientTexture;
  71201. private _createLimitVelocityGradientTexture;
  71202. private _createDragGradientTexture;
  71203. private _createColorGradientTexture;
  71204. /**
  71205. * Renders the particle system in its current state
  71206. * @param preWarm defines if the system should only update the particles but not render them
  71207. * @returns the current number of particles
  71208. */
  71209. render(preWarm?: boolean): number;
  71210. /**
  71211. * Rebuilds the particle system
  71212. */
  71213. rebuild(): void;
  71214. private _releaseBuffers;
  71215. private _releaseVAOs;
  71216. /**
  71217. * Disposes the particle system and free the associated resources
  71218. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71219. */
  71220. dispose(disposeTexture?: boolean): void;
  71221. /**
  71222. * Clones the particle system.
  71223. * @param name The name of the cloned object
  71224. * @param newEmitter The new emitter to use
  71225. * @returns the cloned particle system
  71226. */
  71227. clone(name: string, newEmitter: any): GPUParticleSystem;
  71228. /**
  71229. * Serializes the particle system to a JSON object
  71230. * @param serializeTexture defines if the texture must be serialized as well
  71231. * @returns the JSON object
  71232. */
  71233. serialize(serializeTexture?: boolean): any;
  71234. /**
  71235. * Parses a JSON object to create a GPU particle system.
  71236. * @param parsedParticleSystem The JSON object to parse
  71237. * @param sceneOrEngine The scene or the engine to create the particle system in
  71238. * @param rootUrl The root url to use to load external dependencies like texture
  71239. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71240. * @returns the parsed GPU particle system
  71241. */
  71242. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71243. }
  71244. }
  71245. declare module "babylonjs/Particles/particleSystemSet" {
  71246. import { Nullable } from "babylonjs/types";
  71247. import { Color3 } from "babylonjs/Maths/math.color";
  71248. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71250. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71251. import { Scene, IDisposable } from "babylonjs/scene";
  71252. /**
  71253. * Represents a set of particle systems working together to create a specific effect
  71254. */
  71255. export class ParticleSystemSet implements IDisposable {
  71256. /**
  71257. * Gets or sets base Assets URL
  71258. */
  71259. static BaseAssetsUrl: string;
  71260. private _emitterCreationOptions;
  71261. private _emitterNode;
  71262. /**
  71263. * Gets the particle system list
  71264. */
  71265. systems: IParticleSystem[];
  71266. /**
  71267. * Gets the emitter node used with this set
  71268. */
  71269. get emitterNode(): Nullable<TransformNode>;
  71270. /**
  71271. * Creates a new emitter mesh as a sphere
  71272. * @param options defines the options used to create the sphere
  71273. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71274. * @param scene defines the hosting scene
  71275. */
  71276. setEmitterAsSphere(options: {
  71277. diameter: number;
  71278. segments: number;
  71279. color: Color3;
  71280. }, renderingGroupId: number, scene: Scene): void;
  71281. /**
  71282. * Starts all particle systems of the set
  71283. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71284. */
  71285. start(emitter?: AbstractMesh): void;
  71286. /**
  71287. * Release all associated resources
  71288. */
  71289. dispose(): void;
  71290. /**
  71291. * Serialize the set into a JSON compatible object
  71292. * @param serializeTexture defines if the texture must be serialized as well
  71293. * @returns a JSON compatible representation of the set
  71294. */
  71295. serialize(serializeTexture?: boolean): any;
  71296. /**
  71297. * Parse a new ParticleSystemSet from a serialized source
  71298. * @param data defines a JSON compatible representation of the set
  71299. * @param scene defines the hosting scene
  71300. * @param gpu defines if we want GPU particles or CPU particles
  71301. * @returns a new ParticleSystemSet
  71302. */
  71303. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71304. }
  71305. }
  71306. declare module "babylonjs/Particles/particleHelper" {
  71307. import { Nullable } from "babylonjs/types";
  71308. import { Scene } from "babylonjs/scene";
  71309. import { Vector3 } from "babylonjs/Maths/math.vector";
  71310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71311. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71312. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71313. /**
  71314. * This class is made for on one-liner static method to help creating particle system set.
  71315. */
  71316. export class ParticleHelper {
  71317. /**
  71318. * Gets or sets base Assets URL
  71319. */
  71320. static BaseAssetsUrl: string;
  71321. /** Define the Url to load snippets */
  71322. static SnippetUrl: string;
  71323. /**
  71324. * Create a default particle system that you can tweak
  71325. * @param emitter defines the emitter to use
  71326. * @param capacity defines the system capacity (default is 500 particles)
  71327. * @param scene defines the hosting scene
  71328. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71329. * @returns the new Particle system
  71330. */
  71331. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71332. /**
  71333. * This is the main static method (one-liner) of this helper to create different particle systems
  71334. * @param type This string represents the type to the particle system to create
  71335. * @param scene The scene where the particle system should live
  71336. * @param gpu If the system will use gpu
  71337. * @returns the ParticleSystemSet created
  71338. */
  71339. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71340. /**
  71341. * Static function used to export a particle system to a ParticleSystemSet variable.
  71342. * Please note that the emitter shape is not exported
  71343. * @param systems defines the particle systems to export
  71344. * @returns the created particle system set
  71345. */
  71346. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71347. /**
  71348. * Creates a particle system from a snippet saved in a remote file
  71349. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71350. * @param url defines the url to load from
  71351. * @param scene defines the hosting scene
  71352. * @param gpu If the system will use gpu
  71353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71354. * @returns a promise that will resolve to the new particle system
  71355. */
  71356. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71357. /**
  71358. * Creates a particle system from a snippet saved by the particle system editor
  71359. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71360. * @param scene defines the hosting scene
  71361. * @param gpu If the system will use gpu
  71362. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71363. * @returns a promise that will resolve to the new particle system
  71364. */
  71365. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71366. }
  71367. }
  71368. declare module "babylonjs/Particles/particleSystemComponent" {
  71369. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71370. import { Effect } from "babylonjs/Materials/effect";
  71371. import "babylonjs/Shaders/particles.vertex";
  71372. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71373. module "babylonjs/Engines/engine" {
  71374. interface Engine {
  71375. /**
  71376. * Create an effect to use with particle systems.
  71377. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71378. * the particle system for which you want to create a custom effect in the last parameter
  71379. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71380. * @param uniformsNames defines a list of attribute names
  71381. * @param samplers defines an array of string used to represent textures
  71382. * @param defines defines the string containing the defines to use to compile the shaders
  71383. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71384. * @param onCompiled defines a function to call when the effect creation is successful
  71385. * @param onError defines a function to call when the effect creation has failed
  71386. * @param particleSystem the particle system you want to create the effect for
  71387. * @returns the new Effect
  71388. */
  71389. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71390. }
  71391. }
  71392. module "babylonjs/Meshes/mesh" {
  71393. interface Mesh {
  71394. /**
  71395. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71396. * @returns an array of IParticleSystem
  71397. */
  71398. getEmittedParticleSystems(): IParticleSystem[];
  71399. /**
  71400. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71401. * @returns an array of IParticleSystem
  71402. */
  71403. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71404. }
  71405. }
  71406. }
  71407. declare module "babylonjs/Particles/pointsCloudSystem" {
  71408. import { Color4 } from "babylonjs/Maths/math";
  71409. import { Mesh } from "babylonjs/Meshes/mesh";
  71410. import { Scene, IDisposable } from "babylonjs/scene";
  71411. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71412. /** Defines the 4 color options */
  71413. export enum PointColor {
  71414. /** color value */
  71415. Color = 2,
  71416. /** uv value */
  71417. UV = 1,
  71418. /** random value */
  71419. Random = 0,
  71420. /** stated value */
  71421. Stated = 3
  71422. }
  71423. /**
  71424. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71425. * 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.
  71426. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71427. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71428. *
  71429. * Full documentation here : TO BE ENTERED
  71430. */
  71431. export class PointsCloudSystem implements IDisposable {
  71432. /**
  71433. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71434. * Example : var p = SPS.particles[i];
  71435. */
  71436. particles: CloudPoint[];
  71437. /**
  71438. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71439. */
  71440. nbParticles: number;
  71441. /**
  71442. * This a counter for your own usage. It's not set by any SPS functions.
  71443. */
  71444. counter: number;
  71445. /**
  71446. * The PCS name. This name is also given to the underlying mesh.
  71447. */
  71448. name: string;
  71449. /**
  71450. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71451. */
  71452. mesh: Mesh;
  71453. /**
  71454. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71455. * Please read :
  71456. */
  71457. vars: any;
  71458. /**
  71459. * @hidden
  71460. */
  71461. _size: number;
  71462. private _scene;
  71463. private _promises;
  71464. private _positions;
  71465. private _indices;
  71466. private _normals;
  71467. private _colors;
  71468. private _uvs;
  71469. private _indices32;
  71470. private _positions32;
  71471. private _colors32;
  71472. private _uvs32;
  71473. private _updatable;
  71474. private _isVisibilityBoxLocked;
  71475. private _alwaysVisible;
  71476. private _groups;
  71477. private _groupCounter;
  71478. private _computeParticleColor;
  71479. private _computeParticleTexture;
  71480. private _computeParticleRotation;
  71481. private _computeBoundingBox;
  71482. private _isReady;
  71483. /**
  71484. * Creates a PCS (Points Cloud System) object
  71485. * @param name (String) is the PCS name, this will be the underlying mesh name
  71486. * @param pointSize (number) is the size for each point
  71487. * @param scene (Scene) is the scene in which the PCS is added
  71488. * @param options defines the options of the PCS e.g.
  71489. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71490. */
  71491. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71492. updatable?: boolean;
  71493. });
  71494. /**
  71495. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71496. * If no points were added to the PCS, the returned mesh is just a single point.
  71497. * @returns a promise for the created mesh
  71498. */
  71499. buildMeshAsync(): Promise<Mesh>;
  71500. /**
  71501. * @hidden
  71502. */
  71503. private _buildMesh;
  71504. private _addParticle;
  71505. private _randomUnitVector;
  71506. private _getColorIndicesForCoord;
  71507. private _setPointsColorOrUV;
  71508. private _colorFromTexture;
  71509. private _calculateDensity;
  71510. /**
  71511. * Adds points to the PCS in random positions within a unit sphere
  71512. * @param nb (positive integer) the number of particles to be created from this model
  71513. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71514. * @returns the number of groups in the system
  71515. */
  71516. addPoints(nb: number, pointFunction?: any): number;
  71517. /**
  71518. * Adds points to the PCS from the surface of the model shape
  71519. * @param mesh is any Mesh object that will be used as a surface model for the points
  71520. * @param nb (positive integer) the number of particles to be created from this model
  71521. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71522. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71523. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71524. * @returns the number of groups in the system
  71525. */
  71526. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71527. /**
  71528. * Adds points to the PCS inside the model shape
  71529. * @param mesh is any Mesh object that will be used as a surface model for the points
  71530. * @param nb (positive integer) the number of particles to be created from this model
  71531. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71532. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71533. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71534. * @returns the number of groups in the system
  71535. */
  71536. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71537. /**
  71538. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71539. * This method calls `updateParticle()` for each particle of the SPS.
  71540. * For an animated SPS, it is usually called within the render loop.
  71541. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71542. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71543. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71544. * @returns the PCS.
  71545. */
  71546. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71547. /**
  71548. * Disposes the PCS.
  71549. */
  71550. dispose(): void;
  71551. /**
  71552. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71553. * doc :
  71554. * @returns the PCS.
  71555. */
  71556. refreshVisibleSize(): PointsCloudSystem;
  71557. /**
  71558. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71559. * @param size the size (float) of the visibility box
  71560. * note : this doesn't lock the PCS mesh bounding box.
  71561. * doc :
  71562. */
  71563. setVisibilityBox(size: number): void;
  71564. /**
  71565. * Gets whether the PCS is always visible or not
  71566. * doc :
  71567. */
  71568. get isAlwaysVisible(): boolean;
  71569. /**
  71570. * Sets the PCS as always visible or not
  71571. * doc :
  71572. */
  71573. set isAlwaysVisible(val: boolean);
  71574. /**
  71575. * Tells to `setParticles()` to compute the particle rotations or not
  71576. * Default value : false. The PCS is faster when it's set to false
  71577. * Note : particle rotations are only applied to parent particles
  71578. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71579. */
  71580. set computeParticleRotation(val: boolean);
  71581. /**
  71582. * Tells to `setParticles()` to compute the particle colors or not.
  71583. * Default value : true. The PCS is faster when it's set to false.
  71584. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71585. */
  71586. set computeParticleColor(val: boolean);
  71587. set computeParticleTexture(val: boolean);
  71588. /**
  71589. * Gets if `setParticles()` computes the particle colors or not.
  71590. * Default value : false. The PCS is faster when it's set to false.
  71591. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71592. */
  71593. get computeParticleColor(): boolean;
  71594. /**
  71595. * Gets if `setParticles()` computes the particle textures or not.
  71596. * Default value : false. The PCS is faster when it's set to false.
  71597. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71598. */
  71599. get computeParticleTexture(): boolean;
  71600. /**
  71601. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71602. */
  71603. set computeBoundingBox(val: boolean);
  71604. /**
  71605. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71606. */
  71607. get computeBoundingBox(): boolean;
  71608. /**
  71609. * This function does nothing. It may be overwritten to set all the particle first values.
  71610. * The PCS doesn't call this function, you may have to call it by your own.
  71611. * doc :
  71612. */
  71613. initParticles(): void;
  71614. /**
  71615. * This function does nothing. It may be overwritten to recycle a particle
  71616. * The PCS doesn't call this function, you can to call it
  71617. * doc :
  71618. * @param particle The particle to recycle
  71619. * @returns the recycled particle
  71620. */
  71621. recycleParticle(particle: CloudPoint): CloudPoint;
  71622. /**
  71623. * Updates a particle : this function should be overwritten by the user.
  71624. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71625. * doc :
  71626. * @example : just set a particle position or velocity and recycle conditions
  71627. * @param particle The particle to update
  71628. * @returns the updated particle
  71629. */
  71630. updateParticle(particle: CloudPoint): CloudPoint;
  71631. /**
  71632. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71633. * This does nothing and may be overwritten by the user.
  71634. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71635. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71636. * @param update the boolean update value actually passed to setParticles()
  71637. */
  71638. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71639. /**
  71640. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71641. * This will be passed three parameters.
  71642. * This does nothing and may be overwritten by the user.
  71643. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71644. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71645. * @param update the boolean update value actually passed to setParticles()
  71646. */
  71647. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71648. }
  71649. }
  71650. declare module "babylonjs/Particles/cloudPoint" {
  71651. import { Nullable } from "babylonjs/types";
  71652. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71653. import { Mesh } from "babylonjs/Meshes/mesh";
  71654. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71655. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71656. /**
  71657. * Represents one particle of a points cloud system.
  71658. */
  71659. export class CloudPoint {
  71660. /**
  71661. * particle global index
  71662. */
  71663. idx: number;
  71664. /**
  71665. * The color of the particle
  71666. */
  71667. color: Nullable<Color4>;
  71668. /**
  71669. * The world space position of the particle.
  71670. */
  71671. position: Vector3;
  71672. /**
  71673. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71674. */
  71675. rotation: Vector3;
  71676. /**
  71677. * The world space rotation quaternion of the particle.
  71678. */
  71679. rotationQuaternion: Nullable<Quaternion>;
  71680. /**
  71681. * The uv of the particle.
  71682. */
  71683. uv: Nullable<Vector2>;
  71684. /**
  71685. * The current speed of the particle.
  71686. */
  71687. velocity: Vector3;
  71688. /**
  71689. * The pivot point in the particle local space.
  71690. */
  71691. pivot: Vector3;
  71692. /**
  71693. * Must the particle be translated from its pivot point in its local space ?
  71694. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71695. * Default : false
  71696. */
  71697. translateFromPivot: boolean;
  71698. /**
  71699. * Index of this particle in the global "positions" array (Internal use)
  71700. * @hidden
  71701. */
  71702. _pos: number;
  71703. /**
  71704. * @hidden Index of this particle in the global "indices" array (Internal use)
  71705. */
  71706. _ind: number;
  71707. /**
  71708. * Group this particle belongs to
  71709. */
  71710. _group: PointsGroup;
  71711. /**
  71712. * Group id of this particle
  71713. */
  71714. groupId: number;
  71715. /**
  71716. * Index of the particle in its group id (Internal use)
  71717. */
  71718. idxInGroup: number;
  71719. /**
  71720. * @hidden Particle BoundingInfo object (Internal use)
  71721. */
  71722. _boundingInfo: BoundingInfo;
  71723. /**
  71724. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71725. */
  71726. _pcs: PointsCloudSystem;
  71727. /**
  71728. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71729. */
  71730. _stillInvisible: boolean;
  71731. /**
  71732. * @hidden Last computed particle rotation matrix
  71733. */
  71734. _rotationMatrix: number[];
  71735. /**
  71736. * Parent particle Id, if any.
  71737. * Default null.
  71738. */
  71739. parentId: Nullable<number>;
  71740. /**
  71741. * @hidden Internal global position in the PCS.
  71742. */
  71743. _globalPosition: Vector3;
  71744. /**
  71745. * Creates a Point Cloud object.
  71746. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71747. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71748. * @param group (PointsGroup) is the group the particle belongs to
  71749. * @param groupId (integer) is the group identifier in the PCS.
  71750. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71751. * @param pcs defines the PCS it is associated to
  71752. */
  71753. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71754. /**
  71755. * get point size
  71756. */
  71757. get size(): Vector3;
  71758. /**
  71759. * Set point size
  71760. */
  71761. set size(scale: Vector3);
  71762. /**
  71763. * Legacy support, changed quaternion to rotationQuaternion
  71764. */
  71765. get quaternion(): Nullable<Quaternion>;
  71766. /**
  71767. * Legacy support, changed quaternion to rotationQuaternion
  71768. */
  71769. set quaternion(q: Nullable<Quaternion>);
  71770. /**
  71771. * Returns a boolean. True if the particle intersects a mesh, else false
  71772. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71773. * @param target is the object (point or mesh) what the intersection is computed against
  71774. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71775. * @returns true if it intersects
  71776. */
  71777. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71778. /**
  71779. * get the rotation matrix of the particle
  71780. * @hidden
  71781. */
  71782. getRotationMatrix(m: Matrix): void;
  71783. }
  71784. /**
  71785. * Represents a group of points in a points cloud system
  71786. * * PCS internal tool, don't use it manually.
  71787. */
  71788. export class PointsGroup {
  71789. /**
  71790. * The group id
  71791. * @hidden
  71792. */
  71793. groupID: number;
  71794. /**
  71795. * image data for group (internal use)
  71796. * @hidden
  71797. */
  71798. _groupImageData: Nullable<ArrayBufferView>;
  71799. /**
  71800. * Image Width (internal use)
  71801. * @hidden
  71802. */
  71803. _groupImgWidth: number;
  71804. /**
  71805. * Image Height (internal use)
  71806. * @hidden
  71807. */
  71808. _groupImgHeight: number;
  71809. /**
  71810. * Custom position function (internal use)
  71811. * @hidden
  71812. */
  71813. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71814. /**
  71815. * density per facet for surface points
  71816. * @hidden
  71817. */
  71818. _groupDensity: number[];
  71819. /**
  71820. * Only when points are colored by texture carries pointer to texture list array
  71821. * @hidden
  71822. */
  71823. _textureNb: number;
  71824. /**
  71825. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71826. * PCS internal tool, don't use it manually.
  71827. * @hidden
  71828. */
  71829. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71830. }
  71831. }
  71832. declare module "babylonjs/Particles/index" {
  71833. export * from "babylonjs/Particles/baseParticleSystem";
  71834. export * from "babylonjs/Particles/EmitterTypes/index";
  71835. export * from "babylonjs/Particles/gpuParticleSystem";
  71836. export * from "babylonjs/Particles/IParticleSystem";
  71837. export * from "babylonjs/Particles/particle";
  71838. export * from "babylonjs/Particles/particleHelper";
  71839. export * from "babylonjs/Particles/particleSystem";
  71840. import "babylonjs/Particles/particleSystemComponent";
  71841. export * from "babylonjs/Particles/particleSystemComponent";
  71842. export * from "babylonjs/Particles/particleSystemSet";
  71843. export * from "babylonjs/Particles/solidParticle";
  71844. export * from "babylonjs/Particles/solidParticleSystem";
  71845. export * from "babylonjs/Particles/cloudPoint";
  71846. export * from "babylonjs/Particles/pointsCloudSystem";
  71847. export * from "babylonjs/Particles/subEmitter";
  71848. }
  71849. declare module "babylonjs/Physics/physicsEngineComponent" {
  71850. import { Nullable } from "babylonjs/types";
  71851. import { Observable, Observer } from "babylonjs/Misc/observable";
  71852. import { Vector3 } from "babylonjs/Maths/math.vector";
  71853. import { Mesh } from "babylonjs/Meshes/mesh";
  71854. import { ISceneComponent } from "babylonjs/sceneComponent";
  71855. import { Scene } from "babylonjs/scene";
  71856. import { Node } from "babylonjs/node";
  71857. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71858. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71859. module "babylonjs/scene" {
  71860. interface Scene {
  71861. /** @hidden (Backing field) */
  71862. _physicsEngine: Nullable<IPhysicsEngine>;
  71863. /** @hidden */
  71864. _physicsTimeAccumulator: number;
  71865. /**
  71866. * Gets the current physics engine
  71867. * @returns a IPhysicsEngine or null if none attached
  71868. */
  71869. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71870. /**
  71871. * Enables physics to the current scene
  71872. * @param gravity defines the scene's gravity for the physics engine
  71873. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71874. * @return a boolean indicating if the physics engine was initialized
  71875. */
  71876. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71877. /**
  71878. * Disables and disposes the physics engine associated with the scene
  71879. */
  71880. disablePhysicsEngine(): void;
  71881. /**
  71882. * Gets a boolean indicating if there is an active physics engine
  71883. * @returns a boolean indicating if there is an active physics engine
  71884. */
  71885. isPhysicsEnabled(): boolean;
  71886. /**
  71887. * Deletes a physics compound impostor
  71888. * @param compound defines the compound to delete
  71889. */
  71890. deleteCompoundImpostor(compound: any): void;
  71891. /**
  71892. * An event triggered when physic simulation is about to be run
  71893. */
  71894. onBeforePhysicsObservable: Observable<Scene>;
  71895. /**
  71896. * An event triggered when physic simulation has been done
  71897. */
  71898. onAfterPhysicsObservable: Observable<Scene>;
  71899. }
  71900. }
  71901. module "babylonjs/Meshes/abstractMesh" {
  71902. interface AbstractMesh {
  71903. /** @hidden */
  71904. _physicsImpostor: Nullable<PhysicsImpostor>;
  71905. /**
  71906. * Gets or sets impostor used for physic simulation
  71907. * @see https://doc.babylonjs.com/features/physics_engine
  71908. */
  71909. physicsImpostor: Nullable<PhysicsImpostor>;
  71910. /**
  71911. * Gets the current physics impostor
  71912. * @see https://doc.babylonjs.com/features/physics_engine
  71913. * @returns a physics impostor or null
  71914. */
  71915. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71916. /** Apply a physic impulse to the mesh
  71917. * @param force defines the force to apply
  71918. * @param contactPoint defines where to apply the force
  71919. * @returns the current mesh
  71920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71921. */
  71922. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71923. /**
  71924. * Creates a physic joint between two meshes
  71925. * @param otherMesh defines the other mesh to use
  71926. * @param pivot1 defines the pivot to use on this mesh
  71927. * @param pivot2 defines the pivot to use on the other mesh
  71928. * @param options defines additional options (can be plugin dependent)
  71929. * @returns the current mesh
  71930. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71931. */
  71932. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71933. /** @hidden */
  71934. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71935. }
  71936. }
  71937. /**
  71938. * Defines the physics engine scene component responsible to manage a physics engine
  71939. */
  71940. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71941. /**
  71942. * The component name helpful to identify the component in the list of scene components.
  71943. */
  71944. readonly name: string;
  71945. /**
  71946. * The scene the component belongs to.
  71947. */
  71948. scene: Scene;
  71949. /**
  71950. * Creates a new instance of the component for the given scene
  71951. * @param scene Defines the scene to register the component in
  71952. */
  71953. constructor(scene: Scene);
  71954. /**
  71955. * Registers the component in a given scene
  71956. */
  71957. register(): void;
  71958. /**
  71959. * Rebuilds the elements related to this component in case of
  71960. * context lost for instance.
  71961. */
  71962. rebuild(): void;
  71963. /**
  71964. * Disposes the component and the associated ressources
  71965. */
  71966. dispose(): void;
  71967. }
  71968. }
  71969. declare module "babylonjs/Physics/physicsHelper" {
  71970. import { Nullable } from "babylonjs/types";
  71971. import { Vector3 } from "babylonjs/Maths/math.vector";
  71972. import { Mesh } from "babylonjs/Meshes/mesh";
  71973. import { Scene } from "babylonjs/scene";
  71974. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71975. /**
  71976. * A helper for physics simulations
  71977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71978. */
  71979. export class PhysicsHelper {
  71980. private _scene;
  71981. private _physicsEngine;
  71982. /**
  71983. * Initializes the Physics helper
  71984. * @param scene Babylon.js scene
  71985. */
  71986. constructor(scene: Scene);
  71987. /**
  71988. * Applies a radial explosion impulse
  71989. * @param origin the origin of the explosion
  71990. * @param radiusOrEventOptions the radius or the options of radial explosion
  71991. * @param strength the explosion strength
  71992. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71993. * @returns A physics radial explosion event, or null
  71994. */
  71995. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71996. /**
  71997. * Applies a radial explosion force
  71998. * @param origin the origin of the explosion
  71999. * @param radiusOrEventOptions the radius or the options of radial explosion
  72000. * @param strength the explosion strength
  72001. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72002. * @returns A physics radial explosion event, or null
  72003. */
  72004. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72005. /**
  72006. * Creates a gravitational field
  72007. * @param origin the origin of the explosion
  72008. * @param radiusOrEventOptions the radius or the options of radial explosion
  72009. * @param strength the explosion strength
  72010. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72011. * @returns A physics gravitational field event, or null
  72012. */
  72013. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72014. /**
  72015. * Creates a physics updraft event
  72016. * @param origin the origin of the updraft
  72017. * @param radiusOrEventOptions the radius or the options of the updraft
  72018. * @param strength the strength of the updraft
  72019. * @param height the height of the updraft
  72020. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72021. * @returns A physics updraft event, or null
  72022. */
  72023. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72024. /**
  72025. * Creates a physics vortex event
  72026. * @param origin the of the vortex
  72027. * @param radiusOrEventOptions the radius or the options of the vortex
  72028. * @param strength the strength of the vortex
  72029. * @param height the height of the vortex
  72030. * @returns a Physics vortex event, or null
  72031. * A physics vortex event or null
  72032. */
  72033. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72034. }
  72035. /**
  72036. * Represents a physics radial explosion event
  72037. */
  72038. class PhysicsRadialExplosionEvent {
  72039. private _scene;
  72040. private _options;
  72041. private _sphere;
  72042. private _dataFetched;
  72043. /**
  72044. * Initializes a radial explosioin event
  72045. * @param _scene BabylonJS scene
  72046. * @param _options The options for the vortex event
  72047. */
  72048. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72049. /**
  72050. * Returns the data related to the radial explosion event (sphere).
  72051. * @returns The radial explosion event data
  72052. */
  72053. getData(): PhysicsRadialExplosionEventData;
  72054. /**
  72055. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72056. * @param impostor A physics imposter
  72057. * @param origin the origin of the explosion
  72058. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72059. */
  72060. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72061. /**
  72062. * Triggers affecterd impostors callbacks
  72063. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72064. */
  72065. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72066. /**
  72067. * Disposes the sphere.
  72068. * @param force Specifies if the sphere should be disposed by force
  72069. */
  72070. dispose(force?: boolean): void;
  72071. /*** Helpers ***/
  72072. private _prepareSphere;
  72073. private _intersectsWithSphere;
  72074. }
  72075. /**
  72076. * Represents a gravitational field event
  72077. */
  72078. class PhysicsGravitationalFieldEvent {
  72079. private _physicsHelper;
  72080. private _scene;
  72081. private _origin;
  72082. private _options;
  72083. private _tickCallback;
  72084. private _sphere;
  72085. private _dataFetched;
  72086. /**
  72087. * Initializes the physics gravitational field event
  72088. * @param _physicsHelper A physics helper
  72089. * @param _scene BabylonJS scene
  72090. * @param _origin The origin position of the gravitational field event
  72091. * @param _options The options for the vortex event
  72092. */
  72093. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72094. /**
  72095. * Returns the data related to the gravitational field event (sphere).
  72096. * @returns A gravitational field event
  72097. */
  72098. getData(): PhysicsGravitationalFieldEventData;
  72099. /**
  72100. * Enables the gravitational field.
  72101. */
  72102. enable(): void;
  72103. /**
  72104. * Disables the gravitational field.
  72105. */
  72106. disable(): void;
  72107. /**
  72108. * Disposes the sphere.
  72109. * @param force The force to dispose from the gravitational field event
  72110. */
  72111. dispose(force?: boolean): void;
  72112. private _tick;
  72113. }
  72114. /**
  72115. * Represents a physics updraft event
  72116. */
  72117. class PhysicsUpdraftEvent {
  72118. private _scene;
  72119. private _origin;
  72120. private _options;
  72121. private _physicsEngine;
  72122. private _originTop;
  72123. private _originDirection;
  72124. private _tickCallback;
  72125. private _cylinder;
  72126. private _cylinderPosition;
  72127. private _dataFetched;
  72128. /**
  72129. * Initializes the physics updraft event
  72130. * @param _scene BabylonJS scene
  72131. * @param _origin The origin position of the updraft
  72132. * @param _options The options for the updraft event
  72133. */
  72134. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72135. /**
  72136. * Returns the data related to the updraft event (cylinder).
  72137. * @returns A physics updraft event
  72138. */
  72139. getData(): PhysicsUpdraftEventData;
  72140. /**
  72141. * Enables the updraft.
  72142. */
  72143. enable(): void;
  72144. /**
  72145. * Disables the updraft.
  72146. */
  72147. disable(): void;
  72148. /**
  72149. * Disposes the cylinder.
  72150. * @param force Specifies if the updraft should be disposed by force
  72151. */
  72152. dispose(force?: boolean): void;
  72153. private getImpostorHitData;
  72154. private _tick;
  72155. /*** Helpers ***/
  72156. private _prepareCylinder;
  72157. private _intersectsWithCylinder;
  72158. }
  72159. /**
  72160. * Represents a physics vortex event
  72161. */
  72162. class PhysicsVortexEvent {
  72163. private _scene;
  72164. private _origin;
  72165. private _options;
  72166. private _physicsEngine;
  72167. private _originTop;
  72168. private _tickCallback;
  72169. private _cylinder;
  72170. private _cylinderPosition;
  72171. private _dataFetched;
  72172. /**
  72173. * Initializes the physics vortex event
  72174. * @param _scene The BabylonJS scene
  72175. * @param _origin The origin position of the vortex
  72176. * @param _options The options for the vortex event
  72177. */
  72178. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72179. /**
  72180. * Returns the data related to the vortex event (cylinder).
  72181. * @returns The physics vortex event data
  72182. */
  72183. getData(): PhysicsVortexEventData;
  72184. /**
  72185. * Enables the vortex.
  72186. */
  72187. enable(): void;
  72188. /**
  72189. * Disables the cortex.
  72190. */
  72191. disable(): void;
  72192. /**
  72193. * Disposes the sphere.
  72194. * @param force
  72195. */
  72196. dispose(force?: boolean): void;
  72197. private getImpostorHitData;
  72198. private _tick;
  72199. /*** Helpers ***/
  72200. private _prepareCylinder;
  72201. private _intersectsWithCylinder;
  72202. }
  72203. /**
  72204. * Options fot the radial explosion event
  72205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72206. */
  72207. export class PhysicsRadialExplosionEventOptions {
  72208. /**
  72209. * The radius of the sphere for the radial explosion.
  72210. */
  72211. radius: number;
  72212. /**
  72213. * The strenth of the explosion.
  72214. */
  72215. strength: number;
  72216. /**
  72217. * The strenght of the force in correspondence to the distance of the affected object
  72218. */
  72219. falloff: PhysicsRadialImpulseFalloff;
  72220. /**
  72221. * Sphere options for the radial explosion.
  72222. */
  72223. sphere: {
  72224. segments: number;
  72225. diameter: number;
  72226. };
  72227. /**
  72228. * Sphere options for the radial explosion.
  72229. */
  72230. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72231. }
  72232. /**
  72233. * Options fot the updraft event
  72234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72235. */
  72236. export class PhysicsUpdraftEventOptions {
  72237. /**
  72238. * The radius of the cylinder for the vortex
  72239. */
  72240. radius: number;
  72241. /**
  72242. * The strenth of the updraft.
  72243. */
  72244. strength: number;
  72245. /**
  72246. * The height of the cylinder for the updraft.
  72247. */
  72248. height: number;
  72249. /**
  72250. * The mode for the the updraft.
  72251. */
  72252. updraftMode: PhysicsUpdraftMode;
  72253. }
  72254. /**
  72255. * Options fot the vortex event
  72256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72257. */
  72258. export class PhysicsVortexEventOptions {
  72259. /**
  72260. * The radius of the cylinder for the vortex
  72261. */
  72262. radius: number;
  72263. /**
  72264. * The strenth of the vortex.
  72265. */
  72266. strength: number;
  72267. /**
  72268. * The height of the cylinder for the vortex.
  72269. */
  72270. height: number;
  72271. /**
  72272. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72273. */
  72274. centripetalForceThreshold: number;
  72275. /**
  72276. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72277. */
  72278. centripetalForceMultiplier: number;
  72279. /**
  72280. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72281. */
  72282. centrifugalForceMultiplier: number;
  72283. /**
  72284. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72285. */
  72286. updraftForceMultiplier: number;
  72287. }
  72288. /**
  72289. * The strenght of the force in correspondence to the distance of the affected object
  72290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72291. */
  72292. export enum PhysicsRadialImpulseFalloff {
  72293. /** Defines that impulse is constant in strength across it's whole radius */
  72294. Constant = 0,
  72295. /** Defines that impulse gets weaker if it's further from the origin */
  72296. Linear = 1
  72297. }
  72298. /**
  72299. * The strength of the force in correspondence to the distance of the affected object
  72300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72301. */
  72302. export enum PhysicsUpdraftMode {
  72303. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72304. Center = 0,
  72305. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72306. Perpendicular = 1
  72307. }
  72308. /**
  72309. * Interface for a physics hit data
  72310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72311. */
  72312. export interface PhysicsHitData {
  72313. /**
  72314. * The force applied at the contact point
  72315. */
  72316. force: Vector3;
  72317. /**
  72318. * The contact point
  72319. */
  72320. contactPoint: Vector3;
  72321. /**
  72322. * The distance from the origin to the contact point
  72323. */
  72324. distanceFromOrigin: number;
  72325. }
  72326. /**
  72327. * Interface for radial explosion event data
  72328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72329. */
  72330. export interface PhysicsRadialExplosionEventData {
  72331. /**
  72332. * A sphere used for the radial explosion event
  72333. */
  72334. sphere: Mesh;
  72335. }
  72336. /**
  72337. * Interface for gravitational field event data
  72338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72339. */
  72340. export interface PhysicsGravitationalFieldEventData {
  72341. /**
  72342. * A sphere mesh used for the gravitational field event
  72343. */
  72344. sphere: Mesh;
  72345. }
  72346. /**
  72347. * Interface for updraft event data
  72348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72349. */
  72350. export interface PhysicsUpdraftEventData {
  72351. /**
  72352. * A cylinder used for the updraft event
  72353. */
  72354. cylinder: Mesh;
  72355. }
  72356. /**
  72357. * Interface for vortex event data
  72358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72359. */
  72360. export interface PhysicsVortexEventData {
  72361. /**
  72362. * A cylinder used for the vortex event
  72363. */
  72364. cylinder: Mesh;
  72365. }
  72366. /**
  72367. * Interface for an affected physics impostor
  72368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72369. */
  72370. export interface PhysicsAffectedImpostorWithData {
  72371. /**
  72372. * The impostor affected by the effect
  72373. */
  72374. impostor: PhysicsImpostor;
  72375. /**
  72376. * The data about the hit/horce from the explosion
  72377. */
  72378. hitData: PhysicsHitData;
  72379. }
  72380. }
  72381. declare module "babylonjs/Physics/Plugins/index" {
  72382. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72383. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72384. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72385. }
  72386. declare module "babylonjs/Physics/index" {
  72387. export * from "babylonjs/Physics/IPhysicsEngine";
  72388. export * from "babylonjs/Physics/physicsEngine";
  72389. export * from "babylonjs/Physics/physicsEngineComponent";
  72390. export * from "babylonjs/Physics/physicsHelper";
  72391. export * from "babylonjs/Physics/physicsImpostor";
  72392. export * from "babylonjs/Physics/physicsJoint";
  72393. export * from "babylonjs/Physics/Plugins/index";
  72394. }
  72395. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72396. /** @hidden */
  72397. export var blackAndWhitePixelShader: {
  72398. name: string;
  72399. shader: string;
  72400. };
  72401. }
  72402. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72404. import { Camera } from "babylonjs/Cameras/camera";
  72405. import { Engine } from "babylonjs/Engines/engine";
  72406. import "babylonjs/Shaders/blackAndWhite.fragment";
  72407. import { Nullable } from "babylonjs/types";
  72408. import { Scene } from "babylonjs/scene";
  72409. /**
  72410. * Post process used to render in black and white
  72411. */
  72412. export class BlackAndWhitePostProcess extends PostProcess {
  72413. /**
  72414. * Linear about to convert he result to black and white (default: 1)
  72415. */
  72416. degree: number;
  72417. /**
  72418. * Gets a string identifying the name of the class
  72419. * @returns "BlackAndWhitePostProcess" string
  72420. */
  72421. getClassName(): string;
  72422. /**
  72423. * Creates a black and white post process
  72424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72425. * @param name The name of the effect.
  72426. * @param options The required width/height ratio to downsize to before computing the render pass.
  72427. * @param camera The camera to apply the render pass to.
  72428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72429. * @param engine The engine which the post process will be applied. (default: current engine)
  72430. * @param reusable If the post process can be reused on the same frame. (default: false)
  72431. */
  72432. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72433. /** @hidden */
  72434. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72435. }
  72436. }
  72437. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72438. import { Nullable } from "babylonjs/types";
  72439. import { Camera } from "babylonjs/Cameras/camera";
  72440. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72441. import { Engine } from "babylonjs/Engines/engine";
  72442. /**
  72443. * This represents a set of one or more post processes in Babylon.
  72444. * A post process can be used to apply a shader to a texture after it is rendered.
  72445. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72446. */
  72447. export class PostProcessRenderEffect {
  72448. private _postProcesses;
  72449. private _getPostProcesses;
  72450. private _singleInstance;
  72451. private _cameras;
  72452. private _indicesForCamera;
  72453. /**
  72454. * Name of the effect
  72455. * @hidden
  72456. */
  72457. _name: string;
  72458. /**
  72459. * Instantiates a post process render effect.
  72460. * A post process can be used to apply a shader to a texture after it is rendered.
  72461. * @param engine The engine the effect is tied to
  72462. * @param name The name of the effect
  72463. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72464. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72465. */
  72466. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72467. /**
  72468. * Checks if all the post processes in the effect are supported.
  72469. */
  72470. get isSupported(): boolean;
  72471. /**
  72472. * Updates the current state of the effect
  72473. * @hidden
  72474. */
  72475. _update(): void;
  72476. /**
  72477. * Attaches the effect on cameras
  72478. * @param cameras The camera to attach to.
  72479. * @hidden
  72480. */
  72481. _attachCameras(cameras: Camera): void;
  72482. /**
  72483. * Attaches the effect on cameras
  72484. * @param cameras The camera to attach to.
  72485. * @hidden
  72486. */
  72487. _attachCameras(cameras: Camera[]): void;
  72488. /**
  72489. * Detaches the effect on cameras
  72490. * @param cameras The camera to detatch from.
  72491. * @hidden
  72492. */
  72493. _detachCameras(cameras: Camera): void;
  72494. /**
  72495. * Detatches the effect on cameras
  72496. * @param cameras The camera to detatch from.
  72497. * @hidden
  72498. */
  72499. _detachCameras(cameras: Camera[]): void;
  72500. /**
  72501. * Enables the effect on given cameras
  72502. * @param cameras The camera to enable.
  72503. * @hidden
  72504. */
  72505. _enable(cameras: Camera): void;
  72506. /**
  72507. * Enables the effect on given cameras
  72508. * @param cameras The camera to enable.
  72509. * @hidden
  72510. */
  72511. _enable(cameras: Nullable<Camera[]>): void;
  72512. /**
  72513. * Disables the effect on the given cameras
  72514. * @param cameras The camera to disable.
  72515. * @hidden
  72516. */
  72517. _disable(cameras: Camera): void;
  72518. /**
  72519. * Disables the effect on the given cameras
  72520. * @param cameras The camera to disable.
  72521. * @hidden
  72522. */
  72523. _disable(cameras: Nullable<Camera[]>): void;
  72524. /**
  72525. * Gets a list of the post processes contained in the effect.
  72526. * @param camera The camera to get the post processes on.
  72527. * @returns The list of the post processes in the effect.
  72528. */
  72529. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72530. }
  72531. }
  72532. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72533. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72534. /** @hidden */
  72535. export var extractHighlightsPixelShader: {
  72536. name: string;
  72537. shader: string;
  72538. };
  72539. }
  72540. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72541. import { Nullable } from "babylonjs/types";
  72542. import { Camera } from "babylonjs/Cameras/camera";
  72543. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72544. import { Engine } from "babylonjs/Engines/engine";
  72545. import "babylonjs/Shaders/extractHighlights.fragment";
  72546. /**
  72547. * 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.
  72548. */
  72549. export class ExtractHighlightsPostProcess extends PostProcess {
  72550. /**
  72551. * The luminance threshold, pixels below this value will be set to black.
  72552. */
  72553. threshold: number;
  72554. /** @hidden */
  72555. _exposure: number;
  72556. /**
  72557. * Post process which has the input texture to be used when performing highlight extraction
  72558. * @hidden
  72559. */
  72560. _inputPostProcess: Nullable<PostProcess>;
  72561. /**
  72562. * Gets a string identifying the name of the class
  72563. * @returns "ExtractHighlightsPostProcess" string
  72564. */
  72565. getClassName(): string;
  72566. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72567. }
  72568. }
  72569. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72570. /** @hidden */
  72571. export var bloomMergePixelShader: {
  72572. name: string;
  72573. shader: string;
  72574. };
  72575. }
  72576. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72577. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72578. import { Nullable } from "babylonjs/types";
  72579. import { Engine } from "babylonjs/Engines/engine";
  72580. import { Camera } from "babylonjs/Cameras/camera";
  72581. import "babylonjs/Shaders/bloomMerge.fragment";
  72582. /**
  72583. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72584. */
  72585. export class BloomMergePostProcess extends PostProcess {
  72586. /** Weight of the bloom to be added to the original input. */
  72587. weight: number;
  72588. /**
  72589. * Gets a string identifying the name of the class
  72590. * @returns "BloomMergePostProcess" string
  72591. */
  72592. getClassName(): string;
  72593. /**
  72594. * Creates a new instance of @see BloomMergePostProcess
  72595. * @param name The name of the effect.
  72596. * @param originalFromInput Post process which's input will be used for the merge.
  72597. * @param blurred Blurred highlights post process which's output will be used.
  72598. * @param weight Weight of the bloom to be added to the original input.
  72599. * @param options The required width/height ratio to downsize to before computing the render pass.
  72600. * @param camera The camera to apply the render pass to.
  72601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72602. * @param engine The engine which the post process will be applied. (default: current engine)
  72603. * @param reusable If the post process can be reused on the same frame. (default: false)
  72604. * @param textureType Type of textures used when performing the post process. (default: 0)
  72605. * @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)
  72606. */
  72607. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72608. /** Weight of the bloom to be added to the original input. */
  72609. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72610. }
  72611. }
  72612. declare module "babylonjs/PostProcesses/bloomEffect" {
  72613. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72614. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72615. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72616. import { Camera } from "babylonjs/Cameras/camera";
  72617. import { Scene } from "babylonjs/scene";
  72618. /**
  72619. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72620. */
  72621. export class BloomEffect extends PostProcessRenderEffect {
  72622. private bloomScale;
  72623. /**
  72624. * @hidden Internal
  72625. */
  72626. _effects: Array<PostProcess>;
  72627. /**
  72628. * @hidden Internal
  72629. */
  72630. _downscale: ExtractHighlightsPostProcess;
  72631. private _blurX;
  72632. private _blurY;
  72633. private _merge;
  72634. /**
  72635. * The luminance threshold to find bright areas of the image to bloom.
  72636. */
  72637. get threshold(): number;
  72638. set threshold(value: number);
  72639. /**
  72640. * The strength of the bloom.
  72641. */
  72642. get weight(): number;
  72643. set weight(value: number);
  72644. /**
  72645. * Specifies the size of the bloom blur kernel, relative to the final output size
  72646. */
  72647. get kernel(): number;
  72648. set kernel(value: number);
  72649. /**
  72650. * Creates a new instance of @see BloomEffect
  72651. * @param scene The scene the effect belongs to.
  72652. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72653. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72654. * @param bloomWeight The the strength of bloom.
  72655. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72656. * @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)
  72657. */
  72658. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72659. /**
  72660. * Disposes each of the internal effects for a given camera.
  72661. * @param camera The camera to dispose the effect on.
  72662. */
  72663. disposeEffects(camera: Camera): void;
  72664. /**
  72665. * @hidden Internal
  72666. */
  72667. _updateEffects(): void;
  72668. /**
  72669. * Internal
  72670. * @returns if all the contained post processes are ready.
  72671. * @hidden
  72672. */
  72673. _isReady(): boolean;
  72674. }
  72675. }
  72676. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72677. /** @hidden */
  72678. export var chromaticAberrationPixelShader: {
  72679. name: string;
  72680. shader: string;
  72681. };
  72682. }
  72683. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72684. import { Vector2 } from "babylonjs/Maths/math.vector";
  72685. import { Nullable } from "babylonjs/types";
  72686. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72687. import { Camera } from "babylonjs/Cameras/camera";
  72688. import { Engine } from "babylonjs/Engines/engine";
  72689. import "babylonjs/Shaders/chromaticAberration.fragment";
  72690. import { Scene } from "babylonjs/scene";
  72691. /**
  72692. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72693. */
  72694. export class ChromaticAberrationPostProcess extends PostProcess {
  72695. /**
  72696. * The amount of seperation of rgb channels (default: 30)
  72697. */
  72698. aberrationAmount: number;
  72699. /**
  72700. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72701. */
  72702. radialIntensity: number;
  72703. /**
  72704. * 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))
  72705. */
  72706. direction: Vector2;
  72707. /**
  72708. * 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))
  72709. */
  72710. centerPosition: Vector2;
  72711. /** The width of the screen to apply the effect on */
  72712. screenWidth: number;
  72713. /** The height of the screen to apply the effect on */
  72714. screenHeight: number;
  72715. /**
  72716. * Gets a string identifying the name of the class
  72717. * @returns "ChromaticAberrationPostProcess" string
  72718. */
  72719. getClassName(): string;
  72720. /**
  72721. * Creates a new instance ChromaticAberrationPostProcess
  72722. * @param name The name of the effect.
  72723. * @param screenWidth The width of the screen to apply the effect on.
  72724. * @param screenHeight The height of the screen to apply the effect on.
  72725. * @param options The required width/height ratio to downsize to before computing the render pass.
  72726. * @param camera The camera to apply the render pass to.
  72727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72728. * @param engine The engine which the post process will be applied. (default: current engine)
  72729. * @param reusable If the post process can be reused on the same frame. (default: false)
  72730. * @param textureType Type of textures used when performing the post process. (default: 0)
  72731. * @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)
  72732. */
  72733. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72734. /** @hidden */
  72735. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  72736. }
  72737. }
  72738. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72739. /** @hidden */
  72740. export var circleOfConfusionPixelShader: {
  72741. name: string;
  72742. shader: string;
  72743. };
  72744. }
  72745. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72746. import { Nullable } from "babylonjs/types";
  72747. import { Engine } from "babylonjs/Engines/engine";
  72748. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72749. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72750. import { Camera } from "babylonjs/Cameras/camera";
  72751. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72752. /**
  72753. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72754. */
  72755. export class CircleOfConfusionPostProcess extends PostProcess {
  72756. /**
  72757. * 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.
  72758. */
  72759. lensSize: number;
  72760. /**
  72761. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72762. */
  72763. fStop: number;
  72764. /**
  72765. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72766. */
  72767. focusDistance: number;
  72768. /**
  72769. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72770. */
  72771. focalLength: number;
  72772. /**
  72773. * Gets a string identifying the name of the class
  72774. * @returns "CircleOfConfusionPostProcess" string
  72775. */
  72776. getClassName(): string;
  72777. private _depthTexture;
  72778. /**
  72779. * Creates a new instance CircleOfConfusionPostProcess
  72780. * @param name The name of the effect.
  72781. * @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.
  72782. * @param options The required width/height ratio to downsize to before computing the render pass.
  72783. * @param camera The camera to apply the render pass to.
  72784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72785. * @param engine The engine which the post process will be applied. (default: current engine)
  72786. * @param reusable If the post process can be reused on the same frame. (default: false)
  72787. * @param textureType Type of textures used when performing the post process. (default: 0)
  72788. * @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)
  72789. */
  72790. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72791. /**
  72792. * 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.
  72793. */
  72794. set depthTexture(value: RenderTargetTexture);
  72795. }
  72796. }
  72797. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72798. /** @hidden */
  72799. export var colorCorrectionPixelShader: {
  72800. name: string;
  72801. shader: string;
  72802. };
  72803. }
  72804. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72805. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72806. import { Engine } from "babylonjs/Engines/engine";
  72807. import { Camera } from "babylonjs/Cameras/camera";
  72808. import "babylonjs/Shaders/colorCorrection.fragment";
  72809. import { Nullable } from "babylonjs/types";
  72810. import { Scene } from "babylonjs/scene";
  72811. /**
  72812. *
  72813. * This post-process allows the modification of rendered colors by using
  72814. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72815. *
  72816. * The object needs to be provided an url to a texture containing the color
  72817. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72818. * Use an image editing software to tweak the LUT to match your needs.
  72819. *
  72820. * For an example of a color LUT, see here:
  72821. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72822. * For explanations on color grading, see here:
  72823. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72824. *
  72825. */
  72826. export class ColorCorrectionPostProcess extends PostProcess {
  72827. private _colorTableTexture;
  72828. /**
  72829. * Gets the color table url used to create the LUT texture
  72830. */
  72831. colorTableUrl: string;
  72832. /**
  72833. * Gets a string identifying the name of the class
  72834. * @returns "ColorCorrectionPostProcess" string
  72835. */
  72836. getClassName(): string;
  72837. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72838. /** @hidden */
  72839. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  72840. }
  72841. }
  72842. declare module "babylonjs/Shaders/convolution.fragment" {
  72843. /** @hidden */
  72844. export var convolutionPixelShader: {
  72845. name: string;
  72846. shader: string;
  72847. };
  72848. }
  72849. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72850. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72851. import { Nullable } from "babylonjs/types";
  72852. import { Camera } from "babylonjs/Cameras/camera";
  72853. import { Engine } from "babylonjs/Engines/engine";
  72854. import "babylonjs/Shaders/convolution.fragment";
  72855. import { Scene } from "babylonjs/scene";
  72856. /**
  72857. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72858. * input texture to perform effects such as edge detection or sharpening
  72859. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72860. */
  72861. export class ConvolutionPostProcess extends PostProcess {
  72862. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72863. kernel: number[];
  72864. /**
  72865. * Gets a string identifying the name of the class
  72866. * @returns "ConvolutionPostProcess" string
  72867. */
  72868. getClassName(): string;
  72869. /**
  72870. * Creates a new instance ConvolutionPostProcess
  72871. * @param name The name of the effect.
  72872. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72873. * @param options The required width/height ratio to downsize to before computing the render pass.
  72874. * @param camera The camera to apply the render pass to.
  72875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72876. * @param engine The engine which the post process will be applied. (default: current engine)
  72877. * @param reusable If the post process can be reused on the same frame. (default: false)
  72878. * @param textureType Type of textures used when performing the post process. (default: 0)
  72879. */
  72880. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72881. /** @hidden */
  72882. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  72883. /**
  72884. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72885. */
  72886. static EdgeDetect0Kernel: number[];
  72887. /**
  72888. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72889. */
  72890. static EdgeDetect1Kernel: number[];
  72891. /**
  72892. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72893. */
  72894. static EdgeDetect2Kernel: number[];
  72895. /**
  72896. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72897. */
  72898. static SharpenKernel: number[];
  72899. /**
  72900. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72901. */
  72902. static EmbossKernel: number[];
  72903. /**
  72904. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72905. */
  72906. static GaussianKernel: number[];
  72907. }
  72908. }
  72909. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72910. import { Nullable } from "babylonjs/types";
  72911. import { Vector2 } from "babylonjs/Maths/math.vector";
  72912. import { Camera } from "babylonjs/Cameras/camera";
  72913. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72914. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72915. import { Engine } from "babylonjs/Engines/engine";
  72916. import { Scene } from "babylonjs/scene";
  72917. /**
  72918. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72919. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72920. * based on samples that have a large difference in distance than the center pixel.
  72921. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72922. */
  72923. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72924. /**
  72925. * The direction the blur should be applied
  72926. */
  72927. direction: Vector2;
  72928. /**
  72929. * Gets a string identifying the name of the class
  72930. * @returns "DepthOfFieldBlurPostProcess" string
  72931. */
  72932. getClassName(): string;
  72933. /**
  72934. * Creates a new instance CircleOfConfusionPostProcess
  72935. * @param name The name of the effect.
  72936. * @param scene The scene the effect belongs to.
  72937. * @param direction The direction the blur should be applied.
  72938. * @param kernel The size of the kernel used to blur.
  72939. * @param options The required width/height ratio to downsize to before computing the render pass.
  72940. * @param camera The camera to apply the render pass to.
  72941. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72942. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72944. * @param engine The engine which the post process will be applied. (default: current engine)
  72945. * @param reusable If the post process can be reused on the same frame. (default: false)
  72946. * @param textureType Type of textures used when performing the post process. (default: 0)
  72947. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  72948. */
  72949. constructor(name: string, 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);
  72950. }
  72951. }
  72952. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72953. /** @hidden */
  72954. export var depthOfFieldMergePixelShader: {
  72955. name: string;
  72956. shader: string;
  72957. };
  72958. }
  72959. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72960. import { Nullable } from "babylonjs/types";
  72961. import { Camera } from "babylonjs/Cameras/camera";
  72962. import { Effect } from "babylonjs/Materials/effect";
  72963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72964. import { Engine } from "babylonjs/Engines/engine";
  72965. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72966. /**
  72967. * Options to be set when merging outputs from the default pipeline.
  72968. */
  72969. export class DepthOfFieldMergePostProcessOptions {
  72970. /**
  72971. * The original image to merge on top of
  72972. */
  72973. originalFromInput: PostProcess;
  72974. /**
  72975. * Parameters to perform the merge of the depth of field effect
  72976. */
  72977. depthOfField?: {
  72978. circleOfConfusion: PostProcess;
  72979. blurSteps: Array<PostProcess>;
  72980. };
  72981. /**
  72982. * Parameters to perform the merge of bloom effect
  72983. */
  72984. bloom?: {
  72985. blurred: PostProcess;
  72986. weight: number;
  72987. };
  72988. }
  72989. /**
  72990. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72991. */
  72992. export class DepthOfFieldMergePostProcess extends PostProcess {
  72993. private blurSteps;
  72994. /**
  72995. * Gets a string identifying the name of the class
  72996. * @returns "DepthOfFieldMergePostProcess" string
  72997. */
  72998. getClassName(): string;
  72999. /**
  73000. * Creates a new instance of DepthOfFieldMergePostProcess
  73001. * @param name The name of the effect.
  73002. * @param originalFromInput Post process which's input will be used for the merge.
  73003. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73004. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73005. * @param options The required width/height ratio to downsize to before computing the render pass.
  73006. * @param camera The camera to apply the render pass to.
  73007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73008. * @param engine The engine which the post process will be applied. (default: current engine)
  73009. * @param reusable If the post process can be reused on the same frame. (default: false)
  73010. * @param textureType Type of textures used when performing the post process. (default: 0)
  73011. * @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)
  73012. */
  73013. 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);
  73014. /**
  73015. * Updates the effect with the current post process compile time values and recompiles the shader.
  73016. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73017. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73018. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73019. * @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
  73020. * @param onCompiled Called when the shader has been compiled.
  73021. * @param onError Called if there is an error when compiling a shader.
  73022. */
  73023. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73024. }
  73025. }
  73026. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73027. import { Nullable } from "babylonjs/types";
  73028. import { Camera } from "babylonjs/Cameras/camera";
  73029. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73030. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73031. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73032. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73033. import { Scene } from "babylonjs/scene";
  73034. /**
  73035. * Specifies the level of max blur that should be applied when using the depth of field effect
  73036. */
  73037. export enum DepthOfFieldEffectBlurLevel {
  73038. /**
  73039. * Subtle blur
  73040. */
  73041. Low = 0,
  73042. /**
  73043. * Medium blur
  73044. */
  73045. Medium = 1,
  73046. /**
  73047. * Large blur
  73048. */
  73049. High = 2
  73050. }
  73051. /**
  73052. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73053. */
  73054. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73055. private _circleOfConfusion;
  73056. /**
  73057. * @hidden Internal, blurs from high to low
  73058. */
  73059. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73060. private _depthOfFieldBlurY;
  73061. private _dofMerge;
  73062. /**
  73063. * @hidden Internal post processes in depth of field effect
  73064. */
  73065. _effects: Array<PostProcess>;
  73066. /**
  73067. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73068. */
  73069. set focalLength(value: number);
  73070. get focalLength(): number;
  73071. /**
  73072. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73073. */
  73074. set fStop(value: number);
  73075. get fStop(): number;
  73076. /**
  73077. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73078. */
  73079. set focusDistance(value: number);
  73080. get focusDistance(): number;
  73081. /**
  73082. * 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.
  73083. */
  73084. set lensSize(value: number);
  73085. get lensSize(): number;
  73086. /**
  73087. * Creates a new instance DepthOfFieldEffect
  73088. * @param scene The scene the effect belongs to.
  73089. * @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.
  73090. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73091. * @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)
  73092. */
  73093. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73094. /**
  73095. * Get the current class name of the current effet
  73096. * @returns "DepthOfFieldEffect"
  73097. */
  73098. getClassName(): string;
  73099. /**
  73100. * 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.
  73101. */
  73102. set depthTexture(value: RenderTargetTexture);
  73103. /**
  73104. * Disposes each of the internal effects for a given camera.
  73105. * @param camera The camera to dispose the effect on.
  73106. */
  73107. disposeEffects(camera: Camera): void;
  73108. /**
  73109. * @hidden Internal
  73110. */
  73111. _updateEffects(): void;
  73112. /**
  73113. * Internal
  73114. * @returns if all the contained post processes are ready.
  73115. * @hidden
  73116. */
  73117. _isReady(): boolean;
  73118. }
  73119. }
  73120. declare module "babylonjs/Shaders/displayPass.fragment" {
  73121. /** @hidden */
  73122. export var displayPassPixelShader: {
  73123. name: string;
  73124. shader: string;
  73125. };
  73126. }
  73127. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73128. import { Nullable } from "babylonjs/types";
  73129. import { Camera } from "babylonjs/Cameras/camera";
  73130. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73131. import { Engine } from "babylonjs/Engines/engine";
  73132. import "babylonjs/Shaders/displayPass.fragment";
  73133. import { Scene } from "babylonjs/scene";
  73134. /**
  73135. * DisplayPassPostProcess which produces an output the same as it's input
  73136. */
  73137. export class DisplayPassPostProcess extends PostProcess {
  73138. /**
  73139. * Gets a string identifying the name of the class
  73140. * @returns "DisplayPassPostProcess" string
  73141. */
  73142. getClassName(): string;
  73143. /**
  73144. * Creates the DisplayPassPostProcess
  73145. * @param name The name of the effect.
  73146. * @param options The required width/height ratio to downsize to before computing the render pass.
  73147. * @param camera The camera to apply the render pass to.
  73148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73149. * @param engine The engine which the post process will be applied. (default: current engine)
  73150. * @param reusable If the post process can be reused on the same frame. (default: false)
  73151. */
  73152. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73153. /** @hidden */
  73154. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73155. }
  73156. }
  73157. declare module "babylonjs/Shaders/filter.fragment" {
  73158. /** @hidden */
  73159. export var filterPixelShader: {
  73160. name: string;
  73161. shader: string;
  73162. };
  73163. }
  73164. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73165. import { Nullable } from "babylonjs/types";
  73166. import { Matrix } from "babylonjs/Maths/math.vector";
  73167. import { Camera } from "babylonjs/Cameras/camera";
  73168. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73169. import { Engine } from "babylonjs/Engines/engine";
  73170. import "babylonjs/Shaders/filter.fragment";
  73171. import { Scene } from "babylonjs/scene";
  73172. /**
  73173. * Applies a kernel filter to the image
  73174. */
  73175. export class FilterPostProcess extends PostProcess {
  73176. /** The matrix to be applied to the image */
  73177. kernelMatrix: Matrix;
  73178. /**
  73179. * Gets a string identifying the name of the class
  73180. * @returns "FilterPostProcess" string
  73181. */
  73182. getClassName(): string;
  73183. /**
  73184. *
  73185. * @param name The name of the effect.
  73186. * @param kernelMatrix The matrix to be applied to the image
  73187. * @param options The required width/height ratio to downsize to before computing the render pass.
  73188. * @param camera The camera to apply the render pass to.
  73189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73190. * @param engine The engine which the post process will be applied. (default: current engine)
  73191. * @param reusable If the post process can be reused on the same frame. (default: false)
  73192. */
  73193. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73194. /** @hidden */
  73195. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73196. }
  73197. }
  73198. declare module "babylonjs/Shaders/fxaa.fragment" {
  73199. /** @hidden */
  73200. export var fxaaPixelShader: {
  73201. name: string;
  73202. shader: string;
  73203. };
  73204. }
  73205. declare module "babylonjs/Shaders/fxaa.vertex" {
  73206. /** @hidden */
  73207. export var fxaaVertexShader: {
  73208. name: string;
  73209. shader: string;
  73210. };
  73211. }
  73212. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73213. import { Nullable } from "babylonjs/types";
  73214. import { Camera } from "babylonjs/Cameras/camera";
  73215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73216. import { Engine } from "babylonjs/Engines/engine";
  73217. import "babylonjs/Shaders/fxaa.fragment";
  73218. import "babylonjs/Shaders/fxaa.vertex";
  73219. import { Scene } from "babylonjs/scene";
  73220. /**
  73221. * Fxaa post process
  73222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73223. */
  73224. export class FxaaPostProcess extends PostProcess {
  73225. /**
  73226. * Gets a string identifying the name of the class
  73227. * @returns "FxaaPostProcess" string
  73228. */
  73229. getClassName(): string;
  73230. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73231. private _getDefines;
  73232. /** @hidden */
  73233. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73234. }
  73235. }
  73236. declare module "babylonjs/Shaders/grain.fragment" {
  73237. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73238. /** @hidden */
  73239. export var grainPixelShader: {
  73240. name: string;
  73241. shader: string;
  73242. };
  73243. }
  73244. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73245. import { Nullable } from "babylonjs/types";
  73246. import { Camera } from "babylonjs/Cameras/camera";
  73247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73248. import { Engine } from "babylonjs/Engines/engine";
  73249. import "babylonjs/Shaders/grain.fragment";
  73250. import { Scene } from "babylonjs/scene";
  73251. /**
  73252. * The GrainPostProcess adds noise to the image at mid luminance levels
  73253. */
  73254. export class GrainPostProcess extends PostProcess {
  73255. /**
  73256. * The intensity of the grain added (default: 30)
  73257. */
  73258. intensity: number;
  73259. /**
  73260. * If the grain should be randomized on every frame
  73261. */
  73262. animated: boolean;
  73263. /**
  73264. * Gets a string identifying the name of the class
  73265. * @returns "GrainPostProcess" string
  73266. */
  73267. getClassName(): string;
  73268. /**
  73269. * Creates a new instance of @see GrainPostProcess
  73270. * @param name The name of the effect.
  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 samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73274. * @param engine The engine which the post process will be applied. (default: current engine)
  73275. * @param reusable If the post process can be reused on the same frame. (default: false)
  73276. * @param textureType Type of textures used when performing the post process. (default: 0)
  73277. * @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)
  73278. */
  73279. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73280. /** @hidden */
  73281. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73282. }
  73283. }
  73284. declare module "babylonjs/Shaders/highlights.fragment" {
  73285. /** @hidden */
  73286. export var highlightsPixelShader: {
  73287. name: string;
  73288. shader: string;
  73289. };
  73290. }
  73291. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73292. import { Nullable } from "babylonjs/types";
  73293. import { Camera } from "babylonjs/Cameras/camera";
  73294. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73295. import { Engine } from "babylonjs/Engines/engine";
  73296. import "babylonjs/Shaders/highlights.fragment";
  73297. /**
  73298. * Extracts highlights from the image
  73299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73300. */
  73301. export class HighlightsPostProcess extends PostProcess {
  73302. /**
  73303. * Gets a string identifying the name of the class
  73304. * @returns "HighlightsPostProcess" string
  73305. */
  73306. getClassName(): string;
  73307. /**
  73308. * Extracts highlights from the image
  73309. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73310. * @param name The name of the effect.
  73311. * @param options The required width/height ratio to downsize to before computing the render pass.
  73312. * @param camera The camera to apply the render pass to.
  73313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73314. * @param engine The engine which the post process will be applied. (default: current engine)
  73315. * @param reusable If the post process can be reused on the same frame. (default: false)
  73316. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73317. */
  73318. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73319. }
  73320. }
  73321. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73322. /** @hidden */
  73323. export var mrtFragmentDeclaration: {
  73324. name: string;
  73325. shader: string;
  73326. };
  73327. }
  73328. declare module "babylonjs/Shaders/geometry.fragment" {
  73329. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73330. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73331. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73332. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73333. /** @hidden */
  73334. export var geometryPixelShader: {
  73335. name: string;
  73336. shader: string;
  73337. };
  73338. }
  73339. declare module "babylonjs/Shaders/geometry.vertex" {
  73340. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73341. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73343. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73344. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73345. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73346. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73347. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73348. /** @hidden */
  73349. export var geometryVertexShader: {
  73350. name: string;
  73351. shader: string;
  73352. };
  73353. }
  73354. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73355. import { Matrix } from "babylonjs/Maths/math.vector";
  73356. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73357. import { Mesh } from "babylonjs/Meshes/mesh";
  73358. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73359. import { Effect } from "babylonjs/Materials/effect";
  73360. import { Scene } from "babylonjs/scene";
  73361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73362. import "babylonjs/Shaders/geometry.fragment";
  73363. import "babylonjs/Shaders/geometry.vertex";
  73364. /** @hidden */
  73365. interface ISavedTransformationMatrix {
  73366. world: Matrix;
  73367. viewProjection: Matrix;
  73368. }
  73369. /**
  73370. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73371. */
  73372. export class GeometryBufferRenderer {
  73373. /**
  73374. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73375. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73376. */
  73377. static readonly POSITION_TEXTURE_TYPE: number;
  73378. /**
  73379. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73380. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73381. */
  73382. static readonly VELOCITY_TEXTURE_TYPE: number;
  73383. /**
  73384. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73385. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73386. */
  73387. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73388. /**
  73389. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73390. * in order to compute objects velocities when enableVelocity is set to "true"
  73391. * @hidden
  73392. */
  73393. _previousTransformationMatrices: {
  73394. [index: number]: ISavedTransformationMatrix;
  73395. };
  73396. /**
  73397. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73398. * in order to compute objects velocities when enableVelocity is set to "true"
  73399. * @hidden
  73400. */
  73401. _previousBonesTransformationMatrices: {
  73402. [index: number]: Float32Array;
  73403. };
  73404. /**
  73405. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73406. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73407. */
  73408. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73409. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73410. renderTransparentMeshes: boolean;
  73411. private _scene;
  73412. private _resizeObserver;
  73413. private _multiRenderTarget;
  73414. private _ratio;
  73415. private _enablePosition;
  73416. private _enableVelocity;
  73417. private _enableReflectivity;
  73418. private _positionIndex;
  73419. private _velocityIndex;
  73420. private _reflectivityIndex;
  73421. protected _effect: Effect;
  73422. protected _cachedDefines: string;
  73423. /**
  73424. * Set the render list (meshes to be rendered) used in the G buffer.
  73425. */
  73426. set renderList(meshes: Mesh[]);
  73427. /**
  73428. * Gets wether or not G buffer are supported by the running hardware.
  73429. * This requires draw buffer supports
  73430. */
  73431. get isSupported(): boolean;
  73432. /**
  73433. * Returns the index of the given texture type in the G-Buffer textures array
  73434. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73435. * @returns the index of the given texture type in the G-Buffer textures array
  73436. */
  73437. getTextureIndex(textureType: number): number;
  73438. /**
  73439. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73440. */
  73441. get enablePosition(): boolean;
  73442. /**
  73443. * Sets whether or not objects positions are enabled for the G buffer.
  73444. */
  73445. set enablePosition(enable: boolean);
  73446. /**
  73447. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73448. */
  73449. get enableVelocity(): boolean;
  73450. /**
  73451. * Sets wether or not objects velocities are enabled for the G buffer.
  73452. */
  73453. set enableVelocity(enable: boolean);
  73454. /**
  73455. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73456. */
  73457. get enableReflectivity(): boolean;
  73458. /**
  73459. * Sets wether or not objects roughness are enabled for the G buffer.
  73460. */
  73461. set enableReflectivity(enable: boolean);
  73462. /**
  73463. * Gets the scene associated with the buffer.
  73464. */
  73465. get scene(): Scene;
  73466. /**
  73467. * Gets the ratio used by the buffer during its creation.
  73468. * How big is the buffer related to the main canvas.
  73469. */
  73470. get ratio(): number;
  73471. /** @hidden */
  73472. static _SceneComponentInitialization: (scene: Scene) => void;
  73473. /**
  73474. * Creates a new G Buffer for the scene
  73475. * @param scene The scene the buffer belongs to
  73476. * @param ratio How big is the buffer related to the main canvas.
  73477. */
  73478. constructor(scene: Scene, ratio?: number);
  73479. /**
  73480. * Checks wether everything is ready to render a submesh to the G buffer.
  73481. * @param subMesh the submesh to check readiness for
  73482. * @param useInstances is the mesh drawn using instance or not
  73483. * @returns true if ready otherwise false
  73484. */
  73485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73486. /**
  73487. * Gets the current underlying G Buffer.
  73488. * @returns the buffer
  73489. */
  73490. getGBuffer(): MultiRenderTarget;
  73491. /**
  73492. * Gets the number of samples used to render the buffer (anti aliasing).
  73493. */
  73494. get samples(): number;
  73495. /**
  73496. * Sets the number of samples used to render the buffer (anti aliasing).
  73497. */
  73498. set samples(value: number);
  73499. /**
  73500. * Disposes the renderer and frees up associated resources.
  73501. */
  73502. dispose(): void;
  73503. protected _createRenderTargets(): void;
  73504. private _copyBonesTransformationMatrices;
  73505. }
  73506. }
  73507. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73508. import { Nullable } from "babylonjs/types";
  73509. import { Scene } from "babylonjs/scene";
  73510. import { ISceneComponent } from "babylonjs/sceneComponent";
  73511. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73512. module "babylonjs/scene" {
  73513. interface Scene {
  73514. /** @hidden (Backing field) */
  73515. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73516. /**
  73517. * Gets or Sets the current geometry buffer associated to the scene.
  73518. */
  73519. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73520. /**
  73521. * Enables a GeometryBufferRender and associates it with the scene
  73522. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73523. * @returns the GeometryBufferRenderer
  73524. */
  73525. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73526. /**
  73527. * Disables the GeometryBufferRender associated with the scene
  73528. */
  73529. disableGeometryBufferRenderer(): void;
  73530. }
  73531. }
  73532. /**
  73533. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73534. * in several rendering techniques.
  73535. */
  73536. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73537. /**
  73538. * The component name helpful to identify the component in the list of scene components.
  73539. */
  73540. readonly name: string;
  73541. /**
  73542. * The scene the component belongs to.
  73543. */
  73544. scene: Scene;
  73545. /**
  73546. * Creates a new instance of the component for the given scene
  73547. * @param scene Defines the scene to register the component in
  73548. */
  73549. constructor(scene: Scene);
  73550. /**
  73551. * Registers the component in a given scene
  73552. */
  73553. register(): void;
  73554. /**
  73555. * Rebuilds the elements related to this component in case of
  73556. * context lost for instance.
  73557. */
  73558. rebuild(): void;
  73559. /**
  73560. * Disposes the component and the associated ressources
  73561. */
  73562. dispose(): void;
  73563. private _gatherRenderTargets;
  73564. }
  73565. }
  73566. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73567. /** @hidden */
  73568. export var motionBlurPixelShader: {
  73569. name: string;
  73570. shader: string;
  73571. };
  73572. }
  73573. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73574. import { Nullable } from "babylonjs/types";
  73575. import { Camera } from "babylonjs/Cameras/camera";
  73576. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73578. import "babylonjs/Animations/animatable";
  73579. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73580. import "babylonjs/Shaders/motionBlur.fragment";
  73581. import { Engine } from "babylonjs/Engines/engine";
  73582. import { Scene } from "babylonjs/scene";
  73583. /**
  73584. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73585. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73586. * As an example, all you have to do is to create the post-process:
  73587. * var mb = new BABYLON.MotionBlurPostProcess(
  73588. * 'mb', // The name of the effect.
  73589. * scene, // The scene containing the objects to blur according to their velocity.
  73590. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73591. * camera // The camera to apply the render pass to.
  73592. * );
  73593. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73594. */
  73595. export class MotionBlurPostProcess extends PostProcess {
  73596. /**
  73597. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73598. */
  73599. motionStrength: number;
  73600. /**
  73601. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73602. */
  73603. get motionBlurSamples(): number;
  73604. /**
  73605. * Sets the number of iterations to be used for motion blur quality
  73606. */
  73607. set motionBlurSamples(samples: number);
  73608. private _motionBlurSamples;
  73609. private _geometryBufferRenderer;
  73610. /**
  73611. * Gets a string identifying the name of the class
  73612. * @returns "MotionBlurPostProcess" string
  73613. */
  73614. getClassName(): string;
  73615. /**
  73616. * Creates a new instance MotionBlurPostProcess
  73617. * @param name The name of the effect.
  73618. * @param scene The scene containing the objects to blur according to their velocity.
  73619. * @param options The required width/height ratio to downsize to before computing the render pass.
  73620. * @param camera The camera to apply the render pass to.
  73621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73622. * @param engine The engine which the post process will be applied. (default: current engine)
  73623. * @param reusable If the post process can be reused on the same frame. (default: false)
  73624. * @param textureType Type of textures used when performing the post process. (default: 0)
  73625. * @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)
  73626. */
  73627. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73628. /**
  73629. * Excludes the given skinned mesh from computing bones velocities.
  73630. * 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.
  73631. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73632. */
  73633. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73634. /**
  73635. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73636. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73637. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73638. */
  73639. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73640. /**
  73641. * Disposes the post process.
  73642. * @param camera The camera to dispose the post process on.
  73643. */
  73644. dispose(camera?: Camera): void;
  73645. /** @hidden */
  73646. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73647. }
  73648. }
  73649. declare module "babylonjs/Shaders/refraction.fragment" {
  73650. /** @hidden */
  73651. export var refractionPixelShader: {
  73652. name: string;
  73653. shader: string;
  73654. };
  73655. }
  73656. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73657. import { Color3 } from "babylonjs/Maths/math.color";
  73658. import { Camera } from "babylonjs/Cameras/camera";
  73659. import { Texture } from "babylonjs/Materials/Textures/texture";
  73660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73661. import { Engine } from "babylonjs/Engines/engine";
  73662. import "babylonjs/Shaders/refraction.fragment";
  73663. import { Scene } from "babylonjs/scene";
  73664. /**
  73665. * Post process which applies a refractin texture
  73666. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73667. */
  73668. export class RefractionPostProcess extends PostProcess {
  73669. private _refTexture;
  73670. private _ownRefractionTexture;
  73671. /** the base color of the refraction (used to taint the rendering) */
  73672. color: Color3;
  73673. /** simulated refraction depth */
  73674. depth: number;
  73675. /** the coefficient of the base color (0 to remove base color tainting) */
  73676. colorLevel: number;
  73677. /** Gets the url used to load the refraction texture */
  73678. refractionTextureUrl: string;
  73679. /**
  73680. * Gets or sets the refraction texture
  73681. * Please note that you are responsible for disposing the texture if you set it manually
  73682. */
  73683. get refractionTexture(): Texture;
  73684. set refractionTexture(value: Texture);
  73685. /**
  73686. * Gets a string identifying the name of the class
  73687. * @returns "RefractionPostProcess" string
  73688. */
  73689. getClassName(): string;
  73690. /**
  73691. * Initializes the RefractionPostProcess
  73692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73693. * @param name The name of the effect.
  73694. * @param refractionTextureUrl Url of the refraction texture to use
  73695. * @param color the base color of the refraction (used to taint the rendering)
  73696. * @param depth simulated refraction depth
  73697. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73698. * @param camera The camera to apply the render pass to.
  73699. * @param options The required width/height ratio to downsize to before computing the render pass.
  73700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73701. * @param engine The engine which the post process will be applied. (default: current engine)
  73702. * @param reusable If the post process can be reused on the same frame. (default: false)
  73703. */
  73704. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73705. /**
  73706. * Disposes of the post process
  73707. * @param camera Camera to dispose post process on
  73708. */
  73709. dispose(camera: Camera): void;
  73710. /** @hidden */
  73711. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73712. }
  73713. }
  73714. declare module "babylonjs/Shaders/sharpen.fragment" {
  73715. /** @hidden */
  73716. export var sharpenPixelShader: {
  73717. name: string;
  73718. shader: string;
  73719. };
  73720. }
  73721. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73722. import { Nullable } from "babylonjs/types";
  73723. import { Camera } from "babylonjs/Cameras/camera";
  73724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73725. import "babylonjs/Shaders/sharpen.fragment";
  73726. import { Engine } from "babylonjs/Engines/engine";
  73727. import { Scene } from "babylonjs/scene";
  73728. /**
  73729. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73730. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73731. */
  73732. export class SharpenPostProcess extends PostProcess {
  73733. /**
  73734. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73735. */
  73736. colorAmount: number;
  73737. /**
  73738. * How much sharpness should be applied (default: 0.3)
  73739. */
  73740. edgeAmount: number;
  73741. /**
  73742. * Gets a string identifying the name of the class
  73743. * @returns "SharpenPostProcess" string
  73744. */
  73745. getClassName(): string;
  73746. /**
  73747. * Creates a new instance ConvolutionPostProcess
  73748. * @param name The name of the effect.
  73749. * @param options The required width/height ratio to downsize to before computing the render pass.
  73750. * @param camera The camera to apply the render pass to.
  73751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73752. * @param engine The engine which the post process will be applied. (default: current engine)
  73753. * @param reusable If the post process can be reused on the same frame. (default: false)
  73754. * @param textureType Type of textures used when performing the post process. (default: 0)
  73755. * @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)
  73756. */
  73757. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73758. /** @hidden */
  73759. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  73760. }
  73761. }
  73762. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73763. import { Nullable } from "babylonjs/types";
  73764. import { Camera } from "babylonjs/Cameras/camera";
  73765. import { Engine } from "babylonjs/Engines/engine";
  73766. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73767. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73768. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73769. /**
  73770. * PostProcessRenderPipeline
  73771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73772. */
  73773. export class PostProcessRenderPipeline {
  73774. private engine;
  73775. private _renderEffects;
  73776. private _renderEffectsForIsolatedPass;
  73777. /**
  73778. * List of inspectable custom properties (used by the Inspector)
  73779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73780. */
  73781. inspectableCustomProperties: IInspectable[];
  73782. /**
  73783. * @hidden
  73784. */
  73785. protected _cameras: Camera[];
  73786. /** @hidden */
  73787. _name: string;
  73788. /**
  73789. * Gets pipeline name
  73790. */
  73791. get name(): string;
  73792. /** Gets the list of attached cameras */
  73793. get cameras(): Camera[];
  73794. /**
  73795. * Initializes a PostProcessRenderPipeline
  73796. * @param engine engine to add the pipeline to
  73797. * @param name name of the pipeline
  73798. */
  73799. constructor(engine: Engine, name: string);
  73800. /**
  73801. * Gets the class name
  73802. * @returns "PostProcessRenderPipeline"
  73803. */
  73804. getClassName(): string;
  73805. /**
  73806. * If all the render effects in the pipeline are supported
  73807. */
  73808. get isSupported(): boolean;
  73809. /**
  73810. * Adds an effect to the pipeline
  73811. * @param renderEffect the effect to add
  73812. */
  73813. addEffect(renderEffect: PostProcessRenderEffect): void;
  73814. /** @hidden */
  73815. _rebuild(): void;
  73816. /** @hidden */
  73817. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73818. /** @hidden */
  73819. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73820. /** @hidden */
  73821. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73822. /** @hidden */
  73823. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73824. /** @hidden */
  73825. _attachCameras(cameras: Camera, unique: boolean): void;
  73826. /** @hidden */
  73827. _attachCameras(cameras: Camera[], unique: boolean): void;
  73828. /** @hidden */
  73829. _detachCameras(cameras: Camera): void;
  73830. /** @hidden */
  73831. _detachCameras(cameras: Nullable<Camera[]>): void;
  73832. /** @hidden */
  73833. _update(): void;
  73834. /** @hidden */
  73835. _reset(): void;
  73836. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73837. /**
  73838. * Sets the required values to the prepass renderer.
  73839. * @param prePassRenderer defines the prepass renderer to setup.
  73840. * @returns true if the pre pass is needed.
  73841. */
  73842. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73843. /**
  73844. * Disposes of the pipeline
  73845. */
  73846. dispose(): void;
  73847. }
  73848. }
  73849. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73850. import { Camera } from "babylonjs/Cameras/camera";
  73851. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73852. /**
  73853. * PostProcessRenderPipelineManager class
  73854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73855. */
  73856. export class PostProcessRenderPipelineManager {
  73857. private _renderPipelines;
  73858. /**
  73859. * Initializes a PostProcessRenderPipelineManager
  73860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73861. */
  73862. constructor();
  73863. /**
  73864. * Gets the list of supported render pipelines
  73865. */
  73866. get supportedPipelines(): PostProcessRenderPipeline[];
  73867. /**
  73868. * Adds a pipeline to the manager
  73869. * @param renderPipeline The pipeline to add
  73870. */
  73871. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73872. /**
  73873. * Attaches a camera to the pipeline
  73874. * @param renderPipelineName The name of the pipeline to attach to
  73875. * @param cameras the camera to attach
  73876. * @param unique if the camera can be attached multiple times to the pipeline
  73877. */
  73878. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73879. /**
  73880. * Detaches a camera from the pipeline
  73881. * @param renderPipelineName The name of the pipeline to detach from
  73882. * @param cameras the camera to detach
  73883. */
  73884. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73885. /**
  73886. * Enables an effect by name on a pipeline
  73887. * @param renderPipelineName the name of the pipeline to enable the effect in
  73888. * @param renderEffectName the name of the effect to enable
  73889. * @param cameras the cameras that the effect should be enabled on
  73890. */
  73891. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73892. /**
  73893. * Disables an effect by name on a pipeline
  73894. * @param renderPipelineName the name of the pipeline to disable the effect in
  73895. * @param renderEffectName the name of the effect to disable
  73896. * @param cameras the cameras that the effect should be disabled on
  73897. */
  73898. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73899. /**
  73900. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73901. */
  73902. update(): void;
  73903. /** @hidden */
  73904. _rebuild(): void;
  73905. /**
  73906. * Disposes of the manager and pipelines
  73907. */
  73908. dispose(): void;
  73909. }
  73910. }
  73911. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73912. import { ISceneComponent } from "babylonjs/sceneComponent";
  73913. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73914. import { Scene } from "babylonjs/scene";
  73915. module "babylonjs/scene" {
  73916. interface Scene {
  73917. /** @hidden (Backing field) */
  73918. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73919. /**
  73920. * Gets the postprocess render pipeline manager
  73921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73922. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73923. */
  73924. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73925. }
  73926. }
  73927. /**
  73928. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73929. */
  73930. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73931. /**
  73932. * The component name helpfull to identify the component in the list of scene components.
  73933. */
  73934. readonly name: string;
  73935. /**
  73936. * The scene the component belongs to.
  73937. */
  73938. scene: Scene;
  73939. /**
  73940. * Creates a new instance of the component for the given scene
  73941. * @param scene Defines the scene to register the component in
  73942. */
  73943. constructor(scene: Scene);
  73944. /**
  73945. * Registers the component in a given scene
  73946. */
  73947. register(): void;
  73948. /**
  73949. * Rebuilds the elements related to this component in case of
  73950. * context lost for instance.
  73951. */
  73952. rebuild(): void;
  73953. /**
  73954. * Disposes the component and the associated ressources
  73955. */
  73956. dispose(): void;
  73957. private _gatherRenderTargets;
  73958. }
  73959. }
  73960. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73961. import { Nullable } from "babylonjs/types";
  73962. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73963. import { Camera } from "babylonjs/Cameras/camera";
  73964. import { IDisposable } from "babylonjs/scene";
  73965. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73966. import { Scene } from "babylonjs/scene";
  73967. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73968. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73969. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73970. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73971. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73972. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73973. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73974. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73975. import { Animation } from "babylonjs/Animations/animation";
  73976. /**
  73977. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73978. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73979. */
  73980. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73981. private _scene;
  73982. private _camerasToBeAttached;
  73983. /**
  73984. * ID of the sharpen post process,
  73985. */
  73986. private readonly SharpenPostProcessId;
  73987. /**
  73988. * @ignore
  73989. * ID of the image processing post process;
  73990. */
  73991. readonly ImageProcessingPostProcessId: string;
  73992. /**
  73993. * @ignore
  73994. * ID of the Fast Approximate Anti-Aliasing post process;
  73995. */
  73996. readonly FxaaPostProcessId: string;
  73997. /**
  73998. * ID of the chromatic aberration post process,
  73999. */
  74000. private readonly ChromaticAberrationPostProcessId;
  74001. /**
  74002. * ID of the grain post process
  74003. */
  74004. private readonly GrainPostProcessId;
  74005. /**
  74006. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74007. */
  74008. sharpen: SharpenPostProcess;
  74009. private _sharpenEffect;
  74010. private bloom;
  74011. /**
  74012. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74013. */
  74014. depthOfField: DepthOfFieldEffect;
  74015. /**
  74016. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74017. */
  74018. fxaa: FxaaPostProcess;
  74019. /**
  74020. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74021. */
  74022. imageProcessing: ImageProcessingPostProcess;
  74023. /**
  74024. * Chromatic aberration post process which will shift rgb colors in the image
  74025. */
  74026. chromaticAberration: ChromaticAberrationPostProcess;
  74027. private _chromaticAberrationEffect;
  74028. /**
  74029. * Grain post process which add noise to the image
  74030. */
  74031. grain: GrainPostProcess;
  74032. private _grainEffect;
  74033. /**
  74034. * Glow post process which adds a glow to emissive areas of the image
  74035. */
  74036. private _glowLayer;
  74037. /**
  74038. * Animations which can be used to tweak settings over a period of time
  74039. */
  74040. animations: Animation[];
  74041. private _imageProcessingConfigurationObserver;
  74042. private _sharpenEnabled;
  74043. private _bloomEnabled;
  74044. private _depthOfFieldEnabled;
  74045. private _depthOfFieldBlurLevel;
  74046. private _fxaaEnabled;
  74047. private _imageProcessingEnabled;
  74048. private _defaultPipelineTextureType;
  74049. private _bloomScale;
  74050. private _chromaticAberrationEnabled;
  74051. private _grainEnabled;
  74052. private _buildAllowed;
  74053. /**
  74054. * Gets active scene
  74055. */
  74056. get scene(): Scene;
  74057. /**
  74058. * Enable or disable the sharpen process from the pipeline
  74059. */
  74060. set sharpenEnabled(enabled: boolean);
  74061. get sharpenEnabled(): boolean;
  74062. private _resizeObserver;
  74063. private _hardwareScaleLevel;
  74064. private _bloomKernel;
  74065. /**
  74066. * Specifies the size of the bloom blur kernel, relative to the final output size
  74067. */
  74068. get bloomKernel(): number;
  74069. set bloomKernel(value: number);
  74070. /**
  74071. * Specifies the weight of the bloom in the final rendering
  74072. */
  74073. private _bloomWeight;
  74074. /**
  74075. * Specifies the luma threshold for the area that will be blurred by the bloom
  74076. */
  74077. private _bloomThreshold;
  74078. private _hdr;
  74079. /**
  74080. * The strength of the bloom.
  74081. */
  74082. set bloomWeight(value: number);
  74083. get bloomWeight(): number;
  74084. /**
  74085. * The strength of the bloom.
  74086. */
  74087. set bloomThreshold(value: number);
  74088. get bloomThreshold(): number;
  74089. /**
  74090. * The scale of the bloom, lower value will provide better performance.
  74091. */
  74092. set bloomScale(value: number);
  74093. get bloomScale(): number;
  74094. /**
  74095. * Enable or disable the bloom from the pipeline
  74096. */
  74097. set bloomEnabled(enabled: boolean);
  74098. get bloomEnabled(): boolean;
  74099. private _rebuildBloom;
  74100. /**
  74101. * If the depth of field is enabled.
  74102. */
  74103. get depthOfFieldEnabled(): boolean;
  74104. set depthOfFieldEnabled(enabled: boolean);
  74105. /**
  74106. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74107. */
  74108. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74109. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74110. /**
  74111. * If the anti aliasing is enabled.
  74112. */
  74113. set fxaaEnabled(enabled: boolean);
  74114. get fxaaEnabled(): boolean;
  74115. private _samples;
  74116. /**
  74117. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74118. */
  74119. set samples(sampleCount: number);
  74120. get samples(): number;
  74121. /**
  74122. * If image processing is enabled.
  74123. */
  74124. set imageProcessingEnabled(enabled: boolean);
  74125. get imageProcessingEnabled(): boolean;
  74126. /**
  74127. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74128. */
  74129. set glowLayerEnabled(enabled: boolean);
  74130. get glowLayerEnabled(): boolean;
  74131. /**
  74132. * Gets the glow layer (or null if not defined)
  74133. */
  74134. get glowLayer(): Nullable<GlowLayer>;
  74135. /**
  74136. * Enable or disable the chromaticAberration process from the pipeline
  74137. */
  74138. set chromaticAberrationEnabled(enabled: boolean);
  74139. get chromaticAberrationEnabled(): boolean;
  74140. /**
  74141. * Enable or disable the grain process from the pipeline
  74142. */
  74143. set grainEnabled(enabled: boolean);
  74144. get grainEnabled(): boolean;
  74145. /**
  74146. * @constructor
  74147. * @param name - The rendering pipeline name (default: "")
  74148. * @param hdr - If high dynamic range textures should be used (default: true)
  74149. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74150. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74151. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74152. */
  74153. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74154. /**
  74155. * Get the class name
  74156. * @returns "DefaultRenderingPipeline"
  74157. */
  74158. getClassName(): string;
  74159. /**
  74160. * Force the compilation of the entire pipeline.
  74161. */
  74162. prepare(): void;
  74163. private _hasCleared;
  74164. private _prevPostProcess;
  74165. private _prevPrevPostProcess;
  74166. private _setAutoClearAndTextureSharing;
  74167. private _depthOfFieldSceneObserver;
  74168. private _buildPipeline;
  74169. private _disposePostProcesses;
  74170. /**
  74171. * Adds a camera to the pipeline
  74172. * @param camera the camera to be added
  74173. */
  74174. addCamera(camera: Camera): void;
  74175. /**
  74176. * Removes a camera from the pipeline
  74177. * @param camera the camera to remove
  74178. */
  74179. removeCamera(camera: Camera): void;
  74180. /**
  74181. * Dispose of the pipeline and stop all post processes
  74182. */
  74183. dispose(): void;
  74184. /**
  74185. * Serialize the rendering pipeline (Used when exporting)
  74186. * @returns the serialized object
  74187. */
  74188. serialize(): any;
  74189. /**
  74190. * Parse the serialized pipeline
  74191. * @param source Source pipeline.
  74192. * @param scene The scene to load the pipeline to.
  74193. * @param rootUrl The URL of the serialized pipeline.
  74194. * @returns An instantiated pipeline from the serialized object.
  74195. */
  74196. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74197. }
  74198. }
  74199. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74200. /** @hidden */
  74201. export var lensHighlightsPixelShader: {
  74202. name: string;
  74203. shader: string;
  74204. };
  74205. }
  74206. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74207. /** @hidden */
  74208. export var depthOfFieldPixelShader: {
  74209. name: string;
  74210. shader: string;
  74211. };
  74212. }
  74213. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74214. import { Camera } from "babylonjs/Cameras/camera";
  74215. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74216. import { Scene } from "babylonjs/scene";
  74217. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74218. import "babylonjs/Shaders/chromaticAberration.fragment";
  74219. import "babylonjs/Shaders/lensHighlights.fragment";
  74220. import "babylonjs/Shaders/depthOfField.fragment";
  74221. /**
  74222. * BABYLON.JS Chromatic Aberration GLSL Shader
  74223. * Author: Olivier Guyot
  74224. * Separates very slightly R, G and B colors on the edges of the screen
  74225. * Inspired by Francois Tarlier & Martins Upitis
  74226. */
  74227. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74228. /**
  74229. * @ignore
  74230. * The chromatic aberration PostProcess id in the pipeline
  74231. */
  74232. LensChromaticAberrationEffect: string;
  74233. /**
  74234. * @ignore
  74235. * The highlights enhancing PostProcess id in the pipeline
  74236. */
  74237. HighlightsEnhancingEffect: string;
  74238. /**
  74239. * @ignore
  74240. * The depth-of-field PostProcess id in the pipeline
  74241. */
  74242. LensDepthOfFieldEffect: string;
  74243. private _scene;
  74244. private _depthTexture;
  74245. private _grainTexture;
  74246. private _chromaticAberrationPostProcess;
  74247. private _highlightsPostProcess;
  74248. private _depthOfFieldPostProcess;
  74249. private _edgeBlur;
  74250. private _grainAmount;
  74251. private _chromaticAberration;
  74252. private _distortion;
  74253. private _highlightsGain;
  74254. private _highlightsThreshold;
  74255. private _dofDistance;
  74256. private _dofAperture;
  74257. private _dofDarken;
  74258. private _dofPentagon;
  74259. private _blurNoise;
  74260. /**
  74261. * @constructor
  74262. *
  74263. * Effect parameters are as follow:
  74264. * {
  74265. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74266. * edge_blur: number; // from 0 to x (1 for realism)
  74267. * distortion: number; // from 0 to x (1 for realism)
  74268. * grain_amount: number; // from 0 to 1
  74269. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74270. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74271. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74272. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74273. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74274. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74275. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74276. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74277. * }
  74278. * Note: if an effect parameter is unset, effect is disabled
  74279. *
  74280. * @param name The rendering pipeline name
  74281. * @param parameters - An object containing all parameters (see above)
  74282. * @param scene The scene linked to this pipeline
  74283. * @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)
  74284. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74285. */
  74286. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74287. /**
  74288. * Get the class name
  74289. * @returns "LensRenderingPipeline"
  74290. */
  74291. getClassName(): string;
  74292. /**
  74293. * Gets associated scene
  74294. */
  74295. get scene(): Scene;
  74296. /**
  74297. * Gets or sets the edge blur
  74298. */
  74299. get edgeBlur(): number;
  74300. set edgeBlur(value: number);
  74301. /**
  74302. * Gets or sets the grain amount
  74303. */
  74304. get grainAmount(): number;
  74305. set grainAmount(value: number);
  74306. /**
  74307. * Gets or sets the chromatic aberration amount
  74308. */
  74309. get chromaticAberration(): number;
  74310. set chromaticAberration(value: number);
  74311. /**
  74312. * Gets or sets the depth of field aperture
  74313. */
  74314. get dofAperture(): number;
  74315. set dofAperture(value: number);
  74316. /**
  74317. * Gets or sets the edge distortion
  74318. */
  74319. get edgeDistortion(): number;
  74320. set edgeDistortion(value: number);
  74321. /**
  74322. * Gets or sets the depth of field distortion
  74323. */
  74324. get dofDistortion(): number;
  74325. set dofDistortion(value: number);
  74326. /**
  74327. * Gets or sets the darken out of focus amount
  74328. */
  74329. get darkenOutOfFocus(): number;
  74330. set darkenOutOfFocus(value: number);
  74331. /**
  74332. * Gets or sets a boolean indicating if blur noise is enabled
  74333. */
  74334. get blurNoise(): boolean;
  74335. set blurNoise(value: boolean);
  74336. /**
  74337. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74338. */
  74339. get pentagonBokeh(): boolean;
  74340. set pentagonBokeh(value: boolean);
  74341. /**
  74342. * Gets or sets the highlight grain amount
  74343. */
  74344. get highlightsGain(): number;
  74345. set highlightsGain(value: number);
  74346. /**
  74347. * Gets or sets the highlight threshold
  74348. */
  74349. get highlightsThreshold(): number;
  74350. set highlightsThreshold(value: number);
  74351. /**
  74352. * Sets the amount of blur at the edges
  74353. * @param amount blur amount
  74354. */
  74355. setEdgeBlur(amount: number): void;
  74356. /**
  74357. * Sets edge blur to 0
  74358. */
  74359. disableEdgeBlur(): void;
  74360. /**
  74361. * Sets the amout of grain
  74362. * @param amount Amount of grain
  74363. */
  74364. setGrainAmount(amount: number): void;
  74365. /**
  74366. * Set grain amount to 0
  74367. */
  74368. disableGrain(): void;
  74369. /**
  74370. * Sets the chromatic aberration amount
  74371. * @param amount amount of chromatic aberration
  74372. */
  74373. setChromaticAberration(amount: number): void;
  74374. /**
  74375. * Sets chromatic aberration amount to 0
  74376. */
  74377. disableChromaticAberration(): void;
  74378. /**
  74379. * Sets the EdgeDistortion amount
  74380. * @param amount amount of EdgeDistortion
  74381. */
  74382. setEdgeDistortion(amount: number): void;
  74383. /**
  74384. * Sets edge distortion to 0
  74385. */
  74386. disableEdgeDistortion(): void;
  74387. /**
  74388. * Sets the FocusDistance amount
  74389. * @param amount amount of FocusDistance
  74390. */
  74391. setFocusDistance(amount: number): void;
  74392. /**
  74393. * Disables depth of field
  74394. */
  74395. disableDepthOfField(): void;
  74396. /**
  74397. * Sets the Aperture amount
  74398. * @param amount amount of Aperture
  74399. */
  74400. setAperture(amount: number): void;
  74401. /**
  74402. * Sets the DarkenOutOfFocus amount
  74403. * @param amount amount of DarkenOutOfFocus
  74404. */
  74405. setDarkenOutOfFocus(amount: number): void;
  74406. private _pentagonBokehIsEnabled;
  74407. /**
  74408. * Creates a pentagon bokeh effect
  74409. */
  74410. enablePentagonBokeh(): void;
  74411. /**
  74412. * Disables the pentagon bokeh effect
  74413. */
  74414. disablePentagonBokeh(): void;
  74415. /**
  74416. * Enables noise blur
  74417. */
  74418. enableNoiseBlur(): void;
  74419. /**
  74420. * Disables noise blur
  74421. */
  74422. disableNoiseBlur(): void;
  74423. /**
  74424. * Sets the HighlightsGain amount
  74425. * @param amount amount of HighlightsGain
  74426. */
  74427. setHighlightsGain(amount: number): void;
  74428. /**
  74429. * Sets the HighlightsThreshold amount
  74430. * @param amount amount of HighlightsThreshold
  74431. */
  74432. setHighlightsThreshold(amount: number): void;
  74433. /**
  74434. * Disables highlights
  74435. */
  74436. disableHighlights(): void;
  74437. /**
  74438. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74439. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74440. */
  74441. dispose(disableDepthRender?: boolean): void;
  74442. private _createChromaticAberrationPostProcess;
  74443. private _createHighlightsPostProcess;
  74444. private _createDepthOfFieldPostProcess;
  74445. private _createGrainTexture;
  74446. }
  74447. }
  74448. declare module "babylonjs/Shaders/ssao2.fragment" {
  74449. /** @hidden */
  74450. export var ssao2PixelShader: {
  74451. name: string;
  74452. shader: string;
  74453. };
  74454. }
  74455. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74456. /** @hidden */
  74457. export var ssaoCombinePixelShader: {
  74458. name: string;
  74459. shader: string;
  74460. };
  74461. }
  74462. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74463. import { Camera } from "babylonjs/Cameras/camera";
  74464. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74465. import { Scene } from "babylonjs/scene";
  74466. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74467. import "babylonjs/Shaders/ssao2.fragment";
  74468. import "babylonjs/Shaders/ssaoCombine.fragment";
  74469. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74470. /**
  74471. * Render pipeline to produce ssao effect
  74472. */
  74473. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74474. /**
  74475. * @ignore
  74476. * The PassPostProcess id in the pipeline that contains the original scene color
  74477. */
  74478. SSAOOriginalSceneColorEffect: string;
  74479. /**
  74480. * @ignore
  74481. * The SSAO PostProcess id in the pipeline
  74482. */
  74483. SSAORenderEffect: string;
  74484. /**
  74485. * @ignore
  74486. * The horizontal blur PostProcess id in the pipeline
  74487. */
  74488. SSAOBlurHRenderEffect: string;
  74489. /**
  74490. * @ignore
  74491. * The vertical blur PostProcess id in the pipeline
  74492. */
  74493. SSAOBlurVRenderEffect: string;
  74494. /**
  74495. * @ignore
  74496. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74497. */
  74498. SSAOCombineRenderEffect: string;
  74499. /**
  74500. * The output strength of the SSAO post-process. Default value is 1.0.
  74501. */
  74502. totalStrength: number;
  74503. /**
  74504. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74505. */
  74506. maxZ: number;
  74507. /**
  74508. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74509. */
  74510. minZAspect: number;
  74511. private _samples;
  74512. /**
  74513. * Number of samples used for the SSAO calculations. Default value is 8
  74514. */
  74515. set samples(n: number);
  74516. get samples(): number;
  74517. private _textureSamples;
  74518. /**
  74519. * Number of samples to use for antialiasing
  74520. */
  74521. set textureSamples(n: number);
  74522. get textureSamples(): number;
  74523. /**
  74524. * Force rendering the geometry through geometry buffer
  74525. */
  74526. private _forceGeometryBuffer;
  74527. /**
  74528. * Ratio object used for SSAO ratio and blur ratio
  74529. */
  74530. private _ratio;
  74531. /**
  74532. * Dynamically generated sphere sampler.
  74533. */
  74534. private _sampleSphere;
  74535. /**
  74536. * Blur filter offsets
  74537. */
  74538. private _samplerOffsets;
  74539. private _expensiveBlur;
  74540. /**
  74541. * If bilateral blur should be used
  74542. */
  74543. set expensiveBlur(b: boolean);
  74544. get expensiveBlur(): boolean;
  74545. /**
  74546. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74547. */
  74548. radius: number;
  74549. /**
  74550. * The base color of the SSAO post-process
  74551. * The final result is "base + ssao" between [0, 1]
  74552. */
  74553. base: number;
  74554. /**
  74555. * Support test.
  74556. */
  74557. static get IsSupported(): boolean;
  74558. private _scene;
  74559. private _randomTexture;
  74560. private _originalColorPostProcess;
  74561. private _ssaoPostProcess;
  74562. private _blurHPostProcess;
  74563. private _blurVPostProcess;
  74564. private _ssaoCombinePostProcess;
  74565. private _prePassRenderer;
  74566. /**
  74567. * Gets active scene
  74568. */
  74569. get scene(): Scene;
  74570. /**
  74571. * @constructor
  74572. * @param name The rendering pipeline name
  74573. * @param scene The scene linked to this pipeline
  74574. * @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 }
  74575. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74576. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74577. */
  74578. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74579. /**
  74580. * Get the class name
  74581. * @returns "SSAO2RenderingPipeline"
  74582. */
  74583. getClassName(): string;
  74584. /**
  74585. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74586. */
  74587. dispose(disableGeometryBufferRenderer?: boolean): void;
  74588. private _createBlurPostProcess;
  74589. /** @hidden */
  74590. _rebuild(): void;
  74591. private _bits;
  74592. private _radicalInverse_VdC;
  74593. private _hammersley;
  74594. private _hemisphereSample_uniform;
  74595. private _generateHemisphere;
  74596. private _getDefinesForSSAO;
  74597. private _createSSAOPostProcess;
  74598. private _createSSAOCombinePostProcess;
  74599. private _createRandomTexture;
  74600. /**
  74601. * Serialize the rendering pipeline (Used when exporting)
  74602. * @returns the serialized object
  74603. */
  74604. serialize(): any;
  74605. /**
  74606. * Parse the serialized pipeline
  74607. * @param source Source pipeline.
  74608. * @param scene The scene to load the pipeline to.
  74609. * @param rootUrl The URL of the serialized pipeline.
  74610. * @returns An instantiated pipeline from the serialized object.
  74611. */
  74612. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74613. /**
  74614. * Sets the required values to the prepass renderer.
  74615. * @param prePassRenderer defines the prepass renderer to setup
  74616. * @returns true if the pre pass is needed.
  74617. */
  74618. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74619. }
  74620. }
  74621. declare module "babylonjs/Shaders/ssao.fragment" {
  74622. /** @hidden */
  74623. export var ssaoPixelShader: {
  74624. name: string;
  74625. shader: string;
  74626. };
  74627. }
  74628. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74629. import { Camera } from "babylonjs/Cameras/camera";
  74630. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74631. import { Scene } from "babylonjs/scene";
  74632. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74633. import "babylonjs/Shaders/ssao.fragment";
  74634. import "babylonjs/Shaders/ssaoCombine.fragment";
  74635. /**
  74636. * Render pipeline to produce ssao effect
  74637. */
  74638. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74639. /**
  74640. * @ignore
  74641. * The PassPostProcess id in the pipeline that contains the original scene color
  74642. */
  74643. SSAOOriginalSceneColorEffect: string;
  74644. /**
  74645. * @ignore
  74646. * The SSAO PostProcess id in the pipeline
  74647. */
  74648. SSAORenderEffect: string;
  74649. /**
  74650. * @ignore
  74651. * The horizontal blur PostProcess id in the pipeline
  74652. */
  74653. SSAOBlurHRenderEffect: string;
  74654. /**
  74655. * @ignore
  74656. * The vertical blur PostProcess id in the pipeline
  74657. */
  74658. SSAOBlurVRenderEffect: string;
  74659. /**
  74660. * @ignore
  74661. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74662. */
  74663. SSAOCombineRenderEffect: string;
  74664. /**
  74665. * The output strength of the SSAO post-process. Default value is 1.0.
  74666. */
  74667. totalStrength: number;
  74668. /**
  74669. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74670. */
  74671. radius: number;
  74672. /**
  74673. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74674. * Must not be equal to fallOff and superior to fallOff.
  74675. * Default value is 0.0075
  74676. */
  74677. area: number;
  74678. /**
  74679. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74680. * Must not be equal to area and inferior to area.
  74681. * Default value is 0.000001
  74682. */
  74683. fallOff: number;
  74684. /**
  74685. * The base color of the SSAO post-process
  74686. * The final result is "base + ssao" between [0, 1]
  74687. */
  74688. base: number;
  74689. private _scene;
  74690. private _depthTexture;
  74691. private _randomTexture;
  74692. private _originalColorPostProcess;
  74693. private _ssaoPostProcess;
  74694. private _blurHPostProcess;
  74695. private _blurVPostProcess;
  74696. private _ssaoCombinePostProcess;
  74697. private _firstUpdate;
  74698. /**
  74699. * Gets active scene
  74700. */
  74701. get scene(): Scene;
  74702. /**
  74703. * @constructor
  74704. * @param name - The rendering pipeline name
  74705. * @param scene - The scene linked to this pipeline
  74706. * @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 }
  74707. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74708. */
  74709. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74710. /**
  74711. * Get the class name
  74712. * @returns "SSAORenderingPipeline"
  74713. */
  74714. getClassName(): string;
  74715. /**
  74716. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74717. */
  74718. dispose(disableDepthRender?: boolean): void;
  74719. private _createBlurPostProcess;
  74720. /** @hidden */
  74721. _rebuild(): void;
  74722. private _createSSAOPostProcess;
  74723. private _createSSAOCombinePostProcess;
  74724. private _createRandomTexture;
  74725. }
  74726. }
  74727. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74728. /** @hidden */
  74729. export var screenSpaceReflectionPixelShader: {
  74730. name: string;
  74731. shader: string;
  74732. };
  74733. }
  74734. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74735. import { Nullable } from "babylonjs/types";
  74736. import { Camera } from "babylonjs/Cameras/camera";
  74737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74738. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74739. import { Engine } from "babylonjs/Engines/engine";
  74740. import { Scene } from "babylonjs/scene";
  74741. /**
  74742. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74743. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74744. */
  74745. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74746. /**
  74747. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74748. */
  74749. threshold: number;
  74750. /**
  74751. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74752. */
  74753. strength: number;
  74754. /**
  74755. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74756. */
  74757. reflectionSpecularFalloffExponent: number;
  74758. /**
  74759. * 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]
  74760. */
  74761. step: number;
  74762. /**
  74763. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74764. */
  74765. roughnessFactor: number;
  74766. private _geometryBufferRenderer;
  74767. private _enableSmoothReflections;
  74768. private _reflectionSamples;
  74769. private _smoothSteps;
  74770. /**
  74771. * Gets a string identifying the name of the class
  74772. * @returns "ScreenSpaceReflectionPostProcess" string
  74773. */
  74774. getClassName(): string;
  74775. /**
  74776. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74777. * @param name The name of the effect.
  74778. * @param scene The scene containing the objects to calculate reflections.
  74779. * @param options The required width/height ratio to downsize to before computing the render pass.
  74780. * @param camera The camera to apply the render pass to.
  74781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74782. * @param engine The engine which the post process will be applied. (default: current engine)
  74783. * @param reusable If the post process can be reused on the same frame. (default: false)
  74784. * @param textureType Type of textures used when performing the post process. (default: 0)
  74785. * @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)
  74786. */
  74787. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74788. /**
  74789. * Gets wether or not smoothing reflections is enabled.
  74790. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74791. */
  74792. get enableSmoothReflections(): boolean;
  74793. /**
  74794. * Sets wether or not smoothing reflections is enabled.
  74795. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74796. */
  74797. set enableSmoothReflections(enabled: boolean);
  74798. /**
  74799. * Gets the number of samples taken while computing reflections. More samples count is high,
  74800. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74801. */
  74802. get reflectionSamples(): number;
  74803. /**
  74804. * Sets the number of samples taken while computing reflections. More samples count is high,
  74805. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74806. */
  74807. set reflectionSamples(samples: number);
  74808. /**
  74809. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74810. * more the post-process will require GPU power and can generate a drop in FPS.
  74811. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74812. */
  74813. get smoothSteps(): number;
  74814. set smoothSteps(steps: number);
  74815. private _updateEffectDefines;
  74816. /** @hidden */
  74817. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  74818. }
  74819. }
  74820. declare module "babylonjs/Shaders/standard.fragment" {
  74821. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74822. /** @hidden */
  74823. export var standardPixelShader: {
  74824. name: string;
  74825. shader: string;
  74826. };
  74827. }
  74828. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74829. import { Nullable } from "babylonjs/types";
  74830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74831. import { Camera } from "babylonjs/Cameras/camera";
  74832. import { Texture } from "babylonjs/Materials/Textures/texture";
  74833. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74834. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74835. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74836. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74837. import { IDisposable } from "babylonjs/scene";
  74838. import { SpotLight } from "babylonjs/Lights/spotLight";
  74839. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74840. import { Scene } from "babylonjs/scene";
  74841. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74842. import { Animation } from "babylonjs/Animations/animation";
  74843. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74844. import "babylonjs/Shaders/standard.fragment";
  74845. /**
  74846. * Standard rendering pipeline
  74847. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74848. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74849. */
  74850. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74851. /**
  74852. * Public members
  74853. */
  74854. /**
  74855. * Post-process which contains the original scene color before the pipeline applies all the effects
  74856. */
  74857. originalPostProcess: Nullable<PostProcess>;
  74858. /**
  74859. * Post-process used to down scale an image x4
  74860. */
  74861. downSampleX4PostProcess: Nullable<PostProcess>;
  74862. /**
  74863. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74864. */
  74865. brightPassPostProcess: Nullable<PostProcess>;
  74866. /**
  74867. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74868. */
  74869. blurHPostProcesses: PostProcess[];
  74870. /**
  74871. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74872. */
  74873. blurVPostProcesses: PostProcess[];
  74874. /**
  74875. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74876. */
  74877. textureAdderPostProcess: Nullable<PostProcess>;
  74878. /**
  74879. * Post-process used to create volumetric lighting effect
  74880. */
  74881. volumetricLightPostProcess: Nullable<PostProcess>;
  74882. /**
  74883. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74884. */
  74885. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74886. /**
  74887. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74888. */
  74889. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74890. /**
  74891. * Post-process used to merge the volumetric light effect and the real scene color
  74892. */
  74893. volumetricLightMergePostProces: Nullable<PostProcess>;
  74894. /**
  74895. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74896. */
  74897. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74898. /**
  74899. * Base post-process used to calculate the average luminance of the final image for HDR
  74900. */
  74901. luminancePostProcess: Nullable<PostProcess>;
  74902. /**
  74903. * Post-processes used to create down sample post-processes in order to get
  74904. * the average luminance of the final image for HDR
  74905. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74906. */
  74907. luminanceDownSamplePostProcesses: PostProcess[];
  74908. /**
  74909. * Post-process used to create a HDR effect (light adaptation)
  74910. */
  74911. hdrPostProcess: Nullable<PostProcess>;
  74912. /**
  74913. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74914. */
  74915. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74916. /**
  74917. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74918. */
  74919. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74920. /**
  74921. * Post-process used to merge the final HDR post-process and the real scene color
  74922. */
  74923. hdrFinalPostProcess: Nullable<PostProcess>;
  74924. /**
  74925. * Post-process used to create a lens flare effect
  74926. */
  74927. lensFlarePostProcess: Nullable<PostProcess>;
  74928. /**
  74929. * Post-process that merges the result of the lens flare post-process and the real scene color
  74930. */
  74931. lensFlareComposePostProcess: Nullable<PostProcess>;
  74932. /**
  74933. * Post-process used to create a motion blur effect
  74934. */
  74935. motionBlurPostProcess: Nullable<PostProcess>;
  74936. /**
  74937. * Post-process used to create a depth of field effect
  74938. */
  74939. depthOfFieldPostProcess: Nullable<PostProcess>;
  74940. /**
  74941. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74942. */
  74943. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74944. /**
  74945. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74946. */
  74947. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74948. /**
  74949. * Represents the brightness threshold in order to configure the illuminated surfaces
  74950. */
  74951. brightThreshold: number;
  74952. /**
  74953. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74954. */
  74955. blurWidth: number;
  74956. /**
  74957. * Sets if the blur for highlighted surfaces must be only horizontal
  74958. */
  74959. horizontalBlur: boolean;
  74960. /**
  74961. * Gets the overall exposure used by the pipeline
  74962. */
  74963. get exposure(): number;
  74964. /**
  74965. * Sets the overall exposure used by the pipeline
  74966. */
  74967. set exposure(value: number);
  74968. /**
  74969. * Texture used typically to simulate "dirty" on camera lens
  74970. */
  74971. lensTexture: Nullable<Texture>;
  74972. /**
  74973. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74974. */
  74975. volumetricLightCoefficient: number;
  74976. /**
  74977. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74978. */
  74979. volumetricLightPower: number;
  74980. /**
  74981. * Used the set the blur intensity to smooth the volumetric lights
  74982. */
  74983. volumetricLightBlurScale: number;
  74984. /**
  74985. * Light (spot or directional) used to generate the volumetric lights rays
  74986. * The source light must have a shadow generate so the pipeline can get its
  74987. * depth map
  74988. */
  74989. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74990. /**
  74991. * For eye adaptation, represents the minimum luminance the eye can see
  74992. */
  74993. hdrMinimumLuminance: number;
  74994. /**
  74995. * For eye adaptation, represents the decrease luminance speed
  74996. */
  74997. hdrDecreaseRate: number;
  74998. /**
  74999. * For eye adaptation, represents the increase luminance speed
  75000. */
  75001. hdrIncreaseRate: number;
  75002. /**
  75003. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75004. */
  75005. get hdrAutoExposure(): boolean;
  75006. /**
  75007. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75008. */
  75009. set hdrAutoExposure(value: boolean);
  75010. /**
  75011. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75012. */
  75013. lensColorTexture: Nullable<Texture>;
  75014. /**
  75015. * The overall strengh for the lens flare effect
  75016. */
  75017. lensFlareStrength: number;
  75018. /**
  75019. * Dispersion coefficient for lens flare ghosts
  75020. */
  75021. lensFlareGhostDispersal: number;
  75022. /**
  75023. * Main lens flare halo width
  75024. */
  75025. lensFlareHaloWidth: number;
  75026. /**
  75027. * Based on the lens distortion effect, defines how much the lens flare result
  75028. * is distorted
  75029. */
  75030. lensFlareDistortionStrength: number;
  75031. /**
  75032. * Configures the blur intensity used for for lens flare (halo)
  75033. */
  75034. lensFlareBlurWidth: number;
  75035. /**
  75036. * Lens star texture must be used to simulate rays on the flares and is available
  75037. * in the documentation
  75038. */
  75039. lensStarTexture: Nullable<Texture>;
  75040. /**
  75041. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75042. * flare effect by taking account of the dirt texture
  75043. */
  75044. lensFlareDirtTexture: Nullable<Texture>;
  75045. /**
  75046. * Represents the focal length for the depth of field effect
  75047. */
  75048. depthOfFieldDistance: number;
  75049. /**
  75050. * Represents the blur intensity for the blurred part of the depth of field effect
  75051. */
  75052. depthOfFieldBlurWidth: number;
  75053. /**
  75054. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75055. */
  75056. get motionStrength(): number;
  75057. /**
  75058. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75059. */
  75060. set motionStrength(strength: number);
  75061. /**
  75062. * Gets wether or not the motion blur post-process is object based or screen based.
  75063. */
  75064. get objectBasedMotionBlur(): boolean;
  75065. /**
  75066. * Sets wether or not the motion blur post-process should be object based or screen based
  75067. */
  75068. set objectBasedMotionBlur(value: boolean);
  75069. /**
  75070. * List of animations for the pipeline (IAnimatable implementation)
  75071. */
  75072. animations: Animation[];
  75073. /**
  75074. * Private members
  75075. */
  75076. private _scene;
  75077. private _currentDepthOfFieldSource;
  75078. private _basePostProcess;
  75079. private _fixedExposure;
  75080. private _currentExposure;
  75081. private _hdrAutoExposure;
  75082. private _hdrCurrentLuminance;
  75083. private _motionStrength;
  75084. private _isObjectBasedMotionBlur;
  75085. private _floatTextureType;
  75086. private _camerasToBeAttached;
  75087. private _ratio;
  75088. private _bloomEnabled;
  75089. private _depthOfFieldEnabled;
  75090. private _vlsEnabled;
  75091. private _lensFlareEnabled;
  75092. private _hdrEnabled;
  75093. private _motionBlurEnabled;
  75094. private _fxaaEnabled;
  75095. private _screenSpaceReflectionsEnabled;
  75096. private _motionBlurSamples;
  75097. private _volumetricLightStepsCount;
  75098. private _samples;
  75099. /**
  75100. * @ignore
  75101. * Specifies if the bloom pipeline is enabled
  75102. */
  75103. get BloomEnabled(): boolean;
  75104. set BloomEnabled(enabled: boolean);
  75105. /**
  75106. * @ignore
  75107. * Specifies if the depth of field pipeline is enabed
  75108. */
  75109. get DepthOfFieldEnabled(): boolean;
  75110. set DepthOfFieldEnabled(enabled: boolean);
  75111. /**
  75112. * @ignore
  75113. * Specifies if the lens flare pipeline is enabed
  75114. */
  75115. get LensFlareEnabled(): boolean;
  75116. set LensFlareEnabled(enabled: boolean);
  75117. /**
  75118. * @ignore
  75119. * Specifies if the HDR pipeline is enabled
  75120. */
  75121. get HDREnabled(): boolean;
  75122. set HDREnabled(enabled: boolean);
  75123. /**
  75124. * @ignore
  75125. * Specifies if the volumetric lights scattering effect is enabled
  75126. */
  75127. get VLSEnabled(): boolean;
  75128. set VLSEnabled(enabled: boolean);
  75129. /**
  75130. * @ignore
  75131. * Specifies if the motion blur effect is enabled
  75132. */
  75133. get MotionBlurEnabled(): boolean;
  75134. set MotionBlurEnabled(enabled: boolean);
  75135. /**
  75136. * Specifies if anti-aliasing is enabled
  75137. */
  75138. get fxaaEnabled(): boolean;
  75139. set fxaaEnabled(enabled: boolean);
  75140. /**
  75141. * Specifies if screen space reflections are enabled.
  75142. */
  75143. get screenSpaceReflectionsEnabled(): boolean;
  75144. set screenSpaceReflectionsEnabled(enabled: boolean);
  75145. /**
  75146. * Specifies the number of steps used to calculate the volumetric lights
  75147. * Typically in interval [50, 200]
  75148. */
  75149. get volumetricLightStepsCount(): number;
  75150. set volumetricLightStepsCount(count: number);
  75151. /**
  75152. * Specifies the number of samples used for the motion blur effect
  75153. * Typically in interval [16, 64]
  75154. */
  75155. get motionBlurSamples(): number;
  75156. set motionBlurSamples(samples: number);
  75157. /**
  75158. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75159. */
  75160. get samples(): number;
  75161. set samples(sampleCount: number);
  75162. /**
  75163. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75164. * @constructor
  75165. * @param name The rendering pipeline name
  75166. * @param scene The scene linked to this pipeline
  75167. * @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)
  75168. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75169. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75170. */
  75171. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75172. private _buildPipeline;
  75173. private _createDownSampleX4PostProcess;
  75174. private _createBrightPassPostProcess;
  75175. private _createBlurPostProcesses;
  75176. private _createTextureAdderPostProcess;
  75177. private _createVolumetricLightPostProcess;
  75178. private _createLuminancePostProcesses;
  75179. private _createHdrPostProcess;
  75180. private _createLensFlarePostProcess;
  75181. private _createDepthOfFieldPostProcess;
  75182. private _createMotionBlurPostProcess;
  75183. private _getDepthTexture;
  75184. private _disposePostProcesses;
  75185. /**
  75186. * Dispose of the pipeline and stop all post processes
  75187. */
  75188. dispose(): void;
  75189. /**
  75190. * Serialize the rendering pipeline (Used when exporting)
  75191. * @returns the serialized object
  75192. */
  75193. serialize(): any;
  75194. /**
  75195. * Parse the serialized pipeline
  75196. * @param source Source pipeline.
  75197. * @param scene The scene to load the pipeline to.
  75198. * @param rootUrl The URL of the serialized pipeline.
  75199. * @returns An instantiated pipeline from the serialized object.
  75200. */
  75201. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75202. /**
  75203. * Luminance steps
  75204. */
  75205. static LuminanceSteps: number;
  75206. }
  75207. }
  75208. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75209. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75210. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75211. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75212. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75213. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75214. }
  75215. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75216. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75217. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75218. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75219. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75220. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75221. }
  75222. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75223. /** @hidden */
  75224. export var stereoscopicInterlacePixelShader: {
  75225. name: string;
  75226. shader: string;
  75227. };
  75228. }
  75229. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75230. import { Camera } from "babylonjs/Cameras/camera";
  75231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75232. import { Engine } from "babylonjs/Engines/engine";
  75233. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75234. /**
  75235. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75236. */
  75237. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75238. private _stepSize;
  75239. private _passedProcess;
  75240. /**
  75241. * Gets a string identifying the name of the class
  75242. * @returns "StereoscopicInterlacePostProcessI" string
  75243. */
  75244. getClassName(): string;
  75245. /**
  75246. * Initializes a StereoscopicInterlacePostProcessI
  75247. * @param name The name of the effect.
  75248. * @param rigCameras The rig cameras to be appled to the post process
  75249. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75250. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75252. * @param engine The engine which the post process will be applied. (default: current engine)
  75253. * @param reusable If the post process can be reused on the same frame. (default: false)
  75254. */
  75255. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75256. }
  75257. /**
  75258. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75259. */
  75260. export class StereoscopicInterlacePostProcess extends PostProcess {
  75261. private _stepSize;
  75262. private _passedProcess;
  75263. /**
  75264. * Gets a string identifying the name of the class
  75265. * @returns "StereoscopicInterlacePostProcess" string
  75266. */
  75267. getClassName(): string;
  75268. /**
  75269. * Initializes a StereoscopicInterlacePostProcess
  75270. * @param name The name of the effect.
  75271. * @param rigCameras The rig cameras to be appled to the post process
  75272. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75274. * @param engine The engine which the post process will be applied. (default: current engine)
  75275. * @param reusable If the post process can be reused on the same frame. (default: false)
  75276. */
  75277. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75278. }
  75279. }
  75280. declare module "babylonjs/Shaders/tonemap.fragment" {
  75281. /** @hidden */
  75282. export var tonemapPixelShader: {
  75283. name: string;
  75284. shader: string;
  75285. };
  75286. }
  75287. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75288. import { Camera } from "babylonjs/Cameras/camera";
  75289. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75290. import "babylonjs/Shaders/tonemap.fragment";
  75291. import { Engine } from "babylonjs/Engines/engine";
  75292. /** Defines operator used for tonemapping */
  75293. export enum TonemappingOperator {
  75294. /** Hable */
  75295. Hable = 0,
  75296. /** Reinhard */
  75297. Reinhard = 1,
  75298. /** HejiDawson */
  75299. HejiDawson = 2,
  75300. /** Photographic */
  75301. Photographic = 3
  75302. }
  75303. /**
  75304. * Defines a post process to apply tone mapping
  75305. */
  75306. export class TonemapPostProcess extends PostProcess {
  75307. private _operator;
  75308. /** Defines the required exposure adjustement */
  75309. exposureAdjustment: number;
  75310. /**
  75311. * Gets a string identifying the name of the class
  75312. * @returns "TonemapPostProcess" string
  75313. */
  75314. getClassName(): string;
  75315. /**
  75316. * Creates a new TonemapPostProcess
  75317. * @param name defines the name of the postprocess
  75318. * @param _operator defines the operator to use
  75319. * @param exposureAdjustment defines the required exposure adjustement
  75320. * @param camera defines the camera to use (can be null)
  75321. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75322. * @param engine defines the hosting engine (can be ignore if camera is set)
  75323. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75324. */
  75325. constructor(name: string, _operator: TonemappingOperator,
  75326. /** Defines the required exposure adjustement */
  75327. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75328. }
  75329. }
  75330. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75331. /** @hidden */
  75332. export var volumetricLightScatteringPixelShader: {
  75333. name: string;
  75334. shader: string;
  75335. };
  75336. }
  75337. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75338. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75339. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75340. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75341. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75343. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75344. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75345. /** @hidden */
  75346. export var volumetricLightScatteringPassVertexShader: {
  75347. name: string;
  75348. shader: string;
  75349. };
  75350. }
  75351. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75352. /** @hidden */
  75353. export var volumetricLightScatteringPassPixelShader: {
  75354. name: string;
  75355. shader: string;
  75356. };
  75357. }
  75358. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75359. import { Vector3 } from "babylonjs/Maths/math.vector";
  75360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75361. import { Mesh } from "babylonjs/Meshes/mesh";
  75362. import { Camera } from "babylonjs/Cameras/camera";
  75363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75364. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75365. import { Scene } from "babylonjs/scene";
  75366. import "babylonjs/Meshes/Builders/planeBuilder";
  75367. import "babylonjs/Shaders/depth.vertex";
  75368. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75369. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75370. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75371. import { Engine } from "babylonjs/Engines/engine";
  75372. /**
  75373. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75374. */
  75375. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75376. private _volumetricLightScatteringPass;
  75377. private _volumetricLightScatteringRTT;
  75378. private _viewPort;
  75379. private _screenCoordinates;
  75380. private _cachedDefines;
  75381. /**
  75382. * If not undefined, the mesh position is computed from the attached node position
  75383. */
  75384. attachedNode: {
  75385. position: Vector3;
  75386. };
  75387. /**
  75388. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75389. */
  75390. customMeshPosition: Vector3;
  75391. /**
  75392. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75393. */
  75394. useCustomMeshPosition: boolean;
  75395. /**
  75396. * If the post-process should inverse the light scattering direction
  75397. */
  75398. invert: boolean;
  75399. /**
  75400. * The internal mesh used by the post-process
  75401. */
  75402. mesh: Mesh;
  75403. /**
  75404. * @hidden
  75405. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75406. */
  75407. get useDiffuseColor(): boolean;
  75408. set useDiffuseColor(useDiffuseColor: boolean);
  75409. /**
  75410. * Array containing the excluded meshes not rendered in the internal pass
  75411. */
  75412. excludedMeshes: AbstractMesh[];
  75413. /**
  75414. * Controls the overall intensity of the post-process
  75415. */
  75416. exposure: number;
  75417. /**
  75418. * Dissipates each sample's contribution in range [0, 1]
  75419. */
  75420. decay: number;
  75421. /**
  75422. * Controls the overall intensity of each sample
  75423. */
  75424. weight: number;
  75425. /**
  75426. * Controls the density of each sample
  75427. */
  75428. density: number;
  75429. /**
  75430. * @constructor
  75431. * @param name The post-process name
  75432. * @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)
  75433. * @param camera The camera that the post-process will be attached to
  75434. * @param mesh The mesh used to create the light scattering
  75435. * @param samples The post-process quality, default 100
  75436. * @param samplingModeThe post-process filtering mode
  75437. * @param engine The babylon engine
  75438. * @param reusable If the post-process is reusable
  75439. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75440. */
  75441. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75442. /**
  75443. * Returns the string "VolumetricLightScatteringPostProcess"
  75444. * @returns "VolumetricLightScatteringPostProcess"
  75445. */
  75446. getClassName(): string;
  75447. private _isReady;
  75448. /**
  75449. * Sets the new light position for light scattering effect
  75450. * @param position The new custom light position
  75451. */
  75452. setCustomMeshPosition(position: Vector3): void;
  75453. /**
  75454. * Returns the light position for light scattering effect
  75455. * @return Vector3 The custom light position
  75456. */
  75457. getCustomMeshPosition(): Vector3;
  75458. /**
  75459. * Disposes the internal assets and detaches the post-process from the camera
  75460. */
  75461. dispose(camera: Camera): void;
  75462. /**
  75463. * Returns the render target texture used by the post-process
  75464. * @return the render target texture used by the post-process
  75465. */
  75466. getPass(): RenderTargetTexture;
  75467. private _meshExcluded;
  75468. private _createPass;
  75469. private _updateMeshScreenCoordinates;
  75470. /**
  75471. * Creates a default mesh for the Volumeric Light Scattering post-process
  75472. * @param name The mesh name
  75473. * @param scene The scene where to create the mesh
  75474. * @return the default mesh
  75475. */
  75476. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75477. }
  75478. }
  75479. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75480. /** @hidden */
  75481. export var screenSpaceCurvaturePixelShader: {
  75482. name: string;
  75483. shader: string;
  75484. };
  75485. }
  75486. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75487. import { Nullable } from "babylonjs/types";
  75488. import { Camera } from "babylonjs/Cameras/camera";
  75489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75490. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75491. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75492. import { Engine } from "babylonjs/Engines/engine";
  75493. import { Scene } from "babylonjs/scene";
  75494. /**
  75495. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75496. */
  75497. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75498. /**
  75499. * Defines how much ridge the curvature effect displays.
  75500. */
  75501. ridge: number;
  75502. /**
  75503. * Defines how much valley the curvature effect displays.
  75504. */
  75505. valley: number;
  75506. private _geometryBufferRenderer;
  75507. /**
  75508. * Gets a string identifying the name of the class
  75509. * @returns "ScreenSpaceCurvaturePostProcess" string
  75510. */
  75511. getClassName(): string;
  75512. /**
  75513. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75514. * @param name The name of the effect.
  75515. * @param scene The scene containing the objects to blur according to their velocity.
  75516. * @param options The required width/height ratio to downsize to before computing the render pass.
  75517. * @param camera The camera to apply the render pass to.
  75518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75519. * @param engine The engine which the post process will be applied. (default: current engine)
  75520. * @param reusable If the post process can be reused on the same frame. (default: false)
  75521. * @param textureType Type of textures used when performing the post process. (default: 0)
  75522. * @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)
  75523. */
  75524. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75525. /**
  75526. * Support test.
  75527. */
  75528. static get IsSupported(): boolean;
  75529. /** @hidden */
  75530. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75531. }
  75532. }
  75533. declare module "babylonjs/PostProcesses/index" {
  75534. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75535. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75536. export * from "babylonjs/PostProcesses/bloomEffect";
  75537. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75538. export * from "babylonjs/PostProcesses/blurPostProcess";
  75539. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75540. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75541. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75542. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75543. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75544. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75545. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75546. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75547. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75548. export * from "babylonjs/PostProcesses/filterPostProcess";
  75549. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75550. export * from "babylonjs/PostProcesses/grainPostProcess";
  75551. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75552. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75553. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75554. export * from "babylonjs/PostProcesses/passPostProcess";
  75555. export * from "babylonjs/PostProcesses/postProcess";
  75556. export * from "babylonjs/PostProcesses/postProcessManager";
  75557. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75558. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75559. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75560. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75561. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75562. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75563. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75564. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75565. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75566. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75567. }
  75568. declare module "babylonjs/Probes/index" {
  75569. export * from "babylonjs/Probes/reflectionProbe";
  75570. }
  75571. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75572. import { Scene } from "babylonjs/scene";
  75573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75574. import { SmartArray } from "babylonjs/Misc/smartArray";
  75575. import { ISceneComponent } from "babylonjs/sceneComponent";
  75576. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75577. import "babylonjs/Meshes/Builders/boxBuilder";
  75578. import "babylonjs/Shaders/color.fragment";
  75579. import "babylonjs/Shaders/color.vertex";
  75580. import { Color3 } from "babylonjs/Maths/math.color";
  75581. import { Observable } from "babylonjs/Misc/observable";
  75582. module "babylonjs/scene" {
  75583. interface Scene {
  75584. /** @hidden (Backing field) */
  75585. _boundingBoxRenderer: BoundingBoxRenderer;
  75586. /** @hidden (Backing field) */
  75587. _forceShowBoundingBoxes: boolean;
  75588. /**
  75589. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75590. */
  75591. forceShowBoundingBoxes: boolean;
  75592. /**
  75593. * Gets the bounding box renderer associated with the scene
  75594. * @returns a BoundingBoxRenderer
  75595. */
  75596. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75597. }
  75598. }
  75599. module "babylonjs/Meshes/abstractMesh" {
  75600. interface AbstractMesh {
  75601. /** @hidden (Backing field) */
  75602. _showBoundingBox: boolean;
  75603. /**
  75604. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75605. */
  75606. showBoundingBox: boolean;
  75607. }
  75608. }
  75609. /**
  75610. * Component responsible of rendering the bounding box of the meshes in a scene.
  75611. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75612. */
  75613. export class BoundingBoxRenderer implements ISceneComponent {
  75614. /**
  75615. * The component name helpfull to identify the component in the list of scene components.
  75616. */
  75617. readonly name: string;
  75618. /**
  75619. * The scene the component belongs to.
  75620. */
  75621. scene: Scene;
  75622. /**
  75623. * Color of the bounding box lines placed in front of an object
  75624. */
  75625. frontColor: Color3;
  75626. /**
  75627. * Color of the bounding box lines placed behind an object
  75628. */
  75629. backColor: Color3;
  75630. /**
  75631. * Defines if the renderer should show the back lines or not
  75632. */
  75633. showBackLines: boolean;
  75634. /**
  75635. * Observable raised before rendering a bounding box
  75636. */
  75637. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75638. /**
  75639. * Observable raised after rendering a bounding box
  75640. */
  75641. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75642. /**
  75643. * @hidden
  75644. */
  75645. renderList: SmartArray<BoundingBox>;
  75646. private _colorShader;
  75647. private _vertexBuffers;
  75648. private _indexBuffer;
  75649. private _fillIndexBuffer;
  75650. private _fillIndexData;
  75651. /**
  75652. * Instantiates a new bounding box renderer in a scene.
  75653. * @param scene the scene the renderer renders in
  75654. */
  75655. constructor(scene: Scene);
  75656. /**
  75657. * Registers the component in a given scene
  75658. */
  75659. register(): void;
  75660. private _evaluateSubMesh;
  75661. private _activeMesh;
  75662. private _prepareRessources;
  75663. private _createIndexBuffer;
  75664. /**
  75665. * Rebuilds the elements related to this component in case of
  75666. * context lost for instance.
  75667. */
  75668. rebuild(): void;
  75669. /**
  75670. * @hidden
  75671. */
  75672. reset(): void;
  75673. /**
  75674. * Render the bounding boxes of a specific rendering group
  75675. * @param renderingGroupId defines the rendering group to render
  75676. */
  75677. render(renderingGroupId: number): void;
  75678. /**
  75679. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75680. * @param mesh Define the mesh to render the occlusion bounding box for
  75681. */
  75682. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75683. /**
  75684. * Dispose and release the resources attached to this renderer.
  75685. */
  75686. dispose(): void;
  75687. }
  75688. }
  75689. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75690. import { Nullable } from "babylonjs/types";
  75691. import { Scene } from "babylonjs/scene";
  75692. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75693. import { Camera } from "babylonjs/Cameras/camera";
  75694. import { ISceneComponent } from "babylonjs/sceneComponent";
  75695. module "babylonjs/scene" {
  75696. interface Scene {
  75697. /** @hidden (Backing field) */
  75698. _depthRenderer: {
  75699. [id: string]: DepthRenderer;
  75700. };
  75701. /**
  75702. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75703. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75704. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75705. * @returns the created depth renderer
  75706. */
  75707. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75708. /**
  75709. * Disables a depth renderer for a given camera
  75710. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75711. */
  75712. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75713. }
  75714. }
  75715. /**
  75716. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75717. * in several rendering techniques.
  75718. */
  75719. export class DepthRendererSceneComponent implements ISceneComponent {
  75720. /**
  75721. * The component name helpfull to identify the component in the list of scene components.
  75722. */
  75723. readonly name: string;
  75724. /**
  75725. * The scene the component belongs to.
  75726. */
  75727. scene: Scene;
  75728. /**
  75729. * Creates a new instance of the component for the given scene
  75730. * @param scene Defines the scene to register the component in
  75731. */
  75732. constructor(scene: Scene);
  75733. /**
  75734. * Registers the component in a given scene
  75735. */
  75736. register(): void;
  75737. /**
  75738. * Rebuilds the elements related to this component in case of
  75739. * context lost for instance.
  75740. */
  75741. rebuild(): void;
  75742. /**
  75743. * Disposes the component and the associated ressources
  75744. */
  75745. dispose(): void;
  75746. private _gatherRenderTargets;
  75747. private _gatherActiveCameraRenderTargets;
  75748. }
  75749. }
  75750. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75751. import { Nullable } from "babylonjs/types";
  75752. import { Scene } from "babylonjs/scene";
  75753. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75754. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75755. import { AbstractScene } from "babylonjs/abstractScene";
  75756. module "babylonjs/abstractScene" {
  75757. interface AbstractScene {
  75758. /** @hidden (Backing field) */
  75759. _prePassRenderer: Nullable<PrePassRenderer>;
  75760. /**
  75761. * Gets or Sets the current prepass renderer associated to the scene.
  75762. */
  75763. prePassRenderer: Nullable<PrePassRenderer>;
  75764. /**
  75765. * Enables the prepass and associates it with the scene
  75766. * @returns the PrePassRenderer
  75767. */
  75768. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75769. /**
  75770. * Disables the prepass associated with the scene
  75771. */
  75772. disablePrePassRenderer(): void;
  75773. }
  75774. }
  75775. /**
  75776. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75777. * in several rendering techniques.
  75778. */
  75779. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75780. /**
  75781. * The component name helpful to identify the component in the list of scene components.
  75782. */
  75783. readonly name: string;
  75784. /**
  75785. * The scene the component belongs to.
  75786. */
  75787. scene: Scene;
  75788. /**
  75789. * Creates a new instance of the component for the given scene
  75790. * @param scene Defines the scene to register the component in
  75791. */
  75792. constructor(scene: Scene);
  75793. /**
  75794. * Registers the component in a given scene
  75795. */
  75796. register(): void;
  75797. private _beforeCameraDraw;
  75798. private _afterCameraDraw;
  75799. private _beforeClearStage;
  75800. /**
  75801. * Serializes the component data to the specified json object
  75802. * @param serializationObject The object to serialize to
  75803. */
  75804. serialize(serializationObject: any): void;
  75805. /**
  75806. * Adds all the elements from the container to the scene
  75807. * @param container the container holding the elements
  75808. */
  75809. addFromContainer(container: AbstractScene): void;
  75810. /**
  75811. * Removes all the elements in the container from the scene
  75812. * @param container contains the elements to remove
  75813. * @param dispose if the removed element should be disposed (default: false)
  75814. */
  75815. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75816. /**
  75817. * Rebuilds the elements related to this component in case of
  75818. * context lost for instance.
  75819. */
  75820. rebuild(): void;
  75821. /**
  75822. * Disposes the component and the associated ressources
  75823. */
  75824. dispose(): void;
  75825. }
  75826. }
  75827. declare module "babylonjs/Shaders/outline.fragment" {
  75828. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75829. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75830. /** @hidden */
  75831. export var outlinePixelShader: {
  75832. name: string;
  75833. shader: string;
  75834. };
  75835. }
  75836. declare module "babylonjs/Shaders/outline.vertex" {
  75837. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75840. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75841. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75843. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75844. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75845. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75846. /** @hidden */
  75847. export var outlineVertexShader: {
  75848. name: string;
  75849. shader: string;
  75850. };
  75851. }
  75852. declare module "babylonjs/Rendering/outlineRenderer" {
  75853. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75854. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75855. import { Scene } from "babylonjs/scene";
  75856. import { ISceneComponent } from "babylonjs/sceneComponent";
  75857. import "babylonjs/Shaders/outline.fragment";
  75858. import "babylonjs/Shaders/outline.vertex";
  75859. module "babylonjs/scene" {
  75860. interface Scene {
  75861. /** @hidden */
  75862. _outlineRenderer: OutlineRenderer;
  75863. /**
  75864. * Gets the outline renderer associated with the scene
  75865. * @returns a OutlineRenderer
  75866. */
  75867. getOutlineRenderer(): OutlineRenderer;
  75868. }
  75869. }
  75870. module "babylonjs/Meshes/abstractMesh" {
  75871. interface AbstractMesh {
  75872. /** @hidden (Backing field) */
  75873. _renderOutline: boolean;
  75874. /**
  75875. * Gets or sets a boolean indicating if the outline must be rendered as well
  75876. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75877. */
  75878. renderOutline: boolean;
  75879. /** @hidden (Backing field) */
  75880. _renderOverlay: boolean;
  75881. /**
  75882. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75883. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75884. */
  75885. renderOverlay: boolean;
  75886. }
  75887. }
  75888. /**
  75889. * This class is responsible to draw bothe outline/overlay of meshes.
  75890. * It should not be used directly but through the available method on mesh.
  75891. */
  75892. export class OutlineRenderer implements ISceneComponent {
  75893. /**
  75894. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75895. */
  75896. private static _StencilReference;
  75897. /**
  75898. * The name of the component. Each component must have a unique name.
  75899. */
  75900. name: string;
  75901. /**
  75902. * The scene the component belongs to.
  75903. */
  75904. scene: Scene;
  75905. /**
  75906. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75907. */
  75908. zOffset: number;
  75909. private _engine;
  75910. private _effect;
  75911. private _cachedDefines;
  75912. private _savedDepthWrite;
  75913. /**
  75914. * Instantiates a new outline renderer. (There could be only one per scene).
  75915. * @param scene Defines the scene it belongs to
  75916. */
  75917. constructor(scene: Scene);
  75918. /**
  75919. * Register the component to one instance of a scene.
  75920. */
  75921. register(): void;
  75922. /**
  75923. * Rebuilds the elements related to this component in case of
  75924. * context lost for instance.
  75925. */
  75926. rebuild(): void;
  75927. /**
  75928. * Disposes the component and the associated ressources.
  75929. */
  75930. dispose(): void;
  75931. /**
  75932. * Renders the outline in the canvas.
  75933. * @param subMesh Defines the sumesh to render
  75934. * @param batch Defines the batch of meshes in case of instances
  75935. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75936. */
  75937. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75938. /**
  75939. * Returns whether or not the outline renderer is ready for a given submesh.
  75940. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75941. * @param subMesh Defines the submesh to check readyness for
  75942. * @param useInstances Defines wheter wee are trying to render instances or not
  75943. * @returns true if ready otherwise false
  75944. */
  75945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75946. private _beforeRenderingMesh;
  75947. private _afterRenderingMesh;
  75948. }
  75949. }
  75950. declare module "babylonjs/Rendering/index" {
  75951. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75952. export * from "babylonjs/Rendering/depthRenderer";
  75953. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75954. export * from "babylonjs/Rendering/edgesRenderer";
  75955. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75956. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75957. export * from "babylonjs/Rendering/prePassRenderer";
  75958. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75959. export * from "babylonjs/Rendering/outlineRenderer";
  75960. export * from "babylonjs/Rendering/renderingGroup";
  75961. export * from "babylonjs/Rendering/renderingManager";
  75962. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75963. }
  75964. declare module "babylonjs/Sprites/ISprites" {
  75965. /**
  75966. * Defines the basic options interface of a Sprite Frame Source Size.
  75967. */
  75968. export interface ISpriteJSONSpriteSourceSize {
  75969. /**
  75970. * number of the original width of the Frame
  75971. */
  75972. w: number;
  75973. /**
  75974. * number of the original height of the Frame
  75975. */
  75976. h: number;
  75977. }
  75978. /**
  75979. * Defines the basic options interface of a Sprite Frame Data.
  75980. */
  75981. export interface ISpriteJSONSpriteFrameData {
  75982. /**
  75983. * number of the x offset of the Frame
  75984. */
  75985. x: number;
  75986. /**
  75987. * number of the y offset of the Frame
  75988. */
  75989. y: number;
  75990. /**
  75991. * number of the width of the Frame
  75992. */
  75993. w: number;
  75994. /**
  75995. * number of the height of the Frame
  75996. */
  75997. h: number;
  75998. }
  75999. /**
  76000. * Defines the basic options interface of a JSON Sprite.
  76001. */
  76002. export interface ISpriteJSONSprite {
  76003. /**
  76004. * string name of the Frame
  76005. */
  76006. filename: string;
  76007. /**
  76008. * ISpriteJSONSpriteFrame basic object of the frame data
  76009. */
  76010. frame: ISpriteJSONSpriteFrameData;
  76011. /**
  76012. * boolean to flag is the frame was rotated.
  76013. */
  76014. rotated: boolean;
  76015. /**
  76016. * boolean to flag is the frame was trimmed.
  76017. */
  76018. trimmed: boolean;
  76019. /**
  76020. * ISpriteJSONSpriteFrame basic object of the source data
  76021. */
  76022. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76023. /**
  76024. * ISpriteJSONSpriteFrame basic object of the source data
  76025. */
  76026. sourceSize: ISpriteJSONSpriteSourceSize;
  76027. }
  76028. /**
  76029. * Defines the basic options interface of a JSON atlas.
  76030. */
  76031. export interface ISpriteJSONAtlas {
  76032. /**
  76033. * Array of objects that contain the frame data.
  76034. */
  76035. frames: Array<ISpriteJSONSprite>;
  76036. /**
  76037. * object basic object containing the sprite meta data.
  76038. */
  76039. meta?: object;
  76040. }
  76041. }
  76042. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76043. /** @hidden */
  76044. export var spriteMapPixelShader: {
  76045. name: string;
  76046. shader: string;
  76047. };
  76048. }
  76049. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76050. /** @hidden */
  76051. export var spriteMapVertexShader: {
  76052. name: string;
  76053. shader: string;
  76054. };
  76055. }
  76056. declare module "babylonjs/Sprites/spriteMap" {
  76057. import { IDisposable, Scene } from "babylonjs/scene";
  76058. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76059. import { Texture } from "babylonjs/Materials/Textures/texture";
  76060. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76061. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76062. import "babylonjs/Meshes/Builders/planeBuilder";
  76063. import "babylonjs/Shaders/spriteMap.fragment";
  76064. import "babylonjs/Shaders/spriteMap.vertex";
  76065. /**
  76066. * Defines the basic options interface of a SpriteMap
  76067. */
  76068. export interface ISpriteMapOptions {
  76069. /**
  76070. * Vector2 of the number of cells in the grid.
  76071. */
  76072. stageSize?: Vector2;
  76073. /**
  76074. * Vector2 of the size of the output plane in World Units.
  76075. */
  76076. outputSize?: Vector2;
  76077. /**
  76078. * Vector3 of the position of the output plane in World Units.
  76079. */
  76080. outputPosition?: Vector3;
  76081. /**
  76082. * Vector3 of the rotation of the output plane.
  76083. */
  76084. outputRotation?: Vector3;
  76085. /**
  76086. * number of layers that the system will reserve in resources.
  76087. */
  76088. layerCount?: number;
  76089. /**
  76090. * number of max animation frames a single cell will reserve in resources.
  76091. */
  76092. maxAnimationFrames?: number;
  76093. /**
  76094. * number cell index of the base tile when the system compiles.
  76095. */
  76096. baseTile?: number;
  76097. /**
  76098. * boolean flip the sprite after its been repositioned by the framing data.
  76099. */
  76100. flipU?: boolean;
  76101. /**
  76102. * Vector3 scalar of the global RGB values of the SpriteMap.
  76103. */
  76104. colorMultiply?: Vector3;
  76105. }
  76106. /**
  76107. * Defines the IDisposable interface in order to be cleanable from resources.
  76108. */
  76109. export interface ISpriteMap extends IDisposable {
  76110. /**
  76111. * String name of the SpriteMap.
  76112. */
  76113. name: string;
  76114. /**
  76115. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76116. */
  76117. atlasJSON: ISpriteJSONAtlas;
  76118. /**
  76119. * Texture of the SpriteMap.
  76120. */
  76121. spriteSheet: Texture;
  76122. /**
  76123. * The parameters to initialize the SpriteMap with.
  76124. */
  76125. options: ISpriteMapOptions;
  76126. }
  76127. /**
  76128. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76129. */
  76130. export class SpriteMap implements ISpriteMap {
  76131. /** The Name of the spriteMap */
  76132. name: string;
  76133. /** The JSON file with the frame and meta data */
  76134. atlasJSON: ISpriteJSONAtlas;
  76135. /** The systems Sprite Sheet Texture */
  76136. spriteSheet: Texture;
  76137. /** Arguments passed with the Constructor */
  76138. options: ISpriteMapOptions;
  76139. /** Public Sprite Storage array, parsed from atlasJSON */
  76140. sprites: Array<ISpriteJSONSprite>;
  76141. /** Returns the Number of Sprites in the System */
  76142. get spriteCount(): number;
  76143. /** Returns the Position of Output Plane*/
  76144. get position(): Vector3;
  76145. /** Returns the Position of Output Plane*/
  76146. set position(v: Vector3);
  76147. /** Returns the Rotation of Output Plane*/
  76148. get rotation(): Vector3;
  76149. /** Returns the Rotation of Output Plane*/
  76150. set rotation(v: Vector3);
  76151. /** Sets the AnimationMap*/
  76152. get animationMap(): RawTexture;
  76153. /** Sets the AnimationMap*/
  76154. set animationMap(v: RawTexture);
  76155. /** Scene that the SpriteMap was created in */
  76156. private _scene;
  76157. /** Texture Buffer of Float32 that holds tile frame data*/
  76158. private _frameMap;
  76159. /** Texture Buffers of Float32 that holds tileMap data*/
  76160. private _tileMaps;
  76161. /** Texture Buffer of Float32 that holds Animation Data*/
  76162. private _animationMap;
  76163. /** Custom ShaderMaterial Central to the System*/
  76164. private _material;
  76165. /** Custom ShaderMaterial Central to the System*/
  76166. private _output;
  76167. /** Systems Time Ticker*/
  76168. private _time;
  76169. /**
  76170. * Creates a new SpriteMap
  76171. * @param name defines the SpriteMaps Name
  76172. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76173. * @param spriteSheet is the Texture that the Sprites are on.
  76174. * @param options a basic deployment configuration
  76175. * @param scene The Scene that the map is deployed on
  76176. */
  76177. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76178. /**
  76179. * Returns tileID location
  76180. * @returns Vector2 the cell position ID
  76181. */
  76182. getTileID(): Vector2;
  76183. /**
  76184. * Gets the UV location of the mouse over the SpriteMap.
  76185. * @returns Vector2 the UV position of the mouse interaction
  76186. */
  76187. getMousePosition(): Vector2;
  76188. /**
  76189. * Creates the "frame" texture Buffer
  76190. * -------------------------------------
  76191. * Structure of frames
  76192. * "filename": "Falling-Water-2.png",
  76193. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76194. * "rotated": true,
  76195. * "trimmed": true,
  76196. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76197. * "sourceSize": {"w":32,"h":32}
  76198. * @returns RawTexture of the frameMap
  76199. */
  76200. private _createFrameBuffer;
  76201. /**
  76202. * Creates the tileMap texture Buffer
  76203. * @param buffer normally and array of numbers, or a false to generate from scratch
  76204. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76205. * @returns RawTexture of the tileMap
  76206. */
  76207. private _createTileBuffer;
  76208. /**
  76209. * Modifies the data of the tileMaps
  76210. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76211. * @param pos is the iVector2 Coordinates of the Tile
  76212. * @param tile The SpriteIndex of the new Tile
  76213. */
  76214. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76215. /**
  76216. * Creates the animationMap texture Buffer
  76217. * @param buffer normally and array of numbers, or a false to generate from scratch
  76218. * @returns RawTexture of the animationMap
  76219. */
  76220. private _createTileAnimationBuffer;
  76221. /**
  76222. * Modifies the data of the animationMap
  76223. * @param cellID is the Index of the Sprite
  76224. * @param _frame is the target Animation frame
  76225. * @param toCell is the Target Index of the next frame of the animation
  76226. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76227. * @param speed is a global scalar of the time variable on the map.
  76228. */
  76229. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76230. /**
  76231. * Exports the .tilemaps file
  76232. */
  76233. saveTileMaps(): void;
  76234. /**
  76235. * Imports the .tilemaps file
  76236. * @param url of the .tilemaps file
  76237. */
  76238. loadTileMaps(url: string): void;
  76239. /**
  76240. * Release associated resources
  76241. */
  76242. dispose(): void;
  76243. }
  76244. }
  76245. declare module "babylonjs/Sprites/spritePackedManager" {
  76246. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76247. import { Scene } from "babylonjs/scene";
  76248. /**
  76249. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76250. * @see https://doc.babylonjs.com/babylon101/sprites
  76251. */
  76252. export class SpritePackedManager extends SpriteManager {
  76253. /** defines the packed manager's name */
  76254. name: string;
  76255. /**
  76256. * Creates a new sprite manager from a packed sprite sheet
  76257. * @param name defines the manager's name
  76258. * @param imgUrl defines the sprite sheet url
  76259. * @param capacity defines the maximum allowed number of sprites
  76260. * @param scene defines the hosting scene
  76261. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76262. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76263. * @param samplingMode defines the smapling mode to use with spritesheet
  76264. * @param fromPacked set to true; do not alter
  76265. */
  76266. constructor(
  76267. /** defines the packed manager's name */
  76268. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76269. }
  76270. }
  76271. declare module "babylonjs/Sprites/index" {
  76272. export * from "babylonjs/Sprites/sprite";
  76273. export * from "babylonjs/Sprites/ISprites";
  76274. export * from "babylonjs/Sprites/spriteManager";
  76275. export * from "babylonjs/Sprites/spriteMap";
  76276. export * from "babylonjs/Sprites/spritePackedManager";
  76277. export * from "babylonjs/Sprites/spriteSceneComponent";
  76278. }
  76279. declare module "babylonjs/States/index" {
  76280. export * from "babylonjs/States/alphaCullingState";
  76281. export * from "babylonjs/States/depthCullingState";
  76282. export * from "babylonjs/States/stencilState";
  76283. }
  76284. declare module "babylonjs/Misc/assetsManager" {
  76285. import { Scene } from "babylonjs/scene";
  76286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76287. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76288. import { Skeleton } from "babylonjs/Bones/skeleton";
  76289. import { Observable } from "babylonjs/Misc/observable";
  76290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76291. import { Texture } from "babylonjs/Materials/Textures/texture";
  76292. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76293. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76294. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76295. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76296. import { AssetContainer } from "babylonjs/assetContainer";
  76297. /**
  76298. * Defines the list of states available for a task inside a AssetsManager
  76299. */
  76300. export enum AssetTaskState {
  76301. /**
  76302. * Initialization
  76303. */
  76304. INIT = 0,
  76305. /**
  76306. * Running
  76307. */
  76308. RUNNING = 1,
  76309. /**
  76310. * Done
  76311. */
  76312. DONE = 2,
  76313. /**
  76314. * Error
  76315. */
  76316. ERROR = 3
  76317. }
  76318. /**
  76319. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76320. */
  76321. export abstract class AbstractAssetTask {
  76322. /**
  76323. * Task name
  76324. */ name: string;
  76325. /**
  76326. * Callback called when the task is successful
  76327. */
  76328. onSuccess: (task: any) => void;
  76329. /**
  76330. * Callback called when the task is not successful
  76331. */
  76332. onError: (task: any, message?: string, exception?: any) => void;
  76333. /**
  76334. * Creates a new AssetsManager
  76335. * @param name defines the name of the task
  76336. */
  76337. constructor(
  76338. /**
  76339. * Task name
  76340. */ name: string);
  76341. private _isCompleted;
  76342. private _taskState;
  76343. private _errorObject;
  76344. /**
  76345. * Get if the task is completed
  76346. */
  76347. get isCompleted(): boolean;
  76348. /**
  76349. * Gets the current state of the task
  76350. */
  76351. get taskState(): AssetTaskState;
  76352. /**
  76353. * Gets the current error object (if task is in error)
  76354. */
  76355. get errorObject(): {
  76356. message?: string;
  76357. exception?: any;
  76358. };
  76359. /**
  76360. * Internal only
  76361. * @hidden
  76362. */
  76363. _setErrorObject(message?: string, exception?: any): void;
  76364. /**
  76365. * Execute the current task
  76366. * @param scene defines the scene where you want your assets to be loaded
  76367. * @param onSuccess is a callback called when the task is successfully executed
  76368. * @param onError is a callback called if an error occurs
  76369. */
  76370. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76371. /**
  76372. * Execute the current task
  76373. * @param scene defines the scene where you want your assets to be loaded
  76374. * @param onSuccess is a callback called when the task is successfully executed
  76375. * @param onError is a callback called if an error occurs
  76376. */
  76377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76378. /**
  76379. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76380. * This can be used with failed tasks that have the reason for failure fixed.
  76381. */
  76382. reset(): void;
  76383. private onErrorCallback;
  76384. private onDoneCallback;
  76385. }
  76386. /**
  76387. * Define the interface used by progress events raised during assets loading
  76388. */
  76389. export interface IAssetsProgressEvent {
  76390. /**
  76391. * Defines the number of remaining tasks to process
  76392. */
  76393. remainingCount: number;
  76394. /**
  76395. * Defines the total number of tasks
  76396. */
  76397. totalCount: number;
  76398. /**
  76399. * Defines the task that was just processed
  76400. */
  76401. task: AbstractAssetTask;
  76402. }
  76403. /**
  76404. * Class used to share progress information about assets loading
  76405. */
  76406. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76407. /**
  76408. * Defines the number of remaining tasks to process
  76409. */
  76410. remainingCount: number;
  76411. /**
  76412. * Defines the total number of tasks
  76413. */
  76414. totalCount: number;
  76415. /**
  76416. * Defines the task that was just processed
  76417. */
  76418. task: AbstractAssetTask;
  76419. /**
  76420. * Creates a AssetsProgressEvent
  76421. * @param remainingCount defines the number of remaining tasks to process
  76422. * @param totalCount defines the total number of tasks
  76423. * @param task defines the task that was just processed
  76424. */
  76425. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76426. }
  76427. /**
  76428. * Define a task used by AssetsManager to load assets into a container
  76429. */
  76430. export class ContainerAssetTask extends AbstractAssetTask {
  76431. /**
  76432. * Defines the name of the task
  76433. */
  76434. name: string;
  76435. /**
  76436. * Defines the list of mesh's names you want to load
  76437. */
  76438. meshesNames: any;
  76439. /**
  76440. * Defines the root url to use as a base to load your meshes and associated resources
  76441. */
  76442. rootUrl: string;
  76443. /**
  76444. * Defines the filename or File of the scene to load from
  76445. */
  76446. sceneFilename: string | File;
  76447. /**
  76448. * Get the loaded asset container
  76449. */
  76450. loadedContainer: AssetContainer;
  76451. /**
  76452. * Gets the list of loaded meshes
  76453. */
  76454. loadedMeshes: Array<AbstractMesh>;
  76455. /**
  76456. * Gets the list of loaded particle systems
  76457. */
  76458. loadedParticleSystems: Array<IParticleSystem>;
  76459. /**
  76460. * Gets the list of loaded skeletons
  76461. */
  76462. loadedSkeletons: Array<Skeleton>;
  76463. /**
  76464. * Gets the list of loaded animation groups
  76465. */
  76466. loadedAnimationGroups: Array<AnimationGroup>;
  76467. /**
  76468. * Callback called when the task is successful
  76469. */
  76470. onSuccess: (task: ContainerAssetTask) => void;
  76471. /**
  76472. * Callback called when the task is successful
  76473. */
  76474. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76475. /**
  76476. * Creates a new ContainerAssetTask
  76477. * @param name defines the name of the task
  76478. * @param meshesNames defines the list of mesh's names you want to load
  76479. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76480. * @param sceneFilename defines the filename or File of the scene to load from
  76481. */
  76482. constructor(
  76483. /**
  76484. * Defines the name of the task
  76485. */
  76486. name: string,
  76487. /**
  76488. * Defines the list of mesh's names you want to load
  76489. */
  76490. meshesNames: any,
  76491. /**
  76492. * Defines the root url to use as a base to load your meshes and associated resources
  76493. */
  76494. rootUrl: string,
  76495. /**
  76496. * Defines the filename or File of the scene to load from
  76497. */
  76498. sceneFilename: string | File);
  76499. /**
  76500. * Execute the current task
  76501. * @param scene defines the scene where you want your assets to be loaded
  76502. * @param onSuccess is a callback called when the task is successfully executed
  76503. * @param onError is a callback called if an error occurs
  76504. */
  76505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76506. }
  76507. /**
  76508. * Define a task used by AssetsManager to load meshes
  76509. */
  76510. export class MeshAssetTask extends AbstractAssetTask {
  76511. /**
  76512. * Defines the name of the task
  76513. */
  76514. name: string;
  76515. /**
  76516. * Defines the list of mesh's names you want to load
  76517. */
  76518. meshesNames: any;
  76519. /**
  76520. * Defines the root url to use as a base to load your meshes and associated resources
  76521. */
  76522. rootUrl: string;
  76523. /**
  76524. * Defines the filename or File of the scene to load from
  76525. */
  76526. sceneFilename: string | File;
  76527. /**
  76528. * Gets the list of loaded meshes
  76529. */
  76530. loadedMeshes: Array<AbstractMesh>;
  76531. /**
  76532. * Gets the list of loaded particle systems
  76533. */
  76534. loadedParticleSystems: Array<IParticleSystem>;
  76535. /**
  76536. * Gets the list of loaded skeletons
  76537. */
  76538. loadedSkeletons: Array<Skeleton>;
  76539. /**
  76540. * Gets the list of loaded animation groups
  76541. */
  76542. loadedAnimationGroups: Array<AnimationGroup>;
  76543. /**
  76544. * Callback called when the task is successful
  76545. */
  76546. onSuccess: (task: MeshAssetTask) => void;
  76547. /**
  76548. * Callback called when the task is successful
  76549. */
  76550. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76551. /**
  76552. * Creates a new MeshAssetTask
  76553. * @param name defines the name of the task
  76554. * @param meshesNames defines the list of mesh's names you want to load
  76555. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76556. * @param sceneFilename defines the filename or File of the scene to load from
  76557. */
  76558. constructor(
  76559. /**
  76560. * Defines the name of the task
  76561. */
  76562. name: string,
  76563. /**
  76564. * Defines the list of mesh's names you want to load
  76565. */
  76566. meshesNames: any,
  76567. /**
  76568. * Defines the root url to use as a base to load your meshes and associated resources
  76569. */
  76570. rootUrl: string,
  76571. /**
  76572. * Defines the filename or File of the scene to load from
  76573. */
  76574. sceneFilename: string | File);
  76575. /**
  76576. * Execute the current task
  76577. * @param scene defines the scene where you want your assets to be loaded
  76578. * @param onSuccess is a callback called when the task is successfully executed
  76579. * @param onError is a callback called if an error occurs
  76580. */
  76581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76582. }
  76583. /**
  76584. * Define a task used by AssetsManager to load text content
  76585. */
  76586. export class TextFileAssetTask extends AbstractAssetTask {
  76587. /**
  76588. * Defines the name of the task
  76589. */
  76590. name: string;
  76591. /**
  76592. * Defines the location of the file to load
  76593. */
  76594. url: string;
  76595. /**
  76596. * Gets the loaded text string
  76597. */
  76598. text: string;
  76599. /**
  76600. * Callback called when the task is successful
  76601. */
  76602. onSuccess: (task: TextFileAssetTask) => void;
  76603. /**
  76604. * Callback called when the task is successful
  76605. */
  76606. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76607. /**
  76608. * Creates a new TextFileAssetTask object
  76609. * @param name defines the name of the task
  76610. * @param url defines the location of the file to load
  76611. */
  76612. constructor(
  76613. /**
  76614. * Defines the name of the task
  76615. */
  76616. name: string,
  76617. /**
  76618. * Defines the location of the file to load
  76619. */
  76620. url: string);
  76621. /**
  76622. * Execute the current task
  76623. * @param scene defines the scene where you want your assets to be loaded
  76624. * @param onSuccess is a callback called when the task is successfully executed
  76625. * @param onError is a callback called if an error occurs
  76626. */
  76627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76628. }
  76629. /**
  76630. * Define a task used by AssetsManager to load binary data
  76631. */
  76632. export class BinaryFileAssetTask extends AbstractAssetTask {
  76633. /**
  76634. * Defines the name of the task
  76635. */
  76636. name: string;
  76637. /**
  76638. * Defines the location of the file to load
  76639. */
  76640. url: string;
  76641. /**
  76642. * Gets the lodaded data (as an array buffer)
  76643. */
  76644. data: ArrayBuffer;
  76645. /**
  76646. * Callback called when the task is successful
  76647. */
  76648. onSuccess: (task: BinaryFileAssetTask) => void;
  76649. /**
  76650. * Callback called when the task is successful
  76651. */
  76652. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76653. /**
  76654. * Creates a new BinaryFileAssetTask object
  76655. * @param name defines the name of the new task
  76656. * @param url defines the location of the file to load
  76657. */
  76658. constructor(
  76659. /**
  76660. * Defines the name of the task
  76661. */
  76662. name: string,
  76663. /**
  76664. * Defines the location of the file to load
  76665. */
  76666. url: string);
  76667. /**
  76668. * Execute the current task
  76669. * @param scene defines the scene where you want your assets to be loaded
  76670. * @param onSuccess is a callback called when the task is successfully executed
  76671. * @param onError is a callback called if an error occurs
  76672. */
  76673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76674. }
  76675. /**
  76676. * Define a task used by AssetsManager to load images
  76677. */
  76678. export class ImageAssetTask extends AbstractAssetTask {
  76679. /**
  76680. * Defines the name of the task
  76681. */
  76682. name: string;
  76683. /**
  76684. * Defines the location of the image to load
  76685. */
  76686. url: string;
  76687. /**
  76688. * Gets the loaded images
  76689. */
  76690. image: HTMLImageElement;
  76691. /**
  76692. * Callback called when the task is successful
  76693. */
  76694. onSuccess: (task: ImageAssetTask) => void;
  76695. /**
  76696. * Callback called when the task is successful
  76697. */
  76698. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76699. /**
  76700. * Creates a new ImageAssetTask
  76701. * @param name defines the name of the task
  76702. * @param url defines the location of the image to load
  76703. */
  76704. constructor(
  76705. /**
  76706. * Defines the name of the task
  76707. */
  76708. name: string,
  76709. /**
  76710. * Defines the location of the image to load
  76711. */
  76712. url: string);
  76713. /**
  76714. * Execute the current task
  76715. * @param scene defines the scene where you want your assets to be loaded
  76716. * @param onSuccess is a callback called when the task is successfully executed
  76717. * @param onError is a callback called if an error occurs
  76718. */
  76719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76720. }
  76721. /**
  76722. * Defines the interface used by texture loading tasks
  76723. */
  76724. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76725. /**
  76726. * Gets the loaded texture
  76727. */
  76728. texture: TEX;
  76729. }
  76730. /**
  76731. * Define a task used by AssetsManager to load 2D textures
  76732. */
  76733. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76734. /**
  76735. * Defines the name of the task
  76736. */
  76737. name: string;
  76738. /**
  76739. * Defines the location of the file to load
  76740. */
  76741. url: string;
  76742. /**
  76743. * Defines if mipmap should not be generated (default is false)
  76744. */
  76745. noMipmap?: boolean | undefined;
  76746. /**
  76747. * Defines if texture must be inverted on Y axis (default is true)
  76748. */
  76749. invertY: boolean;
  76750. /**
  76751. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76752. */
  76753. samplingMode: number;
  76754. /**
  76755. * Gets the loaded texture
  76756. */
  76757. texture: Texture;
  76758. /**
  76759. * Callback called when the task is successful
  76760. */
  76761. onSuccess: (task: TextureAssetTask) => void;
  76762. /**
  76763. * Callback called when the task is successful
  76764. */
  76765. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76766. /**
  76767. * Creates a new TextureAssetTask object
  76768. * @param name defines the name of the task
  76769. * @param url defines the location of the file to load
  76770. * @param noMipmap defines if mipmap should not be generated (default is false)
  76771. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76772. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76773. */
  76774. constructor(
  76775. /**
  76776. * Defines the name of the task
  76777. */
  76778. name: string,
  76779. /**
  76780. * Defines the location of the file to load
  76781. */
  76782. url: string,
  76783. /**
  76784. * Defines if mipmap should not be generated (default is false)
  76785. */
  76786. noMipmap?: boolean | undefined,
  76787. /**
  76788. * Defines if texture must be inverted on Y axis (default is true)
  76789. */
  76790. invertY?: boolean,
  76791. /**
  76792. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76793. */
  76794. samplingMode?: number);
  76795. /**
  76796. * Execute the current task
  76797. * @param scene defines the scene where you want your assets to be loaded
  76798. * @param onSuccess is a callback called when the task is successfully executed
  76799. * @param onError is a callback called if an error occurs
  76800. */
  76801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76802. }
  76803. /**
  76804. * Define a task used by AssetsManager to load cube textures
  76805. */
  76806. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76807. /**
  76808. * Defines the name of the task
  76809. */
  76810. name: string;
  76811. /**
  76812. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76813. */
  76814. url: string;
  76815. /**
  76816. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76817. */
  76818. extensions?: string[] | undefined;
  76819. /**
  76820. * Defines if mipmaps should not be generated (default is false)
  76821. */
  76822. noMipmap?: boolean | undefined;
  76823. /**
  76824. * Defines the explicit list of files (undefined by default)
  76825. */
  76826. files?: string[] | undefined;
  76827. /**
  76828. * Gets the loaded texture
  76829. */
  76830. texture: CubeTexture;
  76831. /**
  76832. * Callback called when the task is successful
  76833. */
  76834. onSuccess: (task: CubeTextureAssetTask) => void;
  76835. /**
  76836. * Callback called when the task is successful
  76837. */
  76838. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76839. /**
  76840. * Creates a new CubeTextureAssetTask
  76841. * @param name defines the name of the task
  76842. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76843. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76844. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76845. * @param files defines the explicit list of files (undefined by default)
  76846. */
  76847. constructor(
  76848. /**
  76849. * Defines the name of the task
  76850. */
  76851. name: string,
  76852. /**
  76853. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76854. */
  76855. url: string,
  76856. /**
  76857. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76858. */
  76859. extensions?: string[] | undefined,
  76860. /**
  76861. * Defines if mipmaps should not be generated (default is false)
  76862. */
  76863. noMipmap?: boolean | undefined,
  76864. /**
  76865. * Defines the explicit list of files (undefined by default)
  76866. */
  76867. files?: string[] | undefined);
  76868. /**
  76869. * Execute the current task
  76870. * @param scene defines the scene where you want your assets to be loaded
  76871. * @param onSuccess is a callback called when the task is successfully executed
  76872. * @param onError is a callback called if an error occurs
  76873. */
  76874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76875. }
  76876. /**
  76877. * Define a task used by AssetsManager to load HDR cube textures
  76878. */
  76879. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76880. /**
  76881. * Defines the name of the task
  76882. */
  76883. name: string;
  76884. /**
  76885. * Defines the location of the file to load
  76886. */
  76887. url: string;
  76888. /**
  76889. * Defines the desired size (the more it increases the longer the generation will be)
  76890. */
  76891. size: number;
  76892. /**
  76893. * Defines if mipmaps should not be generated (default is false)
  76894. */
  76895. noMipmap: boolean;
  76896. /**
  76897. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76898. */
  76899. generateHarmonics: boolean;
  76900. /**
  76901. * 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)
  76902. */
  76903. gammaSpace: boolean;
  76904. /**
  76905. * Internal Use Only
  76906. */
  76907. reserved: boolean;
  76908. /**
  76909. * Gets the loaded texture
  76910. */
  76911. texture: HDRCubeTexture;
  76912. /**
  76913. * Callback called when the task is successful
  76914. */
  76915. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76916. /**
  76917. * Callback called when the task is successful
  76918. */
  76919. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76920. /**
  76921. * Creates a new HDRCubeTextureAssetTask object
  76922. * @param name defines the name of the task
  76923. * @param url defines the location of the file to load
  76924. * @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.
  76925. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76926. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76927. * @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)
  76928. * @param reserved Internal use only
  76929. */
  76930. constructor(
  76931. /**
  76932. * Defines the name of the task
  76933. */
  76934. name: string,
  76935. /**
  76936. * Defines the location of the file to load
  76937. */
  76938. url: string,
  76939. /**
  76940. * Defines the desired size (the more it increases the longer the generation will be)
  76941. */
  76942. size: number,
  76943. /**
  76944. * Defines if mipmaps should not be generated (default is false)
  76945. */
  76946. noMipmap?: boolean,
  76947. /**
  76948. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76949. */
  76950. generateHarmonics?: boolean,
  76951. /**
  76952. * 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)
  76953. */
  76954. gammaSpace?: boolean,
  76955. /**
  76956. * Internal Use Only
  76957. */
  76958. reserved?: boolean);
  76959. /**
  76960. * Execute the current task
  76961. * @param scene defines the scene where you want your assets to be loaded
  76962. * @param onSuccess is a callback called when the task is successfully executed
  76963. * @param onError is a callback called if an error occurs
  76964. */
  76965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76966. }
  76967. /**
  76968. * Define a task used by AssetsManager to load Equirectangular cube textures
  76969. */
  76970. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76971. /**
  76972. * Defines the name of the task
  76973. */
  76974. name: string;
  76975. /**
  76976. * Defines the location of the file to load
  76977. */
  76978. url: string;
  76979. /**
  76980. * Defines the desired size (the more it increases the longer the generation will be)
  76981. */
  76982. size: number;
  76983. /**
  76984. * Defines if mipmaps should not be generated (default is false)
  76985. */
  76986. noMipmap: boolean;
  76987. /**
  76988. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76989. * but the standard material would require them in Gamma space) (default is true)
  76990. */
  76991. gammaSpace: boolean;
  76992. /**
  76993. * Gets the loaded texture
  76994. */
  76995. texture: EquiRectangularCubeTexture;
  76996. /**
  76997. * Callback called when the task is successful
  76998. */
  76999. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77000. /**
  77001. * Callback called when the task is successful
  77002. */
  77003. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77004. /**
  77005. * Creates a new EquiRectangularCubeTextureAssetTask object
  77006. * @param name defines the name of the task
  77007. * @param url defines the location of the file to load
  77008. * @param size defines the desired size (the more it increases the longer the generation will be)
  77009. * If the size is omitted this implies you are using a preprocessed cubemap.
  77010. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77011. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77012. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77013. * (default is true)
  77014. */
  77015. constructor(
  77016. /**
  77017. * Defines the name of the task
  77018. */
  77019. name: string,
  77020. /**
  77021. * Defines the location of the file to load
  77022. */
  77023. url: string,
  77024. /**
  77025. * Defines the desired size (the more it increases the longer the generation will be)
  77026. */
  77027. size: number,
  77028. /**
  77029. * Defines if mipmaps should not be generated (default is false)
  77030. */
  77031. noMipmap?: boolean,
  77032. /**
  77033. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77034. * but the standard material would require them in Gamma space) (default is true)
  77035. */
  77036. gammaSpace?: boolean);
  77037. /**
  77038. * Execute the current task
  77039. * @param scene defines the scene where you want your assets to be loaded
  77040. * @param onSuccess is a callback called when the task is successfully executed
  77041. * @param onError is a callback called if an error occurs
  77042. */
  77043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77044. }
  77045. /**
  77046. * This class can be used to easily import assets into a scene
  77047. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77048. */
  77049. export class AssetsManager {
  77050. private _scene;
  77051. private _isLoading;
  77052. protected _tasks: AbstractAssetTask[];
  77053. protected _waitingTasksCount: number;
  77054. protected _totalTasksCount: number;
  77055. /**
  77056. * Callback called when all tasks are processed
  77057. */
  77058. onFinish: (tasks: AbstractAssetTask[]) => void;
  77059. /**
  77060. * Callback called when a task is successful
  77061. */
  77062. onTaskSuccess: (task: AbstractAssetTask) => void;
  77063. /**
  77064. * Callback called when a task had an error
  77065. */
  77066. onTaskError: (task: AbstractAssetTask) => void;
  77067. /**
  77068. * Callback called when a task is done (whatever the result is)
  77069. */
  77070. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77071. /**
  77072. * Observable called when all tasks are processed
  77073. */
  77074. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77075. /**
  77076. * Observable called when a task had an error
  77077. */
  77078. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77079. /**
  77080. * Observable called when all tasks were executed
  77081. */
  77082. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77083. /**
  77084. * Observable called when a task is done (whatever the result is)
  77085. */
  77086. onProgressObservable: Observable<IAssetsProgressEvent>;
  77087. /**
  77088. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77089. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77090. */
  77091. useDefaultLoadingScreen: boolean;
  77092. /**
  77093. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77094. * when all assets have been downloaded.
  77095. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77096. */
  77097. autoHideLoadingUI: boolean;
  77098. /**
  77099. * Creates a new AssetsManager
  77100. * @param scene defines the scene to work on
  77101. */
  77102. constructor(scene: Scene);
  77103. /**
  77104. * Add a ContainerAssetTask to the list of active tasks
  77105. * @param taskName defines the name of the new task
  77106. * @param meshesNames defines the name of meshes to load
  77107. * @param rootUrl defines the root url to use to locate files
  77108. * @param sceneFilename defines the filename of the scene file
  77109. * @returns a new ContainerAssetTask object
  77110. */
  77111. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77112. /**
  77113. * Add a MeshAssetTask to the list of active tasks
  77114. * @param taskName defines the name of the new task
  77115. * @param meshesNames defines the name of meshes to load
  77116. * @param rootUrl defines the root url to use to locate files
  77117. * @param sceneFilename defines the filename of the scene file
  77118. * @returns a new MeshAssetTask object
  77119. */
  77120. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77121. /**
  77122. * Add a TextFileAssetTask to the list of active tasks
  77123. * @param taskName defines the name of the new task
  77124. * @param url defines the url of the file to load
  77125. * @returns a new TextFileAssetTask object
  77126. */
  77127. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77128. /**
  77129. * Add a BinaryFileAssetTask to the list of active tasks
  77130. * @param taskName defines the name of the new task
  77131. * @param url defines the url of the file to load
  77132. * @returns a new BinaryFileAssetTask object
  77133. */
  77134. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77135. /**
  77136. * Add a ImageAssetTask to the list of active tasks
  77137. * @param taskName defines the name of the new task
  77138. * @param url defines the url of the file to load
  77139. * @returns a new ImageAssetTask object
  77140. */
  77141. addImageTask(taskName: string, url: string): ImageAssetTask;
  77142. /**
  77143. * Add a TextureAssetTask to the list of active tasks
  77144. * @param taskName defines the name of the new task
  77145. * @param url defines the url of the file to load
  77146. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77147. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77148. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77149. * @returns a new TextureAssetTask object
  77150. */
  77151. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77152. /**
  77153. * Add a CubeTextureAssetTask to the list of active tasks
  77154. * @param taskName defines the name of the new task
  77155. * @param url defines the url of the file to load
  77156. * @param extensions defines the extension to use to load the cube map (can be null)
  77157. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77158. * @param files defines the list of files to load (can be null)
  77159. * @returns a new CubeTextureAssetTask object
  77160. */
  77161. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77162. /**
  77163. *
  77164. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77165. * @param taskName defines the name of the new task
  77166. * @param url defines the url of the file to load
  77167. * @param size defines the size you want for the cubemap (can be null)
  77168. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77169. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77170. * @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)
  77171. * @param reserved Internal use only
  77172. * @returns a new HDRCubeTextureAssetTask object
  77173. */
  77174. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77175. /**
  77176. *
  77177. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77178. * @param taskName defines the name of the new task
  77179. * @param url defines the url of the file to load
  77180. * @param size defines the size you want for the cubemap (can be null)
  77181. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77182. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77183. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77184. * @returns a new EquiRectangularCubeTextureAssetTask object
  77185. */
  77186. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77187. /**
  77188. * Remove a task from the assets manager.
  77189. * @param task the task to remove
  77190. */
  77191. removeTask(task: AbstractAssetTask): void;
  77192. private _decreaseWaitingTasksCount;
  77193. private _runTask;
  77194. /**
  77195. * Reset the AssetsManager and remove all tasks
  77196. * @return the current instance of the AssetsManager
  77197. */
  77198. reset(): AssetsManager;
  77199. /**
  77200. * Start the loading process
  77201. * @return the current instance of the AssetsManager
  77202. */
  77203. load(): AssetsManager;
  77204. /**
  77205. * Start the loading process as an async operation
  77206. * @return a promise returning the list of failed tasks
  77207. */
  77208. loadAsync(): Promise<void>;
  77209. }
  77210. }
  77211. declare module "babylonjs/Misc/deferred" {
  77212. /**
  77213. * Wrapper class for promise with external resolve and reject.
  77214. */
  77215. export class Deferred<T> {
  77216. /**
  77217. * The promise associated with this deferred object.
  77218. */
  77219. readonly promise: Promise<T>;
  77220. private _resolve;
  77221. private _reject;
  77222. /**
  77223. * The resolve method of the promise associated with this deferred object.
  77224. */
  77225. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77226. /**
  77227. * The reject method of the promise associated with this deferred object.
  77228. */
  77229. get reject(): (reason?: any) => void;
  77230. /**
  77231. * Constructor for this deferred object.
  77232. */
  77233. constructor();
  77234. }
  77235. }
  77236. declare module "babylonjs/Misc/meshExploder" {
  77237. import { Mesh } from "babylonjs/Meshes/mesh";
  77238. /**
  77239. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77240. */
  77241. export class MeshExploder {
  77242. private _centerMesh;
  77243. private _meshes;
  77244. private _meshesOrigins;
  77245. private _toCenterVectors;
  77246. private _scaledDirection;
  77247. private _newPosition;
  77248. private _centerPosition;
  77249. /**
  77250. * Explodes meshes from a center mesh.
  77251. * @param meshes The meshes to explode.
  77252. * @param centerMesh The mesh to be center of explosion.
  77253. */
  77254. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77255. private _setCenterMesh;
  77256. /**
  77257. * Get class name
  77258. * @returns "MeshExploder"
  77259. */
  77260. getClassName(): string;
  77261. /**
  77262. * "Exploded meshes"
  77263. * @returns Array of meshes with the centerMesh at index 0.
  77264. */
  77265. getMeshes(): Array<Mesh>;
  77266. /**
  77267. * Explodes meshes giving a specific direction
  77268. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77269. */
  77270. explode(direction?: number): void;
  77271. }
  77272. }
  77273. declare module "babylonjs/Misc/filesInput" {
  77274. import { Engine } from "babylonjs/Engines/engine";
  77275. import { Scene } from "babylonjs/scene";
  77276. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77277. import { Nullable } from "babylonjs/types";
  77278. /**
  77279. * Class used to help managing file picking and drag'n'drop
  77280. */
  77281. export class FilesInput {
  77282. /**
  77283. * List of files ready to be loaded
  77284. */
  77285. static get FilesToLoad(): {
  77286. [key: string]: File;
  77287. };
  77288. /**
  77289. * Callback called when a file is processed
  77290. */
  77291. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77292. private _engine;
  77293. private _currentScene;
  77294. private _sceneLoadedCallback;
  77295. private _progressCallback;
  77296. private _additionalRenderLoopLogicCallback;
  77297. private _textureLoadingCallback;
  77298. private _startingProcessingFilesCallback;
  77299. private _onReloadCallback;
  77300. private _errorCallback;
  77301. private _elementToMonitor;
  77302. private _sceneFileToLoad;
  77303. private _filesToLoad;
  77304. /**
  77305. * Creates a new FilesInput
  77306. * @param engine defines the rendering engine
  77307. * @param scene defines the hosting scene
  77308. * @param sceneLoadedCallback callback called when scene is loaded
  77309. * @param progressCallback callback called to track progress
  77310. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77311. * @param textureLoadingCallback callback called when a texture is loading
  77312. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77313. * @param onReloadCallback callback called when a reload is requested
  77314. * @param errorCallback callback call if an error occurs
  77315. */
  77316. 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>);
  77317. private _dragEnterHandler;
  77318. private _dragOverHandler;
  77319. private _dropHandler;
  77320. /**
  77321. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77322. * @param elementToMonitor defines the DOM element to track
  77323. */
  77324. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77325. /** Gets the current list of files to load */
  77326. get filesToLoad(): File[];
  77327. /**
  77328. * Release all associated resources
  77329. */
  77330. dispose(): void;
  77331. private renderFunction;
  77332. private drag;
  77333. private drop;
  77334. private _traverseFolder;
  77335. private _processFiles;
  77336. /**
  77337. * Load files from a drop event
  77338. * @param event defines the drop event to use as source
  77339. */
  77340. loadFiles(event: any): void;
  77341. private _processReload;
  77342. /**
  77343. * Reload the current scene from the loaded files
  77344. */
  77345. reload(): void;
  77346. }
  77347. }
  77348. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77349. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77350. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77351. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77352. }
  77353. declare module "babylonjs/Misc/sceneOptimizer" {
  77354. import { Scene, IDisposable } from "babylonjs/scene";
  77355. import { Observable } from "babylonjs/Misc/observable";
  77356. /**
  77357. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77358. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77359. */
  77360. export class SceneOptimization {
  77361. /**
  77362. * Defines the priority of this optimization (0 by default which means first in the list)
  77363. */
  77364. priority: number;
  77365. /**
  77366. * Gets a string describing the action executed by the current optimization
  77367. * @returns description string
  77368. */
  77369. getDescription(): string;
  77370. /**
  77371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77372. * @param scene defines the current scene where to apply this optimization
  77373. * @param optimizer defines the current optimizer
  77374. * @returns true if everything that can be done was applied
  77375. */
  77376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77377. /**
  77378. * Creates the SceneOptimization object
  77379. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77380. * @param desc defines the description associated with the optimization
  77381. */
  77382. constructor(
  77383. /**
  77384. * Defines the priority of this optimization (0 by default which means first in the list)
  77385. */
  77386. priority?: number);
  77387. }
  77388. /**
  77389. * Defines an optimization used to reduce the size of render target textures
  77390. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77391. */
  77392. export class TextureOptimization extends SceneOptimization {
  77393. /**
  77394. * Defines the priority of this optimization (0 by default which means first in the list)
  77395. */
  77396. priority: number;
  77397. /**
  77398. * 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
  77399. */
  77400. maximumSize: number;
  77401. /**
  77402. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77403. */
  77404. step: number;
  77405. /**
  77406. * Gets a string describing the action executed by the current optimization
  77407. * @returns description string
  77408. */
  77409. getDescription(): string;
  77410. /**
  77411. * Creates the TextureOptimization object
  77412. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77413. * @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
  77414. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77415. */
  77416. constructor(
  77417. /**
  77418. * Defines the priority of this optimization (0 by default which means first in the list)
  77419. */
  77420. priority?: number,
  77421. /**
  77422. * 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
  77423. */
  77424. maximumSize?: number,
  77425. /**
  77426. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77427. */
  77428. step?: number);
  77429. /**
  77430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77431. * @param scene defines the current scene where to apply this optimization
  77432. * @param optimizer defines the current optimizer
  77433. * @returns true if everything that can be done was applied
  77434. */
  77435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77436. }
  77437. /**
  77438. * Defines an optimization used to increase or decrease the rendering resolution
  77439. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77440. */
  77441. export class HardwareScalingOptimization extends SceneOptimization {
  77442. /**
  77443. * Defines the priority of this optimization (0 by default which means first in the list)
  77444. */
  77445. priority: number;
  77446. /**
  77447. * Defines the maximum scale to use (2 by default)
  77448. */
  77449. maximumScale: number;
  77450. /**
  77451. * Defines the step to use between two passes (0.5 by default)
  77452. */
  77453. step: number;
  77454. private _currentScale;
  77455. private _directionOffset;
  77456. /**
  77457. * Gets a string describing the action executed by the current optimization
  77458. * @return description string
  77459. */
  77460. getDescription(): string;
  77461. /**
  77462. * Creates the HardwareScalingOptimization object
  77463. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77464. * @param maximumScale defines the maximum scale to use (2 by default)
  77465. * @param step defines the step to use between two passes (0.5 by default)
  77466. */
  77467. constructor(
  77468. /**
  77469. * Defines the priority of this optimization (0 by default which means first in the list)
  77470. */
  77471. priority?: number,
  77472. /**
  77473. * Defines the maximum scale to use (2 by default)
  77474. */
  77475. maximumScale?: number,
  77476. /**
  77477. * Defines the step to use between two passes (0.5 by default)
  77478. */
  77479. step?: number);
  77480. /**
  77481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77482. * @param scene defines the current scene where to apply this optimization
  77483. * @param optimizer defines the current optimizer
  77484. * @returns true if everything that can be done was applied
  77485. */
  77486. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77487. }
  77488. /**
  77489. * Defines an optimization used to remove shadows
  77490. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77491. */
  77492. export class ShadowsOptimization extends SceneOptimization {
  77493. /**
  77494. * Gets a string describing the action executed by the current optimization
  77495. * @return description string
  77496. */
  77497. getDescription(): string;
  77498. /**
  77499. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77500. * @param scene defines the current scene where to apply this optimization
  77501. * @param optimizer defines the current optimizer
  77502. * @returns true if everything that can be done was applied
  77503. */
  77504. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77505. }
  77506. /**
  77507. * Defines an optimization used to turn post-processes off
  77508. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77509. */
  77510. export class PostProcessesOptimization extends SceneOptimization {
  77511. /**
  77512. * Gets a string describing the action executed by the current optimization
  77513. * @return description string
  77514. */
  77515. getDescription(): string;
  77516. /**
  77517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77518. * @param scene defines the current scene where to apply this optimization
  77519. * @param optimizer defines the current optimizer
  77520. * @returns true if everything that can be done was applied
  77521. */
  77522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77523. }
  77524. /**
  77525. * Defines an optimization used to turn lens flares off
  77526. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77527. */
  77528. export class LensFlaresOptimization extends SceneOptimization {
  77529. /**
  77530. * Gets a string describing the action executed by the current optimization
  77531. * @return description string
  77532. */
  77533. getDescription(): string;
  77534. /**
  77535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77536. * @param scene defines the current scene where to apply this optimization
  77537. * @param optimizer defines the current optimizer
  77538. * @returns true if everything that can be done was applied
  77539. */
  77540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77541. }
  77542. /**
  77543. * Defines an optimization based on user defined callback.
  77544. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77545. */
  77546. export class CustomOptimization extends SceneOptimization {
  77547. /**
  77548. * Callback called to apply the custom optimization.
  77549. */
  77550. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77551. /**
  77552. * Callback called to get custom description
  77553. */
  77554. onGetDescription: () => string;
  77555. /**
  77556. * Gets a string describing the action executed by the current optimization
  77557. * @returns description string
  77558. */
  77559. getDescription(): string;
  77560. /**
  77561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77562. * @param scene defines the current scene where to apply this optimization
  77563. * @param optimizer defines the current optimizer
  77564. * @returns true if everything that can be done was applied
  77565. */
  77566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77567. }
  77568. /**
  77569. * Defines an optimization used to turn particles off
  77570. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77571. */
  77572. export class ParticlesOptimization extends SceneOptimization {
  77573. /**
  77574. * Gets a string describing the action executed by the current optimization
  77575. * @return description string
  77576. */
  77577. getDescription(): string;
  77578. /**
  77579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77580. * @param scene defines the current scene where to apply this optimization
  77581. * @param optimizer defines the current optimizer
  77582. * @returns true if everything that can be done was applied
  77583. */
  77584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77585. }
  77586. /**
  77587. * Defines an optimization used to turn render targets off
  77588. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77589. */
  77590. export class RenderTargetsOptimization extends SceneOptimization {
  77591. /**
  77592. * Gets a string describing the action executed by the current optimization
  77593. * @return description string
  77594. */
  77595. getDescription(): string;
  77596. /**
  77597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77598. * @param scene defines the current scene where to apply this optimization
  77599. * @param optimizer defines the current optimizer
  77600. * @returns true if everything that can be done was applied
  77601. */
  77602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77603. }
  77604. /**
  77605. * Defines an optimization used to merge meshes with compatible materials
  77606. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77607. */
  77608. export class MergeMeshesOptimization extends SceneOptimization {
  77609. private static _UpdateSelectionTree;
  77610. /**
  77611. * Gets or sets a boolean which defines if optimization octree has to be updated
  77612. */
  77613. static get UpdateSelectionTree(): boolean;
  77614. /**
  77615. * Gets or sets a boolean which defines if optimization octree has to be updated
  77616. */
  77617. static set UpdateSelectionTree(value: boolean);
  77618. /**
  77619. * Gets a string describing the action executed by the current optimization
  77620. * @return description string
  77621. */
  77622. getDescription(): string;
  77623. private _canBeMerged;
  77624. /**
  77625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77626. * @param scene defines the current scene where to apply this optimization
  77627. * @param optimizer defines the current optimizer
  77628. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77629. * @returns true if everything that can be done was applied
  77630. */
  77631. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77632. }
  77633. /**
  77634. * Defines a list of options used by SceneOptimizer
  77635. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77636. */
  77637. export class SceneOptimizerOptions {
  77638. /**
  77639. * Defines the target frame rate to reach (60 by default)
  77640. */
  77641. targetFrameRate: number;
  77642. /**
  77643. * Defines the interval between two checkes (2000ms by default)
  77644. */
  77645. trackerDuration: number;
  77646. /**
  77647. * Gets the list of optimizations to apply
  77648. */
  77649. optimizations: SceneOptimization[];
  77650. /**
  77651. * Creates a new list of options used by SceneOptimizer
  77652. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77653. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77654. */
  77655. constructor(
  77656. /**
  77657. * Defines the target frame rate to reach (60 by default)
  77658. */
  77659. targetFrameRate?: number,
  77660. /**
  77661. * Defines the interval between two checkes (2000ms by default)
  77662. */
  77663. trackerDuration?: number);
  77664. /**
  77665. * Add a new optimization
  77666. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77667. * @returns the current SceneOptimizerOptions
  77668. */
  77669. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77670. /**
  77671. * Add a new custom optimization
  77672. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77673. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77674. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77675. * @returns the current SceneOptimizerOptions
  77676. */
  77677. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77678. /**
  77679. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77680. * @param targetFrameRate defines the target frame rate (60 by default)
  77681. * @returns a SceneOptimizerOptions object
  77682. */
  77683. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77684. /**
  77685. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77686. * @param targetFrameRate defines the target frame rate (60 by default)
  77687. * @returns a SceneOptimizerOptions object
  77688. */
  77689. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77690. /**
  77691. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77692. * @param targetFrameRate defines the target frame rate (60 by default)
  77693. * @returns a SceneOptimizerOptions object
  77694. */
  77695. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77696. }
  77697. /**
  77698. * Class used to run optimizations in order to reach a target frame rate
  77699. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77700. */
  77701. export class SceneOptimizer implements IDisposable {
  77702. private _isRunning;
  77703. private _options;
  77704. private _scene;
  77705. private _currentPriorityLevel;
  77706. private _targetFrameRate;
  77707. private _trackerDuration;
  77708. private _currentFrameRate;
  77709. private _sceneDisposeObserver;
  77710. private _improvementMode;
  77711. /**
  77712. * Defines an observable called when the optimizer reaches the target frame rate
  77713. */
  77714. onSuccessObservable: Observable<SceneOptimizer>;
  77715. /**
  77716. * Defines an observable called when the optimizer enables an optimization
  77717. */
  77718. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77719. /**
  77720. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77721. */
  77722. onFailureObservable: Observable<SceneOptimizer>;
  77723. /**
  77724. * Gets a boolean indicating if the optimizer is in improvement mode
  77725. */
  77726. get isInImprovementMode(): boolean;
  77727. /**
  77728. * Gets the current priority level (0 at start)
  77729. */
  77730. get currentPriorityLevel(): number;
  77731. /**
  77732. * Gets the current frame rate checked by the SceneOptimizer
  77733. */
  77734. get currentFrameRate(): number;
  77735. /**
  77736. * Gets or sets the current target frame rate (60 by default)
  77737. */
  77738. get targetFrameRate(): number;
  77739. /**
  77740. * Gets or sets the current target frame rate (60 by default)
  77741. */
  77742. set targetFrameRate(value: number);
  77743. /**
  77744. * Gets or sets the current interval between two checks (every 2000ms by default)
  77745. */
  77746. get trackerDuration(): number;
  77747. /**
  77748. * Gets or sets the current interval between two checks (every 2000ms by default)
  77749. */
  77750. set trackerDuration(value: number);
  77751. /**
  77752. * Gets the list of active optimizations
  77753. */
  77754. get optimizations(): SceneOptimization[];
  77755. /**
  77756. * Creates a new SceneOptimizer
  77757. * @param scene defines the scene to work on
  77758. * @param options defines the options to use with the SceneOptimizer
  77759. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77760. * @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)
  77761. */
  77762. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77763. /**
  77764. * Stops the current optimizer
  77765. */
  77766. stop(): void;
  77767. /**
  77768. * Reset the optimizer to initial step (current priority level = 0)
  77769. */
  77770. reset(): void;
  77771. /**
  77772. * Start the optimizer. By default it will try to reach a specific framerate
  77773. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77774. */
  77775. start(): void;
  77776. private _checkCurrentState;
  77777. /**
  77778. * Release all resources
  77779. */
  77780. dispose(): void;
  77781. /**
  77782. * Helper function to create a SceneOptimizer with one single line of code
  77783. * @param scene defines the scene to work on
  77784. * @param options defines the options to use with the SceneOptimizer
  77785. * @param onSuccess defines a callback to call on success
  77786. * @param onFailure defines a callback to call on failure
  77787. * @returns the new SceneOptimizer object
  77788. */
  77789. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77790. }
  77791. }
  77792. declare module "babylonjs/Misc/sceneSerializer" {
  77793. import { Scene } from "babylonjs/scene";
  77794. /**
  77795. * Class used to serialize a scene into a string
  77796. */
  77797. export class SceneSerializer {
  77798. /**
  77799. * Clear cache used by a previous serialization
  77800. */
  77801. static ClearCache(): void;
  77802. /**
  77803. * Serialize a scene into a JSON compatible object
  77804. * @param scene defines the scene to serialize
  77805. * @returns a JSON compatible object
  77806. */
  77807. static Serialize(scene: Scene): any;
  77808. /**
  77809. * Serialize a mesh into a JSON compatible object
  77810. * @param toSerialize defines the mesh to serialize
  77811. * @param withParents defines if parents must be serialized as well
  77812. * @param withChildren defines if children must be serialized as well
  77813. * @returns a JSON compatible object
  77814. */
  77815. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77816. }
  77817. }
  77818. declare module "babylonjs/Misc/textureTools" {
  77819. import { Texture } from "babylonjs/Materials/Textures/texture";
  77820. /**
  77821. * Class used to host texture specific utilities
  77822. */
  77823. export class TextureTools {
  77824. /**
  77825. * Uses the GPU to create a copy texture rescaled at a given size
  77826. * @param texture Texture to copy from
  77827. * @param width defines the desired width
  77828. * @param height defines the desired height
  77829. * @param useBilinearMode defines if bilinear mode has to be used
  77830. * @return the generated texture
  77831. */
  77832. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77833. }
  77834. }
  77835. declare module "babylonjs/Misc/videoRecorder" {
  77836. import { Nullable } from "babylonjs/types";
  77837. import { Engine } from "babylonjs/Engines/engine";
  77838. /**
  77839. * This represents the different options available for the video capture.
  77840. */
  77841. export interface VideoRecorderOptions {
  77842. /** Defines the mime type of the video. */
  77843. mimeType: string;
  77844. /** Defines the FPS the video should be recorded at. */
  77845. fps: number;
  77846. /** Defines the chunk size for the recording data. */
  77847. recordChunckSize: number;
  77848. /** The audio tracks to attach to the recording. */
  77849. audioTracks?: MediaStreamTrack[];
  77850. }
  77851. /**
  77852. * This can help with recording videos from BabylonJS.
  77853. * This is based on the available WebRTC functionalities of the browser.
  77854. *
  77855. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77856. */
  77857. export class VideoRecorder {
  77858. private static readonly _defaultOptions;
  77859. /**
  77860. * Returns whether or not the VideoRecorder is available in your browser.
  77861. * @param engine Defines the Babylon Engine.
  77862. * @returns true if supported otherwise false.
  77863. */
  77864. static IsSupported(engine: Engine): boolean;
  77865. private readonly _options;
  77866. private _canvas;
  77867. private _mediaRecorder;
  77868. private _recordedChunks;
  77869. private _fileName;
  77870. private _resolve;
  77871. private _reject;
  77872. /**
  77873. * True when a recording is already in progress.
  77874. */
  77875. get isRecording(): boolean;
  77876. /**
  77877. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77878. * @param engine Defines the BabylonJS Engine you wish to record.
  77879. * @param options Defines options that can be used to customize the capture.
  77880. */
  77881. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77882. /**
  77883. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77884. */
  77885. stopRecording(): void;
  77886. /**
  77887. * Starts recording the canvas for a max duration specified in parameters.
  77888. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77889. * If null no automatic download will start and you can rely on the promise to get the data back.
  77890. * @param maxDuration Defines the maximum recording time in seconds.
  77891. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77892. * @return A promise callback at the end of the recording with the video data in Blob.
  77893. */
  77894. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77895. /**
  77896. * Releases internal resources used during the recording.
  77897. */
  77898. dispose(): void;
  77899. private _handleDataAvailable;
  77900. private _handleError;
  77901. private _handleStop;
  77902. }
  77903. }
  77904. declare module "babylonjs/Misc/screenshotTools" {
  77905. import { Camera } from "babylonjs/Cameras/camera";
  77906. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77907. import { Engine } from "babylonjs/Engines/engine";
  77908. /**
  77909. * Class containing a set of static utilities functions for screenshots
  77910. */
  77911. export class ScreenshotTools {
  77912. /**
  77913. * Captures a screenshot of the current rendering
  77914. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77915. * @param engine defines the rendering engine
  77916. * @param camera defines the source camera
  77917. * @param size This parameter can be set to a single number or to an object with the
  77918. * following (optional) properties: precision, width, height. If a single number is passed,
  77919. * it will be used for both width and height. If an object is passed, the screenshot size
  77920. * will be derived from the parameters. The precision property is a multiplier allowing
  77921. * rendering at a higher or lower resolution
  77922. * @param successCallback defines the callback receives a single parameter which contains the
  77923. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77924. * src parameter of an <img> to display it
  77925. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77926. * Check your browser for supported MIME types
  77927. */
  77928. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77929. /**
  77930. * Captures a screenshot of the current rendering
  77931. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77932. * @param engine defines the rendering engine
  77933. * @param camera defines the source camera
  77934. * @param size This parameter can be set to a single number or to an object with the
  77935. * following (optional) properties: precision, width, height. If a single number is passed,
  77936. * it will be used for both width and height. If an object is passed, the screenshot size
  77937. * will be derived from the parameters. The precision property is a multiplier allowing
  77938. * rendering at a higher or lower resolution
  77939. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77940. * Check your browser for supported MIME types
  77941. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77942. * to the src parameter of an <img> to display it
  77943. */
  77944. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77945. /**
  77946. * Generates an image screenshot from the specified camera.
  77947. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77948. * @param engine The engine to use for rendering
  77949. * @param camera The camera to use for rendering
  77950. * @param size This parameter can be set to a single number or to an object with the
  77951. * following (optional) properties: precision, width, height. If a single number is passed,
  77952. * it will be used for both width and height. If an object is passed, the screenshot size
  77953. * will be derived from the parameters. The precision property is a multiplier allowing
  77954. * rendering at a higher or lower resolution
  77955. * @param successCallback The callback receives a single parameter which contains the
  77956. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77957. * src parameter of an <img> to display it
  77958. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77959. * Check your browser for supported MIME types
  77960. * @param samples Texture samples (default: 1)
  77961. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77962. * @param fileName A name for for the downloaded file.
  77963. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77964. */
  77965. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77966. /**
  77967. * Generates an image screenshot from the specified camera.
  77968. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77969. * @param engine The engine to use for rendering
  77970. * @param camera The camera to use for rendering
  77971. * @param size This parameter can be set to a single number or to an object with the
  77972. * following (optional) properties: precision, width, height. If a single number is passed,
  77973. * it will be used for both width and height. If an object is passed, the screenshot size
  77974. * will be derived from the parameters. The precision property is a multiplier allowing
  77975. * rendering at a higher or lower resolution
  77976. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77977. * Check your browser for supported MIME types
  77978. * @param samples Texture samples (default: 1)
  77979. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77980. * @param fileName A name for for the downloaded file.
  77981. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77982. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77983. * to the src parameter of an <img> to display it
  77984. */
  77985. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77986. /**
  77987. * Gets height and width for screenshot size
  77988. * @private
  77989. */
  77990. private static _getScreenshotSize;
  77991. }
  77992. }
  77993. declare module "babylonjs/Misc/dataReader" {
  77994. /**
  77995. * Interface for a data buffer
  77996. */
  77997. export interface IDataBuffer {
  77998. /**
  77999. * Reads bytes from the data buffer.
  78000. * @param byteOffset The byte offset to read
  78001. * @param byteLength The byte length to read
  78002. * @returns A promise that resolves when the bytes are read
  78003. */
  78004. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78005. /**
  78006. * The byte length of the buffer.
  78007. */
  78008. readonly byteLength: number;
  78009. }
  78010. /**
  78011. * Utility class for reading from a data buffer
  78012. */
  78013. export class DataReader {
  78014. /**
  78015. * The data buffer associated with this data reader.
  78016. */
  78017. readonly buffer: IDataBuffer;
  78018. /**
  78019. * The current byte offset from the beginning of the data buffer.
  78020. */
  78021. byteOffset: number;
  78022. private _dataView;
  78023. private _dataByteOffset;
  78024. /**
  78025. * Constructor
  78026. * @param buffer The buffer to read
  78027. */
  78028. constructor(buffer: IDataBuffer);
  78029. /**
  78030. * Loads the given byte length.
  78031. * @param byteLength The byte length to load
  78032. * @returns A promise that resolves when the load is complete
  78033. */
  78034. loadAsync(byteLength: number): Promise<void>;
  78035. /**
  78036. * Read a unsigned 32-bit integer from the currently loaded data range.
  78037. * @returns The 32-bit integer read
  78038. */
  78039. readUint32(): number;
  78040. /**
  78041. * Read a byte array from the currently loaded data range.
  78042. * @param byteLength The byte length to read
  78043. * @returns The byte array read
  78044. */
  78045. readUint8Array(byteLength: number): Uint8Array;
  78046. /**
  78047. * Read a string from the currently loaded data range.
  78048. * @param byteLength The byte length to read
  78049. * @returns The string read
  78050. */
  78051. readString(byteLength: number): string;
  78052. /**
  78053. * Skips the given byte length the currently loaded data range.
  78054. * @param byteLength The byte length to skip
  78055. */
  78056. skipBytes(byteLength: number): void;
  78057. }
  78058. }
  78059. declare module "babylonjs/Misc/dataStorage" {
  78060. /**
  78061. * Class for storing data to local storage if available or in-memory storage otherwise
  78062. */
  78063. export class DataStorage {
  78064. private static _Storage;
  78065. private static _GetStorage;
  78066. /**
  78067. * Reads a string from the data storage
  78068. * @param key The key to read
  78069. * @param defaultValue The value if the key doesn't exist
  78070. * @returns The string value
  78071. */
  78072. static ReadString(key: string, defaultValue: string): string;
  78073. /**
  78074. * Writes a string to the data storage
  78075. * @param key The key to write
  78076. * @param value The value to write
  78077. */
  78078. static WriteString(key: string, value: string): void;
  78079. /**
  78080. * Reads a boolean from the data storage
  78081. * @param key The key to read
  78082. * @param defaultValue The value if the key doesn't exist
  78083. * @returns The boolean value
  78084. */
  78085. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78086. /**
  78087. * Writes a boolean to the data storage
  78088. * @param key The key to write
  78089. * @param value The value to write
  78090. */
  78091. static WriteBoolean(key: string, value: boolean): void;
  78092. /**
  78093. * Reads a number from the data storage
  78094. * @param key The key to read
  78095. * @param defaultValue The value if the key doesn't exist
  78096. * @returns The number value
  78097. */
  78098. static ReadNumber(key: string, defaultValue: number): number;
  78099. /**
  78100. * Writes a number to the data storage
  78101. * @param key The key to write
  78102. * @param value The value to write
  78103. */
  78104. static WriteNumber(key: string, value: number): void;
  78105. }
  78106. }
  78107. declare module "babylonjs/Misc/sceneRecorder" {
  78108. import { Scene } from "babylonjs/scene";
  78109. /**
  78110. * Class used to record delta files between 2 scene states
  78111. */
  78112. export class SceneRecorder {
  78113. private _trackedScene;
  78114. private _savedJSON;
  78115. /**
  78116. * Track a given scene. This means the current scene state will be considered the original state
  78117. * @param scene defines the scene to track
  78118. */
  78119. track(scene: Scene): void;
  78120. /**
  78121. * Get the delta between current state and original state
  78122. * @returns a string containing the delta
  78123. */
  78124. getDelta(): any;
  78125. private _compareArray;
  78126. private _compareObjects;
  78127. private _compareCollections;
  78128. private static GetShadowGeneratorById;
  78129. /**
  78130. * Apply a given delta to a given scene
  78131. * @param deltaJSON defines the JSON containing the delta
  78132. * @param scene defines the scene to apply the delta to
  78133. */
  78134. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78135. private static _ApplyPropertiesToEntity;
  78136. private static _ApplyDeltaForEntity;
  78137. }
  78138. }
  78139. declare module "babylonjs/Misc/index" {
  78140. export * from "babylonjs/Misc/andOrNotEvaluator";
  78141. export * from "babylonjs/Misc/assetsManager";
  78142. export * from "babylonjs/Misc/basis";
  78143. export * from "babylonjs/Misc/dds";
  78144. export * from "babylonjs/Misc/decorators";
  78145. export * from "babylonjs/Misc/deferred";
  78146. export * from "babylonjs/Misc/environmentTextureTools";
  78147. export * from "babylonjs/Misc/meshExploder";
  78148. export * from "babylonjs/Misc/filesInput";
  78149. export * from "babylonjs/Misc/HighDynamicRange/index";
  78150. export * from "babylonjs/Misc/khronosTextureContainer";
  78151. export * from "babylonjs/Misc/observable";
  78152. export * from "babylonjs/Misc/performanceMonitor";
  78153. export * from "babylonjs/Misc/promise";
  78154. export * from "babylonjs/Misc/sceneOptimizer";
  78155. export * from "babylonjs/Misc/sceneSerializer";
  78156. export * from "babylonjs/Misc/smartArray";
  78157. export * from "babylonjs/Misc/stringDictionary";
  78158. export * from "babylonjs/Misc/tags";
  78159. export * from "babylonjs/Misc/textureTools";
  78160. export * from "babylonjs/Misc/tga";
  78161. export * from "babylonjs/Misc/tools";
  78162. export * from "babylonjs/Misc/videoRecorder";
  78163. export * from "babylonjs/Misc/virtualJoystick";
  78164. export * from "babylonjs/Misc/workerPool";
  78165. export * from "babylonjs/Misc/logger";
  78166. export * from "babylonjs/Misc/typeStore";
  78167. export * from "babylonjs/Misc/filesInputStore";
  78168. export * from "babylonjs/Misc/deepCopier";
  78169. export * from "babylonjs/Misc/pivotTools";
  78170. export * from "babylonjs/Misc/precisionDate";
  78171. export * from "babylonjs/Misc/screenshotTools";
  78172. export * from "babylonjs/Misc/typeStore";
  78173. export * from "babylonjs/Misc/webRequest";
  78174. export * from "babylonjs/Misc/iInspectable";
  78175. export * from "babylonjs/Misc/brdfTextureTools";
  78176. export * from "babylonjs/Misc/rgbdTextureTools";
  78177. export * from "babylonjs/Misc/gradients";
  78178. export * from "babylonjs/Misc/perfCounter";
  78179. export * from "babylonjs/Misc/fileRequest";
  78180. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78181. export * from "babylonjs/Misc/retryStrategy";
  78182. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78183. export * from "babylonjs/Misc/canvasGenerator";
  78184. export * from "babylonjs/Misc/fileTools";
  78185. export * from "babylonjs/Misc/stringTools";
  78186. export * from "babylonjs/Misc/dataReader";
  78187. export * from "babylonjs/Misc/minMaxReducer";
  78188. export * from "babylonjs/Misc/depthReducer";
  78189. export * from "babylonjs/Misc/dataStorage";
  78190. export * from "babylonjs/Misc/sceneRecorder";
  78191. }
  78192. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78193. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78194. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78195. import { Observable } from "babylonjs/Misc/observable";
  78196. import { Matrix } from "babylonjs/Maths/math.vector";
  78197. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78198. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78199. /**
  78200. * An interface for all Hit test features
  78201. */
  78202. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78203. /**
  78204. * Triggered when new babylon (transformed) hit test results are available
  78205. */
  78206. onHitTestResultObservable: Observable<T[]>;
  78207. }
  78208. /**
  78209. * Options used for hit testing
  78210. */
  78211. export interface IWebXRLegacyHitTestOptions {
  78212. /**
  78213. * Only test when user interacted with the scene. Default - hit test every frame
  78214. */
  78215. testOnPointerDownOnly?: boolean;
  78216. /**
  78217. * The node to use to transform the local results to world coordinates
  78218. */
  78219. worldParentNode?: TransformNode;
  78220. }
  78221. /**
  78222. * Interface defining the babylon result of raycasting/hit-test
  78223. */
  78224. export interface IWebXRLegacyHitResult {
  78225. /**
  78226. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78227. */
  78228. transformationMatrix: Matrix;
  78229. /**
  78230. * The native hit test result
  78231. */
  78232. xrHitResult: XRHitResult | XRHitTestResult;
  78233. }
  78234. /**
  78235. * The currently-working hit-test module.
  78236. * Hit test (or Ray-casting) is used to interact with the real world.
  78237. * For further information read here - https://github.com/immersive-web/hit-test
  78238. */
  78239. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78240. /**
  78241. * options to use when constructing this feature
  78242. */
  78243. readonly options: IWebXRLegacyHitTestOptions;
  78244. private _direction;
  78245. private _mat;
  78246. private _onSelectEnabled;
  78247. private _origin;
  78248. /**
  78249. * The module's name
  78250. */
  78251. static readonly Name: string;
  78252. /**
  78253. * The (Babylon) version of this module.
  78254. * This is an integer representing the implementation version.
  78255. * This number does not correspond to the WebXR specs version
  78256. */
  78257. static readonly Version: number;
  78258. /**
  78259. * Populated with the last native XR Hit Results
  78260. */
  78261. lastNativeXRHitResults: XRHitResult[];
  78262. /**
  78263. * Triggered when new babylon (transformed) hit test results are available
  78264. */
  78265. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78266. /**
  78267. * Creates a new instance of the (legacy version) hit test feature
  78268. * @param _xrSessionManager an instance of WebXRSessionManager
  78269. * @param options options to use when constructing this feature
  78270. */
  78271. constructor(_xrSessionManager: WebXRSessionManager,
  78272. /**
  78273. * options to use when constructing this feature
  78274. */
  78275. options?: IWebXRLegacyHitTestOptions);
  78276. /**
  78277. * execute a hit test with an XR Ray
  78278. *
  78279. * @param xrSession a native xrSession that will execute this hit test
  78280. * @param xrRay the ray (position and direction) to use for ray-casting
  78281. * @param referenceSpace native XR reference space to use for the hit-test
  78282. * @param filter filter function that will filter the results
  78283. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78284. */
  78285. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78286. /**
  78287. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78288. * @param event the (select) event to use to select with
  78289. * @param referenceSpace the reference space to use for this hit test
  78290. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78291. */
  78292. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78293. /**
  78294. * attach this feature
  78295. * Will usually be called by the features manager
  78296. *
  78297. * @returns true if successful.
  78298. */
  78299. attach(): boolean;
  78300. /**
  78301. * detach this feature.
  78302. * Will usually be called by the features manager
  78303. *
  78304. * @returns true if successful.
  78305. */
  78306. detach(): boolean;
  78307. /**
  78308. * Dispose this feature and all of the resources attached
  78309. */
  78310. dispose(): void;
  78311. protected _onXRFrame(frame: XRFrame): void;
  78312. private _onHitTestResults;
  78313. private _onSelect;
  78314. }
  78315. }
  78316. declare module "babylonjs/XR/features/WebXRHitTest" {
  78317. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78318. import { Observable } from "babylonjs/Misc/observable";
  78319. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78320. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78321. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78322. /**
  78323. * Options used for hit testing (version 2)
  78324. */
  78325. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78326. /**
  78327. * Do not create a permanent hit test. Will usually be used when only
  78328. * transient inputs are needed.
  78329. */
  78330. disablePermanentHitTest?: boolean;
  78331. /**
  78332. * Enable transient (for example touch-based) hit test inspections
  78333. */
  78334. enableTransientHitTest?: boolean;
  78335. /**
  78336. * Offset ray for the permanent hit test
  78337. */
  78338. offsetRay?: Vector3;
  78339. /**
  78340. * Offset ray for the transient hit test
  78341. */
  78342. transientOffsetRay?: Vector3;
  78343. /**
  78344. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78345. */
  78346. useReferenceSpace?: boolean;
  78347. /**
  78348. * Override the default entity type(s) of the hit-test result
  78349. */
  78350. entityTypes?: XRHitTestTrackableType[];
  78351. }
  78352. /**
  78353. * Interface defining the babylon result of hit-test
  78354. */
  78355. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78356. /**
  78357. * The input source that generated this hit test (if transient)
  78358. */
  78359. inputSource?: XRInputSource;
  78360. /**
  78361. * Is this a transient hit test
  78362. */
  78363. isTransient?: boolean;
  78364. /**
  78365. * Position of the hit test result
  78366. */
  78367. position: Vector3;
  78368. /**
  78369. * Rotation of the hit test result
  78370. */
  78371. rotationQuaternion: Quaternion;
  78372. /**
  78373. * The native hit test result
  78374. */
  78375. xrHitResult: XRHitTestResult;
  78376. }
  78377. /**
  78378. * The currently-working hit-test module.
  78379. * Hit test (or Ray-casting) is used to interact with the real world.
  78380. * For further information read here - https://github.com/immersive-web/hit-test
  78381. *
  78382. * Tested on chrome (mobile) 80.
  78383. */
  78384. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78385. /**
  78386. * options to use when constructing this feature
  78387. */
  78388. readonly options: IWebXRHitTestOptions;
  78389. private _tmpMat;
  78390. private _tmpPos;
  78391. private _tmpQuat;
  78392. private _transientXrHitTestSource;
  78393. private _xrHitTestSource;
  78394. private initHitTestSource;
  78395. /**
  78396. * The module's name
  78397. */
  78398. static readonly Name: string;
  78399. /**
  78400. * The (Babylon) version of this module.
  78401. * This is an integer representing the implementation version.
  78402. * This number does not correspond to the WebXR specs version
  78403. */
  78404. static readonly Version: number;
  78405. /**
  78406. * When set to true, each hit test will have its own position/rotation objects
  78407. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78408. * the developers will clone them or copy them as they see fit.
  78409. */
  78410. autoCloneTransformation: boolean;
  78411. /**
  78412. * Triggered when new babylon (transformed) hit test results are available
  78413. */
  78414. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78415. /**
  78416. * Use this to temporarily pause hit test checks.
  78417. */
  78418. paused: boolean;
  78419. /**
  78420. * Creates a new instance of the hit test feature
  78421. * @param _xrSessionManager an instance of WebXRSessionManager
  78422. * @param options options to use when constructing this feature
  78423. */
  78424. constructor(_xrSessionManager: WebXRSessionManager,
  78425. /**
  78426. * options to use when constructing this feature
  78427. */
  78428. options?: IWebXRHitTestOptions);
  78429. /**
  78430. * attach this feature
  78431. * Will usually be called by the features manager
  78432. *
  78433. * @returns true if successful.
  78434. */
  78435. attach(): boolean;
  78436. /**
  78437. * detach this feature.
  78438. * Will usually be called by the features manager
  78439. *
  78440. * @returns true if successful.
  78441. */
  78442. detach(): boolean;
  78443. /**
  78444. * Dispose this feature and all of the resources attached
  78445. */
  78446. dispose(): void;
  78447. protected _onXRFrame(frame: XRFrame): void;
  78448. private _processWebXRHitTestResult;
  78449. }
  78450. }
  78451. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78452. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78453. import { Observable } from "babylonjs/Misc/observable";
  78454. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78455. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78456. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78457. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78458. /**
  78459. * Configuration options of the anchor system
  78460. */
  78461. export interface IWebXRAnchorSystemOptions {
  78462. /**
  78463. * a node that will be used to convert local to world coordinates
  78464. */
  78465. worldParentNode?: TransformNode;
  78466. /**
  78467. * If set to true a reference of the created anchors will be kept until the next session starts
  78468. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78469. */
  78470. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78471. }
  78472. /**
  78473. * A babylon container for an XR Anchor
  78474. */
  78475. export interface IWebXRAnchor {
  78476. /**
  78477. * A babylon-assigned ID for this anchor
  78478. */
  78479. id: number;
  78480. /**
  78481. * Transformation matrix to apply to an object attached to this anchor
  78482. */
  78483. transformationMatrix: Matrix;
  78484. /**
  78485. * The native anchor object
  78486. */
  78487. xrAnchor: XRAnchor;
  78488. /**
  78489. * if defined, this object will be constantly updated by the anchor's position and rotation
  78490. */
  78491. attachedNode?: TransformNode;
  78492. }
  78493. /**
  78494. * An implementation of the anchor system for WebXR.
  78495. * For further information see https://github.com/immersive-web/anchors/
  78496. */
  78497. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78498. private _options;
  78499. private _lastFrameDetected;
  78500. private _trackedAnchors;
  78501. private _referenceSpaceForFrameAnchors;
  78502. private _futureAnchors;
  78503. /**
  78504. * The module's name
  78505. */
  78506. static readonly Name: string;
  78507. /**
  78508. * The (Babylon) version of this module.
  78509. * This is an integer representing the implementation version.
  78510. * This number does not correspond to the WebXR specs version
  78511. */
  78512. static readonly Version: number;
  78513. /**
  78514. * Observers registered here will be executed when a new anchor was added to the session
  78515. */
  78516. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78517. /**
  78518. * Observers registered here will be executed when an anchor was removed from the session
  78519. */
  78520. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78521. /**
  78522. * Observers registered here will be executed when an existing anchor updates
  78523. * This can execute N times every frame
  78524. */
  78525. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78526. /**
  78527. * Set the reference space to use for anchor creation, when not using a hit test.
  78528. * Will default to the session's reference space if not defined
  78529. */
  78530. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78531. /**
  78532. * constructs a new anchor system
  78533. * @param _xrSessionManager an instance of WebXRSessionManager
  78534. * @param _options configuration object for this feature
  78535. */
  78536. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78537. private _tmpVector;
  78538. private _tmpQuaternion;
  78539. private _populateTmpTransformation;
  78540. /**
  78541. * Create a new anchor point using a hit test result at a specific point in the scene
  78542. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78543. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78544. *
  78545. * @param hitTestResult The hit test result to use for this anchor creation
  78546. * @param position an optional position offset for this anchor
  78547. * @param rotationQuaternion an optional rotation offset for this anchor
  78548. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78549. */
  78550. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78551. /**
  78552. * Add a new anchor at a specific position and rotation
  78553. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78554. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78555. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78556. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78557. *
  78558. * @param position the position in which to add an anchor
  78559. * @param rotationQuaternion an optional rotation for the anchor transformation
  78560. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78561. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78562. */
  78563. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78564. /**
  78565. * detach this feature.
  78566. * Will usually be called by the features manager
  78567. *
  78568. * @returns true if successful.
  78569. */
  78570. detach(): boolean;
  78571. /**
  78572. * Dispose this feature and all of the resources attached
  78573. */
  78574. dispose(): void;
  78575. protected _onXRFrame(frame: XRFrame): void;
  78576. /**
  78577. * avoiding using Array.find for global support.
  78578. * @param xrAnchor the plane to find in the array
  78579. */
  78580. private _findIndexInAnchorArray;
  78581. private _updateAnchorWithXRFrame;
  78582. private _createAnchorAtTransformation;
  78583. }
  78584. }
  78585. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78586. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78587. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78588. import { Observable } from "babylonjs/Misc/observable";
  78589. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78590. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78591. /**
  78592. * Options used in the plane detector module
  78593. */
  78594. export interface IWebXRPlaneDetectorOptions {
  78595. /**
  78596. * The node to use to transform the local results to world coordinates
  78597. */
  78598. worldParentNode?: TransformNode;
  78599. /**
  78600. * If set to true a reference of the created planes will be kept until the next session starts
  78601. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78602. */
  78603. doNotRemovePlanesOnSessionEnded?: boolean;
  78604. }
  78605. /**
  78606. * A babylon interface for a WebXR plane.
  78607. * A Plane is actually a polygon, built from N points in space
  78608. *
  78609. * Supported in chrome 79, not supported in canary 81 ATM
  78610. */
  78611. export interface IWebXRPlane {
  78612. /**
  78613. * a babylon-assigned ID for this polygon
  78614. */
  78615. id: number;
  78616. /**
  78617. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78618. */
  78619. polygonDefinition: Array<Vector3>;
  78620. /**
  78621. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78622. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78623. */
  78624. transformationMatrix: Matrix;
  78625. /**
  78626. * the native xr-plane object
  78627. */
  78628. xrPlane: XRPlane;
  78629. }
  78630. /**
  78631. * The plane detector is used to detect planes in the real world when in AR
  78632. * For more information see https://github.com/immersive-web/real-world-geometry/
  78633. */
  78634. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78635. private _options;
  78636. private _detectedPlanes;
  78637. private _enabled;
  78638. private _lastFrameDetected;
  78639. /**
  78640. * The module's name
  78641. */
  78642. static readonly Name: string;
  78643. /**
  78644. * The (Babylon) version of this module.
  78645. * This is an integer representing the implementation version.
  78646. * This number does not correspond to the WebXR specs version
  78647. */
  78648. static readonly Version: number;
  78649. /**
  78650. * Observers registered here will be executed when a new plane was added to the session
  78651. */
  78652. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78653. /**
  78654. * Observers registered here will be executed when a plane is no longer detected in the session
  78655. */
  78656. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78657. /**
  78658. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78659. * This can execute N times every frame
  78660. */
  78661. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78662. /**
  78663. * construct a new Plane Detector
  78664. * @param _xrSessionManager an instance of xr Session manager
  78665. * @param _options configuration to use when constructing this feature
  78666. */
  78667. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78668. /**
  78669. * detach this feature.
  78670. * Will usually be called by the features manager
  78671. *
  78672. * @returns true if successful.
  78673. */
  78674. detach(): boolean;
  78675. /**
  78676. * Dispose this feature and all of the resources attached
  78677. */
  78678. dispose(): void;
  78679. protected _onXRFrame(frame: XRFrame): void;
  78680. private _init;
  78681. private _updatePlaneWithXRPlane;
  78682. /**
  78683. * avoiding using Array.find for global support.
  78684. * @param xrPlane the plane to find in the array
  78685. */
  78686. private findIndexInPlaneArray;
  78687. }
  78688. }
  78689. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78690. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78692. import { Observable } from "babylonjs/Misc/observable";
  78693. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78694. /**
  78695. * Options interface for the background remover plugin
  78696. */
  78697. export interface IWebXRBackgroundRemoverOptions {
  78698. /**
  78699. * Further background meshes to disable when entering AR
  78700. */
  78701. backgroundMeshes?: AbstractMesh[];
  78702. /**
  78703. * flags to configure the removal of the environment helper.
  78704. * If not set, the entire background will be removed. If set, flags should be set as well.
  78705. */
  78706. environmentHelperRemovalFlags?: {
  78707. /**
  78708. * Should the skybox be removed (default false)
  78709. */
  78710. skyBox?: boolean;
  78711. /**
  78712. * Should the ground be removed (default false)
  78713. */
  78714. ground?: boolean;
  78715. };
  78716. /**
  78717. * don't disable the environment helper
  78718. */
  78719. ignoreEnvironmentHelper?: boolean;
  78720. }
  78721. /**
  78722. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78723. */
  78724. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78725. /**
  78726. * read-only options to be used in this module
  78727. */
  78728. readonly options: IWebXRBackgroundRemoverOptions;
  78729. /**
  78730. * The module's name
  78731. */
  78732. static readonly Name: string;
  78733. /**
  78734. * The (Babylon) version of this module.
  78735. * This is an integer representing the implementation version.
  78736. * This number does not correspond to the WebXR specs version
  78737. */
  78738. static readonly Version: number;
  78739. /**
  78740. * registered observers will be triggered when the background state changes
  78741. */
  78742. onBackgroundStateChangedObservable: Observable<boolean>;
  78743. /**
  78744. * constructs a new background remover module
  78745. * @param _xrSessionManager the session manager for this module
  78746. * @param options read-only options to be used in this module
  78747. */
  78748. constructor(_xrSessionManager: WebXRSessionManager,
  78749. /**
  78750. * read-only options to be used in this module
  78751. */
  78752. options?: IWebXRBackgroundRemoverOptions);
  78753. /**
  78754. * attach this feature
  78755. * Will usually be called by the features manager
  78756. *
  78757. * @returns true if successful.
  78758. */
  78759. attach(): boolean;
  78760. /**
  78761. * detach this feature.
  78762. * Will usually be called by the features manager
  78763. *
  78764. * @returns true if successful.
  78765. */
  78766. detach(): boolean;
  78767. /**
  78768. * Dispose this feature and all of the resources attached
  78769. */
  78770. dispose(): void;
  78771. protected _onXRFrame(_xrFrame: XRFrame): void;
  78772. private _setBackgroundState;
  78773. }
  78774. }
  78775. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78776. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78777. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78778. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78779. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78780. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78781. import { Nullable } from "babylonjs/types";
  78782. /**
  78783. * Options for the controller physics feature
  78784. */
  78785. export class IWebXRControllerPhysicsOptions {
  78786. /**
  78787. * Should the headset get its own impostor
  78788. */
  78789. enableHeadsetImpostor?: boolean;
  78790. /**
  78791. * Optional parameters for the headset impostor
  78792. */
  78793. headsetImpostorParams?: {
  78794. /**
  78795. * The type of impostor to create. Default is sphere
  78796. */
  78797. impostorType: number;
  78798. /**
  78799. * the size of the impostor. Defaults to 10cm
  78800. */
  78801. impostorSize?: number | {
  78802. width: number;
  78803. height: number;
  78804. depth: number;
  78805. };
  78806. /**
  78807. * Friction definitions
  78808. */
  78809. friction?: number;
  78810. /**
  78811. * Restitution
  78812. */
  78813. restitution?: number;
  78814. };
  78815. /**
  78816. * The physics properties of the future impostors
  78817. */
  78818. physicsProperties?: {
  78819. /**
  78820. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78821. * Note that this requires a physics engine that supports mesh impostors!
  78822. */
  78823. useControllerMesh?: boolean;
  78824. /**
  78825. * The type of impostor to create. Default is sphere
  78826. */
  78827. impostorType?: number;
  78828. /**
  78829. * the size of the impostor. Defaults to 10cm
  78830. */
  78831. impostorSize?: number | {
  78832. width: number;
  78833. height: number;
  78834. depth: number;
  78835. };
  78836. /**
  78837. * Friction definitions
  78838. */
  78839. friction?: number;
  78840. /**
  78841. * Restitution
  78842. */
  78843. restitution?: number;
  78844. };
  78845. /**
  78846. * the xr input to use with this pointer selection
  78847. */
  78848. xrInput: WebXRInput;
  78849. }
  78850. /**
  78851. * Add physics impostor to your webxr controllers,
  78852. * including naive calculation of their linear and angular velocity
  78853. */
  78854. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78855. private readonly _options;
  78856. private _attachController;
  78857. private _controllers;
  78858. private _debugMode;
  78859. private _delta;
  78860. private _headsetImpostor?;
  78861. private _headsetMesh?;
  78862. private _lastTimestamp;
  78863. private _tmpQuaternion;
  78864. private _tmpVector;
  78865. /**
  78866. * The module's name
  78867. */
  78868. static readonly Name: string;
  78869. /**
  78870. * The (Babylon) version of this module.
  78871. * This is an integer representing the implementation version.
  78872. * This number does not correspond to the webxr specs version
  78873. */
  78874. static readonly Version: number;
  78875. /**
  78876. * Construct a new Controller Physics Feature
  78877. * @param _xrSessionManager the corresponding xr session manager
  78878. * @param _options options to create this feature with
  78879. */
  78880. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78881. /**
  78882. * @hidden
  78883. * enable debugging - will show console outputs and the impostor mesh
  78884. */
  78885. _enablePhysicsDebug(): void;
  78886. /**
  78887. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78888. * @param xrController the controller to add
  78889. */
  78890. addController(xrController: WebXRInputSource): void;
  78891. /**
  78892. * attach this feature
  78893. * Will usually be called by the features manager
  78894. *
  78895. * @returns true if successful.
  78896. */
  78897. attach(): boolean;
  78898. /**
  78899. * detach this feature.
  78900. * Will usually be called by the features manager
  78901. *
  78902. * @returns true if successful.
  78903. */
  78904. detach(): boolean;
  78905. /**
  78906. * Get the headset impostor, if enabled
  78907. * @returns the impostor
  78908. */
  78909. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78910. /**
  78911. * Get the physics impostor of a specific controller.
  78912. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78913. * @param controller the controller or the controller id of which to get the impostor
  78914. * @returns the impostor or null
  78915. */
  78916. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78917. /**
  78918. * Update the physics properties provided in the constructor
  78919. * @param newProperties the new properties object
  78920. */
  78921. setPhysicsProperties(newProperties: {
  78922. impostorType?: number;
  78923. impostorSize?: number | {
  78924. width: number;
  78925. height: number;
  78926. depth: number;
  78927. };
  78928. friction?: number;
  78929. restitution?: number;
  78930. }): void;
  78931. protected _onXRFrame(_xrFrame: any): void;
  78932. private _detachController;
  78933. }
  78934. }
  78935. declare module "babylonjs/XR/features/index" {
  78936. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78937. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78938. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78939. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78940. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78941. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78942. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78943. export * from "babylonjs/XR/features/WebXRHitTest";
  78944. }
  78945. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78946. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78948. import { Scene } from "babylonjs/scene";
  78949. /**
  78950. * The motion controller class for all microsoft mixed reality controllers
  78951. */
  78952. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78953. protected readonly _mapping: {
  78954. defaultButton: {
  78955. valueNodeName: string;
  78956. unpressedNodeName: string;
  78957. pressedNodeName: string;
  78958. };
  78959. defaultAxis: {
  78960. valueNodeName: string;
  78961. minNodeName: string;
  78962. maxNodeName: string;
  78963. };
  78964. buttons: {
  78965. "xr-standard-trigger": {
  78966. rootNodeName: string;
  78967. componentProperty: string;
  78968. states: string[];
  78969. };
  78970. "xr-standard-squeeze": {
  78971. rootNodeName: string;
  78972. componentProperty: string;
  78973. states: string[];
  78974. };
  78975. "xr-standard-touchpad": {
  78976. rootNodeName: string;
  78977. labelAnchorNodeName: string;
  78978. touchPointNodeName: string;
  78979. };
  78980. "xr-standard-thumbstick": {
  78981. rootNodeName: string;
  78982. componentProperty: string;
  78983. states: string[];
  78984. };
  78985. };
  78986. axes: {
  78987. "xr-standard-touchpad": {
  78988. "x-axis": {
  78989. rootNodeName: string;
  78990. };
  78991. "y-axis": {
  78992. rootNodeName: string;
  78993. };
  78994. };
  78995. "xr-standard-thumbstick": {
  78996. "x-axis": {
  78997. rootNodeName: string;
  78998. };
  78999. "y-axis": {
  79000. rootNodeName: string;
  79001. };
  79002. };
  79003. };
  79004. };
  79005. /**
  79006. * The base url used to load the left and right controller models
  79007. */
  79008. static MODEL_BASE_URL: string;
  79009. /**
  79010. * The name of the left controller model file
  79011. */
  79012. static MODEL_LEFT_FILENAME: string;
  79013. /**
  79014. * The name of the right controller model file
  79015. */
  79016. static MODEL_RIGHT_FILENAME: string;
  79017. profileId: string;
  79018. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79019. protected _getFilenameAndPath(): {
  79020. filename: string;
  79021. path: string;
  79022. };
  79023. protected _getModelLoadingConstraints(): boolean;
  79024. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79025. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79026. protected _updateModel(): void;
  79027. }
  79028. }
  79029. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79030. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79032. import { Scene } from "babylonjs/scene";
  79033. /**
  79034. * The motion controller class for oculus touch (quest, rift).
  79035. * This class supports legacy mapping as well the standard xr mapping
  79036. */
  79037. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79038. private _forceLegacyControllers;
  79039. private _modelRootNode;
  79040. /**
  79041. * The base url used to load the left and right controller models
  79042. */
  79043. static MODEL_BASE_URL: string;
  79044. /**
  79045. * The name of the left controller model file
  79046. */
  79047. static MODEL_LEFT_FILENAME: string;
  79048. /**
  79049. * The name of the right controller model file
  79050. */
  79051. static MODEL_RIGHT_FILENAME: string;
  79052. /**
  79053. * Base Url for the Quest controller model.
  79054. */
  79055. static QUEST_MODEL_BASE_URL: string;
  79056. profileId: string;
  79057. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79058. protected _getFilenameAndPath(): {
  79059. filename: string;
  79060. path: string;
  79061. };
  79062. protected _getModelLoadingConstraints(): boolean;
  79063. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79064. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79065. protected _updateModel(): void;
  79066. /**
  79067. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79068. * between the touch and touch 2.
  79069. */
  79070. private _isQuest;
  79071. }
  79072. }
  79073. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79074. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79075. import { Scene } from "babylonjs/scene";
  79076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79077. /**
  79078. * The motion controller class for the standard HTC-Vive controllers
  79079. */
  79080. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79081. private _modelRootNode;
  79082. /**
  79083. * The base url used to load the left and right controller models
  79084. */
  79085. static MODEL_BASE_URL: string;
  79086. /**
  79087. * File name for the controller model.
  79088. */
  79089. static MODEL_FILENAME: string;
  79090. profileId: string;
  79091. /**
  79092. * Create a new Vive motion controller object
  79093. * @param scene the scene to use to create this controller
  79094. * @param gamepadObject the corresponding gamepad object
  79095. * @param handedness the handedness of the controller
  79096. */
  79097. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79098. protected _getFilenameAndPath(): {
  79099. filename: string;
  79100. path: string;
  79101. };
  79102. protected _getModelLoadingConstraints(): boolean;
  79103. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79104. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79105. protected _updateModel(): void;
  79106. }
  79107. }
  79108. declare module "babylonjs/XR/motionController/index" {
  79109. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79110. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79111. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79112. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79113. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79114. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79115. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79116. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79117. }
  79118. declare module "babylonjs/XR/index" {
  79119. export * from "babylonjs/XR/webXRCamera";
  79120. export * from "babylonjs/XR/webXREnterExitUI";
  79121. export * from "babylonjs/XR/webXRExperienceHelper";
  79122. export * from "babylonjs/XR/webXRInput";
  79123. export * from "babylonjs/XR/webXRInputSource";
  79124. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79125. export * from "babylonjs/XR/webXRTypes";
  79126. export * from "babylonjs/XR/webXRSessionManager";
  79127. export * from "babylonjs/XR/webXRDefaultExperience";
  79128. export * from "babylonjs/XR/webXRFeaturesManager";
  79129. export * from "babylonjs/XR/features/index";
  79130. export * from "babylonjs/XR/motionController/index";
  79131. }
  79132. declare module "babylonjs/index" {
  79133. export * from "babylonjs/abstractScene";
  79134. export * from "babylonjs/Actions/index";
  79135. export * from "babylonjs/Animations/index";
  79136. export * from "babylonjs/assetContainer";
  79137. export * from "babylonjs/Audio/index";
  79138. export * from "babylonjs/Behaviors/index";
  79139. export * from "babylonjs/Bones/index";
  79140. export * from "babylonjs/Cameras/index";
  79141. export * from "babylonjs/Collisions/index";
  79142. export * from "babylonjs/Culling/index";
  79143. export * from "babylonjs/Debug/index";
  79144. export * from "babylonjs/DeviceInput/index";
  79145. export * from "babylonjs/Engines/index";
  79146. export * from "babylonjs/Events/index";
  79147. export * from "babylonjs/Gamepads/index";
  79148. export * from "babylonjs/Gizmos/index";
  79149. export * from "babylonjs/Helpers/index";
  79150. export * from "babylonjs/Instrumentation/index";
  79151. export * from "babylonjs/Layers/index";
  79152. export * from "babylonjs/LensFlares/index";
  79153. export * from "babylonjs/Lights/index";
  79154. export * from "babylonjs/Loading/index";
  79155. export * from "babylonjs/Materials/index";
  79156. export * from "babylonjs/Maths/index";
  79157. export * from "babylonjs/Meshes/index";
  79158. export * from "babylonjs/Morph/index";
  79159. export * from "babylonjs/Navigation/index";
  79160. export * from "babylonjs/node";
  79161. export * from "babylonjs/Offline/index";
  79162. export * from "babylonjs/Particles/index";
  79163. export * from "babylonjs/Physics/index";
  79164. export * from "babylonjs/PostProcesses/index";
  79165. export * from "babylonjs/Probes/index";
  79166. export * from "babylonjs/Rendering/index";
  79167. export * from "babylonjs/scene";
  79168. export * from "babylonjs/sceneComponent";
  79169. export * from "babylonjs/Sprites/index";
  79170. export * from "babylonjs/States/index";
  79171. export * from "babylonjs/Misc/index";
  79172. export * from "babylonjs/XR/index";
  79173. export * from "babylonjs/types";
  79174. }
  79175. declare module "babylonjs/Animations/pathCursor" {
  79176. import { Vector3 } from "babylonjs/Maths/math.vector";
  79177. import { Path2 } from "babylonjs/Maths/math.path";
  79178. /**
  79179. * A cursor which tracks a point on a path
  79180. */
  79181. export class PathCursor {
  79182. private path;
  79183. /**
  79184. * Stores path cursor callbacks for when an onchange event is triggered
  79185. */
  79186. private _onchange;
  79187. /**
  79188. * The value of the path cursor
  79189. */
  79190. value: number;
  79191. /**
  79192. * The animation array of the path cursor
  79193. */
  79194. animations: Animation[];
  79195. /**
  79196. * Initializes the path cursor
  79197. * @param path The path to track
  79198. */
  79199. constructor(path: Path2);
  79200. /**
  79201. * Gets the cursor point on the path
  79202. * @returns A point on the path cursor at the cursor location
  79203. */
  79204. getPoint(): Vector3;
  79205. /**
  79206. * Moves the cursor ahead by the step amount
  79207. * @param step The amount to move the cursor forward
  79208. * @returns This path cursor
  79209. */
  79210. moveAhead(step?: number): PathCursor;
  79211. /**
  79212. * Moves the cursor behind by the step amount
  79213. * @param step The amount to move the cursor back
  79214. * @returns This path cursor
  79215. */
  79216. moveBack(step?: number): PathCursor;
  79217. /**
  79218. * Moves the cursor by the step amount
  79219. * If the step amount is greater than one, an exception is thrown
  79220. * @param step The amount to move the cursor
  79221. * @returns This path cursor
  79222. */
  79223. move(step: number): PathCursor;
  79224. /**
  79225. * Ensures that the value is limited between zero and one
  79226. * @returns This path cursor
  79227. */
  79228. private ensureLimits;
  79229. /**
  79230. * Runs onchange callbacks on change (used by the animation engine)
  79231. * @returns This path cursor
  79232. */
  79233. private raiseOnChange;
  79234. /**
  79235. * Executes a function on change
  79236. * @param f A path cursor onchange callback
  79237. * @returns This path cursor
  79238. */
  79239. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79240. }
  79241. }
  79242. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79243. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79244. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79245. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79246. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79247. }
  79248. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79249. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79250. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79251. }
  79252. declare module "babylonjs/Engines/Processors/index" {
  79253. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79254. export * from "babylonjs/Engines/Processors/Expressions/index";
  79255. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79256. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79257. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79258. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79259. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79260. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79261. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79262. }
  79263. declare module "babylonjs/Legacy/legacy" {
  79264. import * as Babylon from "babylonjs/index";
  79265. export * from "babylonjs/index";
  79266. }
  79267. declare module "babylonjs/Shaders/blur.fragment" {
  79268. /** @hidden */
  79269. export var blurPixelShader: {
  79270. name: string;
  79271. shader: string;
  79272. };
  79273. }
  79274. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79275. /** @hidden */
  79276. export var pointCloudVertexDeclaration: {
  79277. name: string;
  79278. shader: string;
  79279. };
  79280. }
  79281. declare module "babylonjs" {
  79282. export * from "babylonjs/Legacy/legacy";
  79283. }
  79284. declare module BABYLON {
  79285. /** Alias type for value that can be null */
  79286. export type Nullable<T> = T | null;
  79287. /**
  79288. * Alias type for number that are floats
  79289. * @ignorenaming
  79290. */
  79291. export type float = number;
  79292. /**
  79293. * Alias type for number that are doubles.
  79294. * @ignorenaming
  79295. */
  79296. export type double = number;
  79297. /**
  79298. * Alias type for number that are integer
  79299. * @ignorenaming
  79300. */
  79301. export type int = number;
  79302. /** Alias type for number array or Float32Array */
  79303. export type FloatArray = number[] | Float32Array;
  79304. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79305. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79306. /**
  79307. * Alias for types that can be used by a Buffer or VertexBuffer.
  79308. */
  79309. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79310. /**
  79311. * Alias type for primitive types
  79312. * @ignorenaming
  79313. */
  79314. type Primitive = undefined | null | boolean | string | number | Function;
  79315. /**
  79316. * Type modifier to make all the properties of an object Readonly
  79317. */
  79318. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79319. /**
  79320. * Type modifier to make all the properties of an object Readonly recursively
  79321. */
  79322. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79323. /**
  79324. * Type modifier to make object properties readonly.
  79325. */
  79326. export type DeepImmutableObject<T> = {
  79327. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79328. };
  79329. /** @hidden */
  79330. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79331. }
  79332. }
  79333. declare module BABYLON {
  79334. /**
  79335. * A class serves as a medium between the observable and its observers
  79336. */
  79337. export class EventState {
  79338. /**
  79339. * Create a new EventState
  79340. * @param mask defines the mask associated with this state
  79341. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79342. * @param target defines the original target of the state
  79343. * @param currentTarget defines the current target of the state
  79344. */
  79345. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79346. /**
  79347. * Initialize the current event state
  79348. * @param mask defines the mask associated with this state
  79349. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79350. * @param target defines the original target of the state
  79351. * @param currentTarget defines the current target of the state
  79352. * @returns the current event state
  79353. */
  79354. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79355. /**
  79356. * An Observer can set this property to true to prevent subsequent observers of being notified
  79357. */
  79358. skipNextObservers: boolean;
  79359. /**
  79360. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79361. */
  79362. mask: number;
  79363. /**
  79364. * The object that originally notified the event
  79365. */
  79366. target?: any;
  79367. /**
  79368. * The current object in the bubbling phase
  79369. */
  79370. currentTarget?: any;
  79371. /**
  79372. * This will be populated with the return value of the last function that was executed.
  79373. * If it is the first function in the callback chain it will be the event data.
  79374. */
  79375. lastReturnValue?: any;
  79376. }
  79377. /**
  79378. * Represent an Observer registered to a given Observable object.
  79379. */
  79380. export class Observer<T> {
  79381. /**
  79382. * Defines the callback to call when the observer is notified
  79383. */
  79384. callback: (eventData: T, eventState: EventState) => void;
  79385. /**
  79386. * Defines the mask of the observer (used to filter notifications)
  79387. */
  79388. mask: number;
  79389. /**
  79390. * Defines the current scope used to restore the JS context
  79391. */
  79392. scope: any;
  79393. /** @hidden */
  79394. _willBeUnregistered: boolean;
  79395. /**
  79396. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79397. */
  79398. unregisterOnNextCall: boolean;
  79399. /**
  79400. * Creates a new observer
  79401. * @param callback defines the callback to call when the observer is notified
  79402. * @param mask defines the mask of the observer (used to filter notifications)
  79403. * @param scope defines the current scope used to restore the JS context
  79404. */
  79405. constructor(
  79406. /**
  79407. * Defines the callback to call when the observer is notified
  79408. */
  79409. callback: (eventData: T, eventState: EventState) => void,
  79410. /**
  79411. * Defines the mask of the observer (used to filter notifications)
  79412. */
  79413. mask: number,
  79414. /**
  79415. * Defines the current scope used to restore the JS context
  79416. */
  79417. scope?: any);
  79418. }
  79419. /**
  79420. * Represent a list of observers registered to multiple Observables object.
  79421. */
  79422. export class MultiObserver<T> {
  79423. private _observers;
  79424. private _observables;
  79425. /**
  79426. * Release associated resources
  79427. */
  79428. dispose(): void;
  79429. /**
  79430. * Raise a callback when one of the observable will notify
  79431. * @param observables defines a list of observables to watch
  79432. * @param callback defines the callback to call on notification
  79433. * @param mask defines the mask used to filter notifications
  79434. * @param scope defines the current scope used to restore the JS context
  79435. * @returns the new MultiObserver
  79436. */
  79437. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79438. }
  79439. /**
  79440. * The Observable class is a simple implementation of the Observable pattern.
  79441. *
  79442. * 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.
  79443. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79444. * 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).
  79445. * 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.
  79446. */
  79447. export class Observable<T> {
  79448. private _observers;
  79449. private _eventState;
  79450. private _onObserverAdded;
  79451. /**
  79452. * Gets the list of observers
  79453. */
  79454. get observers(): Array<Observer<T>>;
  79455. /**
  79456. * Creates a new observable
  79457. * @param onObserverAdded defines a callback to call when a new observer is added
  79458. */
  79459. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79460. /**
  79461. * Create a new Observer with the specified callback
  79462. * @param callback the callback that will be executed for that Observer
  79463. * @param mask the mask used to filter observers
  79464. * @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.
  79465. * @param scope optional scope for the callback to be called from
  79466. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79467. * @returns the new observer created for the callback
  79468. */
  79469. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79470. /**
  79471. * Create a new Observer with the specified callback and unregisters after the next notification
  79472. * @param callback the callback that will be executed for that Observer
  79473. * @returns the new observer created for the callback
  79474. */
  79475. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79476. /**
  79477. * Remove an Observer from the Observable object
  79478. * @param observer the instance of the Observer to remove
  79479. * @returns false if it doesn't belong to this Observable
  79480. */
  79481. remove(observer: Nullable<Observer<T>>): boolean;
  79482. /**
  79483. * Remove a callback from the Observable object
  79484. * @param callback the callback to remove
  79485. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79486. * @returns false if it doesn't belong to this Observable
  79487. */
  79488. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79489. private _deferUnregister;
  79490. private _remove;
  79491. /**
  79492. * Moves the observable to the top of the observer list making it get called first when notified
  79493. * @param observer the observer to move
  79494. */
  79495. makeObserverTopPriority(observer: Observer<T>): void;
  79496. /**
  79497. * Moves the observable to the bottom of the observer list making it get called last when notified
  79498. * @param observer the observer to move
  79499. */
  79500. makeObserverBottomPriority(observer: Observer<T>): void;
  79501. /**
  79502. * Notify all Observers by calling their respective callback with the given data
  79503. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79504. * @param eventData defines the data to send to all observers
  79505. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79506. * @param target defines the original target of the state
  79507. * @param currentTarget defines the current target of the state
  79508. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79509. */
  79510. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79511. /**
  79512. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79513. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79514. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79515. * and it is crucial that all callbacks will be executed.
  79516. * The order of the callbacks is kept, callbacks are not executed parallel.
  79517. *
  79518. * @param eventData The data to be sent to each callback
  79519. * @param mask is used to filter observers defaults to -1
  79520. * @param target defines the callback target (see EventState)
  79521. * @param currentTarget defines he current object in the bubbling phase
  79522. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79523. */
  79524. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79525. /**
  79526. * Notify a specific observer
  79527. * @param observer defines the observer to notify
  79528. * @param eventData defines the data to be sent to each callback
  79529. * @param mask is used to filter observers defaults to -1
  79530. */
  79531. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79532. /**
  79533. * Gets a boolean indicating if the observable has at least one observer
  79534. * @returns true is the Observable has at least one Observer registered
  79535. */
  79536. hasObservers(): boolean;
  79537. /**
  79538. * Clear the list of observers
  79539. */
  79540. clear(): void;
  79541. /**
  79542. * Clone the current observable
  79543. * @returns a new observable
  79544. */
  79545. clone(): Observable<T>;
  79546. /**
  79547. * Does this observable handles observer registered with a given mask
  79548. * @param mask defines the mask to be tested
  79549. * @return whether or not one observer registered with the given mask is handeled
  79550. **/
  79551. hasSpecificMask(mask?: number): boolean;
  79552. }
  79553. }
  79554. declare module BABYLON {
  79555. /**
  79556. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79557. * Babylon.js
  79558. */
  79559. export class DomManagement {
  79560. /**
  79561. * Checks if the window object exists
  79562. * @returns true if the window object exists
  79563. */
  79564. static IsWindowObjectExist(): boolean;
  79565. /**
  79566. * Checks if the navigator object exists
  79567. * @returns true if the navigator object exists
  79568. */
  79569. static IsNavigatorAvailable(): boolean;
  79570. /**
  79571. * Check if the document object exists
  79572. * @returns true if the document object exists
  79573. */
  79574. static IsDocumentAvailable(): boolean;
  79575. /**
  79576. * Extracts text content from a DOM element hierarchy
  79577. * @param element defines the root element
  79578. * @returns a string
  79579. */
  79580. static GetDOMTextContent(element: HTMLElement): string;
  79581. }
  79582. }
  79583. declare module BABYLON {
  79584. /**
  79585. * Logger used througouht the application to allow configuration of
  79586. * the log level required for the messages.
  79587. */
  79588. export class Logger {
  79589. /**
  79590. * No log
  79591. */
  79592. static readonly NoneLogLevel: number;
  79593. /**
  79594. * Only message logs
  79595. */
  79596. static readonly MessageLogLevel: number;
  79597. /**
  79598. * Only warning logs
  79599. */
  79600. static readonly WarningLogLevel: number;
  79601. /**
  79602. * Only error logs
  79603. */
  79604. static readonly ErrorLogLevel: number;
  79605. /**
  79606. * All logs
  79607. */
  79608. static readonly AllLogLevel: number;
  79609. private static _LogCache;
  79610. /**
  79611. * Gets a value indicating the number of loading errors
  79612. * @ignorenaming
  79613. */
  79614. static errorsCount: number;
  79615. /**
  79616. * Callback called when a new log is added
  79617. */
  79618. static OnNewCacheEntry: (entry: string) => void;
  79619. private static _AddLogEntry;
  79620. private static _FormatMessage;
  79621. private static _LogDisabled;
  79622. private static _LogEnabled;
  79623. private static _WarnDisabled;
  79624. private static _WarnEnabled;
  79625. private static _ErrorDisabled;
  79626. private static _ErrorEnabled;
  79627. /**
  79628. * Log a message to the console
  79629. */
  79630. static Log: (message: string) => void;
  79631. /**
  79632. * Write a warning message to the console
  79633. */
  79634. static Warn: (message: string) => void;
  79635. /**
  79636. * Write an error message to the console
  79637. */
  79638. static Error: (message: string) => void;
  79639. /**
  79640. * Gets current log cache (list of logs)
  79641. */
  79642. static get LogCache(): string;
  79643. /**
  79644. * Clears the log cache
  79645. */
  79646. static ClearLogCache(): void;
  79647. /**
  79648. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79649. */
  79650. static set LogLevels(level: number);
  79651. }
  79652. }
  79653. declare module BABYLON {
  79654. /** @hidden */
  79655. export class _TypeStore {
  79656. /** @hidden */
  79657. static RegisteredTypes: {
  79658. [key: string]: Object;
  79659. };
  79660. /** @hidden */
  79661. static GetClass(fqdn: string): any;
  79662. }
  79663. }
  79664. declare module BABYLON {
  79665. /**
  79666. * Helper to manipulate strings
  79667. */
  79668. export class StringTools {
  79669. /**
  79670. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79671. * @param str Source string
  79672. * @param suffix Suffix to search for in the source string
  79673. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79674. */
  79675. static EndsWith(str: string, suffix: string): boolean;
  79676. /**
  79677. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79678. * @param str Source string
  79679. * @param suffix Suffix to search for in the source string
  79680. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79681. */
  79682. static StartsWith(str: string, suffix: string): boolean;
  79683. /**
  79684. * Decodes a buffer into a string
  79685. * @param buffer The buffer to decode
  79686. * @returns The decoded string
  79687. */
  79688. static Decode(buffer: Uint8Array | Uint16Array): string;
  79689. /**
  79690. * Encode a buffer to a base64 string
  79691. * @param buffer defines the buffer to encode
  79692. * @returns the encoded string
  79693. */
  79694. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79695. /**
  79696. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79697. * @param num the number to convert and pad
  79698. * @param length the expected length of the string
  79699. * @returns the padded string
  79700. */
  79701. static PadNumber(num: number, length: number): string;
  79702. }
  79703. }
  79704. declare module BABYLON {
  79705. /**
  79706. * Class containing a set of static utilities functions for deep copy.
  79707. */
  79708. export class DeepCopier {
  79709. /**
  79710. * Tries to copy an object by duplicating every property
  79711. * @param source defines the source object
  79712. * @param destination defines the target object
  79713. * @param doNotCopyList defines a list of properties to avoid
  79714. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79715. */
  79716. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79717. }
  79718. }
  79719. declare module BABYLON {
  79720. /**
  79721. * Class containing a set of static utilities functions for precision date
  79722. */
  79723. export class PrecisionDate {
  79724. /**
  79725. * Gets either window.performance.now() if supported or Date.now() else
  79726. */
  79727. static get Now(): number;
  79728. }
  79729. }
  79730. declare module BABYLON {
  79731. /** @hidden */
  79732. export class _DevTools {
  79733. static WarnImport(name: string): string;
  79734. }
  79735. }
  79736. declare module BABYLON {
  79737. /**
  79738. * Interface used to define the mechanism to get data from the network
  79739. */
  79740. export interface IWebRequest {
  79741. /**
  79742. * Returns client's response url
  79743. */
  79744. responseURL: string;
  79745. /**
  79746. * Returns client's status
  79747. */
  79748. status: number;
  79749. /**
  79750. * Returns client's status as a text
  79751. */
  79752. statusText: string;
  79753. }
  79754. }
  79755. declare module BABYLON {
  79756. /**
  79757. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79758. */
  79759. export class WebRequest implements IWebRequest {
  79760. private _xhr;
  79761. /**
  79762. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79763. * i.e. when loading files, where the server/service expects an Authorization header
  79764. */
  79765. static CustomRequestHeaders: {
  79766. [key: string]: string;
  79767. };
  79768. /**
  79769. * Add callback functions in this array to update all the requests before they get sent to the network
  79770. */
  79771. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79772. private _injectCustomRequestHeaders;
  79773. /**
  79774. * Gets or sets a function to be called when loading progress changes
  79775. */
  79776. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79777. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79778. /**
  79779. * Returns client's state
  79780. */
  79781. get readyState(): number;
  79782. /**
  79783. * Returns client's status
  79784. */
  79785. get status(): number;
  79786. /**
  79787. * Returns client's status as a text
  79788. */
  79789. get statusText(): string;
  79790. /**
  79791. * Returns client's response
  79792. */
  79793. get response(): any;
  79794. /**
  79795. * Returns client's response url
  79796. */
  79797. get responseURL(): string;
  79798. /**
  79799. * Returns client's response as text
  79800. */
  79801. get responseText(): string;
  79802. /**
  79803. * Gets or sets the expected response type
  79804. */
  79805. get responseType(): XMLHttpRequestResponseType;
  79806. set responseType(value: XMLHttpRequestResponseType);
  79807. /** @hidden */
  79808. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79809. /** @hidden */
  79810. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79811. /**
  79812. * Cancels any network activity
  79813. */
  79814. abort(): void;
  79815. /**
  79816. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79817. * @param body defines an optional request body
  79818. */
  79819. send(body?: Document | BodyInit | null): void;
  79820. /**
  79821. * Sets the request method, request URL
  79822. * @param method defines the method to use (GET, POST, etc..)
  79823. * @param url defines the url to connect with
  79824. */
  79825. open(method: string, url: string): void;
  79826. /**
  79827. * Sets the value of a request header.
  79828. * @param name The name of the header whose value is to be set
  79829. * @param value The value to set as the body of the header
  79830. */
  79831. setRequestHeader(name: string, value: string): void;
  79832. /**
  79833. * Get the string containing the text of a particular header's value.
  79834. * @param name The name of the header
  79835. * @returns The string containing the text of the given header name
  79836. */
  79837. getResponseHeader(name: string): Nullable<string>;
  79838. }
  79839. }
  79840. declare module BABYLON {
  79841. /**
  79842. * File request interface
  79843. */
  79844. export interface IFileRequest {
  79845. /**
  79846. * Raised when the request is complete (success or error).
  79847. */
  79848. onCompleteObservable: Observable<IFileRequest>;
  79849. /**
  79850. * Aborts the request for a file.
  79851. */
  79852. abort: () => void;
  79853. }
  79854. }
  79855. declare module BABYLON {
  79856. /**
  79857. * Define options used to create a render target texture
  79858. */
  79859. export class RenderTargetCreationOptions {
  79860. /**
  79861. * Specifies is mipmaps must be generated
  79862. */
  79863. generateMipMaps?: boolean;
  79864. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79865. generateDepthBuffer?: boolean;
  79866. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79867. generateStencilBuffer?: boolean;
  79868. /** Defines texture type (int by default) */
  79869. type?: number;
  79870. /** Defines sampling mode (trilinear by default) */
  79871. samplingMode?: number;
  79872. /** Defines format (RGBA by default) */
  79873. format?: number;
  79874. }
  79875. }
  79876. declare module BABYLON {
  79877. /** Defines the cross module used constants to avoid circular dependncies */
  79878. export class Constants {
  79879. /** Defines that alpha blending is disabled */
  79880. static readonly ALPHA_DISABLE: number;
  79881. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79882. static readonly ALPHA_ADD: number;
  79883. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79884. static readonly ALPHA_COMBINE: number;
  79885. /** Defines that alpha blending is DEST - SRC * DEST */
  79886. static readonly ALPHA_SUBTRACT: number;
  79887. /** Defines that alpha blending is SRC * DEST */
  79888. static readonly ALPHA_MULTIPLY: number;
  79889. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79890. static readonly ALPHA_MAXIMIZED: number;
  79891. /** Defines that alpha blending is SRC + DEST */
  79892. static readonly ALPHA_ONEONE: number;
  79893. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79894. static readonly ALPHA_PREMULTIPLIED: number;
  79895. /**
  79896. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79897. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79898. */
  79899. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79900. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79901. static readonly ALPHA_INTERPOLATE: number;
  79902. /**
  79903. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79904. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79905. */
  79906. static readonly ALPHA_SCREENMODE: number;
  79907. /**
  79908. * Defines that alpha blending is SRC + DST
  79909. * Alpha will be set to SRC ALPHA + DST ALPHA
  79910. */
  79911. static readonly ALPHA_ONEONE_ONEONE: number;
  79912. /**
  79913. * Defines that alpha blending is SRC * DST ALPHA + DST
  79914. * Alpha will be set to 0
  79915. */
  79916. static readonly ALPHA_ALPHATOCOLOR: number;
  79917. /**
  79918. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79919. */
  79920. static readonly ALPHA_REVERSEONEMINUS: number;
  79921. /**
  79922. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79923. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79924. */
  79925. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79926. /**
  79927. * Defines that alpha blending is SRC + DST
  79928. * Alpha will be set to SRC ALPHA
  79929. */
  79930. static readonly ALPHA_ONEONE_ONEZERO: number;
  79931. /**
  79932. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79933. * Alpha will be set to DST ALPHA
  79934. */
  79935. static readonly ALPHA_EXCLUSION: number;
  79936. /** Defines that alpha blending equation a SUM */
  79937. static readonly ALPHA_EQUATION_ADD: number;
  79938. /** Defines that alpha blending equation a SUBSTRACTION */
  79939. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79940. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79941. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79942. /** Defines that alpha blending equation a MAX operation */
  79943. static readonly ALPHA_EQUATION_MAX: number;
  79944. /** Defines that alpha blending equation a MIN operation */
  79945. static readonly ALPHA_EQUATION_MIN: number;
  79946. /**
  79947. * Defines that alpha blending equation a DARKEN operation:
  79948. * It takes the min of the src and sums the alpha channels.
  79949. */
  79950. static readonly ALPHA_EQUATION_DARKEN: number;
  79951. /** Defines that the ressource is not delayed*/
  79952. static readonly DELAYLOADSTATE_NONE: number;
  79953. /** Defines that the ressource was successfully delay loaded */
  79954. static readonly DELAYLOADSTATE_LOADED: number;
  79955. /** Defines that the ressource is currently delay loading */
  79956. static readonly DELAYLOADSTATE_LOADING: number;
  79957. /** Defines that the ressource is delayed and has not started loading */
  79958. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79959. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79960. static readonly NEVER: number;
  79961. /** 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 */
  79962. static readonly ALWAYS: number;
  79963. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79964. static readonly LESS: number;
  79965. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79966. static readonly EQUAL: number;
  79967. /** 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 */
  79968. static readonly LEQUAL: number;
  79969. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79970. static readonly GREATER: number;
  79971. /** 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 */
  79972. static readonly GEQUAL: number;
  79973. /** 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 */
  79974. static readonly NOTEQUAL: number;
  79975. /** Passed to stencilOperation to specify that stencil value must be kept */
  79976. static readonly KEEP: number;
  79977. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79978. static readonly REPLACE: number;
  79979. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79980. static readonly INCR: number;
  79981. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79982. static readonly DECR: number;
  79983. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79984. static readonly INVERT: number;
  79985. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79986. static readonly INCR_WRAP: number;
  79987. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79988. static readonly DECR_WRAP: number;
  79989. /** Texture is not repeating outside of 0..1 UVs */
  79990. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79991. /** Texture is repeating outside of 0..1 UVs */
  79992. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79993. /** Texture is repeating and mirrored */
  79994. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79995. /** ALPHA */
  79996. static readonly TEXTUREFORMAT_ALPHA: number;
  79997. /** LUMINANCE */
  79998. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79999. /** LUMINANCE_ALPHA */
  80000. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80001. /** RGB */
  80002. static readonly TEXTUREFORMAT_RGB: number;
  80003. /** RGBA */
  80004. static readonly TEXTUREFORMAT_RGBA: number;
  80005. /** RED */
  80006. static readonly TEXTUREFORMAT_RED: number;
  80007. /** RED (2nd reference) */
  80008. static readonly TEXTUREFORMAT_R: number;
  80009. /** RG */
  80010. static readonly TEXTUREFORMAT_RG: number;
  80011. /** RED_INTEGER */
  80012. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80013. /** RED_INTEGER (2nd reference) */
  80014. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80015. /** RG_INTEGER */
  80016. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80017. /** RGB_INTEGER */
  80018. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80019. /** RGBA_INTEGER */
  80020. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80021. /** UNSIGNED_BYTE */
  80022. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80023. /** UNSIGNED_BYTE (2nd reference) */
  80024. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80025. /** FLOAT */
  80026. static readonly TEXTURETYPE_FLOAT: number;
  80027. /** HALF_FLOAT */
  80028. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80029. /** BYTE */
  80030. static readonly TEXTURETYPE_BYTE: number;
  80031. /** SHORT */
  80032. static readonly TEXTURETYPE_SHORT: number;
  80033. /** UNSIGNED_SHORT */
  80034. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80035. /** INT */
  80036. static readonly TEXTURETYPE_INT: number;
  80037. /** UNSIGNED_INT */
  80038. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80039. /** UNSIGNED_SHORT_4_4_4_4 */
  80040. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80041. /** UNSIGNED_SHORT_5_5_5_1 */
  80042. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80043. /** UNSIGNED_SHORT_5_6_5 */
  80044. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80045. /** UNSIGNED_INT_2_10_10_10_REV */
  80046. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80047. /** UNSIGNED_INT_24_8 */
  80048. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80049. /** UNSIGNED_INT_10F_11F_11F_REV */
  80050. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80051. /** UNSIGNED_INT_5_9_9_9_REV */
  80052. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80053. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80054. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80055. /** nearest is mag = nearest and min = nearest and no mip */
  80056. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80057. /** mag = nearest and min = nearest and mip = none */
  80058. static readonly TEXTURE_NEAREST_NEAREST: number;
  80059. /** Bilinear is mag = linear and min = linear and no mip */
  80060. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80061. /** mag = linear and min = linear and mip = none */
  80062. static readonly TEXTURE_LINEAR_LINEAR: number;
  80063. /** Trilinear is mag = linear and min = linear and mip = linear */
  80064. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80065. /** Trilinear is mag = linear and min = linear and mip = linear */
  80066. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80067. /** mag = nearest and min = nearest and mip = nearest */
  80068. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80069. /** mag = nearest and min = linear and mip = nearest */
  80070. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80071. /** mag = nearest and min = linear and mip = linear */
  80072. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80073. /** mag = nearest and min = linear and mip = none */
  80074. static readonly TEXTURE_NEAREST_LINEAR: number;
  80075. /** nearest is mag = nearest and min = nearest and mip = linear */
  80076. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80077. /** mag = linear and min = nearest and mip = nearest */
  80078. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80079. /** mag = linear and min = nearest and mip = linear */
  80080. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80081. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80082. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80083. /** mag = linear and min = nearest and mip = none */
  80084. static readonly TEXTURE_LINEAR_NEAREST: number;
  80085. /** Explicit coordinates mode */
  80086. static readonly TEXTURE_EXPLICIT_MODE: number;
  80087. /** Spherical coordinates mode */
  80088. static readonly TEXTURE_SPHERICAL_MODE: number;
  80089. /** Planar coordinates mode */
  80090. static readonly TEXTURE_PLANAR_MODE: number;
  80091. /** Cubic coordinates mode */
  80092. static readonly TEXTURE_CUBIC_MODE: number;
  80093. /** Projection coordinates mode */
  80094. static readonly TEXTURE_PROJECTION_MODE: number;
  80095. /** Skybox coordinates mode */
  80096. static readonly TEXTURE_SKYBOX_MODE: number;
  80097. /** Inverse Cubic coordinates mode */
  80098. static readonly TEXTURE_INVCUBIC_MODE: number;
  80099. /** Equirectangular coordinates mode */
  80100. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80101. /** Equirectangular Fixed coordinates mode */
  80102. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80103. /** Equirectangular Fixed Mirrored coordinates mode */
  80104. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80105. /** Offline (baking) quality for texture filtering */
  80106. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80107. /** High quality for texture filtering */
  80108. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80109. /** Medium quality for texture filtering */
  80110. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80111. /** Low quality for texture filtering */
  80112. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80113. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80114. static readonly SCALEMODE_FLOOR: number;
  80115. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80116. static readonly SCALEMODE_NEAREST: number;
  80117. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80118. static readonly SCALEMODE_CEILING: number;
  80119. /**
  80120. * The dirty texture flag value
  80121. */
  80122. static readonly MATERIAL_TextureDirtyFlag: number;
  80123. /**
  80124. * The dirty light flag value
  80125. */
  80126. static readonly MATERIAL_LightDirtyFlag: number;
  80127. /**
  80128. * The dirty fresnel flag value
  80129. */
  80130. static readonly MATERIAL_FresnelDirtyFlag: number;
  80131. /**
  80132. * The dirty attribute flag value
  80133. */
  80134. static readonly MATERIAL_AttributesDirtyFlag: number;
  80135. /**
  80136. * The dirty misc flag value
  80137. */
  80138. static readonly MATERIAL_MiscDirtyFlag: number;
  80139. /**
  80140. * The all dirty flag value
  80141. */
  80142. static readonly MATERIAL_AllDirtyFlag: number;
  80143. /**
  80144. * Returns the triangle fill mode
  80145. */
  80146. static readonly MATERIAL_TriangleFillMode: number;
  80147. /**
  80148. * Returns the wireframe mode
  80149. */
  80150. static readonly MATERIAL_WireFrameFillMode: number;
  80151. /**
  80152. * Returns the point fill mode
  80153. */
  80154. static readonly MATERIAL_PointFillMode: number;
  80155. /**
  80156. * Returns the point list draw mode
  80157. */
  80158. static readonly MATERIAL_PointListDrawMode: number;
  80159. /**
  80160. * Returns the line list draw mode
  80161. */
  80162. static readonly MATERIAL_LineListDrawMode: number;
  80163. /**
  80164. * Returns the line loop draw mode
  80165. */
  80166. static readonly MATERIAL_LineLoopDrawMode: number;
  80167. /**
  80168. * Returns the line strip draw mode
  80169. */
  80170. static readonly MATERIAL_LineStripDrawMode: number;
  80171. /**
  80172. * Returns the triangle strip draw mode
  80173. */
  80174. static readonly MATERIAL_TriangleStripDrawMode: number;
  80175. /**
  80176. * Returns the triangle fan draw mode
  80177. */
  80178. static readonly MATERIAL_TriangleFanDrawMode: number;
  80179. /**
  80180. * Stores the clock-wise side orientation
  80181. */
  80182. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80183. /**
  80184. * Stores the counter clock-wise side orientation
  80185. */
  80186. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80187. /**
  80188. * Nothing
  80189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80190. */
  80191. static readonly ACTION_NothingTrigger: number;
  80192. /**
  80193. * On pick
  80194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80195. */
  80196. static readonly ACTION_OnPickTrigger: number;
  80197. /**
  80198. * On left pick
  80199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80200. */
  80201. static readonly ACTION_OnLeftPickTrigger: number;
  80202. /**
  80203. * On right pick
  80204. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80205. */
  80206. static readonly ACTION_OnRightPickTrigger: number;
  80207. /**
  80208. * On center pick
  80209. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80210. */
  80211. static readonly ACTION_OnCenterPickTrigger: number;
  80212. /**
  80213. * On pick down
  80214. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80215. */
  80216. static readonly ACTION_OnPickDownTrigger: number;
  80217. /**
  80218. * On double pick
  80219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80220. */
  80221. static readonly ACTION_OnDoublePickTrigger: number;
  80222. /**
  80223. * On pick up
  80224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80225. */
  80226. static readonly ACTION_OnPickUpTrigger: number;
  80227. /**
  80228. * On pick out.
  80229. * This trigger will only be raised if you also declared a OnPickDown
  80230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80231. */
  80232. static readonly ACTION_OnPickOutTrigger: number;
  80233. /**
  80234. * On long press
  80235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80236. */
  80237. static readonly ACTION_OnLongPressTrigger: number;
  80238. /**
  80239. * On pointer over
  80240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80241. */
  80242. static readonly ACTION_OnPointerOverTrigger: number;
  80243. /**
  80244. * On pointer out
  80245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80246. */
  80247. static readonly ACTION_OnPointerOutTrigger: number;
  80248. /**
  80249. * On every frame
  80250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80251. */
  80252. static readonly ACTION_OnEveryFrameTrigger: number;
  80253. /**
  80254. * On intersection enter
  80255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80256. */
  80257. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80258. /**
  80259. * On intersection exit
  80260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80261. */
  80262. static readonly ACTION_OnIntersectionExitTrigger: number;
  80263. /**
  80264. * On key down
  80265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80266. */
  80267. static readonly ACTION_OnKeyDownTrigger: number;
  80268. /**
  80269. * On key up
  80270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80271. */
  80272. static readonly ACTION_OnKeyUpTrigger: number;
  80273. /**
  80274. * Billboard mode will only apply to Y axis
  80275. */
  80276. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80277. /**
  80278. * Billboard mode will apply to all axes
  80279. */
  80280. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80281. /**
  80282. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80283. */
  80284. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80285. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80286. * Test order :
  80287. * Is the bounding sphere outside the frustum ?
  80288. * If not, are the bounding box vertices outside the frustum ?
  80289. * It not, then the cullable object is in the frustum.
  80290. */
  80291. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80292. /** Culling strategy : Bounding Sphere Only.
  80293. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80294. * It's also less accurate than the standard because some not visible objects can still be selected.
  80295. * Test : is the bounding sphere outside the frustum ?
  80296. * If not, then the cullable object is in the frustum.
  80297. */
  80298. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80299. /** Culling strategy : Optimistic Inclusion.
  80300. * This in an inclusion test first, then the standard exclusion test.
  80301. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80302. * 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.
  80303. * Anyway, it's as accurate as the standard strategy.
  80304. * Test :
  80305. * Is the cullable object bounding sphere center in the frustum ?
  80306. * If not, apply the default culling strategy.
  80307. */
  80308. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80309. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80310. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80311. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80312. * 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.
  80313. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80314. * Test :
  80315. * Is the cullable object bounding sphere center in the frustum ?
  80316. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80317. */
  80318. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80319. /**
  80320. * No logging while loading
  80321. */
  80322. static readonly SCENELOADER_NO_LOGGING: number;
  80323. /**
  80324. * Minimal logging while loading
  80325. */
  80326. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80327. /**
  80328. * Summary logging while loading
  80329. */
  80330. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80331. /**
  80332. * Detailled logging while loading
  80333. */
  80334. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80335. /**
  80336. * Prepass texture index for color
  80337. */
  80338. static readonly PREPASS_COLOR_INDEX: number;
  80339. /**
  80340. * Prepass texture index for irradiance
  80341. */
  80342. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80343. /**
  80344. * Prepass texture index for depth + normal
  80345. */
  80346. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80347. /**
  80348. * Prepass texture index for albedo
  80349. */
  80350. static readonly PREPASS_ALBEDO_INDEX: number;
  80351. }
  80352. }
  80353. declare module BABYLON {
  80354. /**
  80355. * This represents the required contract to create a new type of texture loader.
  80356. */
  80357. export interface IInternalTextureLoader {
  80358. /**
  80359. * Defines wether the loader supports cascade loading the different faces.
  80360. */
  80361. supportCascades: boolean;
  80362. /**
  80363. * This returns if the loader support the current file information.
  80364. * @param extension defines the file extension of the file being loaded
  80365. * @param mimeType defines the optional mime type of the file being loaded
  80366. * @returns true if the loader can load the specified file
  80367. */
  80368. canLoad(extension: string, mimeType?: string): boolean;
  80369. /**
  80370. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80371. * @param data contains the texture data
  80372. * @param texture defines the BabylonJS internal texture
  80373. * @param createPolynomials will be true if polynomials have been requested
  80374. * @param onLoad defines the callback to trigger once the texture is ready
  80375. * @param onError defines the callback to trigger in case of error
  80376. */
  80377. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80378. /**
  80379. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80380. * @param data contains the texture data
  80381. * @param texture defines the BabylonJS internal texture
  80382. * @param callback defines the method to call once ready to upload
  80383. */
  80384. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80385. }
  80386. }
  80387. declare module BABYLON {
  80388. /**
  80389. * Class used to store and describe the pipeline context associated with an effect
  80390. */
  80391. export interface IPipelineContext {
  80392. /**
  80393. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80394. */
  80395. isAsync: boolean;
  80396. /**
  80397. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80398. */
  80399. isReady: boolean;
  80400. /** @hidden */
  80401. _getVertexShaderCode(): string | null;
  80402. /** @hidden */
  80403. _getFragmentShaderCode(): string | null;
  80404. /** @hidden */
  80405. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80406. }
  80407. }
  80408. declare module BABYLON {
  80409. /**
  80410. * Class used to store gfx data (like WebGLBuffer)
  80411. */
  80412. export class DataBuffer {
  80413. /**
  80414. * Gets or sets the number of objects referencing this buffer
  80415. */
  80416. references: number;
  80417. /** Gets or sets the size of the underlying buffer */
  80418. capacity: number;
  80419. /**
  80420. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80421. */
  80422. is32Bits: boolean;
  80423. /**
  80424. * Gets the underlying buffer
  80425. */
  80426. get underlyingResource(): any;
  80427. }
  80428. }
  80429. declare module BABYLON {
  80430. /** @hidden */
  80431. export interface IShaderProcessor {
  80432. attributeProcessor?: (attribute: string) => string;
  80433. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80434. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80435. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80436. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80437. lineProcessor?: (line: string, isFragment: boolean) => string;
  80438. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80439. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80440. }
  80441. }
  80442. declare module BABYLON {
  80443. /** @hidden */
  80444. export interface ProcessingOptions {
  80445. defines: string[];
  80446. indexParameters: any;
  80447. isFragment: boolean;
  80448. shouldUseHighPrecisionShader: boolean;
  80449. supportsUniformBuffers: boolean;
  80450. shadersRepository: string;
  80451. includesShadersStore: {
  80452. [key: string]: string;
  80453. };
  80454. processor?: IShaderProcessor;
  80455. version: string;
  80456. platformName: string;
  80457. lookForClosingBracketForUniformBuffer?: boolean;
  80458. }
  80459. }
  80460. declare module BABYLON {
  80461. /** @hidden */
  80462. export class ShaderCodeNode {
  80463. line: string;
  80464. children: ShaderCodeNode[];
  80465. additionalDefineKey?: string;
  80466. additionalDefineValue?: string;
  80467. isValid(preprocessors: {
  80468. [key: string]: string;
  80469. }): boolean;
  80470. process(preprocessors: {
  80471. [key: string]: string;
  80472. }, options: ProcessingOptions): string;
  80473. }
  80474. }
  80475. declare module BABYLON {
  80476. /** @hidden */
  80477. export class ShaderCodeCursor {
  80478. private _lines;
  80479. lineIndex: number;
  80480. get currentLine(): string;
  80481. get canRead(): boolean;
  80482. set lines(value: string[]);
  80483. }
  80484. }
  80485. declare module BABYLON {
  80486. /** @hidden */
  80487. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80488. process(preprocessors: {
  80489. [key: string]: string;
  80490. }, options: ProcessingOptions): string;
  80491. }
  80492. }
  80493. declare module BABYLON {
  80494. /** @hidden */
  80495. export class ShaderDefineExpression {
  80496. isTrue(preprocessors: {
  80497. [key: string]: string;
  80498. }): boolean;
  80499. private static _OperatorPriority;
  80500. private static _Stack;
  80501. static postfixToInfix(postfix: string[]): string;
  80502. static infixToPostfix(infix: string): string[];
  80503. }
  80504. }
  80505. declare module BABYLON {
  80506. /** @hidden */
  80507. export class ShaderCodeTestNode extends ShaderCodeNode {
  80508. testExpression: ShaderDefineExpression;
  80509. isValid(preprocessors: {
  80510. [key: string]: string;
  80511. }): boolean;
  80512. }
  80513. }
  80514. declare module BABYLON {
  80515. /** @hidden */
  80516. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80517. define: string;
  80518. not: boolean;
  80519. constructor(define: string, not?: boolean);
  80520. isTrue(preprocessors: {
  80521. [key: string]: string;
  80522. }): boolean;
  80523. }
  80524. }
  80525. declare module BABYLON {
  80526. /** @hidden */
  80527. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80528. leftOperand: ShaderDefineExpression;
  80529. rightOperand: ShaderDefineExpression;
  80530. isTrue(preprocessors: {
  80531. [key: string]: string;
  80532. }): boolean;
  80533. }
  80534. }
  80535. declare module BABYLON {
  80536. /** @hidden */
  80537. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80538. leftOperand: ShaderDefineExpression;
  80539. rightOperand: ShaderDefineExpression;
  80540. isTrue(preprocessors: {
  80541. [key: string]: string;
  80542. }): boolean;
  80543. }
  80544. }
  80545. declare module BABYLON {
  80546. /** @hidden */
  80547. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80548. define: string;
  80549. operand: string;
  80550. testValue: string;
  80551. constructor(define: string, operand: string, testValue: string);
  80552. isTrue(preprocessors: {
  80553. [key: string]: string;
  80554. }): boolean;
  80555. }
  80556. }
  80557. declare module BABYLON {
  80558. /**
  80559. * Class used to enable access to offline support
  80560. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80561. */
  80562. export interface IOfflineProvider {
  80563. /**
  80564. * Gets a boolean indicating if scene must be saved in the database
  80565. */
  80566. enableSceneOffline: boolean;
  80567. /**
  80568. * Gets a boolean indicating if textures must be saved in the database
  80569. */
  80570. enableTexturesOffline: boolean;
  80571. /**
  80572. * Open the offline support and make it available
  80573. * @param successCallback defines the callback to call on success
  80574. * @param errorCallback defines the callback to call on error
  80575. */
  80576. open(successCallback: () => void, errorCallback: () => void): void;
  80577. /**
  80578. * Loads an image from the offline support
  80579. * @param url defines the url to load from
  80580. * @param image defines the target DOM image
  80581. */
  80582. loadImage(url: string, image: HTMLImageElement): void;
  80583. /**
  80584. * Loads a file from offline support
  80585. * @param url defines the URL to load from
  80586. * @param sceneLoaded defines a callback to call on success
  80587. * @param progressCallBack defines a callback to call when progress changed
  80588. * @param errorCallback defines a callback to call on error
  80589. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80590. */
  80591. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80592. }
  80593. }
  80594. declare module BABYLON {
  80595. /**
  80596. * Class used to help managing file picking and drag'n'drop
  80597. * File Storage
  80598. */
  80599. export class FilesInputStore {
  80600. /**
  80601. * List of files ready to be loaded
  80602. */
  80603. static FilesToLoad: {
  80604. [key: string]: File;
  80605. };
  80606. }
  80607. }
  80608. declare module BABYLON {
  80609. /**
  80610. * Class used to define a retry strategy when error happens while loading assets
  80611. */
  80612. export class RetryStrategy {
  80613. /**
  80614. * Function used to defines an exponential back off strategy
  80615. * @param maxRetries defines the maximum number of retries (3 by default)
  80616. * @param baseInterval defines the interval between retries
  80617. * @returns the strategy function to use
  80618. */
  80619. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80620. }
  80621. }
  80622. declare module BABYLON {
  80623. /**
  80624. * @ignore
  80625. * Application error to support additional information when loading a file
  80626. */
  80627. export abstract class BaseError extends Error {
  80628. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80629. }
  80630. }
  80631. declare module BABYLON {
  80632. /** @ignore */
  80633. export class LoadFileError extends BaseError {
  80634. request?: WebRequest;
  80635. file?: File;
  80636. /**
  80637. * Creates a new LoadFileError
  80638. * @param message defines the message of the error
  80639. * @param request defines the optional web request
  80640. * @param file defines the optional file
  80641. */
  80642. constructor(message: string, object?: WebRequest | File);
  80643. }
  80644. /** @ignore */
  80645. export class RequestFileError extends BaseError {
  80646. request: WebRequest;
  80647. /**
  80648. * Creates a new LoadFileError
  80649. * @param message defines the message of the error
  80650. * @param request defines the optional web request
  80651. */
  80652. constructor(message: string, request: WebRequest);
  80653. }
  80654. /** @ignore */
  80655. export class ReadFileError extends BaseError {
  80656. file: File;
  80657. /**
  80658. * Creates a new ReadFileError
  80659. * @param message defines the message of the error
  80660. * @param file defines the optional file
  80661. */
  80662. constructor(message: string, file: File);
  80663. }
  80664. /**
  80665. * @hidden
  80666. */
  80667. export class FileTools {
  80668. /**
  80669. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80670. */
  80671. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80672. /**
  80673. * Gets or sets the base URL to use to load assets
  80674. */
  80675. static BaseUrl: string;
  80676. /**
  80677. * Default behaviour for cors in the application.
  80678. * It can be a string if the expected behavior is identical in the entire app.
  80679. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80680. */
  80681. static CorsBehavior: string | ((url: string | string[]) => string);
  80682. /**
  80683. * Gets or sets a function used to pre-process url before using them to load assets
  80684. */
  80685. static PreprocessUrl: (url: string) => string;
  80686. /**
  80687. * Removes unwanted characters from an url
  80688. * @param url defines the url to clean
  80689. * @returns the cleaned url
  80690. */
  80691. private static _CleanUrl;
  80692. /**
  80693. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80694. * @param url define the url we are trying
  80695. * @param element define the dom element where to configure the cors policy
  80696. */
  80697. static SetCorsBehavior(url: string | string[], element: {
  80698. crossOrigin: string | null;
  80699. }): void;
  80700. /**
  80701. * Loads an image as an HTMLImageElement.
  80702. * @param input url string, ArrayBuffer, or Blob to load
  80703. * @param onLoad callback called when the image successfully loads
  80704. * @param onError callback called when the image fails to load
  80705. * @param offlineProvider offline provider for caching
  80706. * @param mimeType optional mime type
  80707. * @returns the HTMLImageElement of the loaded image
  80708. */
  80709. 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>;
  80710. /**
  80711. * Reads a file from a File object
  80712. * @param file defines the file to load
  80713. * @param onSuccess defines the callback to call when data is loaded
  80714. * @param onProgress defines the callback to call during loading process
  80715. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80716. * @param onError defines the callback to call when an error occurs
  80717. * @returns a file request object
  80718. */
  80719. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80720. /**
  80721. * Loads a file from a url
  80722. * @param url url to load
  80723. * @param onSuccess callback called when the file successfully loads
  80724. * @param onProgress callback called while file is loading (if the server supports this mode)
  80725. * @param offlineProvider defines the offline provider for caching
  80726. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80727. * @param onError callback called when the file fails to load
  80728. * @returns a file request object
  80729. */
  80730. 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;
  80731. /**
  80732. * Loads a file
  80733. * @param url url to load
  80734. * @param onSuccess callback called when the file successfully loads
  80735. * @param onProgress callback called while file is loading (if the server supports this mode)
  80736. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80737. * @param onError callback called when the file fails to load
  80738. * @param onOpened callback called when the web request is opened
  80739. * @returns a file request object
  80740. */
  80741. 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;
  80742. /**
  80743. * Checks if the loaded document was accessed via `file:`-Protocol.
  80744. * @returns boolean
  80745. */
  80746. static IsFileURL(): boolean;
  80747. }
  80748. }
  80749. declare module BABYLON {
  80750. /** @hidden */
  80751. export class ShaderProcessor {
  80752. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80753. private static _ProcessPrecision;
  80754. private static _ExtractOperation;
  80755. private static _BuildSubExpression;
  80756. private static _BuildExpression;
  80757. private static _MoveCursorWithinIf;
  80758. private static _MoveCursor;
  80759. private static _EvaluatePreProcessors;
  80760. private static _PreparePreProcessors;
  80761. private static _ProcessShaderConversion;
  80762. private static _ProcessIncludes;
  80763. /**
  80764. * Loads a file from a url
  80765. * @param url url to load
  80766. * @param onSuccess callback called when the file successfully loads
  80767. * @param onProgress callback called while file is loading (if the server supports this mode)
  80768. * @param offlineProvider defines the offline provider for caching
  80769. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80770. * @param onError callback called when the file fails to load
  80771. * @returns a file request object
  80772. * @hidden
  80773. */
  80774. 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;
  80775. }
  80776. }
  80777. declare module BABYLON {
  80778. /**
  80779. * @hidden
  80780. */
  80781. export interface IColor4Like {
  80782. r: float;
  80783. g: float;
  80784. b: float;
  80785. a: float;
  80786. }
  80787. /**
  80788. * @hidden
  80789. */
  80790. export interface IColor3Like {
  80791. r: float;
  80792. g: float;
  80793. b: float;
  80794. }
  80795. /**
  80796. * @hidden
  80797. */
  80798. export interface IVector4Like {
  80799. x: float;
  80800. y: float;
  80801. z: float;
  80802. w: float;
  80803. }
  80804. /**
  80805. * @hidden
  80806. */
  80807. export interface IVector3Like {
  80808. x: float;
  80809. y: float;
  80810. z: float;
  80811. }
  80812. /**
  80813. * @hidden
  80814. */
  80815. export interface IVector2Like {
  80816. x: float;
  80817. y: float;
  80818. }
  80819. /**
  80820. * @hidden
  80821. */
  80822. export interface IMatrixLike {
  80823. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80824. updateFlag: int;
  80825. }
  80826. /**
  80827. * @hidden
  80828. */
  80829. export interface IViewportLike {
  80830. x: float;
  80831. y: float;
  80832. width: float;
  80833. height: float;
  80834. }
  80835. /**
  80836. * @hidden
  80837. */
  80838. export interface IPlaneLike {
  80839. normal: IVector3Like;
  80840. d: float;
  80841. normalize(): void;
  80842. }
  80843. }
  80844. declare module BABYLON {
  80845. /**
  80846. * Interface used to define common properties for effect fallbacks
  80847. */
  80848. export interface IEffectFallbacks {
  80849. /**
  80850. * Removes the defines that should be removed when falling back.
  80851. * @param currentDefines defines the current define statements for the shader.
  80852. * @param effect defines the current effect we try to compile
  80853. * @returns The resulting defines with defines of the current rank removed.
  80854. */
  80855. reduce(currentDefines: string, effect: Effect): string;
  80856. /**
  80857. * Removes the fallback from the bound mesh.
  80858. */
  80859. unBindMesh(): void;
  80860. /**
  80861. * Checks to see if more fallbacks are still availible.
  80862. */
  80863. hasMoreFallbacks: boolean;
  80864. }
  80865. }
  80866. declare module BABYLON {
  80867. /**
  80868. * Class used to evalaute queries containing `and` and `or` operators
  80869. */
  80870. export class AndOrNotEvaluator {
  80871. /**
  80872. * Evaluate a query
  80873. * @param query defines the query to evaluate
  80874. * @param evaluateCallback defines the callback used to filter result
  80875. * @returns true if the query matches
  80876. */
  80877. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80878. private static _HandleParenthesisContent;
  80879. private static _SimplifyNegation;
  80880. }
  80881. }
  80882. declare module BABYLON {
  80883. /**
  80884. * Class used to store custom tags
  80885. */
  80886. export class Tags {
  80887. /**
  80888. * Adds support for tags on the given object
  80889. * @param obj defines the object to use
  80890. */
  80891. static EnableFor(obj: any): void;
  80892. /**
  80893. * Removes tags support
  80894. * @param obj defines the object to use
  80895. */
  80896. static DisableFor(obj: any): void;
  80897. /**
  80898. * Gets a boolean indicating if the given object has tags
  80899. * @param obj defines the object to use
  80900. * @returns a boolean
  80901. */
  80902. static HasTags(obj: any): boolean;
  80903. /**
  80904. * Gets the tags available on a given object
  80905. * @param obj defines the object to use
  80906. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80907. * @returns the tags
  80908. */
  80909. static GetTags(obj: any, asString?: boolean): any;
  80910. /**
  80911. * Adds tags to an object
  80912. * @param obj defines the object to use
  80913. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80914. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80915. */
  80916. static AddTagsTo(obj: any, tagsString: string): void;
  80917. /**
  80918. * @hidden
  80919. */
  80920. static _AddTagTo(obj: any, tag: string): void;
  80921. /**
  80922. * Removes specific tags from a specific object
  80923. * @param obj defines the object to use
  80924. * @param tagsString defines the tags to remove
  80925. */
  80926. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80927. /**
  80928. * @hidden
  80929. */
  80930. static _RemoveTagFrom(obj: any, tag: string): void;
  80931. /**
  80932. * Defines if tags hosted on an object match a given query
  80933. * @param obj defines the object to use
  80934. * @param tagsQuery defines the tag query
  80935. * @returns a boolean
  80936. */
  80937. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80938. }
  80939. }
  80940. declare module BABYLON {
  80941. /**
  80942. * Scalar computation library
  80943. */
  80944. export class Scalar {
  80945. /**
  80946. * Two pi constants convenient for computation.
  80947. */
  80948. static TwoPi: number;
  80949. /**
  80950. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80951. * @param a number
  80952. * @param b number
  80953. * @param epsilon (default = 1.401298E-45)
  80954. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80955. */
  80956. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80957. /**
  80958. * Returns a string : the upper case translation of the number i to hexadecimal.
  80959. * @param i number
  80960. * @returns the upper case translation of the number i to hexadecimal.
  80961. */
  80962. static ToHex(i: number): string;
  80963. /**
  80964. * Returns -1 if value is negative and +1 is value is positive.
  80965. * @param value the value
  80966. * @returns the value itself if it's equal to zero.
  80967. */
  80968. static Sign(value: number): number;
  80969. /**
  80970. * Returns the value itself if it's between min and max.
  80971. * Returns min if the value is lower than min.
  80972. * Returns max if the value is greater than max.
  80973. * @param value the value to clmap
  80974. * @param min the min value to clamp to (default: 0)
  80975. * @param max the max value to clamp to (default: 1)
  80976. * @returns the clamped value
  80977. */
  80978. static Clamp(value: number, min?: number, max?: number): number;
  80979. /**
  80980. * the log2 of value.
  80981. * @param value the value to compute log2 of
  80982. * @returns the log2 of value.
  80983. */
  80984. static Log2(value: number): number;
  80985. /**
  80986. * Loops the value, so that it is never larger than length and never smaller than 0.
  80987. *
  80988. * This is similar to the modulo operator but it works with floating point numbers.
  80989. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80990. * With t = 5 and length = 2.5, the result would be 0.0.
  80991. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80992. * @param value the value
  80993. * @param length the length
  80994. * @returns the looped value
  80995. */
  80996. static Repeat(value: number, length: number): number;
  80997. /**
  80998. * Normalize the value between 0.0 and 1.0 using min and max values
  80999. * @param value value to normalize
  81000. * @param min max to normalize between
  81001. * @param max min to normalize between
  81002. * @returns the normalized value
  81003. */
  81004. static Normalize(value: number, min: number, max: number): number;
  81005. /**
  81006. * Denormalize the value from 0.0 and 1.0 using min and max values
  81007. * @param normalized value to denormalize
  81008. * @param min max to denormalize between
  81009. * @param max min to denormalize between
  81010. * @returns the denormalized value
  81011. */
  81012. static Denormalize(normalized: number, min: number, max: number): number;
  81013. /**
  81014. * Calculates the shortest difference between two given angles given in degrees.
  81015. * @param current current angle in degrees
  81016. * @param target target angle in degrees
  81017. * @returns the delta
  81018. */
  81019. static DeltaAngle(current: number, target: number): number;
  81020. /**
  81021. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81022. * @param tx value
  81023. * @param length length
  81024. * @returns The returned value will move back and forth between 0 and length
  81025. */
  81026. static PingPong(tx: number, length: number): number;
  81027. /**
  81028. * Interpolates between min and max with smoothing at the limits.
  81029. *
  81030. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81031. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81032. * @param from from
  81033. * @param to to
  81034. * @param tx value
  81035. * @returns the smooth stepped value
  81036. */
  81037. static SmoothStep(from: number, to: number, tx: number): number;
  81038. /**
  81039. * Moves a value current towards target.
  81040. *
  81041. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81042. * Negative values of maxDelta pushes the value away from target.
  81043. * @param current current value
  81044. * @param target target value
  81045. * @param maxDelta max distance to move
  81046. * @returns resulting value
  81047. */
  81048. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81049. /**
  81050. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81051. *
  81052. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81053. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81054. * @param current current value
  81055. * @param target target value
  81056. * @param maxDelta max distance to move
  81057. * @returns resulting angle
  81058. */
  81059. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81060. /**
  81061. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81062. * @param start start value
  81063. * @param end target value
  81064. * @param amount amount to lerp between
  81065. * @returns the lerped value
  81066. */
  81067. static Lerp(start: number, end: number, amount: number): number;
  81068. /**
  81069. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81070. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81071. * @param start start value
  81072. * @param end target value
  81073. * @param amount amount to lerp between
  81074. * @returns the lerped value
  81075. */
  81076. static LerpAngle(start: number, end: number, amount: number): number;
  81077. /**
  81078. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81079. * @param a start value
  81080. * @param b target value
  81081. * @param value value between a and b
  81082. * @returns the inverseLerp value
  81083. */
  81084. static InverseLerp(a: number, b: number, value: number): number;
  81085. /**
  81086. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81087. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81088. * @param value1 spline value
  81089. * @param tangent1 spline value
  81090. * @param value2 spline value
  81091. * @param tangent2 spline value
  81092. * @param amount input value
  81093. * @returns hermite result
  81094. */
  81095. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81096. /**
  81097. * Returns a random float number between and min and max values
  81098. * @param min min value of random
  81099. * @param max max value of random
  81100. * @returns random value
  81101. */
  81102. static RandomRange(min: number, max: number): number;
  81103. /**
  81104. * This function returns percentage of a number in a given range.
  81105. *
  81106. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81107. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81108. * @param number to convert to percentage
  81109. * @param min min range
  81110. * @param max max range
  81111. * @returns the percentage
  81112. */
  81113. static RangeToPercent(number: number, min: number, max: number): number;
  81114. /**
  81115. * This function returns number that corresponds to the percentage in a given range.
  81116. *
  81117. * PercentToRange(0.34,0,100) will return 34.
  81118. * @param percent to convert to number
  81119. * @param min min range
  81120. * @param max max range
  81121. * @returns the number
  81122. */
  81123. static PercentToRange(percent: number, min: number, max: number): number;
  81124. /**
  81125. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81126. * @param angle The angle to normalize in radian.
  81127. * @return The converted angle.
  81128. */
  81129. static NormalizeRadians(angle: number): number;
  81130. }
  81131. }
  81132. declare module BABYLON {
  81133. /**
  81134. * Constant used to convert a value to gamma space
  81135. * @ignorenaming
  81136. */
  81137. export const ToGammaSpace: number;
  81138. /**
  81139. * Constant used to convert a value to linear space
  81140. * @ignorenaming
  81141. */
  81142. export const ToLinearSpace = 2.2;
  81143. /**
  81144. * Constant used to define the minimal number value in Babylon.js
  81145. * @ignorenaming
  81146. */
  81147. let Epsilon: number;
  81148. }
  81149. declare module BABYLON {
  81150. /**
  81151. * Class used to represent a viewport on screen
  81152. */
  81153. export class Viewport {
  81154. /** viewport left coordinate */
  81155. x: number;
  81156. /** viewport top coordinate */
  81157. y: number;
  81158. /**viewport width */
  81159. width: number;
  81160. /** viewport height */
  81161. height: number;
  81162. /**
  81163. * Creates a Viewport object located at (x, y) and sized (width, height)
  81164. * @param x defines viewport left coordinate
  81165. * @param y defines viewport top coordinate
  81166. * @param width defines the viewport width
  81167. * @param height defines the viewport height
  81168. */
  81169. constructor(
  81170. /** viewport left coordinate */
  81171. x: number,
  81172. /** viewport top coordinate */
  81173. y: number,
  81174. /**viewport width */
  81175. width: number,
  81176. /** viewport height */
  81177. height: number);
  81178. /**
  81179. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81180. * @param renderWidth defines the rendering width
  81181. * @param renderHeight defines the rendering height
  81182. * @returns a new Viewport
  81183. */
  81184. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81185. /**
  81186. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81187. * @param renderWidth defines the rendering width
  81188. * @param renderHeight defines the rendering height
  81189. * @param ref defines the target viewport
  81190. * @returns the current viewport
  81191. */
  81192. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81193. /**
  81194. * Returns a new Viewport copied from the current one
  81195. * @returns a new Viewport
  81196. */
  81197. clone(): Viewport;
  81198. }
  81199. }
  81200. declare module BABYLON {
  81201. /**
  81202. * Class containing a set of static utilities functions for arrays.
  81203. */
  81204. export class ArrayTools {
  81205. /**
  81206. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81207. * @param size the number of element to construct and put in the array
  81208. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81209. * @returns a new array filled with new objects
  81210. */
  81211. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81212. }
  81213. }
  81214. declare module BABYLON {
  81215. /**
  81216. * Represents a plane by the equation ax + by + cz + d = 0
  81217. */
  81218. export class Plane {
  81219. private static _TmpMatrix;
  81220. /**
  81221. * Normal of the plane (a,b,c)
  81222. */
  81223. normal: Vector3;
  81224. /**
  81225. * d component of the plane
  81226. */
  81227. d: number;
  81228. /**
  81229. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81230. * @param a a component of the plane
  81231. * @param b b component of the plane
  81232. * @param c c component of the plane
  81233. * @param d d component of the plane
  81234. */
  81235. constructor(a: number, b: number, c: number, d: number);
  81236. /**
  81237. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81238. */
  81239. asArray(): number[];
  81240. /**
  81241. * @returns a new plane copied from the current Plane.
  81242. */
  81243. clone(): Plane;
  81244. /**
  81245. * @returns the string "Plane".
  81246. */
  81247. getClassName(): string;
  81248. /**
  81249. * @returns the Plane hash code.
  81250. */
  81251. getHashCode(): number;
  81252. /**
  81253. * Normalize the current Plane in place.
  81254. * @returns the updated Plane.
  81255. */
  81256. normalize(): Plane;
  81257. /**
  81258. * Applies a transformation the plane and returns the result
  81259. * @param transformation the transformation matrix to be applied to the plane
  81260. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81261. */
  81262. transform(transformation: DeepImmutable<Matrix>): Plane;
  81263. /**
  81264. * Compute the dot product between the point and the plane normal
  81265. * @param point point to calculate the dot product with
  81266. * @returns the dot product (float) of the point coordinates and the plane normal.
  81267. */
  81268. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81269. /**
  81270. * Updates the current Plane from the plane defined by the three given points.
  81271. * @param point1 one of the points used to contruct the plane
  81272. * @param point2 one of the points used to contruct the plane
  81273. * @param point3 one of the points used to contruct the plane
  81274. * @returns the updated Plane.
  81275. */
  81276. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81277. /**
  81278. * Checks if the plane is facing a given direction
  81279. * @param direction the direction to check if the plane is facing
  81280. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81281. * @returns True is the vector "direction" is the same side than the plane normal.
  81282. */
  81283. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81284. /**
  81285. * Calculates the distance to a point
  81286. * @param point point to calculate distance to
  81287. * @returns the signed distance (float) from the given point to the Plane.
  81288. */
  81289. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81290. /**
  81291. * Creates a plane from an array
  81292. * @param array the array to create a plane from
  81293. * @returns a new Plane from the given array.
  81294. */
  81295. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81296. /**
  81297. * Creates a plane from three points
  81298. * @param point1 point used to create the plane
  81299. * @param point2 point used to create the plane
  81300. * @param point3 point used to create the plane
  81301. * @returns a new Plane defined by the three given points.
  81302. */
  81303. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81304. /**
  81305. * Creates a plane from an origin point and a normal
  81306. * @param origin origin of the plane to be constructed
  81307. * @param normal normal of the plane to be constructed
  81308. * @returns a new Plane the normal vector to this plane at the given origin point.
  81309. * Note : the vector "normal" is updated because normalized.
  81310. */
  81311. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81312. /**
  81313. * Calculates the distance from a plane and a point
  81314. * @param origin origin of the plane to be constructed
  81315. * @param normal normal of the plane to be constructed
  81316. * @param point point to calculate distance to
  81317. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81318. */
  81319. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81320. }
  81321. }
  81322. declare module BABYLON {
  81323. /** @hidden */
  81324. export class PerformanceConfigurator {
  81325. /** @hidden */
  81326. static MatrixUse64Bits: boolean;
  81327. /** @hidden */
  81328. static MatrixTrackPrecisionChange: boolean;
  81329. /** @hidden */
  81330. static MatrixCurrentType: any;
  81331. /** @hidden */
  81332. static MatrixTrackedMatrices: Array<any> | null;
  81333. /** @hidden */
  81334. static SetMatrixPrecision(use64bits: boolean): void;
  81335. }
  81336. }
  81337. declare module BABYLON {
  81338. /**
  81339. * Class representing a vector containing 2 coordinates
  81340. */
  81341. export class Vector2 {
  81342. /** defines the first coordinate */
  81343. x: number;
  81344. /** defines the second coordinate */
  81345. y: number;
  81346. /**
  81347. * Creates a new Vector2 from the given x and y coordinates
  81348. * @param x defines the first coordinate
  81349. * @param y defines the second coordinate
  81350. */
  81351. constructor(
  81352. /** defines the first coordinate */
  81353. x?: number,
  81354. /** defines the second coordinate */
  81355. y?: number);
  81356. /**
  81357. * Gets a string with the Vector2 coordinates
  81358. * @returns a string with the Vector2 coordinates
  81359. */
  81360. toString(): string;
  81361. /**
  81362. * Gets class name
  81363. * @returns the string "Vector2"
  81364. */
  81365. getClassName(): string;
  81366. /**
  81367. * Gets current vector hash code
  81368. * @returns the Vector2 hash code as a number
  81369. */
  81370. getHashCode(): number;
  81371. /**
  81372. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81373. * @param array defines the source array
  81374. * @param index defines the offset in source array
  81375. * @returns the current Vector2
  81376. */
  81377. toArray(array: FloatArray, index?: number): Vector2;
  81378. /**
  81379. * Update the current vector from an array
  81380. * @param array defines the destination array
  81381. * @param index defines the offset in the destination array
  81382. * @returns the current Vector3
  81383. */
  81384. fromArray(array: FloatArray, index?: number): Vector2;
  81385. /**
  81386. * Copy the current vector to an array
  81387. * @returns a new array with 2 elements: the Vector2 coordinates.
  81388. */
  81389. asArray(): number[];
  81390. /**
  81391. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81392. * @param source defines the source Vector2
  81393. * @returns the current updated Vector2
  81394. */
  81395. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81396. /**
  81397. * Sets the Vector2 coordinates with the given floats
  81398. * @param x defines the first coordinate
  81399. * @param y defines the second coordinate
  81400. * @returns the current updated Vector2
  81401. */
  81402. copyFromFloats(x: number, y: number): Vector2;
  81403. /**
  81404. * Sets the Vector2 coordinates with the given floats
  81405. * @param x defines the first coordinate
  81406. * @param y defines the second coordinate
  81407. * @returns the current updated Vector2
  81408. */
  81409. set(x: number, y: number): Vector2;
  81410. /**
  81411. * Add another vector with the current one
  81412. * @param otherVector defines the other vector
  81413. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81414. */
  81415. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81416. /**
  81417. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81418. * @param otherVector defines the other vector
  81419. * @param result defines the target vector
  81420. * @returns the unmodified current Vector2
  81421. */
  81422. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81423. /**
  81424. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81425. * @param otherVector defines the other vector
  81426. * @returns the current updated Vector2
  81427. */
  81428. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81429. /**
  81430. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81431. * @param otherVector defines the other vector
  81432. * @returns a new Vector2
  81433. */
  81434. addVector3(otherVector: Vector3): Vector2;
  81435. /**
  81436. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81437. * @param otherVector defines the other vector
  81438. * @returns a new Vector2
  81439. */
  81440. subtract(otherVector: Vector2): Vector2;
  81441. /**
  81442. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81443. * @param otherVector defines the other vector
  81444. * @param result defines the target vector
  81445. * @returns the unmodified current Vector2
  81446. */
  81447. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81448. /**
  81449. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81450. * @param otherVector defines the other vector
  81451. * @returns the current updated Vector2
  81452. */
  81453. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81454. /**
  81455. * Multiplies in place the current Vector2 coordinates by the given ones
  81456. * @param otherVector defines the other vector
  81457. * @returns the current updated Vector2
  81458. */
  81459. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81460. /**
  81461. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81462. * @param otherVector defines the other vector
  81463. * @returns a new Vector2
  81464. */
  81465. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81466. /**
  81467. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81468. * @param otherVector defines the other vector
  81469. * @param result defines the target vector
  81470. * @returns the unmodified current Vector2
  81471. */
  81472. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81473. /**
  81474. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81475. * @param x defines the first coordinate
  81476. * @param y defines the second coordinate
  81477. * @returns a new Vector2
  81478. */
  81479. multiplyByFloats(x: number, y: number): Vector2;
  81480. /**
  81481. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81482. * @param otherVector defines the other vector
  81483. * @returns a new Vector2
  81484. */
  81485. divide(otherVector: Vector2): Vector2;
  81486. /**
  81487. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81488. * @param otherVector defines the other vector
  81489. * @param result defines the target vector
  81490. * @returns the unmodified current Vector2
  81491. */
  81492. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81493. /**
  81494. * Divides the current Vector2 coordinates by the given ones
  81495. * @param otherVector defines the other vector
  81496. * @returns the current updated Vector2
  81497. */
  81498. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81499. /**
  81500. * Gets a new Vector2 with current Vector2 negated coordinates
  81501. * @returns a new Vector2
  81502. */
  81503. negate(): Vector2;
  81504. /**
  81505. * Negate this vector in place
  81506. * @returns this
  81507. */
  81508. negateInPlace(): Vector2;
  81509. /**
  81510. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81511. * @param result defines the Vector3 object where to store the result
  81512. * @returns the current Vector2
  81513. */
  81514. negateToRef(result: Vector2): Vector2;
  81515. /**
  81516. * Multiply the Vector2 coordinates by scale
  81517. * @param scale defines the scaling factor
  81518. * @returns the current updated Vector2
  81519. */
  81520. scaleInPlace(scale: number): Vector2;
  81521. /**
  81522. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81523. * @param scale defines the scaling factor
  81524. * @returns a new Vector2
  81525. */
  81526. scale(scale: number): Vector2;
  81527. /**
  81528. * Scale the current Vector2 values by a factor to a given Vector2
  81529. * @param scale defines the scale factor
  81530. * @param result defines the Vector2 object where to store the result
  81531. * @returns the unmodified current Vector2
  81532. */
  81533. scaleToRef(scale: number, result: Vector2): Vector2;
  81534. /**
  81535. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81536. * @param scale defines the scale factor
  81537. * @param result defines the Vector2 object where to store the result
  81538. * @returns the unmodified current Vector2
  81539. */
  81540. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81541. /**
  81542. * Gets a boolean if two vectors are equals
  81543. * @param otherVector defines the other vector
  81544. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81545. */
  81546. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81547. /**
  81548. * Gets a boolean if two vectors are equals (using an epsilon value)
  81549. * @param otherVector defines the other vector
  81550. * @param epsilon defines the minimal distance to consider equality
  81551. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81552. */
  81553. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81554. /**
  81555. * Gets a new Vector2 from current Vector2 floored values
  81556. * @returns a new Vector2
  81557. */
  81558. floor(): Vector2;
  81559. /**
  81560. * Gets a new Vector2 from current Vector2 floored values
  81561. * @returns a new Vector2
  81562. */
  81563. fract(): Vector2;
  81564. /**
  81565. * Gets the length of the vector
  81566. * @returns the vector length (float)
  81567. */
  81568. length(): number;
  81569. /**
  81570. * Gets the vector squared length
  81571. * @returns the vector squared length (float)
  81572. */
  81573. lengthSquared(): number;
  81574. /**
  81575. * Normalize the vector
  81576. * @returns the current updated Vector2
  81577. */
  81578. normalize(): Vector2;
  81579. /**
  81580. * Gets a new Vector2 copied from the Vector2
  81581. * @returns a new Vector2
  81582. */
  81583. clone(): Vector2;
  81584. /**
  81585. * Gets a new Vector2(0, 0)
  81586. * @returns a new Vector2
  81587. */
  81588. static Zero(): Vector2;
  81589. /**
  81590. * Gets a new Vector2(1, 1)
  81591. * @returns a new Vector2
  81592. */
  81593. static One(): Vector2;
  81594. /**
  81595. * Gets a new Vector2 set from the given index element of the given array
  81596. * @param array defines the data source
  81597. * @param offset defines the offset in the data source
  81598. * @returns a new Vector2
  81599. */
  81600. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81601. /**
  81602. * Sets "result" from the given index element of the given array
  81603. * @param array defines the data source
  81604. * @param offset defines the offset in the data source
  81605. * @param result defines the target vector
  81606. */
  81607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81608. /**
  81609. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81610. * @param value1 defines 1st point of control
  81611. * @param value2 defines 2nd point of control
  81612. * @param value3 defines 3rd point of control
  81613. * @param value4 defines 4th point of control
  81614. * @param amount defines the interpolation factor
  81615. * @returns a new Vector2
  81616. */
  81617. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81618. /**
  81619. * 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".
  81620. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81621. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81622. * @param value defines the value to clamp
  81623. * @param min defines the lower limit
  81624. * @param max defines the upper limit
  81625. * @returns a new Vector2
  81626. */
  81627. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81628. /**
  81629. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81630. * @param value1 defines the 1st control point
  81631. * @param tangent1 defines the outgoing tangent
  81632. * @param value2 defines the 2nd control point
  81633. * @param tangent2 defines the incoming tangent
  81634. * @param amount defines the interpolation factor
  81635. * @returns a new Vector2
  81636. */
  81637. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81638. /**
  81639. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81640. * @param start defines the start vector
  81641. * @param end defines the end vector
  81642. * @param amount defines the interpolation factor
  81643. * @returns a new Vector2
  81644. */
  81645. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81646. /**
  81647. * Gets the dot product of the vector "left" and the vector "right"
  81648. * @param left defines first vector
  81649. * @param right defines second vector
  81650. * @returns the dot product (float)
  81651. */
  81652. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81653. /**
  81654. * Returns a new Vector2 equal to the normalized given vector
  81655. * @param vector defines the vector to normalize
  81656. * @returns a new Vector2
  81657. */
  81658. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81659. /**
  81660. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81661. * @param left defines 1st vector
  81662. * @param right defines 2nd vector
  81663. * @returns a new Vector2
  81664. */
  81665. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81666. /**
  81667. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81668. * @param left defines 1st vector
  81669. * @param right defines 2nd vector
  81670. * @returns a new Vector2
  81671. */
  81672. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81673. /**
  81674. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81675. * @param vector defines the vector to transform
  81676. * @param transformation defines the matrix to apply
  81677. * @returns a new Vector2
  81678. */
  81679. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81680. /**
  81681. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81682. * @param vector defines the vector to transform
  81683. * @param transformation defines the matrix to apply
  81684. * @param result defines the target vector
  81685. */
  81686. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81687. /**
  81688. * Determines if a given vector is included in a triangle
  81689. * @param p defines the vector to test
  81690. * @param p0 defines 1st triangle point
  81691. * @param p1 defines 2nd triangle point
  81692. * @param p2 defines 3rd triangle point
  81693. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81694. */
  81695. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81696. /**
  81697. * Gets the distance between the vectors "value1" and "value2"
  81698. * @param value1 defines first vector
  81699. * @param value2 defines second vector
  81700. * @returns the distance between vectors
  81701. */
  81702. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81703. /**
  81704. * Returns the squared distance between the vectors "value1" and "value2"
  81705. * @param value1 defines first vector
  81706. * @param value2 defines second vector
  81707. * @returns the squared distance between vectors
  81708. */
  81709. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81710. /**
  81711. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81712. * @param value1 defines first vector
  81713. * @param value2 defines second vector
  81714. * @returns a new Vector2
  81715. */
  81716. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81717. /**
  81718. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81719. * @param p defines the middle point
  81720. * @param segA defines one point of the segment
  81721. * @param segB defines the other point of the segment
  81722. * @returns the shortest distance
  81723. */
  81724. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81725. }
  81726. /**
  81727. * Class used to store (x,y,z) vector representation
  81728. * A Vector3 is the main object used in 3D geometry
  81729. * It can represent etiher the coordinates of a point the space, either a direction
  81730. * Reminder: js uses a left handed forward facing system
  81731. */
  81732. export class Vector3 {
  81733. private static _UpReadOnly;
  81734. private static _ZeroReadOnly;
  81735. /** @hidden */
  81736. _x: number;
  81737. /** @hidden */
  81738. _y: number;
  81739. /** @hidden */
  81740. _z: number;
  81741. /** @hidden */
  81742. _isDirty: boolean;
  81743. /** Gets or sets the x coordinate */
  81744. get x(): number;
  81745. set x(value: number);
  81746. /** Gets or sets the y coordinate */
  81747. get y(): number;
  81748. set y(value: number);
  81749. /** Gets or sets the z coordinate */
  81750. get z(): number;
  81751. set z(value: number);
  81752. /**
  81753. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81754. * @param x defines the first coordinates (on X axis)
  81755. * @param y defines the second coordinates (on Y axis)
  81756. * @param z defines the third coordinates (on Z axis)
  81757. */
  81758. constructor(x?: number, y?: number, z?: number);
  81759. /**
  81760. * Creates a string representation of the Vector3
  81761. * @returns a string with the Vector3 coordinates.
  81762. */
  81763. toString(): string;
  81764. /**
  81765. * Gets the class name
  81766. * @returns the string "Vector3"
  81767. */
  81768. getClassName(): string;
  81769. /**
  81770. * Creates the Vector3 hash code
  81771. * @returns a number which tends to be unique between Vector3 instances
  81772. */
  81773. getHashCode(): number;
  81774. /**
  81775. * Creates an array containing three elements : the coordinates of the Vector3
  81776. * @returns a new array of numbers
  81777. */
  81778. asArray(): number[];
  81779. /**
  81780. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81781. * @param array defines the destination array
  81782. * @param index defines the offset in the destination array
  81783. * @returns the current Vector3
  81784. */
  81785. toArray(array: FloatArray, index?: number): Vector3;
  81786. /**
  81787. * Update the current vector from an array
  81788. * @param array defines the destination array
  81789. * @param index defines the offset in the destination array
  81790. * @returns the current Vector3
  81791. */
  81792. fromArray(array: FloatArray, index?: number): Vector3;
  81793. /**
  81794. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81795. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81796. */
  81797. toQuaternion(): Quaternion;
  81798. /**
  81799. * Adds the given vector to the current Vector3
  81800. * @param otherVector defines the second operand
  81801. * @returns the current updated Vector3
  81802. */
  81803. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81804. /**
  81805. * Adds the given coordinates to the current Vector3
  81806. * @param x defines the x coordinate of the operand
  81807. * @param y defines the y coordinate of the operand
  81808. * @param z defines the z coordinate of the operand
  81809. * @returns the current updated Vector3
  81810. */
  81811. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81812. /**
  81813. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81814. * @param otherVector defines the second operand
  81815. * @returns the resulting Vector3
  81816. */
  81817. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81818. /**
  81819. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81820. * @param otherVector defines the second operand
  81821. * @param result defines the Vector3 object where to store the result
  81822. * @returns the current Vector3
  81823. */
  81824. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81825. /**
  81826. * Subtract the given vector from the current Vector3
  81827. * @param otherVector defines the second operand
  81828. * @returns the current updated Vector3
  81829. */
  81830. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81831. /**
  81832. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81833. * @param otherVector defines the second operand
  81834. * @returns the resulting Vector3
  81835. */
  81836. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81837. /**
  81838. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81839. * @param otherVector defines the second operand
  81840. * @param result defines the Vector3 object where to store the result
  81841. * @returns the current Vector3
  81842. */
  81843. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81844. /**
  81845. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81846. * @param x defines the x coordinate of the operand
  81847. * @param y defines the y coordinate of the operand
  81848. * @param z defines the z coordinate of the operand
  81849. * @returns the resulting Vector3
  81850. */
  81851. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81852. /**
  81853. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81854. * @param x defines the x coordinate of the operand
  81855. * @param y defines the y coordinate of the operand
  81856. * @param z defines the z coordinate of the operand
  81857. * @param result defines the Vector3 object where to store the result
  81858. * @returns the current Vector3
  81859. */
  81860. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81861. /**
  81862. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81863. * @returns a new Vector3
  81864. */
  81865. negate(): Vector3;
  81866. /**
  81867. * Negate this vector in place
  81868. * @returns this
  81869. */
  81870. negateInPlace(): Vector3;
  81871. /**
  81872. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81873. * @param result defines the Vector3 object where to store the result
  81874. * @returns the current Vector3
  81875. */
  81876. negateToRef(result: Vector3): Vector3;
  81877. /**
  81878. * Multiplies the Vector3 coordinates by the float "scale"
  81879. * @param scale defines the multiplier factor
  81880. * @returns the current updated Vector3
  81881. */
  81882. scaleInPlace(scale: number): Vector3;
  81883. /**
  81884. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81885. * @param scale defines the multiplier factor
  81886. * @returns a new Vector3
  81887. */
  81888. scale(scale: number): Vector3;
  81889. /**
  81890. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81891. * @param scale defines the multiplier factor
  81892. * @param result defines the Vector3 object where to store the result
  81893. * @returns the current Vector3
  81894. */
  81895. scaleToRef(scale: number, result: Vector3): Vector3;
  81896. /**
  81897. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81898. * @param scale defines the scale factor
  81899. * @param result defines the Vector3 object where to store the result
  81900. * @returns the unmodified current Vector3
  81901. */
  81902. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81903. /**
  81904. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81905. * @param origin defines the origin of the projection ray
  81906. * @param plane defines the plane to project to
  81907. * @returns the projected vector3
  81908. */
  81909. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81910. /**
  81911. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81912. * @param origin defines the origin of the projection ray
  81913. * @param plane defines the plane to project to
  81914. * @param result defines the Vector3 where to store the result
  81915. */
  81916. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81917. /**
  81918. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81919. * @param otherVector defines the second operand
  81920. * @returns true if both vectors are equals
  81921. */
  81922. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81923. /**
  81924. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81925. * @param otherVector defines the second operand
  81926. * @param epsilon defines the minimal distance to define values as equals
  81927. * @returns true if both vectors are distant less than epsilon
  81928. */
  81929. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81930. /**
  81931. * Returns true if the current Vector3 coordinates equals the given floats
  81932. * @param x defines the x coordinate of the operand
  81933. * @param y defines the y coordinate of the operand
  81934. * @param z defines the z coordinate of the operand
  81935. * @returns true if both vectors are equals
  81936. */
  81937. equalsToFloats(x: number, y: number, z: number): boolean;
  81938. /**
  81939. * Multiplies the current Vector3 coordinates by the given ones
  81940. * @param otherVector defines the second operand
  81941. * @returns the current updated Vector3
  81942. */
  81943. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81944. /**
  81945. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81946. * @param otherVector defines the second operand
  81947. * @returns the new Vector3
  81948. */
  81949. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81950. /**
  81951. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81952. * @param otherVector defines the second operand
  81953. * @param result defines the Vector3 object where to store the result
  81954. * @returns the current Vector3
  81955. */
  81956. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81957. /**
  81958. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81959. * @param x defines the x coordinate of the operand
  81960. * @param y defines the y coordinate of the operand
  81961. * @param z defines the z coordinate of the operand
  81962. * @returns the new Vector3
  81963. */
  81964. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81965. /**
  81966. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81967. * @param otherVector defines the second operand
  81968. * @returns the new Vector3
  81969. */
  81970. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81971. /**
  81972. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81973. * @param otherVector defines the second operand
  81974. * @param result defines the Vector3 object where to store the result
  81975. * @returns the current Vector3
  81976. */
  81977. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81978. /**
  81979. * Divides the current Vector3 coordinates by the given ones.
  81980. * @param otherVector defines the second operand
  81981. * @returns the current updated Vector3
  81982. */
  81983. divideInPlace(otherVector: Vector3): Vector3;
  81984. /**
  81985. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81986. * @param other defines the second operand
  81987. * @returns the current updated Vector3
  81988. */
  81989. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81990. /**
  81991. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81992. * @param other defines the second operand
  81993. * @returns the current updated Vector3
  81994. */
  81995. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81996. /**
  81997. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81998. * @param x defines the x coordinate of the operand
  81999. * @param y defines the y coordinate of the operand
  82000. * @param z defines the z coordinate of the operand
  82001. * @returns the current updated Vector3
  82002. */
  82003. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82004. /**
  82005. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82006. * @param x defines the x coordinate of the operand
  82007. * @param y defines the y coordinate of the operand
  82008. * @param z defines the z coordinate of the operand
  82009. * @returns the current updated Vector3
  82010. */
  82011. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82012. /**
  82013. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82014. * Check if is non uniform within a certain amount of decimal places to account for this
  82015. * @param epsilon the amount the values can differ
  82016. * @returns if the the vector is non uniform to a certain number of decimal places
  82017. */
  82018. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82019. /**
  82020. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82021. */
  82022. get isNonUniform(): boolean;
  82023. /**
  82024. * Gets a new Vector3 from current Vector3 floored values
  82025. * @returns a new Vector3
  82026. */
  82027. floor(): Vector3;
  82028. /**
  82029. * Gets a new Vector3 from current Vector3 floored values
  82030. * @returns a new Vector3
  82031. */
  82032. fract(): Vector3;
  82033. /**
  82034. * Gets the length of the Vector3
  82035. * @returns the length of the Vector3
  82036. */
  82037. length(): number;
  82038. /**
  82039. * Gets the squared length of the Vector3
  82040. * @returns squared length of the Vector3
  82041. */
  82042. lengthSquared(): number;
  82043. /**
  82044. * Normalize the current Vector3.
  82045. * Please note that this is an in place operation.
  82046. * @returns the current updated Vector3
  82047. */
  82048. normalize(): Vector3;
  82049. /**
  82050. * Reorders the x y z properties of the vector in place
  82051. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82052. * @returns the current updated vector
  82053. */
  82054. reorderInPlace(order: string): this;
  82055. /**
  82056. * Rotates the vector around 0,0,0 by a quaternion
  82057. * @param quaternion the rotation quaternion
  82058. * @param result vector to store the result
  82059. * @returns the resulting vector
  82060. */
  82061. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82062. /**
  82063. * Rotates a vector around a given point
  82064. * @param quaternion the rotation quaternion
  82065. * @param point the point to rotate around
  82066. * @param result vector to store the result
  82067. * @returns the resulting vector
  82068. */
  82069. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82070. /**
  82071. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82072. * The cross product is then orthogonal to both current and "other"
  82073. * @param other defines the right operand
  82074. * @returns the cross product
  82075. */
  82076. cross(other: Vector3): Vector3;
  82077. /**
  82078. * Normalize the current Vector3 with the given input length.
  82079. * Please note that this is an in place operation.
  82080. * @param len the length of the vector
  82081. * @returns the current updated Vector3
  82082. */
  82083. normalizeFromLength(len: number): Vector3;
  82084. /**
  82085. * Normalize the current Vector3 to a new vector
  82086. * @returns the new Vector3
  82087. */
  82088. normalizeToNew(): Vector3;
  82089. /**
  82090. * Normalize the current Vector3 to the reference
  82091. * @param reference define the Vector3 to update
  82092. * @returns the updated Vector3
  82093. */
  82094. normalizeToRef(reference: Vector3): Vector3;
  82095. /**
  82096. * Creates a new Vector3 copied from the current Vector3
  82097. * @returns the new Vector3
  82098. */
  82099. clone(): Vector3;
  82100. /**
  82101. * Copies the given vector coordinates to the current Vector3 ones
  82102. * @param source defines the source Vector3
  82103. * @returns the current updated Vector3
  82104. */
  82105. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82106. /**
  82107. * Copies the given floats to the current Vector3 coordinates
  82108. * @param x defines the x coordinate of the operand
  82109. * @param y defines the y coordinate of the operand
  82110. * @param z defines the z coordinate of the operand
  82111. * @returns the current updated Vector3
  82112. */
  82113. copyFromFloats(x: number, y: number, z: number): Vector3;
  82114. /**
  82115. * Copies the given floats to the current Vector3 coordinates
  82116. * @param x defines the x coordinate of the operand
  82117. * @param y defines the y coordinate of the operand
  82118. * @param z defines the z coordinate of the operand
  82119. * @returns the current updated Vector3
  82120. */
  82121. set(x: number, y: number, z: number): Vector3;
  82122. /**
  82123. * Copies the given float to the current Vector3 coordinates
  82124. * @param v defines the x, y and z coordinates of the operand
  82125. * @returns the current updated Vector3
  82126. */
  82127. setAll(v: number): Vector3;
  82128. /**
  82129. * Get the clip factor between two vectors
  82130. * @param vector0 defines the first operand
  82131. * @param vector1 defines the second operand
  82132. * @param axis defines the axis to use
  82133. * @param size defines the size along the axis
  82134. * @returns the clip factor
  82135. */
  82136. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82137. /**
  82138. * Get angle between two vectors
  82139. * @param vector0 angle between vector0 and vector1
  82140. * @param vector1 angle between vector0 and vector1
  82141. * @param normal direction of the normal
  82142. * @return the angle between vector0 and vector1
  82143. */
  82144. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82145. /**
  82146. * Returns a new Vector3 set from the index "offset" of the given array
  82147. * @param array defines the source array
  82148. * @param offset defines the offset in the source array
  82149. * @returns the new Vector3
  82150. */
  82151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82152. /**
  82153. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82154. * @param array defines the source array
  82155. * @param offset defines the offset in the source array
  82156. * @returns the new Vector3
  82157. * @deprecated Please use FromArray instead.
  82158. */
  82159. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82160. /**
  82161. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82162. * @param array defines the source array
  82163. * @param offset defines the offset in the source array
  82164. * @param result defines the Vector3 where to store the result
  82165. */
  82166. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82167. /**
  82168. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82169. * @param array defines the source array
  82170. * @param offset defines the offset in the source array
  82171. * @param result defines the Vector3 where to store the result
  82172. * @deprecated Please use FromArrayToRef instead.
  82173. */
  82174. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82175. /**
  82176. * Sets the given vector "result" with the given floats.
  82177. * @param x defines the x coordinate of the source
  82178. * @param y defines the y coordinate of the source
  82179. * @param z defines the z coordinate of the source
  82180. * @param result defines the Vector3 where to store the result
  82181. */
  82182. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82183. /**
  82184. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82185. * @returns a new empty Vector3
  82186. */
  82187. static Zero(): Vector3;
  82188. /**
  82189. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82190. * @returns a new unit Vector3
  82191. */
  82192. static One(): Vector3;
  82193. /**
  82194. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82195. * @returns a new up Vector3
  82196. */
  82197. static Up(): Vector3;
  82198. /**
  82199. * Gets a up Vector3 that must not be updated
  82200. */
  82201. static get UpReadOnly(): DeepImmutable<Vector3>;
  82202. /**
  82203. * Gets a zero Vector3 that must not be updated
  82204. */
  82205. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82206. /**
  82207. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82208. * @returns a new down Vector3
  82209. */
  82210. static Down(): Vector3;
  82211. /**
  82212. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82213. * @param rightHandedSystem is the scene right-handed (negative z)
  82214. * @returns a new forward Vector3
  82215. */
  82216. static Forward(rightHandedSystem?: boolean): Vector3;
  82217. /**
  82218. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82219. * @param rightHandedSystem is the scene right-handed (negative-z)
  82220. * @returns a new forward Vector3
  82221. */
  82222. static Backward(rightHandedSystem?: boolean): Vector3;
  82223. /**
  82224. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82225. * @returns a new right Vector3
  82226. */
  82227. static Right(): Vector3;
  82228. /**
  82229. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82230. * @returns a new left Vector3
  82231. */
  82232. static Left(): Vector3;
  82233. /**
  82234. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82235. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82236. * @param vector defines the Vector3 to transform
  82237. * @param transformation defines the transformation matrix
  82238. * @returns the transformed Vector3
  82239. */
  82240. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82241. /**
  82242. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82244. * @param vector defines the Vector3 to transform
  82245. * @param transformation defines the transformation matrix
  82246. * @param result defines the Vector3 where to store the result
  82247. */
  82248. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82249. /**
  82250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82251. * This method computes tranformed coordinates only, not transformed direction vectors
  82252. * @param x define the x coordinate of the source vector
  82253. * @param y define the y coordinate of the source vector
  82254. * @param z define the z coordinate of the source vector
  82255. * @param transformation defines the transformation matrix
  82256. * @param result defines the Vector3 where to store the result
  82257. */
  82258. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82259. /**
  82260. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82261. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82262. * @param vector defines the Vector3 to transform
  82263. * @param transformation defines the transformation matrix
  82264. * @returns the new Vector3
  82265. */
  82266. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82267. /**
  82268. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82270. * @param vector defines the Vector3 to transform
  82271. * @param transformation defines the transformation matrix
  82272. * @param result defines the Vector3 where to store the result
  82273. */
  82274. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82275. /**
  82276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82278. * @param x define the x coordinate of the source vector
  82279. * @param y define the y coordinate of the source vector
  82280. * @param z define the z coordinate of the source vector
  82281. * @param transformation defines the transformation matrix
  82282. * @param result defines the Vector3 where to store the result
  82283. */
  82284. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82285. /**
  82286. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82287. * @param value1 defines the first control point
  82288. * @param value2 defines the second control point
  82289. * @param value3 defines the third control point
  82290. * @param value4 defines the fourth control point
  82291. * @param amount defines the amount on the spline to use
  82292. * @returns the new Vector3
  82293. */
  82294. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82295. /**
  82296. * 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"
  82297. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82298. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82299. * @param value defines the current value
  82300. * @param min defines the lower range value
  82301. * @param max defines the upper range value
  82302. * @returns the new Vector3
  82303. */
  82304. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82305. /**
  82306. * 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"
  82307. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82308. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82309. * @param value defines the current value
  82310. * @param min defines the lower range value
  82311. * @param max defines the upper range value
  82312. * @param result defines the Vector3 where to store the result
  82313. */
  82314. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82315. /**
  82316. * Checks if a given vector is inside a specific range
  82317. * @param v defines the vector to test
  82318. * @param min defines the minimum range
  82319. * @param max defines the maximum range
  82320. */
  82321. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82322. /**
  82323. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82324. * @param value1 defines the first control point
  82325. * @param tangent1 defines the first tangent vector
  82326. * @param value2 defines the second control point
  82327. * @param tangent2 defines the second tangent vector
  82328. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82329. * @returns the new Vector3
  82330. */
  82331. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82332. /**
  82333. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82334. * @param start defines the start value
  82335. * @param end defines the end value
  82336. * @param amount max defines amount between both (between 0 and 1)
  82337. * @returns the new Vector3
  82338. */
  82339. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82340. /**
  82341. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82342. * @param start defines the start value
  82343. * @param end defines the end value
  82344. * @param amount max defines amount between both (between 0 and 1)
  82345. * @param result defines the Vector3 where to store the result
  82346. */
  82347. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82348. /**
  82349. * Returns the dot product (float) between the vectors "left" and "right"
  82350. * @param left defines the left operand
  82351. * @param right defines the right operand
  82352. * @returns the dot product
  82353. */
  82354. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82355. /**
  82356. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82357. * The cross product is then orthogonal to both "left" and "right"
  82358. * @param left defines the left operand
  82359. * @param right defines the right operand
  82360. * @returns the cross product
  82361. */
  82362. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82363. /**
  82364. * Sets the given vector "result" with the cross product of "left" and "right"
  82365. * The cross product is then orthogonal to both "left" and "right"
  82366. * @param left defines the left operand
  82367. * @param right defines the right operand
  82368. * @param result defines the Vector3 where to store the result
  82369. */
  82370. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82371. /**
  82372. * Returns a new Vector3 as the normalization of the given vector
  82373. * @param vector defines the Vector3 to normalize
  82374. * @returns the new Vector3
  82375. */
  82376. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82377. /**
  82378. * Sets the given vector "result" with the normalization of the given first vector
  82379. * @param vector defines the Vector3 to normalize
  82380. * @param result defines the Vector3 where to store the result
  82381. */
  82382. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82383. /**
  82384. * Project a Vector3 onto screen space
  82385. * @param vector defines the Vector3 to project
  82386. * @param world defines the world matrix to use
  82387. * @param transform defines the transform (view x projection) matrix to use
  82388. * @param viewport defines the screen viewport to use
  82389. * @returns the new Vector3
  82390. */
  82391. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82392. /** @hidden */
  82393. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82394. /**
  82395. * Unproject from screen space to object space
  82396. * @param source defines the screen space Vector3 to use
  82397. * @param viewportWidth defines the current width of the viewport
  82398. * @param viewportHeight defines the current height of the viewport
  82399. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82400. * @param transform defines the transform (view x projection) matrix to use
  82401. * @returns the new Vector3
  82402. */
  82403. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82404. /**
  82405. * Unproject from screen space to object space
  82406. * @param source defines the screen space Vector3 to use
  82407. * @param viewportWidth defines the current width of the viewport
  82408. * @param viewportHeight defines the current height of the viewport
  82409. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82410. * @param view defines the view matrix to use
  82411. * @param projection defines the projection matrix to use
  82412. * @returns the new Vector3
  82413. */
  82414. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82415. /**
  82416. * Unproject from screen space to object space
  82417. * @param source defines the screen space Vector3 to use
  82418. * @param viewportWidth defines the current width of the viewport
  82419. * @param viewportHeight defines the current height of the viewport
  82420. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82421. * @param view defines the view matrix to use
  82422. * @param projection defines the projection matrix to use
  82423. * @param result defines the Vector3 where to store the result
  82424. */
  82425. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82426. /**
  82427. * Unproject from screen space to object space
  82428. * @param sourceX defines the screen space x coordinate to use
  82429. * @param sourceY defines the screen space y coordinate to use
  82430. * @param sourceZ defines the screen space z coordinate to use
  82431. * @param viewportWidth defines the current width of the viewport
  82432. * @param viewportHeight defines the current height of the viewport
  82433. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82434. * @param view defines the view matrix to use
  82435. * @param projection defines the projection matrix to use
  82436. * @param result defines the Vector3 where to store the result
  82437. */
  82438. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82439. /**
  82440. * Gets the minimal coordinate values between two Vector3
  82441. * @param left defines the first operand
  82442. * @param right defines the second operand
  82443. * @returns the new Vector3
  82444. */
  82445. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82446. /**
  82447. * Gets the maximal coordinate values between two Vector3
  82448. * @param left defines the first operand
  82449. * @param right defines the second operand
  82450. * @returns the new Vector3
  82451. */
  82452. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82453. /**
  82454. * Returns the distance between the vectors "value1" and "value2"
  82455. * @param value1 defines the first operand
  82456. * @param value2 defines the second operand
  82457. * @returns the distance
  82458. */
  82459. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82460. /**
  82461. * Returns the squared distance between the vectors "value1" and "value2"
  82462. * @param value1 defines the first operand
  82463. * @param value2 defines the second operand
  82464. * @returns the squared distance
  82465. */
  82466. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82467. /**
  82468. * Returns a new Vector3 located at the center between "value1" and "value2"
  82469. * @param value1 defines the first operand
  82470. * @param value2 defines the second operand
  82471. * @returns the new Vector3
  82472. */
  82473. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82474. /**
  82475. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82476. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82477. * to something in order to rotate it from its local system to the given target system
  82478. * Note: axis1, axis2 and axis3 are normalized during this operation
  82479. * @param axis1 defines the first axis
  82480. * @param axis2 defines the second axis
  82481. * @param axis3 defines the third axis
  82482. * @returns a new Vector3
  82483. */
  82484. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82485. /**
  82486. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82487. * @param axis1 defines the first axis
  82488. * @param axis2 defines the second axis
  82489. * @param axis3 defines the third axis
  82490. * @param ref defines the Vector3 where to store the result
  82491. */
  82492. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82493. }
  82494. /**
  82495. * Vector4 class created for EulerAngle class conversion to Quaternion
  82496. */
  82497. export class Vector4 {
  82498. /** x value of the vector */
  82499. x: number;
  82500. /** y value of the vector */
  82501. y: number;
  82502. /** z value of the vector */
  82503. z: number;
  82504. /** w value of the vector */
  82505. w: number;
  82506. /**
  82507. * Creates a Vector4 object from the given floats.
  82508. * @param x x value of the vector
  82509. * @param y y value of the vector
  82510. * @param z z value of the vector
  82511. * @param w w value of the vector
  82512. */
  82513. constructor(
  82514. /** x value of the vector */
  82515. x: number,
  82516. /** y value of the vector */
  82517. y: number,
  82518. /** z value of the vector */
  82519. z: number,
  82520. /** w value of the vector */
  82521. w: number);
  82522. /**
  82523. * Returns the string with the Vector4 coordinates.
  82524. * @returns a string containing all the vector values
  82525. */
  82526. toString(): string;
  82527. /**
  82528. * Returns the string "Vector4".
  82529. * @returns "Vector4"
  82530. */
  82531. getClassName(): string;
  82532. /**
  82533. * Returns the Vector4 hash code.
  82534. * @returns a unique hash code
  82535. */
  82536. getHashCode(): number;
  82537. /**
  82538. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82539. * @returns the resulting array
  82540. */
  82541. asArray(): number[];
  82542. /**
  82543. * Populates the given array from the given index with the Vector4 coordinates.
  82544. * @param array array to populate
  82545. * @param index index of the array to start at (default: 0)
  82546. * @returns the Vector4.
  82547. */
  82548. toArray(array: FloatArray, index?: number): Vector4;
  82549. /**
  82550. * Update the current vector from an array
  82551. * @param array defines the destination array
  82552. * @param index defines the offset in the destination array
  82553. * @returns the current Vector3
  82554. */
  82555. fromArray(array: FloatArray, index?: number): Vector4;
  82556. /**
  82557. * Adds the given vector to the current Vector4.
  82558. * @param otherVector the vector to add
  82559. * @returns the updated Vector4.
  82560. */
  82561. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82562. /**
  82563. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82564. * @param otherVector the vector to add
  82565. * @returns the resulting vector
  82566. */
  82567. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82568. /**
  82569. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82570. * @param otherVector the vector to add
  82571. * @param result the vector to store the result
  82572. * @returns the current Vector4.
  82573. */
  82574. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82575. /**
  82576. * Subtract in place the given vector from the current Vector4.
  82577. * @param otherVector the vector to subtract
  82578. * @returns the updated Vector4.
  82579. */
  82580. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82581. /**
  82582. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82583. * @param otherVector the vector to add
  82584. * @returns the new vector with the result
  82585. */
  82586. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82587. /**
  82588. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82589. * @param otherVector the vector to subtract
  82590. * @param result the vector to store the result
  82591. * @returns the current Vector4.
  82592. */
  82593. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82594. /**
  82595. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82596. */
  82597. /**
  82598. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82599. * @param x value to subtract
  82600. * @param y value to subtract
  82601. * @param z value to subtract
  82602. * @param w value to subtract
  82603. * @returns new vector containing the result
  82604. */
  82605. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82606. /**
  82607. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82608. * @param x value to subtract
  82609. * @param y value to subtract
  82610. * @param z value to subtract
  82611. * @param w value to subtract
  82612. * @param result the vector to store the result in
  82613. * @returns the current Vector4.
  82614. */
  82615. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82616. /**
  82617. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82618. * @returns a new vector with the negated values
  82619. */
  82620. negate(): Vector4;
  82621. /**
  82622. * Negate this vector in place
  82623. * @returns this
  82624. */
  82625. negateInPlace(): Vector4;
  82626. /**
  82627. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82628. * @param result defines the Vector3 object where to store the result
  82629. * @returns the current Vector4
  82630. */
  82631. negateToRef(result: Vector4): Vector4;
  82632. /**
  82633. * Multiplies the current Vector4 coordinates by scale (float).
  82634. * @param scale the number to scale with
  82635. * @returns the updated Vector4.
  82636. */
  82637. scaleInPlace(scale: number): Vector4;
  82638. /**
  82639. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82640. * @param scale the number to scale with
  82641. * @returns a new vector with the result
  82642. */
  82643. scale(scale: number): Vector4;
  82644. /**
  82645. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82646. * @param scale the number to scale with
  82647. * @param result a vector to store the result in
  82648. * @returns the current Vector4.
  82649. */
  82650. scaleToRef(scale: number, result: Vector4): Vector4;
  82651. /**
  82652. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82653. * @param scale defines the scale factor
  82654. * @param result defines the Vector4 object where to store the result
  82655. * @returns the unmodified current Vector4
  82656. */
  82657. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82658. /**
  82659. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82660. * @param otherVector the vector to compare against
  82661. * @returns true if they are equal
  82662. */
  82663. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82664. /**
  82665. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82666. * @param otherVector vector to compare against
  82667. * @param epsilon (Default: very small number)
  82668. * @returns true if they are equal
  82669. */
  82670. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82671. /**
  82672. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82673. * @param x x value to compare against
  82674. * @param y y value to compare against
  82675. * @param z z value to compare against
  82676. * @param w w value to compare against
  82677. * @returns true if equal
  82678. */
  82679. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82680. /**
  82681. * Multiplies in place the current Vector4 by the given one.
  82682. * @param otherVector vector to multiple with
  82683. * @returns the updated Vector4.
  82684. */
  82685. multiplyInPlace(otherVector: Vector4): Vector4;
  82686. /**
  82687. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82688. * @param otherVector vector to multiple with
  82689. * @returns resulting new vector
  82690. */
  82691. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82692. /**
  82693. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82694. * @param otherVector vector to multiple with
  82695. * @param result vector to store the result
  82696. * @returns the current Vector4.
  82697. */
  82698. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82699. /**
  82700. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82701. * @param x x value multiply with
  82702. * @param y y value multiply with
  82703. * @param z z value multiply with
  82704. * @param w w value multiply with
  82705. * @returns resulting new vector
  82706. */
  82707. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82708. /**
  82709. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82710. * @param otherVector vector to devide with
  82711. * @returns resulting new vector
  82712. */
  82713. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82714. /**
  82715. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82716. * @param otherVector vector to devide with
  82717. * @param result vector to store the result
  82718. * @returns the current Vector4.
  82719. */
  82720. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82721. /**
  82722. * Divides the current Vector3 coordinates by the given ones.
  82723. * @param otherVector vector to devide with
  82724. * @returns the updated Vector3.
  82725. */
  82726. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82727. /**
  82728. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82729. * @param other defines the second operand
  82730. * @returns the current updated Vector4
  82731. */
  82732. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82733. /**
  82734. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82735. * @param other defines the second operand
  82736. * @returns the current updated Vector4
  82737. */
  82738. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82739. /**
  82740. * Gets a new Vector4 from current Vector4 floored values
  82741. * @returns a new Vector4
  82742. */
  82743. floor(): Vector4;
  82744. /**
  82745. * Gets a new Vector4 from current Vector3 floored values
  82746. * @returns a new Vector4
  82747. */
  82748. fract(): Vector4;
  82749. /**
  82750. * Returns the Vector4 length (float).
  82751. * @returns the length
  82752. */
  82753. length(): number;
  82754. /**
  82755. * Returns the Vector4 squared length (float).
  82756. * @returns the length squared
  82757. */
  82758. lengthSquared(): number;
  82759. /**
  82760. * Normalizes in place the Vector4.
  82761. * @returns the updated Vector4.
  82762. */
  82763. normalize(): Vector4;
  82764. /**
  82765. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82766. * @returns this converted to a new vector3
  82767. */
  82768. toVector3(): Vector3;
  82769. /**
  82770. * Returns a new Vector4 copied from the current one.
  82771. * @returns the new cloned vector
  82772. */
  82773. clone(): Vector4;
  82774. /**
  82775. * Updates the current Vector4 with the given one coordinates.
  82776. * @param source the source vector to copy from
  82777. * @returns the updated Vector4.
  82778. */
  82779. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82780. /**
  82781. * Updates the current Vector4 coordinates with the given floats.
  82782. * @param x float to copy from
  82783. * @param y float to copy from
  82784. * @param z float to copy from
  82785. * @param w float to copy from
  82786. * @returns the updated Vector4.
  82787. */
  82788. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82789. /**
  82790. * Updates the current Vector4 coordinates with the given floats.
  82791. * @param x float to set from
  82792. * @param y float to set from
  82793. * @param z float to set from
  82794. * @param w float to set from
  82795. * @returns the updated Vector4.
  82796. */
  82797. set(x: number, y: number, z: number, w: number): Vector4;
  82798. /**
  82799. * Copies the given float to the current Vector3 coordinates
  82800. * @param v defines the x, y, z and w coordinates of the operand
  82801. * @returns the current updated Vector3
  82802. */
  82803. setAll(v: number): Vector4;
  82804. /**
  82805. * Returns a new Vector4 set from the starting index of the given array.
  82806. * @param array the array to pull values from
  82807. * @param offset the offset into the array to start at
  82808. * @returns the new vector
  82809. */
  82810. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82811. /**
  82812. * Updates the given vector "result" from the starting index of the given array.
  82813. * @param array the array to pull values from
  82814. * @param offset the offset into the array to start at
  82815. * @param result the vector to store the result in
  82816. */
  82817. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82818. /**
  82819. * Updates the given vector "result" from the starting index of the given Float32Array.
  82820. * @param array the array to pull values from
  82821. * @param offset the offset into the array to start at
  82822. * @param result the vector to store the result in
  82823. */
  82824. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82825. /**
  82826. * Updates the given vector "result" coordinates from the given floats.
  82827. * @param x float to set from
  82828. * @param y float to set from
  82829. * @param z float to set from
  82830. * @param w float to set from
  82831. * @param result the vector to the floats in
  82832. */
  82833. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82834. /**
  82835. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82836. * @returns the new vector
  82837. */
  82838. static Zero(): Vector4;
  82839. /**
  82840. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82841. * @returns the new vector
  82842. */
  82843. static One(): Vector4;
  82844. /**
  82845. * Returns a new normalized Vector4 from the given one.
  82846. * @param vector the vector to normalize
  82847. * @returns the vector
  82848. */
  82849. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82850. /**
  82851. * Updates the given vector "result" from the normalization of the given one.
  82852. * @param vector the vector to normalize
  82853. * @param result the vector to store the result in
  82854. */
  82855. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82856. /**
  82857. * Returns a vector with the minimum values from the left and right vectors
  82858. * @param left left vector to minimize
  82859. * @param right right vector to minimize
  82860. * @returns a new vector with the minimum of the left and right vector values
  82861. */
  82862. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82863. /**
  82864. * Returns a vector with the maximum values from the left and right vectors
  82865. * @param left left vector to maximize
  82866. * @param right right vector to maximize
  82867. * @returns a new vector with the maximum of the left and right vector values
  82868. */
  82869. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82870. /**
  82871. * Returns the distance (float) between the vectors "value1" and "value2".
  82872. * @param value1 value to calulate the distance between
  82873. * @param value2 value to calulate the distance between
  82874. * @return the distance between the two vectors
  82875. */
  82876. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82877. /**
  82878. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82879. * @param value1 value to calulate the distance between
  82880. * @param value2 value to calulate the distance between
  82881. * @return the distance between the two vectors squared
  82882. */
  82883. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82884. /**
  82885. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82886. * @param value1 value to calulate the center between
  82887. * @param value2 value to calulate the center between
  82888. * @return the center between the two vectors
  82889. */
  82890. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82891. /**
  82892. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82893. * This methods computes transformed normalized direction vectors only.
  82894. * @param vector the vector to transform
  82895. * @param transformation the transformation matrix to apply
  82896. * @returns the new vector
  82897. */
  82898. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82899. /**
  82900. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82901. * This methods computes transformed normalized direction vectors only.
  82902. * @param vector the vector to transform
  82903. * @param transformation the transformation matrix to apply
  82904. * @param result the vector to store the result in
  82905. */
  82906. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82907. /**
  82908. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82909. * This methods computes transformed normalized direction vectors only.
  82910. * @param x value to transform
  82911. * @param y value to transform
  82912. * @param z value to transform
  82913. * @param w value to transform
  82914. * @param transformation the transformation matrix to apply
  82915. * @param result the vector to store the results in
  82916. */
  82917. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82918. /**
  82919. * Creates a new Vector4 from a Vector3
  82920. * @param source defines the source data
  82921. * @param w defines the 4th component (default is 0)
  82922. * @returns a new Vector4
  82923. */
  82924. static FromVector3(source: Vector3, w?: number): Vector4;
  82925. }
  82926. /**
  82927. * Class used to store quaternion data
  82928. * @see https://en.wikipedia.org/wiki/Quaternion
  82929. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82930. */
  82931. export class Quaternion {
  82932. /** @hidden */
  82933. _x: number;
  82934. /** @hidden */
  82935. _y: number;
  82936. /** @hidden */
  82937. _z: number;
  82938. /** @hidden */
  82939. _w: number;
  82940. /** @hidden */
  82941. _isDirty: boolean;
  82942. /** Gets or sets the x coordinate */
  82943. get x(): number;
  82944. set x(value: number);
  82945. /** Gets or sets the y coordinate */
  82946. get y(): number;
  82947. set y(value: number);
  82948. /** Gets or sets the z coordinate */
  82949. get z(): number;
  82950. set z(value: number);
  82951. /** Gets or sets the w coordinate */
  82952. get w(): number;
  82953. set w(value: number);
  82954. /**
  82955. * Creates a new Quaternion from the given floats
  82956. * @param x defines the first component (0 by default)
  82957. * @param y defines the second component (0 by default)
  82958. * @param z defines the third component (0 by default)
  82959. * @param w defines the fourth component (1.0 by default)
  82960. */
  82961. constructor(x?: number, y?: number, z?: number, w?: number);
  82962. /**
  82963. * Gets a string representation for the current quaternion
  82964. * @returns a string with the Quaternion coordinates
  82965. */
  82966. toString(): string;
  82967. /**
  82968. * Gets the class name of the quaternion
  82969. * @returns the string "Quaternion"
  82970. */
  82971. getClassName(): string;
  82972. /**
  82973. * Gets a hash code for this quaternion
  82974. * @returns the quaternion hash code
  82975. */
  82976. getHashCode(): number;
  82977. /**
  82978. * Copy the quaternion to an array
  82979. * @returns a new array populated with 4 elements from the quaternion coordinates
  82980. */
  82981. asArray(): number[];
  82982. /**
  82983. * Check if two quaternions are equals
  82984. * @param otherQuaternion defines the second operand
  82985. * @return true if the current quaternion and the given one coordinates are strictly equals
  82986. */
  82987. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82988. /**
  82989. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82990. * @param otherQuaternion defines the other quaternion
  82991. * @param epsilon defines the minimal distance to consider equality
  82992. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82993. */
  82994. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82995. /**
  82996. * Clone the current quaternion
  82997. * @returns a new quaternion copied from the current one
  82998. */
  82999. clone(): Quaternion;
  83000. /**
  83001. * Copy a quaternion to the current one
  83002. * @param other defines the other quaternion
  83003. * @returns the updated current quaternion
  83004. */
  83005. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83006. /**
  83007. * Updates the current quaternion with the given float coordinates
  83008. * @param x defines the x coordinate
  83009. * @param y defines the y coordinate
  83010. * @param z defines the z coordinate
  83011. * @param w defines the w coordinate
  83012. * @returns the updated current quaternion
  83013. */
  83014. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83015. /**
  83016. * Updates the current quaternion from the given float coordinates
  83017. * @param x defines the x coordinate
  83018. * @param y defines the y coordinate
  83019. * @param z defines the z coordinate
  83020. * @param w defines the w coordinate
  83021. * @returns the updated current quaternion
  83022. */
  83023. set(x: number, y: number, z: number, w: number): Quaternion;
  83024. /**
  83025. * Adds two quaternions
  83026. * @param other defines the second operand
  83027. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83028. */
  83029. add(other: DeepImmutable<Quaternion>): Quaternion;
  83030. /**
  83031. * Add a quaternion to the current one
  83032. * @param other defines the quaternion to add
  83033. * @returns the current quaternion
  83034. */
  83035. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83036. /**
  83037. * Subtract two quaternions
  83038. * @param other defines the second operand
  83039. * @returns a new quaternion as the subtraction result of the given one from the current one
  83040. */
  83041. subtract(other: Quaternion): Quaternion;
  83042. /**
  83043. * Multiplies the current quaternion by a scale factor
  83044. * @param value defines the scale factor
  83045. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83046. */
  83047. scale(value: number): Quaternion;
  83048. /**
  83049. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83050. * @param scale defines the scale factor
  83051. * @param result defines the Quaternion object where to store the result
  83052. * @returns the unmodified current quaternion
  83053. */
  83054. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83055. /**
  83056. * Multiplies in place the current quaternion by a scale factor
  83057. * @param value defines the scale factor
  83058. * @returns the current modified quaternion
  83059. */
  83060. scaleInPlace(value: number): Quaternion;
  83061. /**
  83062. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83063. * @param scale defines the scale factor
  83064. * @param result defines the Quaternion object where to store the result
  83065. * @returns the unmodified current quaternion
  83066. */
  83067. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83068. /**
  83069. * Multiplies two quaternions
  83070. * @param q1 defines the second operand
  83071. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83072. */
  83073. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83074. /**
  83075. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83076. * @param q1 defines the second operand
  83077. * @param result defines the target quaternion
  83078. * @returns the current quaternion
  83079. */
  83080. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83081. /**
  83082. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83083. * @param q1 defines the second operand
  83084. * @returns the currentupdated quaternion
  83085. */
  83086. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83087. /**
  83088. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83089. * @param ref defines the target quaternion
  83090. * @returns the current quaternion
  83091. */
  83092. conjugateToRef(ref: Quaternion): Quaternion;
  83093. /**
  83094. * Conjugates in place (1-q) the current quaternion
  83095. * @returns the current updated quaternion
  83096. */
  83097. conjugateInPlace(): Quaternion;
  83098. /**
  83099. * Conjugates in place (1-q) the current quaternion
  83100. * @returns a new quaternion
  83101. */
  83102. conjugate(): Quaternion;
  83103. /**
  83104. * Gets length of current quaternion
  83105. * @returns the quaternion length (float)
  83106. */
  83107. length(): number;
  83108. /**
  83109. * Normalize in place the current quaternion
  83110. * @returns the current updated quaternion
  83111. */
  83112. normalize(): Quaternion;
  83113. /**
  83114. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83115. * @param order is a reserved parameter and is ignore for now
  83116. * @returns a new Vector3 containing the Euler angles
  83117. */
  83118. toEulerAngles(order?: string): Vector3;
  83119. /**
  83120. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83121. * @param result defines the vector which will be filled with the Euler angles
  83122. * @param order is a reserved parameter and is ignore for now
  83123. * @returns the current unchanged quaternion
  83124. */
  83125. toEulerAnglesToRef(result: Vector3): Quaternion;
  83126. /**
  83127. * Updates the given rotation matrix with the current quaternion values
  83128. * @param result defines the target matrix
  83129. * @returns the current unchanged quaternion
  83130. */
  83131. toRotationMatrix(result: Matrix): Quaternion;
  83132. /**
  83133. * Updates the current quaternion from the given rotation matrix values
  83134. * @param matrix defines the source matrix
  83135. * @returns the current updated quaternion
  83136. */
  83137. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83138. /**
  83139. * Creates a new quaternion from a rotation matrix
  83140. * @param matrix defines the source matrix
  83141. * @returns a new quaternion created from the given rotation matrix values
  83142. */
  83143. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83144. /**
  83145. * Updates the given quaternion with the given rotation matrix values
  83146. * @param matrix defines the source matrix
  83147. * @param result defines the target quaternion
  83148. */
  83149. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83150. /**
  83151. * Returns the dot product (float) between the quaternions "left" and "right"
  83152. * @param left defines the left operand
  83153. * @param right defines the right operand
  83154. * @returns the dot product
  83155. */
  83156. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83157. /**
  83158. * Checks if the two quaternions are close to each other
  83159. * @param quat0 defines the first quaternion to check
  83160. * @param quat1 defines the second quaternion to check
  83161. * @returns true if the two quaternions are close to each other
  83162. */
  83163. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83164. /**
  83165. * Creates an empty quaternion
  83166. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83167. */
  83168. static Zero(): Quaternion;
  83169. /**
  83170. * Inverse a given quaternion
  83171. * @param q defines the source quaternion
  83172. * @returns a new quaternion as the inverted current quaternion
  83173. */
  83174. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83175. /**
  83176. * Inverse a given quaternion
  83177. * @param q defines the source quaternion
  83178. * @param result the quaternion the result will be stored in
  83179. * @returns the result quaternion
  83180. */
  83181. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83182. /**
  83183. * Creates an identity quaternion
  83184. * @returns the identity quaternion
  83185. */
  83186. static Identity(): Quaternion;
  83187. /**
  83188. * Gets a boolean indicating if the given quaternion is identity
  83189. * @param quaternion defines the quaternion to check
  83190. * @returns true if the quaternion is identity
  83191. */
  83192. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83193. /**
  83194. * Creates a quaternion from a rotation around an axis
  83195. * @param axis defines the axis to use
  83196. * @param angle defines the angle to use
  83197. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83198. */
  83199. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83200. /**
  83201. * Creates a rotation around an axis and stores it into the given quaternion
  83202. * @param axis defines the axis to use
  83203. * @param angle defines the angle to use
  83204. * @param result defines the target quaternion
  83205. * @returns the target quaternion
  83206. */
  83207. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83208. /**
  83209. * Creates a new quaternion from data stored into an array
  83210. * @param array defines the data source
  83211. * @param offset defines the offset in the source array where the data starts
  83212. * @returns a new quaternion
  83213. */
  83214. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83215. /**
  83216. * Updates the given quaternion "result" from the starting index of the given array.
  83217. * @param array the array to pull values from
  83218. * @param offset the offset into the array to start at
  83219. * @param result the quaternion to store the result in
  83220. */
  83221. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83222. /**
  83223. * Create a quaternion from Euler rotation angles
  83224. * @param x Pitch
  83225. * @param y Yaw
  83226. * @param z Roll
  83227. * @returns the new Quaternion
  83228. */
  83229. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83230. /**
  83231. * Updates a quaternion from Euler rotation angles
  83232. * @param x Pitch
  83233. * @param y Yaw
  83234. * @param z Roll
  83235. * @param result the quaternion to store the result
  83236. * @returns the updated quaternion
  83237. */
  83238. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83239. /**
  83240. * Create a quaternion from Euler rotation vector
  83241. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83242. * @returns the new Quaternion
  83243. */
  83244. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83245. /**
  83246. * Updates a quaternion from Euler rotation vector
  83247. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83248. * @param result the quaternion to store the result
  83249. * @returns the updated quaternion
  83250. */
  83251. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83252. /**
  83253. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83254. * @param yaw defines the rotation around Y axis
  83255. * @param pitch defines the rotation around X axis
  83256. * @param roll defines the rotation around Z axis
  83257. * @returns the new quaternion
  83258. */
  83259. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83260. /**
  83261. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83262. * @param yaw defines the rotation around Y axis
  83263. * @param pitch defines the rotation around X axis
  83264. * @param roll defines the rotation around Z axis
  83265. * @param result defines the target quaternion
  83266. */
  83267. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83268. /**
  83269. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83270. * @param alpha defines the rotation around first axis
  83271. * @param beta defines the rotation around second axis
  83272. * @param gamma defines the rotation around third axis
  83273. * @returns the new quaternion
  83274. */
  83275. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83276. /**
  83277. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83278. * @param alpha defines the rotation around first axis
  83279. * @param beta defines the rotation around second axis
  83280. * @param gamma defines the rotation around third axis
  83281. * @param result defines the target quaternion
  83282. */
  83283. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83284. /**
  83285. * 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)
  83286. * @param axis1 defines the first axis
  83287. * @param axis2 defines the second axis
  83288. * @param axis3 defines the third axis
  83289. * @returns the new quaternion
  83290. */
  83291. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83292. /**
  83293. * 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
  83294. * @param axis1 defines the first axis
  83295. * @param axis2 defines the second axis
  83296. * @param axis3 defines the third axis
  83297. * @param ref defines the target quaternion
  83298. */
  83299. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83300. /**
  83301. * Interpolates between two quaternions
  83302. * @param left defines first quaternion
  83303. * @param right defines second quaternion
  83304. * @param amount defines the gradient to use
  83305. * @returns the new interpolated quaternion
  83306. */
  83307. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83308. /**
  83309. * Interpolates between two quaternions and stores it into a target quaternion
  83310. * @param left defines first quaternion
  83311. * @param right defines second quaternion
  83312. * @param amount defines the gradient to use
  83313. * @param result defines the target quaternion
  83314. */
  83315. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83316. /**
  83317. * Interpolate between two quaternions using Hermite interpolation
  83318. * @param value1 defines first quaternion
  83319. * @param tangent1 defines the incoming tangent
  83320. * @param value2 defines second quaternion
  83321. * @param tangent2 defines the outgoing tangent
  83322. * @param amount defines the target quaternion
  83323. * @returns the new interpolated quaternion
  83324. */
  83325. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83326. }
  83327. /**
  83328. * Class used to store matrix data (4x4)
  83329. */
  83330. export class Matrix {
  83331. /**
  83332. * Gets the precision of matrix computations
  83333. */
  83334. static get Use64Bits(): boolean;
  83335. private static _updateFlagSeed;
  83336. private static _identityReadOnly;
  83337. private _isIdentity;
  83338. private _isIdentityDirty;
  83339. private _isIdentity3x2;
  83340. private _isIdentity3x2Dirty;
  83341. /**
  83342. * Gets the update flag of the matrix which is an unique number for the matrix.
  83343. * It will be incremented every time the matrix data change.
  83344. * You can use it to speed the comparison between two versions of the same matrix.
  83345. */
  83346. updateFlag: number;
  83347. private readonly _m;
  83348. /**
  83349. * Gets the internal data of the matrix
  83350. */
  83351. get m(): DeepImmutable<Float32Array | Array<number>>;
  83352. /** @hidden */
  83353. _markAsUpdated(): void;
  83354. /** @hidden */
  83355. private _updateIdentityStatus;
  83356. /**
  83357. * Creates an empty matrix (filled with zeros)
  83358. */
  83359. constructor();
  83360. /**
  83361. * Check if the current matrix is identity
  83362. * @returns true is the matrix is the identity matrix
  83363. */
  83364. isIdentity(): boolean;
  83365. /**
  83366. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83367. * @returns true is the matrix is the identity matrix
  83368. */
  83369. isIdentityAs3x2(): boolean;
  83370. /**
  83371. * Gets the determinant of the matrix
  83372. * @returns the matrix determinant
  83373. */
  83374. determinant(): number;
  83375. /**
  83376. * Returns the matrix as a Float32Array or Array<number>
  83377. * @returns the matrix underlying array
  83378. */
  83379. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83380. /**
  83381. * Returns the matrix as a Float32Array or Array<number>
  83382. * @returns the matrix underlying array.
  83383. */
  83384. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83385. /**
  83386. * Inverts the current matrix in place
  83387. * @returns the current inverted matrix
  83388. */
  83389. invert(): Matrix;
  83390. /**
  83391. * Sets all the matrix elements to zero
  83392. * @returns the current matrix
  83393. */
  83394. reset(): Matrix;
  83395. /**
  83396. * Adds the current matrix with a second one
  83397. * @param other defines the matrix to add
  83398. * @returns a new matrix as the addition of the current matrix and the given one
  83399. */
  83400. add(other: DeepImmutable<Matrix>): Matrix;
  83401. /**
  83402. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83403. * @param other defines the matrix to add
  83404. * @param result defines the target matrix
  83405. * @returns the current matrix
  83406. */
  83407. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83408. /**
  83409. * Adds in place the given matrix to the current matrix
  83410. * @param other defines the second operand
  83411. * @returns the current updated matrix
  83412. */
  83413. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83414. /**
  83415. * Sets the given matrix to the current inverted Matrix
  83416. * @param other defines the target matrix
  83417. * @returns the unmodified current matrix
  83418. */
  83419. invertToRef(other: Matrix): Matrix;
  83420. /**
  83421. * add a value at the specified position in the current Matrix
  83422. * @param index the index of the value within the matrix. between 0 and 15.
  83423. * @param value the value to be added
  83424. * @returns the current updated matrix
  83425. */
  83426. addAtIndex(index: number, value: number): Matrix;
  83427. /**
  83428. * mutiply the specified position in the current Matrix by a value
  83429. * @param index the index of the value within the matrix. between 0 and 15.
  83430. * @param value the value to be added
  83431. * @returns the current updated matrix
  83432. */
  83433. multiplyAtIndex(index: number, value: number): Matrix;
  83434. /**
  83435. * Inserts the translation vector (using 3 floats) in the current matrix
  83436. * @param x defines the 1st component of the translation
  83437. * @param y defines the 2nd component of the translation
  83438. * @param z defines the 3rd component of the translation
  83439. * @returns the current updated matrix
  83440. */
  83441. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83442. /**
  83443. * Adds the translation vector (using 3 floats) in the current matrix
  83444. * @param x defines the 1st component of the translation
  83445. * @param y defines the 2nd component of the translation
  83446. * @param z defines the 3rd component of the translation
  83447. * @returns the current updated matrix
  83448. */
  83449. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83450. /**
  83451. * Inserts the translation vector in the current matrix
  83452. * @param vector3 defines the translation to insert
  83453. * @returns the current updated matrix
  83454. */
  83455. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83456. /**
  83457. * Gets the translation value of the current matrix
  83458. * @returns a new Vector3 as the extracted translation from the matrix
  83459. */
  83460. getTranslation(): Vector3;
  83461. /**
  83462. * Fill a Vector3 with the extracted translation from the matrix
  83463. * @param result defines the Vector3 where to store the translation
  83464. * @returns the current matrix
  83465. */
  83466. getTranslationToRef(result: Vector3): Matrix;
  83467. /**
  83468. * Remove rotation and scaling part from the matrix
  83469. * @returns the updated matrix
  83470. */
  83471. removeRotationAndScaling(): Matrix;
  83472. /**
  83473. * Multiply two matrices
  83474. * @param other defines the second operand
  83475. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83476. */
  83477. multiply(other: DeepImmutable<Matrix>): Matrix;
  83478. /**
  83479. * Copy the current matrix from the given one
  83480. * @param other defines the source matrix
  83481. * @returns the current updated matrix
  83482. */
  83483. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83484. /**
  83485. * Populates the given array from the starting index with the current matrix values
  83486. * @param array defines the target array
  83487. * @param offset defines the offset in the target array where to start storing values
  83488. * @returns the current matrix
  83489. */
  83490. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83491. /**
  83492. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83493. * @param other defines the second operand
  83494. * @param result defines the matrix where to store the multiplication
  83495. * @returns the current matrix
  83496. */
  83497. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83498. /**
  83499. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83500. * @param other defines the second operand
  83501. * @param result defines the array where to store the multiplication
  83502. * @param offset defines the offset in the target array where to start storing values
  83503. * @returns the current matrix
  83504. */
  83505. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83506. /**
  83507. * Check equality between this matrix and a second one
  83508. * @param value defines the second matrix to compare
  83509. * @returns true is the current matrix and the given one values are strictly equal
  83510. */
  83511. equals(value: DeepImmutable<Matrix>): boolean;
  83512. /**
  83513. * Clone the current matrix
  83514. * @returns a new matrix from the current matrix
  83515. */
  83516. clone(): Matrix;
  83517. /**
  83518. * Returns the name of the current matrix class
  83519. * @returns the string "Matrix"
  83520. */
  83521. getClassName(): string;
  83522. /**
  83523. * Gets the hash code of the current matrix
  83524. * @returns the hash code
  83525. */
  83526. getHashCode(): number;
  83527. /**
  83528. * Decomposes the current Matrix into a translation, rotation and scaling components
  83529. * @param scale defines the scale vector3 given as a reference to update
  83530. * @param rotation defines the rotation quaternion given as a reference to update
  83531. * @param translation defines the translation vector3 given as a reference to update
  83532. * @returns true if operation was successful
  83533. */
  83534. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83535. /**
  83536. * Gets specific row of the matrix
  83537. * @param index defines the number of the row to get
  83538. * @returns the index-th row of the current matrix as a new Vector4
  83539. */
  83540. getRow(index: number): Nullable<Vector4>;
  83541. /**
  83542. * Sets the index-th row of the current matrix to the vector4 values
  83543. * @param index defines the number of the row to set
  83544. * @param row defines the target vector4
  83545. * @returns the updated current matrix
  83546. */
  83547. setRow(index: number, row: Vector4): Matrix;
  83548. /**
  83549. * Compute the transpose of the matrix
  83550. * @returns the new transposed matrix
  83551. */
  83552. transpose(): Matrix;
  83553. /**
  83554. * Compute the transpose of the matrix and store it in a given matrix
  83555. * @param result defines the target matrix
  83556. * @returns the current matrix
  83557. */
  83558. transposeToRef(result: Matrix): Matrix;
  83559. /**
  83560. * Sets the index-th row of the current matrix with the given 4 x float values
  83561. * @param index defines the row index
  83562. * @param x defines the x component to set
  83563. * @param y defines the y component to set
  83564. * @param z defines the z component to set
  83565. * @param w defines the w component to set
  83566. * @returns the updated current matrix
  83567. */
  83568. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83569. /**
  83570. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83571. * @param scale defines the scale factor
  83572. * @returns a new matrix
  83573. */
  83574. scale(scale: number): Matrix;
  83575. /**
  83576. * Scale the current matrix values by a factor to a given result matrix
  83577. * @param scale defines the scale factor
  83578. * @param result defines the matrix to store the result
  83579. * @returns the current matrix
  83580. */
  83581. scaleToRef(scale: number, result: Matrix): Matrix;
  83582. /**
  83583. * Scale the current matrix values by a factor and add the result to a given matrix
  83584. * @param scale defines the scale factor
  83585. * @param result defines the Matrix to store the result
  83586. * @returns the current matrix
  83587. */
  83588. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83589. /**
  83590. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83591. * @param ref matrix to store the result
  83592. */
  83593. toNormalMatrix(ref: Matrix): void;
  83594. /**
  83595. * Gets only rotation part of the current matrix
  83596. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83597. */
  83598. getRotationMatrix(): Matrix;
  83599. /**
  83600. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83601. * @param result defines the target matrix to store data to
  83602. * @returns the current matrix
  83603. */
  83604. getRotationMatrixToRef(result: Matrix): Matrix;
  83605. /**
  83606. * Toggles model matrix from being right handed to left handed in place and vice versa
  83607. */
  83608. toggleModelMatrixHandInPlace(): void;
  83609. /**
  83610. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83611. */
  83612. toggleProjectionMatrixHandInPlace(): void;
  83613. /**
  83614. * Creates a matrix from an array
  83615. * @param array defines the source array
  83616. * @param offset defines an offset in the source array
  83617. * @returns a new Matrix set from the starting index of the given array
  83618. */
  83619. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83620. /**
  83621. * Copy the content of an array into a given matrix
  83622. * @param array defines the source array
  83623. * @param offset defines an offset in the source array
  83624. * @param result defines the target matrix
  83625. */
  83626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83627. /**
  83628. * Stores an array into a matrix after having multiplied each component by a given factor
  83629. * @param array defines the source array
  83630. * @param offset defines the offset in the source array
  83631. * @param scale defines the scaling factor
  83632. * @param result defines the target matrix
  83633. */
  83634. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83635. /**
  83636. * Gets an identity matrix that must not be updated
  83637. */
  83638. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83639. /**
  83640. * Stores a list of values (16) inside a given matrix
  83641. * @param initialM11 defines 1st value of 1st row
  83642. * @param initialM12 defines 2nd value of 1st row
  83643. * @param initialM13 defines 3rd value of 1st row
  83644. * @param initialM14 defines 4th value of 1st row
  83645. * @param initialM21 defines 1st value of 2nd row
  83646. * @param initialM22 defines 2nd value of 2nd row
  83647. * @param initialM23 defines 3rd value of 2nd row
  83648. * @param initialM24 defines 4th value of 2nd row
  83649. * @param initialM31 defines 1st value of 3rd row
  83650. * @param initialM32 defines 2nd value of 3rd row
  83651. * @param initialM33 defines 3rd value of 3rd row
  83652. * @param initialM34 defines 4th value of 3rd row
  83653. * @param initialM41 defines 1st value of 4th row
  83654. * @param initialM42 defines 2nd value of 4th row
  83655. * @param initialM43 defines 3rd value of 4th row
  83656. * @param initialM44 defines 4th value of 4th row
  83657. * @param result defines the target matrix
  83658. */
  83659. 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;
  83660. /**
  83661. * Creates new matrix from a list of values (16)
  83662. * @param initialM11 defines 1st value of 1st row
  83663. * @param initialM12 defines 2nd value of 1st row
  83664. * @param initialM13 defines 3rd value of 1st row
  83665. * @param initialM14 defines 4th value of 1st row
  83666. * @param initialM21 defines 1st value of 2nd row
  83667. * @param initialM22 defines 2nd value of 2nd row
  83668. * @param initialM23 defines 3rd value of 2nd row
  83669. * @param initialM24 defines 4th value of 2nd row
  83670. * @param initialM31 defines 1st value of 3rd row
  83671. * @param initialM32 defines 2nd value of 3rd row
  83672. * @param initialM33 defines 3rd value of 3rd row
  83673. * @param initialM34 defines 4th value of 3rd row
  83674. * @param initialM41 defines 1st value of 4th row
  83675. * @param initialM42 defines 2nd value of 4th row
  83676. * @param initialM43 defines 3rd value of 4th row
  83677. * @param initialM44 defines 4th value of 4th row
  83678. * @returns the new matrix
  83679. */
  83680. 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;
  83681. /**
  83682. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83683. * @param scale defines the scale vector3
  83684. * @param rotation defines the rotation quaternion
  83685. * @param translation defines the translation vector3
  83686. * @returns a new matrix
  83687. */
  83688. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83689. /**
  83690. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83691. * @param scale defines the scale vector3
  83692. * @param rotation defines the rotation quaternion
  83693. * @param translation defines the translation vector3
  83694. * @param result defines the target matrix
  83695. */
  83696. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83697. /**
  83698. * Creates a new identity matrix
  83699. * @returns a new identity matrix
  83700. */
  83701. static Identity(): Matrix;
  83702. /**
  83703. * Creates a new identity matrix and stores the result in a given matrix
  83704. * @param result defines the target matrix
  83705. */
  83706. static IdentityToRef(result: Matrix): void;
  83707. /**
  83708. * Creates a new zero matrix
  83709. * @returns a new zero matrix
  83710. */
  83711. static Zero(): Matrix;
  83712. /**
  83713. * Creates a new rotation matrix for "angle" radians around the X axis
  83714. * @param angle defines the angle (in radians) to use
  83715. * @return the new matrix
  83716. */
  83717. static RotationX(angle: number): Matrix;
  83718. /**
  83719. * Creates a new matrix as the invert of a given matrix
  83720. * @param source defines the source matrix
  83721. * @returns the new matrix
  83722. */
  83723. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83724. /**
  83725. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83726. * @param angle defines the angle (in radians) to use
  83727. * @param result defines the target matrix
  83728. */
  83729. static RotationXToRef(angle: number, result: Matrix): void;
  83730. /**
  83731. * Creates a new rotation matrix for "angle" radians around the Y axis
  83732. * @param angle defines the angle (in radians) to use
  83733. * @return the new matrix
  83734. */
  83735. static RotationY(angle: number): Matrix;
  83736. /**
  83737. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83738. * @param angle defines the angle (in radians) to use
  83739. * @param result defines the target matrix
  83740. */
  83741. static RotationYToRef(angle: number, result: Matrix): void;
  83742. /**
  83743. * Creates a new rotation matrix for "angle" radians around the Z axis
  83744. * @param angle defines the angle (in radians) to use
  83745. * @return the new matrix
  83746. */
  83747. static RotationZ(angle: number): Matrix;
  83748. /**
  83749. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83750. * @param angle defines the angle (in radians) to use
  83751. * @param result defines the target matrix
  83752. */
  83753. static RotationZToRef(angle: number, result: Matrix): void;
  83754. /**
  83755. * Creates a new rotation matrix for "angle" radians around the given axis
  83756. * @param axis defines the axis to use
  83757. * @param angle defines the angle (in radians) to use
  83758. * @return the new matrix
  83759. */
  83760. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83761. /**
  83762. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83763. * @param axis defines the axis to use
  83764. * @param angle defines the angle (in radians) to use
  83765. * @param result defines the target matrix
  83766. */
  83767. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83768. /**
  83769. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83770. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83771. * @param from defines the vector to align
  83772. * @param to defines the vector to align to
  83773. * @param result defines the target matrix
  83774. */
  83775. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83776. /**
  83777. * Creates a rotation matrix
  83778. * @param yaw defines the yaw angle in radians (Y axis)
  83779. * @param pitch defines the pitch angle in radians (X axis)
  83780. * @param roll defines the roll angle in radians (Z axis)
  83781. * @returns the new rotation matrix
  83782. */
  83783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83784. /**
  83785. * Creates a rotation matrix and stores it in a given matrix
  83786. * @param yaw defines the yaw angle in radians (Y axis)
  83787. * @param pitch defines the pitch angle in radians (X axis)
  83788. * @param roll defines the roll angle in radians (Z axis)
  83789. * @param result defines the target matrix
  83790. */
  83791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83792. /**
  83793. * Creates a scaling matrix
  83794. * @param x defines the scale factor on X axis
  83795. * @param y defines the scale factor on Y axis
  83796. * @param z defines the scale factor on Z axis
  83797. * @returns the new matrix
  83798. */
  83799. static Scaling(x: number, y: number, z: number): Matrix;
  83800. /**
  83801. * Creates a scaling matrix and stores it in a given matrix
  83802. * @param x defines the scale factor on X axis
  83803. * @param y defines the scale factor on Y axis
  83804. * @param z defines the scale factor on Z axis
  83805. * @param result defines the target matrix
  83806. */
  83807. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83808. /**
  83809. * Creates a translation matrix
  83810. * @param x defines the translation on X axis
  83811. * @param y defines the translation on Y axis
  83812. * @param z defines the translationon Z axis
  83813. * @returns the new matrix
  83814. */
  83815. static Translation(x: number, y: number, z: number): Matrix;
  83816. /**
  83817. * Creates a translation matrix and stores it in a given matrix
  83818. * @param x defines the translation on X axis
  83819. * @param y defines the translation on Y axis
  83820. * @param z defines the translationon Z axis
  83821. * @param result defines the target matrix
  83822. */
  83823. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83824. /**
  83825. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83826. * @param startValue defines the start value
  83827. * @param endValue defines the end value
  83828. * @param gradient defines the gradient factor
  83829. * @returns the new matrix
  83830. */
  83831. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83832. /**
  83833. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83834. * @param startValue defines the start value
  83835. * @param endValue defines the end value
  83836. * @param gradient defines the gradient factor
  83837. * @param result defines the Matrix object where to store data
  83838. */
  83839. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83840. /**
  83841. * Builds a new matrix whose values are computed by:
  83842. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83843. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83844. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83845. * @param startValue defines the first matrix
  83846. * @param endValue defines the second matrix
  83847. * @param gradient defines the gradient between the two matrices
  83848. * @returns the new matrix
  83849. */
  83850. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83851. /**
  83852. * Update a matrix to values which are computed by:
  83853. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83854. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83855. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83856. * @param startValue defines the first matrix
  83857. * @param endValue defines the second matrix
  83858. * @param gradient defines the gradient between the two matrices
  83859. * @param result defines the target matrix
  83860. */
  83861. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83862. /**
  83863. * 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"
  83864. * This function works in left handed mode
  83865. * @param eye defines the final position of the entity
  83866. * @param target defines where the entity should look at
  83867. * @param up defines the up vector for the entity
  83868. * @returns the new matrix
  83869. */
  83870. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83871. /**
  83872. * 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".
  83873. * This function works in left handed mode
  83874. * @param eye defines the final position of the entity
  83875. * @param target defines where the entity should look at
  83876. * @param up defines the up vector for the entity
  83877. * @param result defines the target matrix
  83878. */
  83879. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83880. /**
  83881. * 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"
  83882. * This function works in right handed mode
  83883. * @param eye defines the final position of the entity
  83884. * @param target defines where the entity should look at
  83885. * @param up defines the up vector for the entity
  83886. * @returns the new matrix
  83887. */
  83888. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83889. /**
  83890. * 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".
  83891. * This function works in right handed mode
  83892. * @param eye defines the final position of the entity
  83893. * @param target defines where the entity should look at
  83894. * @param up defines the up vector for the entity
  83895. * @param result defines the target matrix
  83896. */
  83897. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83898. /**
  83899. * Create a left-handed orthographic projection matrix
  83900. * @param width defines the viewport width
  83901. * @param height defines the viewport height
  83902. * @param znear defines the near clip plane
  83903. * @param zfar defines the far clip plane
  83904. * @returns a new matrix as a left-handed orthographic projection matrix
  83905. */
  83906. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83907. /**
  83908. * Store a left-handed orthographic projection to a given matrix
  83909. * @param width defines the viewport width
  83910. * @param height defines the viewport height
  83911. * @param znear defines the near clip plane
  83912. * @param zfar defines the far clip plane
  83913. * @param result defines the target matrix
  83914. */
  83915. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83916. /**
  83917. * Create a left-handed orthographic projection matrix
  83918. * @param left defines the viewport left coordinate
  83919. * @param right defines the viewport right coordinate
  83920. * @param bottom defines the viewport bottom coordinate
  83921. * @param top defines the viewport top coordinate
  83922. * @param znear defines the near clip plane
  83923. * @param zfar defines the far clip plane
  83924. * @returns a new matrix as a left-handed orthographic projection matrix
  83925. */
  83926. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83927. /**
  83928. * Stores a left-handed orthographic projection into a given matrix
  83929. * @param left defines the viewport left coordinate
  83930. * @param right defines the viewport right coordinate
  83931. * @param bottom defines the viewport bottom coordinate
  83932. * @param top defines the viewport top coordinate
  83933. * @param znear defines the near clip plane
  83934. * @param zfar defines the far clip plane
  83935. * @param result defines the target matrix
  83936. */
  83937. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83938. /**
  83939. * Creates a right-handed orthographic projection matrix
  83940. * @param left defines the viewport left coordinate
  83941. * @param right defines the viewport right coordinate
  83942. * @param bottom defines the viewport bottom coordinate
  83943. * @param top defines the viewport top coordinate
  83944. * @param znear defines the near clip plane
  83945. * @param zfar defines the far clip plane
  83946. * @returns a new matrix as a right-handed orthographic projection matrix
  83947. */
  83948. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83949. /**
  83950. * Stores a right-handed orthographic projection into a given matrix
  83951. * @param left defines the viewport left coordinate
  83952. * @param right defines the viewport right coordinate
  83953. * @param bottom defines the viewport bottom coordinate
  83954. * @param top defines the viewport top coordinate
  83955. * @param znear defines the near clip plane
  83956. * @param zfar defines the far clip plane
  83957. * @param result defines the target matrix
  83958. */
  83959. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83960. /**
  83961. * Creates a left-handed perspective projection matrix
  83962. * @param width defines the viewport width
  83963. * @param height defines the viewport height
  83964. * @param znear defines the near clip plane
  83965. * @param zfar defines the far clip plane
  83966. * @returns a new matrix as a left-handed perspective projection matrix
  83967. */
  83968. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83969. /**
  83970. * Creates a left-handed perspective projection matrix
  83971. * @param fov defines the horizontal field of view
  83972. * @param aspect defines the aspect ratio
  83973. * @param znear defines the near clip plane
  83974. * @param zfar defines the far clip plane
  83975. * @returns a new matrix as a left-handed perspective projection matrix
  83976. */
  83977. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83978. /**
  83979. * Stores a left-handed perspective projection into a given matrix
  83980. * @param fov defines the horizontal field of view
  83981. * @param aspect defines the aspect ratio
  83982. * @param znear defines the near clip plane
  83983. * @param zfar defines the far clip plane
  83984. * @param result defines the target matrix
  83985. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83986. */
  83987. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83988. /**
  83989. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83990. * @param fov defines the horizontal field of view
  83991. * @param aspect defines the aspect ratio
  83992. * @param znear defines the near clip plane
  83993. * @param zfar not used as infinity is used as far clip
  83994. * @param result defines the target matrix
  83995. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83996. */
  83997. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83998. /**
  83999. * Creates a right-handed perspective projection matrix
  84000. * @param fov defines the horizontal field of view
  84001. * @param aspect defines the aspect ratio
  84002. * @param znear defines the near clip plane
  84003. * @param zfar defines the far clip plane
  84004. * @returns a new matrix as a right-handed perspective projection matrix
  84005. */
  84006. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84007. /**
  84008. * Stores a right-handed perspective projection into a given matrix
  84009. * @param fov defines the horizontal field of view
  84010. * @param aspect defines the aspect ratio
  84011. * @param znear defines the near clip plane
  84012. * @param zfar defines the far clip plane
  84013. * @param result defines the target matrix
  84014. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84015. */
  84016. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84017. /**
  84018. * Stores a right-handed perspective projection into a given matrix
  84019. * @param fov defines the horizontal field of view
  84020. * @param aspect defines the aspect ratio
  84021. * @param znear defines the near clip plane
  84022. * @param zfar not used as infinity is used as far clip
  84023. * @param result defines the target matrix
  84024. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84025. */
  84026. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84027. /**
  84028. * Stores a perspective projection for WebVR info a given matrix
  84029. * @param fov defines the field of view
  84030. * @param znear defines the near clip plane
  84031. * @param zfar defines the far clip plane
  84032. * @param result defines the target matrix
  84033. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84034. */
  84035. static PerspectiveFovWebVRToRef(fov: {
  84036. upDegrees: number;
  84037. downDegrees: number;
  84038. leftDegrees: number;
  84039. rightDegrees: number;
  84040. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84041. /**
  84042. * Computes a complete transformation matrix
  84043. * @param viewport defines the viewport to use
  84044. * @param world defines the world matrix
  84045. * @param view defines the view matrix
  84046. * @param projection defines the projection matrix
  84047. * @param zmin defines the near clip plane
  84048. * @param zmax defines the far clip plane
  84049. * @returns the transformation matrix
  84050. */
  84051. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84052. /**
  84053. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84054. * @param matrix defines the matrix to use
  84055. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84056. */
  84057. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84058. /**
  84059. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84060. * @param matrix defines the matrix to use
  84061. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84062. */
  84063. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84064. /**
  84065. * Compute the transpose of a given matrix
  84066. * @param matrix defines the matrix to transpose
  84067. * @returns the new matrix
  84068. */
  84069. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84070. /**
  84071. * Compute the transpose of a matrix and store it in a target matrix
  84072. * @param matrix defines the matrix to transpose
  84073. * @param result defines the target matrix
  84074. */
  84075. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84076. /**
  84077. * Computes a reflection matrix from a plane
  84078. * @param plane defines the reflection plane
  84079. * @returns a new matrix
  84080. */
  84081. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84082. /**
  84083. * Computes a reflection matrix from a plane
  84084. * @param plane defines the reflection plane
  84085. * @param result defines the target matrix
  84086. */
  84087. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84088. /**
  84089. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84090. * @param xaxis defines the value of the 1st axis
  84091. * @param yaxis defines the value of the 2nd axis
  84092. * @param zaxis defines the value of the 3rd axis
  84093. * @param result defines the target matrix
  84094. */
  84095. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84096. /**
  84097. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84098. * @param quat defines the quaternion to use
  84099. * @param result defines the target matrix
  84100. */
  84101. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84102. }
  84103. /**
  84104. * @hidden
  84105. */
  84106. export class TmpVectors {
  84107. static Vector2: Vector2[];
  84108. static Vector3: Vector3[];
  84109. static Vector4: Vector4[];
  84110. static Quaternion: Quaternion[];
  84111. static Matrix: Matrix[];
  84112. }
  84113. }
  84114. declare module BABYLON {
  84115. /**
  84116. * Defines potential orientation for back face culling
  84117. */
  84118. export enum Orientation {
  84119. /**
  84120. * Clockwise
  84121. */
  84122. CW = 0,
  84123. /** Counter clockwise */
  84124. CCW = 1
  84125. }
  84126. /** Class used to represent a Bezier curve */
  84127. export class BezierCurve {
  84128. /**
  84129. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84130. * @param t defines the time
  84131. * @param x1 defines the left coordinate on X axis
  84132. * @param y1 defines the left coordinate on Y axis
  84133. * @param x2 defines the right coordinate on X axis
  84134. * @param y2 defines the right coordinate on Y axis
  84135. * @returns the interpolated value
  84136. */
  84137. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84138. }
  84139. /**
  84140. * Defines angle representation
  84141. */
  84142. export class Angle {
  84143. private _radians;
  84144. /**
  84145. * Creates an Angle object of "radians" radians (float).
  84146. * @param radians the angle in radians
  84147. */
  84148. constructor(radians: number);
  84149. /**
  84150. * Get value in degrees
  84151. * @returns the Angle value in degrees (float)
  84152. */
  84153. degrees(): number;
  84154. /**
  84155. * Get value in radians
  84156. * @returns the Angle value in radians (float)
  84157. */
  84158. radians(): number;
  84159. /**
  84160. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84161. * @param a defines first point as the origin
  84162. * @param b defines point
  84163. * @returns a new Angle
  84164. */
  84165. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84166. /**
  84167. * Gets a new Angle object from the given float in radians
  84168. * @param radians defines the angle value in radians
  84169. * @returns a new Angle
  84170. */
  84171. static FromRadians(radians: number): Angle;
  84172. /**
  84173. * Gets a new Angle object from the given float in degrees
  84174. * @param degrees defines the angle value in degrees
  84175. * @returns a new Angle
  84176. */
  84177. static FromDegrees(degrees: number): Angle;
  84178. }
  84179. /**
  84180. * This represents an arc in a 2d space.
  84181. */
  84182. export class Arc2 {
  84183. /** Defines the start point of the arc */
  84184. startPoint: Vector2;
  84185. /** Defines the mid point of the arc */
  84186. midPoint: Vector2;
  84187. /** Defines the end point of the arc */
  84188. endPoint: Vector2;
  84189. /**
  84190. * Defines the center point of the arc.
  84191. */
  84192. centerPoint: Vector2;
  84193. /**
  84194. * Defines the radius of the arc.
  84195. */
  84196. radius: number;
  84197. /**
  84198. * Defines the angle of the arc (from mid point to end point).
  84199. */
  84200. angle: Angle;
  84201. /**
  84202. * Defines the start angle of the arc (from start point to middle point).
  84203. */
  84204. startAngle: Angle;
  84205. /**
  84206. * Defines the orientation of the arc (clock wise/counter clock wise).
  84207. */
  84208. orientation: Orientation;
  84209. /**
  84210. * Creates an Arc object from the three given points : start, middle and end.
  84211. * @param startPoint Defines the start point of the arc
  84212. * @param midPoint Defines the midlle point of the arc
  84213. * @param endPoint Defines the end point of the arc
  84214. */
  84215. constructor(
  84216. /** Defines the start point of the arc */
  84217. startPoint: Vector2,
  84218. /** Defines the mid point of the arc */
  84219. midPoint: Vector2,
  84220. /** Defines the end point of the arc */
  84221. endPoint: Vector2);
  84222. }
  84223. /**
  84224. * Represents a 2D path made up of multiple 2D points
  84225. */
  84226. export class Path2 {
  84227. private _points;
  84228. private _length;
  84229. /**
  84230. * If the path start and end point are the same
  84231. */
  84232. closed: boolean;
  84233. /**
  84234. * Creates a Path2 object from the starting 2D coordinates x and y.
  84235. * @param x the starting points x value
  84236. * @param y the starting points y value
  84237. */
  84238. constructor(x: number, y: number);
  84239. /**
  84240. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84241. * @param x the added points x value
  84242. * @param y the added points y value
  84243. * @returns the updated Path2.
  84244. */
  84245. addLineTo(x: number, y: number): Path2;
  84246. /**
  84247. * 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.
  84248. * @param midX middle point x value
  84249. * @param midY middle point y value
  84250. * @param endX end point x value
  84251. * @param endY end point y value
  84252. * @param numberOfSegments (default: 36)
  84253. * @returns the updated Path2.
  84254. */
  84255. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84256. /**
  84257. * Closes the Path2.
  84258. * @returns the Path2.
  84259. */
  84260. close(): Path2;
  84261. /**
  84262. * Gets the sum of the distance between each sequential point in the path
  84263. * @returns the Path2 total length (float).
  84264. */
  84265. length(): number;
  84266. /**
  84267. * Gets the points which construct the path
  84268. * @returns the Path2 internal array of points.
  84269. */
  84270. getPoints(): Vector2[];
  84271. /**
  84272. * Retreives the point at the distance aways from the starting point
  84273. * @param normalizedLengthPosition the length along the path to retreive the point from
  84274. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84275. */
  84276. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84277. /**
  84278. * Creates a new path starting from an x and y position
  84279. * @param x starting x value
  84280. * @param y starting y value
  84281. * @returns a new Path2 starting at the coordinates (x, y).
  84282. */
  84283. static StartingAt(x: number, y: number): Path2;
  84284. }
  84285. /**
  84286. * Represents a 3D path made up of multiple 3D points
  84287. */
  84288. export class Path3D {
  84289. /**
  84290. * an array of Vector3, the curve axis of the Path3D
  84291. */
  84292. path: Vector3[];
  84293. private _curve;
  84294. private _distances;
  84295. private _tangents;
  84296. private _normals;
  84297. private _binormals;
  84298. private _raw;
  84299. private _alignTangentsWithPath;
  84300. private readonly _pointAtData;
  84301. /**
  84302. * new Path3D(path, normal, raw)
  84303. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84304. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84305. * @param path an array of Vector3, the curve axis of the Path3D
  84306. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84307. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84308. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84309. */
  84310. constructor(
  84311. /**
  84312. * an array of Vector3, the curve axis of the Path3D
  84313. */
  84314. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84315. /**
  84316. * Returns the Path3D array of successive Vector3 designing its curve.
  84317. * @returns the Path3D array of successive Vector3 designing its curve.
  84318. */
  84319. getCurve(): Vector3[];
  84320. /**
  84321. * Returns the Path3D array of successive Vector3 designing its curve.
  84322. * @returns the Path3D array of successive Vector3 designing its curve.
  84323. */
  84324. getPoints(): Vector3[];
  84325. /**
  84326. * @returns the computed length (float) of the path.
  84327. */
  84328. length(): number;
  84329. /**
  84330. * Returns an array populated with tangent vectors on each Path3D curve point.
  84331. * @returns an array populated with tangent vectors on each Path3D curve point.
  84332. */
  84333. getTangents(): Vector3[];
  84334. /**
  84335. * Returns an array populated with normal vectors on each Path3D curve point.
  84336. * @returns an array populated with normal vectors on each Path3D curve point.
  84337. */
  84338. getNormals(): Vector3[];
  84339. /**
  84340. * Returns an array populated with binormal vectors on each Path3D curve point.
  84341. * @returns an array populated with binormal vectors on each Path3D curve point.
  84342. */
  84343. getBinormals(): Vector3[];
  84344. /**
  84345. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84346. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84347. */
  84348. getDistances(): number[];
  84349. /**
  84350. * Returns an interpolated point along this path
  84351. * @param position the position of the point along this path, from 0.0 to 1.0
  84352. * @returns a new Vector3 as the point
  84353. */
  84354. getPointAt(position: number): Vector3;
  84355. /**
  84356. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84357. * @param position the position of the point along this path, from 0.0 to 1.0
  84358. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84359. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84360. */
  84361. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84362. /**
  84363. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84364. * @param position the position of the point along this path, from 0.0 to 1.0
  84365. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84366. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84367. */
  84368. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84369. /**
  84370. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84371. * @param position the position of the point along this path, from 0.0 to 1.0
  84372. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84373. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84374. */
  84375. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84376. /**
  84377. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84378. * @param position the position of the point along this path, from 0.0 to 1.0
  84379. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84380. */
  84381. getDistanceAt(position: number): number;
  84382. /**
  84383. * Returns the array index of the previous point of an interpolated point along this path
  84384. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84385. * @returns the array index
  84386. */
  84387. getPreviousPointIndexAt(position: number): number;
  84388. /**
  84389. * 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)
  84390. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84391. * @returns the sub position
  84392. */
  84393. getSubPositionAt(position: number): number;
  84394. /**
  84395. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84396. * @param target the vector of which to get the closest position to
  84397. * @returns the position of the closest virtual point on this path to the target vector
  84398. */
  84399. getClosestPositionTo(target: Vector3): number;
  84400. /**
  84401. * Returns a sub path (slice) of this path
  84402. * @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
  84403. * @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
  84404. * @returns a sub path (slice) of this path
  84405. */
  84406. slice(start?: number, end?: number): Path3D;
  84407. /**
  84408. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84409. * @param path path which all values are copied into the curves points
  84410. * @param firstNormal which should be projected onto the curve
  84411. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84412. * @returns the same object updated.
  84413. */
  84414. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84415. private _compute;
  84416. private _getFirstNonNullVector;
  84417. private _getLastNonNullVector;
  84418. private _normalVector;
  84419. /**
  84420. * Updates the point at data for an interpolated point along this curve
  84421. * @param position the position of the point along this curve, from 0.0 to 1.0
  84422. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84423. * @returns the (updated) point at data
  84424. */
  84425. private _updatePointAtData;
  84426. /**
  84427. * Updates the point at data from the specified parameters
  84428. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84429. * @param point the interpolated point
  84430. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84431. */
  84432. private _setPointAtData;
  84433. /**
  84434. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84435. */
  84436. private _updateInterpolationMatrix;
  84437. }
  84438. /**
  84439. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84440. * A Curve3 is designed from a series of successive Vector3.
  84441. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84442. */
  84443. export class Curve3 {
  84444. private _points;
  84445. private _length;
  84446. /**
  84447. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84448. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84449. * @param v1 (Vector3) the control point
  84450. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84451. * @param nbPoints (integer) the wanted number of points in the curve
  84452. * @returns the created Curve3
  84453. */
  84454. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84455. /**
  84456. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84457. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84458. * @param v1 (Vector3) the first control point
  84459. * @param v2 (Vector3) the second control point
  84460. * @param v3 (Vector3) the end point of the Cubic Bezier
  84461. * @param nbPoints (integer) the wanted number of points in the curve
  84462. * @returns the created Curve3
  84463. */
  84464. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84465. /**
  84466. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84467. * @param p1 (Vector3) the origin point of the Hermite Spline
  84468. * @param t1 (Vector3) the tangent vector at the origin point
  84469. * @param p2 (Vector3) the end point of the Hermite Spline
  84470. * @param t2 (Vector3) the tangent vector at the end point
  84471. * @param nbPoints (integer) the wanted number of points in the curve
  84472. * @returns the created Curve3
  84473. */
  84474. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84475. /**
  84476. * Returns a Curve3 object along a CatmullRom Spline curve :
  84477. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84478. * @param nbPoints (integer) the wanted number of points between each curve control points
  84479. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84480. * @returns the created Curve3
  84481. */
  84482. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84483. /**
  84484. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84485. * A Curve3 is designed from a series of successive Vector3.
  84486. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84487. * @param points points which make up the curve
  84488. */
  84489. constructor(points: Vector3[]);
  84490. /**
  84491. * @returns the Curve3 stored array of successive Vector3
  84492. */
  84493. getPoints(): Vector3[];
  84494. /**
  84495. * @returns the computed length (float) of the curve.
  84496. */
  84497. length(): number;
  84498. /**
  84499. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84500. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84501. * curveA and curveB keep unchanged.
  84502. * @param curve the curve to continue from this curve
  84503. * @returns the newly constructed curve
  84504. */
  84505. continue(curve: DeepImmutable<Curve3>): Curve3;
  84506. private _computeLength;
  84507. }
  84508. }
  84509. declare module BABYLON {
  84510. /**
  84511. * This represents the main contract an easing function should follow.
  84512. * Easing functions are used throughout the animation system.
  84513. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84514. */
  84515. export interface IEasingFunction {
  84516. /**
  84517. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84518. * of the easing function.
  84519. * The link below provides some of the most common examples of easing functions.
  84520. * @see https://easings.net/
  84521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84522. * @returns the corresponding value on the curve defined by the easing function
  84523. */
  84524. ease(gradient: number): number;
  84525. }
  84526. /**
  84527. * Base class used for every default easing function.
  84528. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84529. */
  84530. export class EasingFunction implements IEasingFunction {
  84531. /**
  84532. * Interpolation follows the mathematical formula associated with the easing function.
  84533. */
  84534. static readonly EASINGMODE_EASEIN: number;
  84535. /**
  84536. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84537. */
  84538. static readonly EASINGMODE_EASEOUT: number;
  84539. /**
  84540. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84541. */
  84542. static readonly EASINGMODE_EASEINOUT: number;
  84543. private _easingMode;
  84544. /**
  84545. * Sets the easing mode of the current function.
  84546. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84547. */
  84548. setEasingMode(easingMode: number): void;
  84549. /**
  84550. * Gets the current easing mode.
  84551. * @returns the easing mode
  84552. */
  84553. getEasingMode(): number;
  84554. /**
  84555. * @hidden
  84556. */
  84557. easeInCore(gradient: number): number;
  84558. /**
  84559. * Given an input gradient between 0 and 1, this returns the corresponding value
  84560. * of the easing function.
  84561. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84562. * @returns the corresponding value on the curve defined by the easing function
  84563. */
  84564. ease(gradient: number): number;
  84565. }
  84566. /**
  84567. * Easing function with a circle shape (see link below).
  84568. * @see https://easings.net/#easeInCirc
  84569. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84570. */
  84571. export class CircleEase extends EasingFunction implements IEasingFunction {
  84572. /** @hidden */
  84573. easeInCore(gradient: number): number;
  84574. }
  84575. /**
  84576. * Easing function with a ease back shape (see link below).
  84577. * @see https://easings.net/#easeInBack
  84578. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84579. */
  84580. export class BackEase extends EasingFunction implements IEasingFunction {
  84581. /** Defines the amplitude of the function */
  84582. amplitude: number;
  84583. /**
  84584. * Instantiates a back ease easing
  84585. * @see https://easings.net/#easeInBack
  84586. * @param amplitude Defines the amplitude of the function
  84587. */
  84588. constructor(
  84589. /** Defines the amplitude of the function */
  84590. amplitude?: number);
  84591. /** @hidden */
  84592. easeInCore(gradient: number): number;
  84593. }
  84594. /**
  84595. * Easing function with a bouncing shape (see link below).
  84596. * @see https://easings.net/#easeInBounce
  84597. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84598. */
  84599. export class BounceEase extends EasingFunction implements IEasingFunction {
  84600. /** Defines the number of bounces */
  84601. bounces: number;
  84602. /** Defines the amplitude of the bounce */
  84603. bounciness: number;
  84604. /**
  84605. * Instantiates a bounce easing
  84606. * @see https://easings.net/#easeInBounce
  84607. * @param bounces Defines the number of bounces
  84608. * @param bounciness Defines the amplitude of the bounce
  84609. */
  84610. constructor(
  84611. /** Defines the number of bounces */
  84612. bounces?: number,
  84613. /** Defines the amplitude of the bounce */
  84614. bounciness?: number);
  84615. /** @hidden */
  84616. easeInCore(gradient: number): number;
  84617. }
  84618. /**
  84619. * Easing function with a power of 3 shape (see link below).
  84620. * @see https://easings.net/#easeInCubic
  84621. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84622. */
  84623. export class CubicEase extends EasingFunction implements IEasingFunction {
  84624. /** @hidden */
  84625. easeInCore(gradient: number): number;
  84626. }
  84627. /**
  84628. * Easing function with an elastic shape (see link below).
  84629. * @see https://easings.net/#easeInElastic
  84630. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84631. */
  84632. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84633. /** Defines the number of oscillations*/
  84634. oscillations: number;
  84635. /** Defines the amplitude of the oscillations*/
  84636. springiness: number;
  84637. /**
  84638. * Instantiates an elastic easing function
  84639. * @see https://easings.net/#easeInElastic
  84640. * @param oscillations Defines the number of oscillations
  84641. * @param springiness Defines the amplitude of the oscillations
  84642. */
  84643. constructor(
  84644. /** Defines the number of oscillations*/
  84645. oscillations?: number,
  84646. /** Defines the amplitude of the oscillations*/
  84647. springiness?: number);
  84648. /** @hidden */
  84649. easeInCore(gradient: number): number;
  84650. }
  84651. /**
  84652. * Easing function with an exponential shape (see link below).
  84653. * @see https://easings.net/#easeInExpo
  84654. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84655. */
  84656. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84657. /** Defines the exponent of the function */
  84658. exponent: number;
  84659. /**
  84660. * Instantiates an exponential easing function
  84661. * @see https://easings.net/#easeInExpo
  84662. * @param exponent Defines the exponent of the function
  84663. */
  84664. constructor(
  84665. /** Defines the exponent of the function */
  84666. exponent?: number);
  84667. /** @hidden */
  84668. easeInCore(gradient: number): number;
  84669. }
  84670. /**
  84671. * Easing function with a power shape (see link below).
  84672. * @see https://easings.net/#easeInQuad
  84673. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84674. */
  84675. export class PowerEase extends EasingFunction implements IEasingFunction {
  84676. /** Defines the power of the function */
  84677. power: number;
  84678. /**
  84679. * Instantiates an power base easing function
  84680. * @see https://easings.net/#easeInQuad
  84681. * @param power Defines the power of the function
  84682. */
  84683. constructor(
  84684. /** Defines the power of the function */
  84685. power?: number);
  84686. /** @hidden */
  84687. easeInCore(gradient: number): number;
  84688. }
  84689. /**
  84690. * Easing function with a power of 2 shape (see link below).
  84691. * @see https://easings.net/#easeInQuad
  84692. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84693. */
  84694. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84695. /** @hidden */
  84696. easeInCore(gradient: number): number;
  84697. }
  84698. /**
  84699. * Easing function with a power of 4 shape (see link below).
  84700. * @see https://easings.net/#easeInQuart
  84701. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84702. */
  84703. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84704. /** @hidden */
  84705. easeInCore(gradient: number): number;
  84706. }
  84707. /**
  84708. * Easing function with a power of 5 shape (see link below).
  84709. * @see https://easings.net/#easeInQuint
  84710. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84711. */
  84712. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84713. /** @hidden */
  84714. easeInCore(gradient: number): number;
  84715. }
  84716. /**
  84717. * Easing function with a sin shape (see link below).
  84718. * @see https://easings.net/#easeInSine
  84719. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84720. */
  84721. export class SineEase extends EasingFunction implements IEasingFunction {
  84722. /** @hidden */
  84723. easeInCore(gradient: number): number;
  84724. }
  84725. /**
  84726. * Easing function with a bezier shape (see link below).
  84727. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84728. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84729. */
  84730. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84731. /** Defines the x component of the start tangent in the bezier curve */
  84732. x1: number;
  84733. /** Defines the y component of the start tangent in the bezier curve */
  84734. y1: number;
  84735. /** Defines the x component of the end tangent in the bezier curve */
  84736. x2: number;
  84737. /** Defines the y component of the end tangent in the bezier curve */
  84738. y2: number;
  84739. /**
  84740. * Instantiates a bezier function
  84741. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84742. * @param x1 Defines the x component of the start tangent in the bezier curve
  84743. * @param y1 Defines the y component of the start tangent in the bezier curve
  84744. * @param x2 Defines the x component of the end tangent in the bezier curve
  84745. * @param y2 Defines the y component of the end tangent in the bezier curve
  84746. */
  84747. constructor(
  84748. /** Defines the x component of the start tangent in the bezier curve */
  84749. x1?: number,
  84750. /** Defines the y component of the start tangent in the bezier curve */
  84751. y1?: number,
  84752. /** Defines the x component of the end tangent in the bezier curve */
  84753. x2?: number,
  84754. /** Defines the y component of the end tangent in the bezier curve */
  84755. y2?: number);
  84756. /** @hidden */
  84757. easeInCore(gradient: number): number;
  84758. }
  84759. }
  84760. declare module BABYLON {
  84761. /**
  84762. * Class used to hold a RBG color
  84763. */
  84764. export class Color3 {
  84765. /**
  84766. * Defines the red component (between 0 and 1, default is 0)
  84767. */
  84768. r: number;
  84769. /**
  84770. * Defines the green component (between 0 and 1, default is 0)
  84771. */
  84772. g: number;
  84773. /**
  84774. * Defines the blue component (between 0 and 1, default is 0)
  84775. */
  84776. b: number;
  84777. /**
  84778. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84779. * @param r defines the red component (between 0 and 1, default is 0)
  84780. * @param g defines the green component (between 0 and 1, default is 0)
  84781. * @param b defines the blue component (between 0 and 1, default is 0)
  84782. */
  84783. constructor(
  84784. /**
  84785. * Defines the red component (between 0 and 1, default is 0)
  84786. */
  84787. r?: number,
  84788. /**
  84789. * Defines the green component (between 0 and 1, default is 0)
  84790. */
  84791. g?: number,
  84792. /**
  84793. * Defines the blue component (between 0 and 1, default is 0)
  84794. */
  84795. b?: number);
  84796. /**
  84797. * Creates a string with the Color3 current values
  84798. * @returns the string representation of the Color3 object
  84799. */
  84800. toString(): string;
  84801. /**
  84802. * Returns the string "Color3"
  84803. * @returns "Color3"
  84804. */
  84805. getClassName(): string;
  84806. /**
  84807. * Compute the Color3 hash code
  84808. * @returns an unique number that can be used to hash Color3 objects
  84809. */
  84810. getHashCode(): number;
  84811. /**
  84812. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84813. * @param array defines the array where to store the r,g,b components
  84814. * @param index defines an optional index in the target array to define where to start storing values
  84815. * @returns the current Color3 object
  84816. */
  84817. toArray(array: FloatArray, index?: number): Color3;
  84818. /**
  84819. * Update the current color with values stored in an array from the starting index of the given array
  84820. * @param array defines the source array
  84821. * @param offset defines an offset in the source array
  84822. * @returns the current Color3 object
  84823. */
  84824. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84825. /**
  84826. * Returns a new Color4 object from the current Color3 and the given alpha
  84827. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84828. * @returns a new Color4 object
  84829. */
  84830. toColor4(alpha?: number): Color4;
  84831. /**
  84832. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84833. * @returns the new array
  84834. */
  84835. asArray(): number[];
  84836. /**
  84837. * Returns the luminance value
  84838. * @returns a float value
  84839. */
  84840. toLuminance(): number;
  84841. /**
  84842. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84843. * @param otherColor defines the second operand
  84844. * @returns the new Color3 object
  84845. */
  84846. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84847. /**
  84848. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84849. * @param otherColor defines the second operand
  84850. * @param result defines the Color3 object where to store the result
  84851. * @returns the current Color3
  84852. */
  84853. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84854. /**
  84855. * Determines equality between Color3 objects
  84856. * @param otherColor defines the second operand
  84857. * @returns true if the rgb values are equal to the given ones
  84858. */
  84859. equals(otherColor: DeepImmutable<Color3>): boolean;
  84860. /**
  84861. * Determines equality between the current Color3 object and a set of r,b,g values
  84862. * @param r defines the red component to check
  84863. * @param g defines the green component to check
  84864. * @param b defines the blue component to check
  84865. * @returns true if the rgb values are equal to the given ones
  84866. */
  84867. equalsFloats(r: number, g: number, b: number): boolean;
  84868. /**
  84869. * Multiplies in place each rgb value by scale
  84870. * @param scale defines the scaling factor
  84871. * @returns the updated Color3
  84872. */
  84873. scale(scale: number): Color3;
  84874. /**
  84875. * Multiplies the rgb values by scale and stores the result into "result"
  84876. * @param scale defines the scaling factor
  84877. * @param result defines the Color3 object where to store the result
  84878. * @returns the unmodified current Color3
  84879. */
  84880. scaleToRef(scale: number, result: Color3): Color3;
  84881. /**
  84882. * Scale the current Color3 values by a factor and add the result to a given Color3
  84883. * @param scale defines the scale factor
  84884. * @param result defines color to store the result into
  84885. * @returns the unmodified current Color3
  84886. */
  84887. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84888. /**
  84889. * Clamps the rgb values by the min and max values and stores the result into "result"
  84890. * @param min defines minimum clamping value (default is 0)
  84891. * @param max defines maximum clamping value (default is 1)
  84892. * @param result defines color to store the result into
  84893. * @returns the original Color3
  84894. */
  84895. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84896. /**
  84897. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84898. * @param otherColor defines the second operand
  84899. * @returns the new Color3
  84900. */
  84901. add(otherColor: DeepImmutable<Color3>): Color3;
  84902. /**
  84903. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84904. * @param otherColor defines the second operand
  84905. * @param result defines Color3 object to store the result into
  84906. * @returns the unmodified current Color3
  84907. */
  84908. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84909. /**
  84910. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84911. * @param otherColor defines the second operand
  84912. * @returns the new Color3
  84913. */
  84914. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84915. /**
  84916. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84917. * @param otherColor defines the second operand
  84918. * @param result defines Color3 object to store the result into
  84919. * @returns the unmodified current Color3
  84920. */
  84921. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84922. /**
  84923. * Copy the current object
  84924. * @returns a new Color3 copied the current one
  84925. */
  84926. clone(): Color3;
  84927. /**
  84928. * Copies the rgb values from the source in the current Color3
  84929. * @param source defines the source Color3 object
  84930. * @returns the updated Color3 object
  84931. */
  84932. copyFrom(source: DeepImmutable<Color3>): Color3;
  84933. /**
  84934. * Updates the Color3 rgb values from the given floats
  84935. * @param r defines the red component to read from
  84936. * @param g defines the green component to read from
  84937. * @param b defines the blue component to read from
  84938. * @returns the current Color3 object
  84939. */
  84940. copyFromFloats(r: number, g: number, b: number): Color3;
  84941. /**
  84942. * Updates the Color3 rgb values from the given floats
  84943. * @param r defines the red component to read from
  84944. * @param g defines the green component to read from
  84945. * @param b defines the blue component to read from
  84946. * @returns the current Color3 object
  84947. */
  84948. set(r: number, g: number, b: number): Color3;
  84949. /**
  84950. * Compute the Color3 hexadecimal code as a string
  84951. * @returns a string containing the hexadecimal representation of the Color3 object
  84952. */
  84953. toHexString(): string;
  84954. /**
  84955. * Computes a new Color3 converted from the current one to linear space
  84956. * @returns a new Color3 object
  84957. */
  84958. toLinearSpace(): Color3;
  84959. /**
  84960. * Converts current color in rgb space to HSV values
  84961. * @returns a new color3 representing the HSV values
  84962. */
  84963. toHSV(): Color3;
  84964. /**
  84965. * Converts current color in rgb space to HSV values
  84966. * @param result defines the Color3 where to store the HSV values
  84967. */
  84968. toHSVToRef(result: Color3): void;
  84969. /**
  84970. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84971. * @param convertedColor defines the Color3 object where to store the linear space version
  84972. * @returns the unmodified Color3
  84973. */
  84974. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84975. /**
  84976. * Computes a new Color3 converted from the current one to gamma space
  84977. * @returns a new Color3 object
  84978. */
  84979. toGammaSpace(): Color3;
  84980. /**
  84981. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84982. * @param convertedColor defines the Color3 object where to store the gamma space version
  84983. * @returns the unmodified Color3
  84984. */
  84985. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84986. private static _BlackReadOnly;
  84987. /**
  84988. * Convert Hue, saturation and value to a Color3 (RGB)
  84989. * @param hue defines the hue
  84990. * @param saturation defines the saturation
  84991. * @param value defines the value
  84992. * @param result defines the Color3 where to store the RGB values
  84993. */
  84994. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84995. /**
  84996. * Creates a new Color3 from the string containing valid hexadecimal values
  84997. * @param hex defines a string containing valid hexadecimal values
  84998. * @returns a new Color3 object
  84999. */
  85000. static FromHexString(hex: string): Color3;
  85001. /**
  85002. * Creates a new Color3 from the starting index of the given array
  85003. * @param array defines the source array
  85004. * @param offset defines an offset in the source array
  85005. * @returns a new Color3 object
  85006. */
  85007. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85008. /**
  85009. * Creates a new Color3 from the starting index element of the given array
  85010. * @param array defines the source array to read from
  85011. * @param offset defines the offset in the source array
  85012. * @param result defines the target Color3 object
  85013. */
  85014. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85015. /**
  85016. * Creates a new Color3 from integer values (< 256)
  85017. * @param r defines the red component to read from (value between 0 and 255)
  85018. * @param g defines the green component to read from (value between 0 and 255)
  85019. * @param b defines the blue component to read from (value between 0 and 255)
  85020. * @returns a new Color3 object
  85021. */
  85022. static FromInts(r: number, g: number, b: number): Color3;
  85023. /**
  85024. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85025. * @param start defines the start Color3 value
  85026. * @param end defines the end Color3 value
  85027. * @param amount defines the gradient value between start and end
  85028. * @returns a new Color3 object
  85029. */
  85030. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85031. /**
  85032. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85033. * @param left defines the start value
  85034. * @param right defines the end value
  85035. * @param amount defines the gradient factor
  85036. * @param result defines the Color3 object where to store the result
  85037. */
  85038. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85039. /**
  85040. * Returns a Color3 value containing a red color
  85041. * @returns a new Color3 object
  85042. */
  85043. static Red(): Color3;
  85044. /**
  85045. * Returns a Color3 value containing a green color
  85046. * @returns a new Color3 object
  85047. */
  85048. static Green(): Color3;
  85049. /**
  85050. * Returns a Color3 value containing a blue color
  85051. * @returns a new Color3 object
  85052. */
  85053. static Blue(): Color3;
  85054. /**
  85055. * Returns a Color3 value containing a black color
  85056. * @returns a new Color3 object
  85057. */
  85058. static Black(): Color3;
  85059. /**
  85060. * Gets a Color3 value containing a black color that must not be updated
  85061. */
  85062. static get BlackReadOnly(): DeepImmutable<Color3>;
  85063. /**
  85064. * Returns a Color3 value containing a white color
  85065. * @returns a new Color3 object
  85066. */
  85067. static White(): Color3;
  85068. /**
  85069. * Returns a Color3 value containing a purple color
  85070. * @returns a new Color3 object
  85071. */
  85072. static Purple(): Color3;
  85073. /**
  85074. * Returns a Color3 value containing a magenta color
  85075. * @returns a new Color3 object
  85076. */
  85077. static Magenta(): Color3;
  85078. /**
  85079. * Returns a Color3 value containing a yellow color
  85080. * @returns a new Color3 object
  85081. */
  85082. static Yellow(): Color3;
  85083. /**
  85084. * Returns a Color3 value containing a gray color
  85085. * @returns a new Color3 object
  85086. */
  85087. static Gray(): Color3;
  85088. /**
  85089. * Returns a Color3 value containing a teal color
  85090. * @returns a new Color3 object
  85091. */
  85092. static Teal(): Color3;
  85093. /**
  85094. * Returns a Color3 value containing a random color
  85095. * @returns a new Color3 object
  85096. */
  85097. static Random(): Color3;
  85098. }
  85099. /**
  85100. * Class used to hold a RBGA color
  85101. */
  85102. export class Color4 {
  85103. /**
  85104. * Defines the red component (between 0 and 1, default is 0)
  85105. */
  85106. r: number;
  85107. /**
  85108. * Defines the green component (between 0 and 1, default is 0)
  85109. */
  85110. g: number;
  85111. /**
  85112. * Defines the blue component (between 0 and 1, default is 0)
  85113. */
  85114. b: number;
  85115. /**
  85116. * Defines the alpha component (between 0 and 1, default is 1)
  85117. */
  85118. a: number;
  85119. /**
  85120. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85121. * @param r defines the red component (between 0 and 1, default is 0)
  85122. * @param g defines the green component (between 0 and 1, default is 0)
  85123. * @param b defines the blue component (between 0 and 1, default is 0)
  85124. * @param a defines the alpha component (between 0 and 1, default is 1)
  85125. */
  85126. constructor(
  85127. /**
  85128. * Defines the red component (between 0 and 1, default is 0)
  85129. */
  85130. r?: number,
  85131. /**
  85132. * Defines the green component (between 0 and 1, default is 0)
  85133. */
  85134. g?: number,
  85135. /**
  85136. * Defines the blue component (between 0 and 1, default is 0)
  85137. */
  85138. b?: number,
  85139. /**
  85140. * Defines the alpha component (between 0 and 1, default is 1)
  85141. */
  85142. a?: number);
  85143. /**
  85144. * Adds in place the given Color4 values to the current Color4 object
  85145. * @param right defines the second operand
  85146. * @returns the current updated Color4 object
  85147. */
  85148. addInPlace(right: DeepImmutable<Color4>): Color4;
  85149. /**
  85150. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85151. * @returns the new array
  85152. */
  85153. asArray(): number[];
  85154. /**
  85155. * Stores from the starting index in the given array the Color4 successive values
  85156. * @param array defines the array where to store the r,g,b components
  85157. * @param index defines an optional index in the target array to define where to start storing values
  85158. * @returns the current Color4 object
  85159. */
  85160. toArray(array: number[], index?: number): Color4;
  85161. /**
  85162. * Update the current color with values stored in an array from the starting index of the given array
  85163. * @param array defines the source array
  85164. * @param offset defines an offset in the source array
  85165. * @returns the current Color4 object
  85166. */
  85167. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85168. /**
  85169. * Determines equality between Color4 objects
  85170. * @param otherColor defines the second operand
  85171. * @returns true if the rgba values are equal to the given ones
  85172. */
  85173. equals(otherColor: DeepImmutable<Color4>): boolean;
  85174. /**
  85175. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85176. * @param right defines the second operand
  85177. * @returns a new Color4 object
  85178. */
  85179. add(right: DeepImmutable<Color4>): Color4;
  85180. /**
  85181. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85182. * @param right defines the second operand
  85183. * @returns a new Color4 object
  85184. */
  85185. subtract(right: DeepImmutable<Color4>): Color4;
  85186. /**
  85187. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85188. * @param right defines the second operand
  85189. * @param result defines the Color4 object where to store the result
  85190. * @returns the current Color4 object
  85191. */
  85192. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85193. /**
  85194. * Creates a new Color4 with the current Color4 values multiplied by scale
  85195. * @param scale defines the scaling factor to apply
  85196. * @returns a new Color4 object
  85197. */
  85198. scale(scale: number): Color4;
  85199. /**
  85200. * Multiplies the current Color4 values by scale and stores the result in "result"
  85201. * @param scale defines the scaling factor to apply
  85202. * @param result defines the Color4 object where to store the result
  85203. * @returns the current unmodified Color4
  85204. */
  85205. scaleToRef(scale: number, result: Color4): Color4;
  85206. /**
  85207. * Scale the current Color4 values by a factor and add the result to a given Color4
  85208. * @param scale defines the scale factor
  85209. * @param result defines the Color4 object where to store the result
  85210. * @returns the unmodified current Color4
  85211. */
  85212. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85213. /**
  85214. * Clamps the rgb values by the min and max values and stores the result into "result"
  85215. * @param min defines minimum clamping value (default is 0)
  85216. * @param max defines maximum clamping value (default is 1)
  85217. * @param result defines color to store the result into.
  85218. * @returns the cuurent Color4
  85219. */
  85220. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85221. /**
  85222. * Multipy an Color4 value by another and return a new Color4 object
  85223. * @param color defines the Color4 value to multiply by
  85224. * @returns a new Color4 object
  85225. */
  85226. multiply(color: Color4): Color4;
  85227. /**
  85228. * Multipy a Color4 value by another and push the result in a reference value
  85229. * @param color defines the Color4 value to multiply by
  85230. * @param result defines the Color4 to fill the result in
  85231. * @returns the result Color4
  85232. */
  85233. multiplyToRef(color: Color4, result: Color4): Color4;
  85234. /**
  85235. * Creates a string with the Color4 current values
  85236. * @returns the string representation of the Color4 object
  85237. */
  85238. toString(): string;
  85239. /**
  85240. * Returns the string "Color4"
  85241. * @returns "Color4"
  85242. */
  85243. getClassName(): string;
  85244. /**
  85245. * Compute the Color4 hash code
  85246. * @returns an unique number that can be used to hash Color4 objects
  85247. */
  85248. getHashCode(): number;
  85249. /**
  85250. * Creates a new Color4 copied from the current one
  85251. * @returns a new Color4 object
  85252. */
  85253. clone(): Color4;
  85254. /**
  85255. * Copies the given Color4 values into the current one
  85256. * @param source defines the source Color4 object
  85257. * @returns the current updated Color4 object
  85258. */
  85259. copyFrom(source: Color4): Color4;
  85260. /**
  85261. * Copies the given float values into the current one
  85262. * @param r defines the red component to read from
  85263. * @param g defines the green component to read from
  85264. * @param b defines the blue component to read from
  85265. * @param a defines the alpha component to read from
  85266. * @returns the current updated Color4 object
  85267. */
  85268. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85269. /**
  85270. * Copies the given float values into the current one
  85271. * @param r defines the red component to read from
  85272. * @param g defines the green component to read from
  85273. * @param b defines the blue component to read from
  85274. * @param a defines the alpha component to read from
  85275. * @returns the current updated Color4 object
  85276. */
  85277. set(r: number, g: number, b: number, a: number): Color4;
  85278. /**
  85279. * Compute the Color4 hexadecimal code as a string
  85280. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85281. * @returns a string containing the hexadecimal representation of the Color4 object
  85282. */
  85283. toHexString(returnAsColor3?: boolean): string;
  85284. /**
  85285. * Computes a new Color4 converted from the current one to linear space
  85286. * @returns a new Color4 object
  85287. */
  85288. toLinearSpace(): Color4;
  85289. /**
  85290. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85291. * @param convertedColor defines the Color4 object where to store the linear space version
  85292. * @returns the unmodified Color4
  85293. */
  85294. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85295. /**
  85296. * Computes a new Color4 converted from the current one to gamma space
  85297. * @returns a new Color4 object
  85298. */
  85299. toGammaSpace(): Color4;
  85300. /**
  85301. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85302. * @param convertedColor defines the Color4 object where to store the gamma space version
  85303. * @returns the unmodified Color4
  85304. */
  85305. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85306. /**
  85307. * Creates a new Color4 from the string containing valid hexadecimal values
  85308. * @param hex defines a string containing valid hexadecimal values
  85309. * @returns a new Color4 object
  85310. */
  85311. static FromHexString(hex: string): Color4;
  85312. /**
  85313. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85314. * @param left defines the start value
  85315. * @param right defines the end value
  85316. * @param amount defines the gradient factor
  85317. * @returns a new Color4 object
  85318. */
  85319. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85320. /**
  85321. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85322. * @param left defines the start value
  85323. * @param right defines the end value
  85324. * @param amount defines the gradient factor
  85325. * @param result defines the Color4 object where to store data
  85326. */
  85327. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85328. /**
  85329. * Creates a new Color4 from a Color3 and an alpha value
  85330. * @param color3 defines the source Color3 to read from
  85331. * @param alpha defines the alpha component (1.0 by default)
  85332. * @returns a new Color4 object
  85333. */
  85334. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85335. /**
  85336. * Creates a new Color4 from the starting index element of the given array
  85337. * @param array defines the source array to read from
  85338. * @param offset defines the offset in the source array
  85339. * @returns a new Color4 object
  85340. */
  85341. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85342. /**
  85343. * Creates a new Color4 from the starting index element of the given array
  85344. * @param array defines the source array to read from
  85345. * @param offset defines the offset in the source array
  85346. * @param result defines the target Color4 object
  85347. */
  85348. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85349. /**
  85350. * Creates a new Color3 from integer values (< 256)
  85351. * @param r defines the red component to read from (value between 0 and 255)
  85352. * @param g defines the green component to read from (value between 0 and 255)
  85353. * @param b defines the blue component to read from (value between 0 and 255)
  85354. * @param a defines the alpha component to read from (value between 0 and 255)
  85355. * @returns a new Color3 object
  85356. */
  85357. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85358. /**
  85359. * Check the content of a given array and convert it to an array containing RGBA data
  85360. * If the original array was already containing count * 4 values then it is returned directly
  85361. * @param colors defines the array to check
  85362. * @param count defines the number of RGBA data to expect
  85363. * @returns an array containing count * 4 values (RGBA)
  85364. */
  85365. static CheckColors4(colors: number[], count: number): number[];
  85366. }
  85367. /**
  85368. * @hidden
  85369. */
  85370. export class TmpColors {
  85371. static Color3: Color3[];
  85372. static Color4: Color4[];
  85373. }
  85374. }
  85375. declare module BABYLON {
  85376. /**
  85377. * Defines an interface which represents an animation key frame
  85378. */
  85379. export interface IAnimationKey {
  85380. /**
  85381. * Frame of the key frame
  85382. */
  85383. frame: number;
  85384. /**
  85385. * Value at the specifies key frame
  85386. */
  85387. value: any;
  85388. /**
  85389. * The input tangent for the cubic hermite spline
  85390. */
  85391. inTangent?: any;
  85392. /**
  85393. * The output tangent for the cubic hermite spline
  85394. */
  85395. outTangent?: any;
  85396. /**
  85397. * The animation interpolation type
  85398. */
  85399. interpolation?: AnimationKeyInterpolation;
  85400. }
  85401. /**
  85402. * Enum for the animation key frame interpolation type
  85403. */
  85404. export enum AnimationKeyInterpolation {
  85405. /**
  85406. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85407. */
  85408. STEP = 1
  85409. }
  85410. }
  85411. declare module BABYLON {
  85412. /**
  85413. * Represents the range of an animation
  85414. */
  85415. export class AnimationRange {
  85416. /**The name of the animation range**/
  85417. name: string;
  85418. /**The starting frame of the animation */
  85419. from: number;
  85420. /**The ending frame of the animation*/
  85421. to: number;
  85422. /**
  85423. * Initializes the range of an animation
  85424. * @param name The name of the animation range
  85425. * @param from The starting frame of the animation
  85426. * @param to The ending frame of the animation
  85427. */
  85428. constructor(
  85429. /**The name of the animation range**/
  85430. name: string,
  85431. /**The starting frame of the animation */
  85432. from: number,
  85433. /**The ending frame of the animation*/
  85434. to: number);
  85435. /**
  85436. * Makes a copy of the animation range
  85437. * @returns A copy of the animation range
  85438. */
  85439. clone(): AnimationRange;
  85440. }
  85441. }
  85442. declare module BABYLON {
  85443. /**
  85444. * Composed of a frame, and an action function
  85445. */
  85446. export class AnimationEvent {
  85447. /** The frame for which the event is triggered **/
  85448. frame: number;
  85449. /** The event to perform when triggered **/
  85450. action: (currentFrame: number) => void;
  85451. /** Specifies if the event should be triggered only once**/
  85452. onlyOnce?: boolean | undefined;
  85453. /**
  85454. * Specifies if the animation event is done
  85455. */
  85456. isDone: boolean;
  85457. /**
  85458. * Initializes the animation event
  85459. * @param frame The frame for which the event is triggered
  85460. * @param action The event to perform when triggered
  85461. * @param onlyOnce Specifies if the event should be triggered only once
  85462. */
  85463. constructor(
  85464. /** The frame for which the event is triggered **/
  85465. frame: number,
  85466. /** The event to perform when triggered **/
  85467. action: (currentFrame: number) => void,
  85468. /** Specifies if the event should be triggered only once**/
  85469. onlyOnce?: boolean | undefined);
  85470. /** @hidden */
  85471. _clone(): AnimationEvent;
  85472. }
  85473. }
  85474. declare module BABYLON {
  85475. /**
  85476. * Interface used to define a behavior
  85477. */
  85478. export interface Behavior<T> {
  85479. /** gets or sets behavior's name */
  85480. name: string;
  85481. /**
  85482. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85483. */
  85484. init(): void;
  85485. /**
  85486. * Called when the behavior is attached to a target
  85487. * @param target defines the target where the behavior is attached to
  85488. */
  85489. attach(target: T): void;
  85490. /**
  85491. * Called when the behavior is detached from its target
  85492. */
  85493. detach(): void;
  85494. }
  85495. /**
  85496. * Interface implemented by classes supporting behaviors
  85497. */
  85498. export interface IBehaviorAware<T> {
  85499. /**
  85500. * Attach a behavior
  85501. * @param behavior defines the behavior to attach
  85502. * @returns the current host
  85503. */
  85504. addBehavior(behavior: Behavior<T>): T;
  85505. /**
  85506. * Remove a behavior from the current object
  85507. * @param behavior defines the behavior to detach
  85508. * @returns the current host
  85509. */
  85510. removeBehavior(behavior: Behavior<T>): T;
  85511. /**
  85512. * Gets a behavior using its name to search
  85513. * @param name defines the name to search
  85514. * @returns the behavior or null if not found
  85515. */
  85516. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85517. }
  85518. }
  85519. declare module BABYLON {
  85520. /**
  85521. * Defines an array and its length.
  85522. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85523. */
  85524. export interface ISmartArrayLike<T> {
  85525. /**
  85526. * The data of the array.
  85527. */
  85528. data: Array<T>;
  85529. /**
  85530. * The active length of the array.
  85531. */
  85532. length: number;
  85533. }
  85534. /**
  85535. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85536. */
  85537. export class SmartArray<T> implements ISmartArrayLike<T> {
  85538. /**
  85539. * The full set of data from the array.
  85540. */
  85541. data: Array<T>;
  85542. /**
  85543. * The active length of the array.
  85544. */
  85545. length: number;
  85546. protected _id: number;
  85547. /**
  85548. * Instantiates a Smart Array.
  85549. * @param capacity defines the default capacity of the array.
  85550. */
  85551. constructor(capacity: number);
  85552. /**
  85553. * Pushes a value at the end of the active data.
  85554. * @param value defines the object to push in the array.
  85555. */
  85556. push(value: T): void;
  85557. /**
  85558. * Iterates over the active data and apply the lambda to them.
  85559. * @param func defines the action to apply on each value.
  85560. */
  85561. forEach(func: (content: T) => void): void;
  85562. /**
  85563. * Sorts the full sets of data.
  85564. * @param compareFn defines the comparison function to apply.
  85565. */
  85566. sort(compareFn: (a: T, b: T) => number): void;
  85567. /**
  85568. * Resets the active data to an empty array.
  85569. */
  85570. reset(): void;
  85571. /**
  85572. * Releases all the data from the array as well as the array.
  85573. */
  85574. dispose(): void;
  85575. /**
  85576. * Concats the active data with a given array.
  85577. * @param array defines the data to concatenate with.
  85578. */
  85579. concat(array: any): void;
  85580. /**
  85581. * Returns the position of a value in the active data.
  85582. * @param value defines the value to find the index for
  85583. * @returns the index if found in the active data otherwise -1
  85584. */
  85585. indexOf(value: T): number;
  85586. /**
  85587. * Returns whether an element is part of the active data.
  85588. * @param value defines the value to look for
  85589. * @returns true if found in the active data otherwise false
  85590. */
  85591. contains(value: T): boolean;
  85592. private static _GlobalId;
  85593. }
  85594. /**
  85595. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85596. * The data in this array can only be present once
  85597. */
  85598. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85599. private _duplicateId;
  85600. /**
  85601. * Pushes a value at the end of the active data.
  85602. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85603. * @param value defines the object to push in the array.
  85604. */
  85605. push(value: T): void;
  85606. /**
  85607. * Pushes a value at the end of the active data.
  85608. * If the data is already present, it won t be added again
  85609. * @param value defines the object to push in the array.
  85610. * @returns true if added false if it was already present
  85611. */
  85612. pushNoDuplicate(value: T): boolean;
  85613. /**
  85614. * Resets the active data to an empty array.
  85615. */
  85616. reset(): void;
  85617. /**
  85618. * Concats the active data with a given array.
  85619. * This ensures no dupplicate will be present in the result.
  85620. * @param array defines the data to concatenate with.
  85621. */
  85622. concatWithNoDuplicate(array: any): void;
  85623. }
  85624. }
  85625. declare module BABYLON {
  85626. /**
  85627. * @ignore
  85628. * This is a list of all the different input types that are available in the application.
  85629. * Fo instance: ArcRotateCameraGamepadInput...
  85630. */
  85631. export var CameraInputTypes: {};
  85632. /**
  85633. * This is the contract to implement in order to create a new input class.
  85634. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85635. */
  85636. export interface ICameraInput<TCamera extends Camera> {
  85637. /**
  85638. * Defines the camera the input is attached to.
  85639. */
  85640. camera: Nullable<TCamera>;
  85641. /**
  85642. * Gets the class name of the current intput.
  85643. * @returns the class name
  85644. */
  85645. getClassName(): string;
  85646. /**
  85647. * Get the friendly name associated with the input class.
  85648. * @returns the input friendly name
  85649. */
  85650. getSimpleName(): string;
  85651. /**
  85652. * Attach the input controls to a specific dom element to get the input from.
  85653. * @param element Defines the element the controls should be listened from
  85654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85655. */
  85656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85657. /**
  85658. * Detach the current controls from the specified dom element.
  85659. * @param element Defines the element to stop listening the inputs from
  85660. */
  85661. detachControl(element: Nullable<HTMLElement>): void;
  85662. /**
  85663. * Update the current camera state depending on the inputs that have been used this frame.
  85664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85665. */
  85666. checkInputs?: () => void;
  85667. }
  85668. /**
  85669. * Represents a map of input types to input instance or input index to input instance.
  85670. */
  85671. export interface CameraInputsMap<TCamera extends Camera> {
  85672. /**
  85673. * Accessor to the input by input type.
  85674. */
  85675. [name: string]: ICameraInput<TCamera>;
  85676. /**
  85677. * Accessor to the input by input index.
  85678. */
  85679. [idx: number]: ICameraInput<TCamera>;
  85680. }
  85681. /**
  85682. * This represents the input manager used within a camera.
  85683. * It helps dealing with all the different kind of input attached to a camera.
  85684. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85685. */
  85686. export class CameraInputsManager<TCamera extends Camera> {
  85687. /**
  85688. * Defines the list of inputs attahed to the camera.
  85689. */
  85690. attached: CameraInputsMap<TCamera>;
  85691. /**
  85692. * Defines the dom element the camera is collecting inputs from.
  85693. * This is null if the controls have not been attached.
  85694. */
  85695. attachedElement: Nullable<HTMLElement>;
  85696. /**
  85697. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85698. */
  85699. noPreventDefault: boolean;
  85700. /**
  85701. * Defined the camera the input manager belongs to.
  85702. */
  85703. camera: TCamera;
  85704. /**
  85705. * Update the current camera state depending on the inputs that have been used this frame.
  85706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85707. */
  85708. checkInputs: () => void;
  85709. /**
  85710. * Instantiate a new Camera Input Manager.
  85711. * @param camera Defines the camera the input manager blongs to
  85712. */
  85713. constructor(camera: TCamera);
  85714. /**
  85715. * Add an input method to a camera
  85716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85717. * @param input camera input method
  85718. */
  85719. add(input: ICameraInput<TCamera>): void;
  85720. /**
  85721. * Remove a specific input method from a camera
  85722. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85723. * @param inputToRemove camera input method
  85724. */
  85725. remove(inputToRemove: ICameraInput<TCamera>): void;
  85726. /**
  85727. * Remove a specific input type from a camera
  85728. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85729. * @param inputType the type of the input to remove
  85730. */
  85731. removeByType(inputType: string): void;
  85732. private _addCheckInputs;
  85733. /**
  85734. * Attach the input controls to the currently attached dom element to listen the events from.
  85735. * @param input Defines the input to attach
  85736. */
  85737. attachInput(input: ICameraInput<TCamera>): void;
  85738. /**
  85739. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85740. * @param element Defines the dom element to collect the events from
  85741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85742. */
  85743. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85744. /**
  85745. * Detach the current manager inputs controls from a specific dom element.
  85746. * @param element Defines the dom element to collect the events from
  85747. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85748. */
  85749. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85750. /**
  85751. * Rebuild the dynamic inputCheck function from the current list of
  85752. * defined inputs in the manager.
  85753. */
  85754. rebuildInputCheck(): void;
  85755. /**
  85756. * Remove all attached input methods from a camera
  85757. */
  85758. clear(): void;
  85759. /**
  85760. * Serialize the current input manager attached to a camera.
  85761. * This ensures than once parsed,
  85762. * the input associated to the camera will be identical to the current ones
  85763. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85764. */
  85765. serialize(serializedCamera: any): void;
  85766. /**
  85767. * Parses an input manager serialized JSON to restore the previous list of inputs
  85768. * and states associated to a camera.
  85769. * @param parsedCamera Defines the JSON to parse
  85770. */
  85771. parse(parsedCamera: any): void;
  85772. }
  85773. }
  85774. declare module BABYLON {
  85775. /**
  85776. * Class used to store data that will be store in GPU memory
  85777. */
  85778. export class Buffer {
  85779. private _engine;
  85780. private _buffer;
  85781. /** @hidden */
  85782. _data: Nullable<DataArray>;
  85783. private _updatable;
  85784. private _instanced;
  85785. private _divisor;
  85786. /**
  85787. * Gets the byte stride.
  85788. */
  85789. readonly byteStride: number;
  85790. /**
  85791. * Constructor
  85792. * @param engine the engine
  85793. * @param data the data to use for this buffer
  85794. * @param updatable whether the data is updatable
  85795. * @param stride the stride (optional)
  85796. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85797. * @param instanced whether the buffer is instanced (optional)
  85798. * @param useBytes set to true if the stride in in bytes (optional)
  85799. * @param divisor sets an optional divisor for instances (1 by default)
  85800. */
  85801. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85802. /**
  85803. * Create a new VertexBuffer based on the current buffer
  85804. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85805. * @param offset defines offset in the buffer (0 by default)
  85806. * @param size defines the size in floats of attributes (position is 3 for instance)
  85807. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85808. * @param instanced defines if the vertex buffer contains indexed data
  85809. * @param useBytes defines if the offset and stride are in bytes *
  85810. * @param divisor sets an optional divisor for instances (1 by default)
  85811. * @returns the new vertex buffer
  85812. */
  85813. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85814. /**
  85815. * Gets a boolean indicating if the Buffer is updatable?
  85816. * @returns true if the buffer is updatable
  85817. */
  85818. isUpdatable(): boolean;
  85819. /**
  85820. * Gets current buffer's data
  85821. * @returns a DataArray or null
  85822. */
  85823. getData(): Nullable<DataArray>;
  85824. /**
  85825. * Gets underlying native buffer
  85826. * @returns underlying native buffer
  85827. */
  85828. getBuffer(): Nullable<DataBuffer>;
  85829. /**
  85830. * Gets the stride in float32 units (i.e. byte stride / 4).
  85831. * May not be an integer if the byte stride is not divisible by 4.
  85832. * @returns the stride in float32 units
  85833. * @deprecated Please use byteStride instead.
  85834. */
  85835. getStrideSize(): number;
  85836. /**
  85837. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85838. * @param data defines the data to store
  85839. */
  85840. create(data?: Nullable<DataArray>): void;
  85841. /** @hidden */
  85842. _rebuild(): void;
  85843. /**
  85844. * Update current buffer data
  85845. * @param data defines the data to store
  85846. */
  85847. update(data: DataArray): void;
  85848. /**
  85849. * Updates the data directly.
  85850. * @param data the new data
  85851. * @param offset the new offset
  85852. * @param vertexCount the vertex count (optional)
  85853. * @param useBytes set to true if the offset is in bytes
  85854. */
  85855. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85856. /**
  85857. * Release all resources
  85858. */
  85859. dispose(): void;
  85860. }
  85861. /**
  85862. * Specialized buffer used to store vertex data
  85863. */
  85864. export class VertexBuffer {
  85865. /** @hidden */
  85866. _buffer: Buffer;
  85867. private _kind;
  85868. private _size;
  85869. private _ownsBuffer;
  85870. private _instanced;
  85871. private _instanceDivisor;
  85872. /**
  85873. * The byte type.
  85874. */
  85875. static readonly BYTE: number;
  85876. /**
  85877. * The unsigned byte type.
  85878. */
  85879. static readonly UNSIGNED_BYTE: number;
  85880. /**
  85881. * The short type.
  85882. */
  85883. static readonly SHORT: number;
  85884. /**
  85885. * The unsigned short type.
  85886. */
  85887. static readonly UNSIGNED_SHORT: number;
  85888. /**
  85889. * The integer type.
  85890. */
  85891. static readonly INT: number;
  85892. /**
  85893. * The unsigned integer type.
  85894. */
  85895. static readonly UNSIGNED_INT: number;
  85896. /**
  85897. * The float type.
  85898. */
  85899. static readonly FLOAT: number;
  85900. /**
  85901. * Gets or sets the instance divisor when in instanced mode
  85902. */
  85903. get instanceDivisor(): number;
  85904. set instanceDivisor(value: number);
  85905. /**
  85906. * Gets the byte stride.
  85907. */
  85908. readonly byteStride: number;
  85909. /**
  85910. * Gets the byte offset.
  85911. */
  85912. readonly byteOffset: number;
  85913. /**
  85914. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85915. */
  85916. readonly normalized: boolean;
  85917. /**
  85918. * Gets the data type of each component in the array.
  85919. */
  85920. readonly type: number;
  85921. /**
  85922. * Constructor
  85923. * @param engine the engine
  85924. * @param data the data to use for this vertex buffer
  85925. * @param kind the vertex buffer kind
  85926. * @param updatable whether the data is updatable
  85927. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85928. * @param stride the stride (optional)
  85929. * @param instanced whether the buffer is instanced (optional)
  85930. * @param offset the offset of the data (optional)
  85931. * @param size the number of components (optional)
  85932. * @param type the type of the component (optional)
  85933. * @param normalized whether the data contains normalized data (optional)
  85934. * @param useBytes set to true if stride and offset are in bytes (optional)
  85935. * @param divisor defines the instance divisor to use (1 by default)
  85936. */
  85937. 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);
  85938. /** @hidden */
  85939. _rebuild(): void;
  85940. /**
  85941. * Returns the kind of the VertexBuffer (string)
  85942. * @returns a string
  85943. */
  85944. getKind(): string;
  85945. /**
  85946. * Gets a boolean indicating if the VertexBuffer is updatable?
  85947. * @returns true if the buffer is updatable
  85948. */
  85949. isUpdatable(): boolean;
  85950. /**
  85951. * Gets current buffer's data
  85952. * @returns a DataArray or null
  85953. */
  85954. getData(): Nullable<DataArray>;
  85955. /**
  85956. * Gets underlying native buffer
  85957. * @returns underlying native buffer
  85958. */
  85959. getBuffer(): Nullable<DataBuffer>;
  85960. /**
  85961. * Gets the stride in float32 units (i.e. byte stride / 4).
  85962. * May not be an integer if the byte stride is not divisible by 4.
  85963. * @returns the stride in float32 units
  85964. * @deprecated Please use byteStride instead.
  85965. */
  85966. getStrideSize(): number;
  85967. /**
  85968. * Returns the offset as a multiple of the type byte length.
  85969. * @returns the offset in bytes
  85970. * @deprecated Please use byteOffset instead.
  85971. */
  85972. getOffset(): number;
  85973. /**
  85974. * Returns the number of components per vertex attribute (integer)
  85975. * @returns the size in float
  85976. */
  85977. getSize(): number;
  85978. /**
  85979. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85980. * @returns true if this buffer is instanced
  85981. */
  85982. getIsInstanced(): boolean;
  85983. /**
  85984. * Returns the instancing divisor, zero for non-instanced (integer).
  85985. * @returns a number
  85986. */
  85987. getInstanceDivisor(): number;
  85988. /**
  85989. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85990. * @param data defines the data to store
  85991. */
  85992. create(data?: DataArray): void;
  85993. /**
  85994. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85995. * This function will create a new buffer if the current one is not updatable
  85996. * @param data defines the data to store
  85997. */
  85998. update(data: DataArray): void;
  85999. /**
  86000. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86001. * Returns the directly updated WebGLBuffer.
  86002. * @param data the new data
  86003. * @param offset the new offset
  86004. * @param useBytes set to true if the offset is in bytes
  86005. */
  86006. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86007. /**
  86008. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86009. */
  86010. dispose(): void;
  86011. /**
  86012. * Enumerates each value of this vertex buffer as numbers.
  86013. * @param count the number of values to enumerate
  86014. * @param callback the callback function called for each value
  86015. */
  86016. forEach(count: number, callback: (value: number, index: number) => void): void;
  86017. /**
  86018. * Positions
  86019. */
  86020. static readonly PositionKind: string;
  86021. /**
  86022. * Normals
  86023. */
  86024. static readonly NormalKind: string;
  86025. /**
  86026. * Tangents
  86027. */
  86028. static readonly TangentKind: string;
  86029. /**
  86030. * Texture coordinates
  86031. */
  86032. static readonly UVKind: string;
  86033. /**
  86034. * Texture coordinates 2
  86035. */
  86036. static readonly UV2Kind: string;
  86037. /**
  86038. * Texture coordinates 3
  86039. */
  86040. static readonly UV3Kind: string;
  86041. /**
  86042. * Texture coordinates 4
  86043. */
  86044. static readonly UV4Kind: string;
  86045. /**
  86046. * Texture coordinates 5
  86047. */
  86048. static readonly UV5Kind: string;
  86049. /**
  86050. * Texture coordinates 6
  86051. */
  86052. static readonly UV6Kind: string;
  86053. /**
  86054. * Colors
  86055. */
  86056. static readonly ColorKind: string;
  86057. /**
  86058. * Matrix indices (for bones)
  86059. */
  86060. static readonly MatricesIndicesKind: string;
  86061. /**
  86062. * Matrix weights (for bones)
  86063. */
  86064. static readonly MatricesWeightsKind: string;
  86065. /**
  86066. * Additional matrix indices (for bones)
  86067. */
  86068. static readonly MatricesIndicesExtraKind: string;
  86069. /**
  86070. * Additional matrix weights (for bones)
  86071. */
  86072. static readonly MatricesWeightsExtraKind: string;
  86073. /**
  86074. * Deduces the stride given a kind.
  86075. * @param kind The kind string to deduce
  86076. * @returns The deduced stride
  86077. */
  86078. static DeduceStride(kind: string): number;
  86079. /**
  86080. * Gets the byte length of the given type.
  86081. * @param type the type
  86082. * @returns the number of bytes
  86083. */
  86084. static GetTypeByteLength(type: number): number;
  86085. /**
  86086. * Enumerates each value of the given parameters as numbers.
  86087. * @param data the data to enumerate
  86088. * @param byteOffset the byte offset of the data
  86089. * @param byteStride the byte stride of the data
  86090. * @param componentCount the number of components per element
  86091. * @param componentType the type of the component
  86092. * @param count the number of values to enumerate
  86093. * @param normalized whether the data is normalized
  86094. * @param callback the callback function called for each value
  86095. */
  86096. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86097. private static _GetFloatValue;
  86098. }
  86099. }
  86100. declare module BABYLON {
  86101. /**
  86102. * @hidden
  86103. */
  86104. export class IntersectionInfo {
  86105. bu: Nullable<number>;
  86106. bv: Nullable<number>;
  86107. distance: number;
  86108. faceId: number;
  86109. subMeshId: number;
  86110. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86111. }
  86112. }
  86113. declare module BABYLON {
  86114. /**
  86115. * Class used to store bounding sphere information
  86116. */
  86117. export class BoundingSphere {
  86118. /**
  86119. * Gets the center of the bounding sphere in local space
  86120. */
  86121. readonly center: Vector3;
  86122. /**
  86123. * Radius of the bounding sphere in local space
  86124. */
  86125. radius: number;
  86126. /**
  86127. * Gets the center of the bounding sphere in world space
  86128. */
  86129. readonly centerWorld: Vector3;
  86130. /**
  86131. * Radius of the bounding sphere in world space
  86132. */
  86133. radiusWorld: number;
  86134. /**
  86135. * Gets the minimum vector in local space
  86136. */
  86137. readonly minimum: Vector3;
  86138. /**
  86139. * Gets the maximum vector in local space
  86140. */
  86141. readonly maximum: Vector3;
  86142. private _worldMatrix;
  86143. private static readonly TmpVector3;
  86144. /**
  86145. * Creates a new bounding sphere
  86146. * @param min defines the minimum vector (in local space)
  86147. * @param max defines the maximum vector (in local space)
  86148. * @param worldMatrix defines the new world matrix
  86149. */
  86150. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86151. /**
  86152. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86153. * @param min defines the new minimum vector (in local space)
  86154. * @param max defines the new maximum vector (in local space)
  86155. * @param worldMatrix defines the new world matrix
  86156. */
  86157. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86158. /**
  86159. * Scale the current bounding sphere by applying a scale factor
  86160. * @param factor defines the scale factor to apply
  86161. * @returns the current bounding box
  86162. */
  86163. scale(factor: number): BoundingSphere;
  86164. /**
  86165. * Gets the world matrix of the bounding box
  86166. * @returns a matrix
  86167. */
  86168. getWorldMatrix(): DeepImmutable<Matrix>;
  86169. /** @hidden */
  86170. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86171. /**
  86172. * Tests if the bounding sphere is intersecting the frustum planes
  86173. * @param frustumPlanes defines the frustum planes to test
  86174. * @returns true if there is an intersection
  86175. */
  86176. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86177. /**
  86178. * Tests if the bounding sphere center is in between the frustum planes.
  86179. * Used for optimistic fast inclusion.
  86180. * @param frustumPlanes defines the frustum planes to test
  86181. * @returns true if the sphere center is in between the frustum planes
  86182. */
  86183. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86184. /**
  86185. * Tests if a point is inside the bounding sphere
  86186. * @param point defines the point to test
  86187. * @returns true if the point is inside the bounding sphere
  86188. */
  86189. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86190. /**
  86191. * Checks if two sphere intersct
  86192. * @param sphere0 sphere 0
  86193. * @param sphere1 sphere 1
  86194. * @returns true if the speres intersect
  86195. */
  86196. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86197. }
  86198. }
  86199. declare module BABYLON {
  86200. /**
  86201. * Class used to store bounding box information
  86202. */
  86203. export class BoundingBox implements ICullable {
  86204. /**
  86205. * Gets the 8 vectors representing the bounding box in local space
  86206. */
  86207. readonly vectors: Vector3[];
  86208. /**
  86209. * Gets the center of the bounding box in local space
  86210. */
  86211. readonly center: Vector3;
  86212. /**
  86213. * Gets the center of the bounding box in world space
  86214. */
  86215. readonly centerWorld: Vector3;
  86216. /**
  86217. * Gets the extend size in local space
  86218. */
  86219. readonly extendSize: Vector3;
  86220. /**
  86221. * Gets the extend size in world space
  86222. */
  86223. readonly extendSizeWorld: Vector3;
  86224. /**
  86225. * Gets the OBB (object bounding box) directions
  86226. */
  86227. readonly directions: Vector3[];
  86228. /**
  86229. * Gets the 8 vectors representing the bounding box in world space
  86230. */
  86231. readonly vectorsWorld: Vector3[];
  86232. /**
  86233. * Gets the minimum vector in world space
  86234. */
  86235. readonly minimumWorld: Vector3;
  86236. /**
  86237. * Gets the maximum vector in world space
  86238. */
  86239. readonly maximumWorld: Vector3;
  86240. /**
  86241. * Gets the minimum vector in local space
  86242. */
  86243. readonly minimum: Vector3;
  86244. /**
  86245. * Gets the maximum vector in local space
  86246. */
  86247. readonly maximum: Vector3;
  86248. private _worldMatrix;
  86249. private static readonly TmpVector3;
  86250. /**
  86251. * @hidden
  86252. */
  86253. _tag: number;
  86254. /**
  86255. * Creates a new bounding box
  86256. * @param min defines the minimum vector (in local space)
  86257. * @param max defines the maximum vector (in local space)
  86258. * @param worldMatrix defines the new world matrix
  86259. */
  86260. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86261. /**
  86262. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86263. * @param min defines the new minimum vector (in local space)
  86264. * @param max defines the new maximum vector (in local space)
  86265. * @param worldMatrix defines the new world matrix
  86266. */
  86267. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86268. /**
  86269. * Scale the current bounding box by applying a scale factor
  86270. * @param factor defines the scale factor to apply
  86271. * @returns the current bounding box
  86272. */
  86273. scale(factor: number): BoundingBox;
  86274. /**
  86275. * Gets the world matrix of the bounding box
  86276. * @returns a matrix
  86277. */
  86278. getWorldMatrix(): DeepImmutable<Matrix>;
  86279. /** @hidden */
  86280. _update(world: DeepImmutable<Matrix>): void;
  86281. /**
  86282. * Tests if the bounding box is intersecting the frustum planes
  86283. * @param frustumPlanes defines the frustum planes to test
  86284. * @returns true if there is an intersection
  86285. */
  86286. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86287. /**
  86288. * Tests if the bounding box is entirely inside the frustum planes
  86289. * @param frustumPlanes defines the frustum planes to test
  86290. * @returns true if there is an inclusion
  86291. */
  86292. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86293. /**
  86294. * Tests if a point is inside the bounding box
  86295. * @param point defines the point to test
  86296. * @returns true if the point is inside the bounding box
  86297. */
  86298. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86299. /**
  86300. * Tests if the bounding box intersects with a bounding sphere
  86301. * @param sphere defines the sphere to test
  86302. * @returns true if there is an intersection
  86303. */
  86304. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86305. /**
  86306. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86307. * @param min defines the min vector to use
  86308. * @param max defines the max vector to use
  86309. * @returns true if there is an intersection
  86310. */
  86311. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86312. /**
  86313. * Tests if two bounding boxes are intersections
  86314. * @param box0 defines the first box to test
  86315. * @param box1 defines the second box to test
  86316. * @returns true if there is an intersection
  86317. */
  86318. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86319. /**
  86320. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86321. * @param minPoint defines the minimum vector of the bounding box
  86322. * @param maxPoint defines the maximum vector of the bounding box
  86323. * @param sphereCenter defines the sphere center
  86324. * @param sphereRadius defines the sphere radius
  86325. * @returns true if there is an intersection
  86326. */
  86327. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86328. /**
  86329. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86330. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86331. * @param frustumPlanes defines the frustum planes to test
  86332. * @return true if there is an inclusion
  86333. */
  86334. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86335. /**
  86336. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86337. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86338. * @param frustumPlanes defines the frustum planes to test
  86339. * @return true if there is an intersection
  86340. */
  86341. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86342. }
  86343. }
  86344. declare module BABYLON {
  86345. /** @hidden */
  86346. export class Collider {
  86347. /** Define if a collision was found */
  86348. collisionFound: boolean;
  86349. /**
  86350. * Define last intersection point in local space
  86351. */
  86352. intersectionPoint: Vector3;
  86353. /**
  86354. * Define last collided mesh
  86355. */
  86356. collidedMesh: Nullable<AbstractMesh>;
  86357. private _collisionPoint;
  86358. private _planeIntersectionPoint;
  86359. private _tempVector;
  86360. private _tempVector2;
  86361. private _tempVector3;
  86362. private _tempVector4;
  86363. private _edge;
  86364. private _baseToVertex;
  86365. private _destinationPoint;
  86366. private _slidePlaneNormal;
  86367. private _displacementVector;
  86368. /** @hidden */
  86369. _radius: Vector3;
  86370. /** @hidden */
  86371. _retry: number;
  86372. private _velocity;
  86373. private _basePoint;
  86374. private _epsilon;
  86375. /** @hidden */
  86376. _velocityWorldLength: number;
  86377. /** @hidden */
  86378. _basePointWorld: Vector3;
  86379. private _velocityWorld;
  86380. private _normalizedVelocity;
  86381. /** @hidden */
  86382. _initialVelocity: Vector3;
  86383. /** @hidden */
  86384. _initialPosition: Vector3;
  86385. private _nearestDistance;
  86386. private _collisionMask;
  86387. get collisionMask(): number;
  86388. set collisionMask(mask: number);
  86389. /**
  86390. * Gets the plane normal used to compute the sliding response (in local space)
  86391. */
  86392. get slidePlaneNormal(): Vector3;
  86393. /** @hidden */
  86394. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86395. /** @hidden */
  86396. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86397. /** @hidden */
  86398. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86399. /** @hidden */
  86400. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86401. /** @hidden */
  86402. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86403. /** @hidden */
  86404. _getResponse(pos: Vector3, vel: Vector3): void;
  86405. }
  86406. }
  86407. declare module BABYLON {
  86408. /**
  86409. * Interface for cullable objects
  86410. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86411. */
  86412. export interface ICullable {
  86413. /**
  86414. * Checks if the object or part of the object is in the frustum
  86415. * @param frustumPlanes Camera near/planes
  86416. * @returns true if the object is in frustum otherwise false
  86417. */
  86418. isInFrustum(frustumPlanes: Plane[]): boolean;
  86419. /**
  86420. * Checks if a cullable object (mesh...) is in the camera frustum
  86421. * Unlike isInFrustum this cheks the full bounding box
  86422. * @param frustumPlanes Camera near/planes
  86423. * @returns true if the object is in frustum otherwise false
  86424. */
  86425. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86426. }
  86427. /**
  86428. * Info for a bounding data of a mesh
  86429. */
  86430. export class BoundingInfo implements ICullable {
  86431. /**
  86432. * Bounding box for the mesh
  86433. */
  86434. readonly boundingBox: BoundingBox;
  86435. /**
  86436. * Bounding sphere for the mesh
  86437. */
  86438. readonly boundingSphere: BoundingSphere;
  86439. private _isLocked;
  86440. private static readonly TmpVector3;
  86441. /**
  86442. * Constructs bounding info
  86443. * @param minimum min vector of the bounding box/sphere
  86444. * @param maximum max vector of the bounding box/sphere
  86445. * @param worldMatrix defines the new world matrix
  86446. */
  86447. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86448. /**
  86449. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86450. * @param min defines the new minimum vector (in local space)
  86451. * @param max defines the new maximum vector (in local space)
  86452. * @param worldMatrix defines the new world matrix
  86453. */
  86454. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86455. /**
  86456. * min vector of the bounding box/sphere
  86457. */
  86458. get minimum(): Vector3;
  86459. /**
  86460. * max vector of the bounding box/sphere
  86461. */
  86462. get maximum(): Vector3;
  86463. /**
  86464. * If the info is locked and won't be updated to avoid perf overhead
  86465. */
  86466. get isLocked(): boolean;
  86467. set isLocked(value: boolean);
  86468. /**
  86469. * Updates the bounding sphere and box
  86470. * @param world world matrix to be used to update
  86471. */
  86472. update(world: DeepImmutable<Matrix>): void;
  86473. /**
  86474. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86475. * @param center New center of the bounding info
  86476. * @param extend New extend of the bounding info
  86477. * @returns the current bounding info
  86478. */
  86479. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86480. /**
  86481. * Scale the current bounding info by applying a scale factor
  86482. * @param factor defines the scale factor to apply
  86483. * @returns the current bounding info
  86484. */
  86485. scale(factor: number): BoundingInfo;
  86486. /**
  86487. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86488. * @param frustumPlanes defines the frustum to test
  86489. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86490. * @returns true if the bounding info is in the frustum planes
  86491. */
  86492. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86493. /**
  86494. * Gets the world distance between the min and max points of the bounding box
  86495. */
  86496. get diagonalLength(): number;
  86497. /**
  86498. * Checks if a cullable object (mesh...) is in the camera frustum
  86499. * Unlike isInFrustum this cheks the full bounding box
  86500. * @param frustumPlanes Camera near/planes
  86501. * @returns true if the object is in frustum otherwise false
  86502. */
  86503. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86504. /** @hidden */
  86505. _checkCollision(collider: Collider): boolean;
  86506. /**
  86507. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86509. * @param point the point to check intersection with
  86510. * @returns if the point intersects
  86511. */
  86512. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86513. /**
  86514. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86515. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86516. * @param boundingInfo the bounding info to check intersection with
  86517. * @param precise if the intersection should be done using OBB
  86518. * @returns if the bounding info intersects
  86519. */
  86520. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86521. }
  86522. }
  86523. declare module BABYLON {
  86524. /**
  86525. * Extracts minimum and maximum values from a list of indexed positions
  86526. * @param positions defines the positions to use
  86527. * @param indices defines the indices to the positions
  86528. * @param indexStart defines the start index
  86529. * @param indexCount defines the end index
  86530. * @param bias defines bias value to add to the result
  86531. * @return minimum and maximum values
  86532. */
  86533. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86534. minimum: Vector3;
  86535. maximum: Vector3;
  86536. };
  86537. /**
  86538. * Extracts minimum and maximum values from a list of positions
  86539. * @param positions defines the positions to use
  86540. * @param start defines the start index in the positions array
  86541. * @param count defines the number of positions to handle
  86542. * @param bias defines bias value to add to the result
  86543. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86544. * @return minimum and maximum values
  86545. */
  86546. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86547. minimum: Vector3;
  86548. maximum: Vector3;
  86549. };
  86550. }
  86551. declare module BABYLON {
  86552. /** @hidden */
  86553. export class WebGLDataBuffer extends DataBuffer {
  86554. private _buffer;
  86555. constructor(resource: WebGLBuffer);
  86556. get underlyingResource(): any;
  86557. }
  86558. }
  86559. declare module BABYLON {
  86560. /** @hidden */
  86561. export class WebGLPipelineContext implements IPipelineContext {
  86562. engine: ThinEngine;
  86563. program: Nullable<WebGLProgram>;
  86564. context?: WebGLRenderingContext;
  86565. vertexShader?: WebGLShader;
  86566. fragmentShader?: WebGLShader;
  86567. isParallelCompiled: boolean;
  86568. onCompiled?: () => void;
  86569. transformFeedback?: WebGLTransformFeedback | null;
  86570. vertexCompilationError: Nullable<string>;
  86571. fragmentCompilationError: Nullable<string>;
  86572. programLinkError: Nullable<string>;
  86573. programValidationError: Nullable<string>;
  86574. get isAsync(): boolean;
  86575. get isReady(): boolean;
  86576. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86577. _getVertexShaderCode(): string | null;
  86578. _getFragmentShaderCode(): string | null;
  86579. }
  86580. }
  86581. declare module BABYLON {
  86582. interface ThinEngine {
  86583. /**
  86584. * Create an uniform buffer
  86585. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86586. * @param elements defines the content of the uniform buffer
  86587. * @returns the webGL uniform buffer
  86588. */
  86589. createUniformBuffer(elements: FloatArray): DataBuffer;
  86590. /**
  86591. * Create a dynamic uniform buffer
  86592. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86593. * @param elements defines the content of the uniform buffer
  86594. * @returns the webGL uniform buffer
  86595. */
  86596. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86597. /**
  86598. * Update an existing uniform buffer
  86599. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86600. * @param uniformBuffer defines the target uniform buffer
  86601. * @param elements defines the content to update
  86602. * @param offset defines the offset in the uniform buffer where update should start
  86603. * @param count defines the size of the data to update
  86604. */
  86605. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86606. /**
  86607. * Bind an uniform buffer to the current webGL context
  86608. * @param buffer defines the buffer to bind
  86609. */
  86610. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86611. /**
  86612. * Bind a buffer to the current webGL context at a given location
  86613. * @param buffer defines the buffer to bind
  86614. * @param location defines the index where to bind the buffer
  86615. */
  86616. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86617. /**
  86618. * Bind a specific block at a given index in a specific shader program
  86619. * @param pipelineContext defines the pipeline context to use
  86620. * @param blockName defines the block name
  86621. * @param index defines the index where to bind the block
  86622. */
  86623. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86624. }
  86625. }
  86626. declare module BABYLON {
  86627. /**
  86628. * Uniform buffer objects.
  86629. *
  86630. * Handles blocks of uniform on the GPU.
  86631. *
  86632. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86633. *
  86634. * For more information, please refer to :
  86635. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86636. */
  86637. export class UniformBuffer {
  86638. private _engine;
  86639. private _buffer;
  86640. private _data;
  86641. private _bufferData;
  86642. private _dynamic?;
  86643. private _uniformLocations;
  86644. private _uniformSizes;
  86645. private _uniformLocationPointer;
  86646. private _needSync;
  86647. private _noUBO;
  86648. private _currentEffect;
  86649. /** @hidden */
  86650. _alreadyBound: boolean;
  86651. private static _MAX_UNIFORM_SIZE;
  86652. private static _tempBuffer;
  86653. /**
  86654. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86655. * This is dynamic to allow compat with webgl 1 and 2.
  86656. * You will need to pass the name of the uniform as well as the value.
  86657. */
  86658. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86659. /**
  86660. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86661. * This is dynamic to allow compat with webgl 1 and 2.
  86662. * You will need to pass the name of the uniform as well as the value.
  86663. */
  86664. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86665. /**
  86666. * Lambda to Update a single float in a uniform buffer.
  86667. * This is dynamic to allow compat with webgl 1 and 2.
  86668. * You will need to pass the name of the uniform as well as the value.
  86669. */
  86670. updateFloat: (name: string, x: number) => void;
  86671. /**
  86672. * Lambda to Update a vec2 of float in a uniform buffer.
  86673. * This is dynamic to allow compat with webgl 1 and 2.
  86674. * You will need to pass the name of the uniform as well as the value.
  86675. */
  86676. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86677. /**
  86678. * Lambda to Update a vec3 of float in a uniform buffer.
  86679. * This is dynamic to allow compat with webgl 1 and 2.
  86680. * You will need to pass the name of the uniform as well as the value.
  86681. */
  86682. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86683. /**
  86684. * Lambda to Update a vec4 of float in a uniform buffer.
  86685. * This is dynamic to allow compat with webgl 1 and 2.
  86686. * You will need to pass the name of the uniform as well as the value.
  86687. */
  86688. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86689. /**
  86690. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86691. * This is dynamic to allow compat with webgl 1 and 2.
  86692. * You will need to pass the name of the uniform as well as the value.
  86693. */
  86694. updateMatrix: (name: string, mat: Matrix) => void;
  86695. /**
  86696. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86697. * This is dynamic to allow compat with webgl 1 and 2.
  86698. * You will need to pass the name of the uniform as well as the value.
  86699. */
  86700. updateVector3: (name: string, vector: Vector3) => void;
  86701. /**
  86702. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86703. * This is dynamic to allow compat with webgl 1 and 2.
  86704. * You will need to pass the name of the uniform as well as the value.
  86705. */
  86706. updateVector4: (name: string, vector: Vector4) => void;
  86707. /**
  86708. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86709. * This is dynamic to allow compat with webgl 1 and 2.
  86710. * You will need to pass the name of the uniform as well as the value.
  86711. */
  86712. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86713. /**
  86714. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86715. * This is dynamic to allow compat with webgl 1 and 2.
  86716. * You will need to pass the name of the uniform as well as the value.
  86717. */
  86718. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86719. /**
  86720. * Instantiates a new Uniform buffer objects.
  86721. *
  86722. * Handles blocks of uniform on the GPU.
  86723. *
  86724. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86725. *
  86726. * For more information, please refer to :
  86727. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86728. * @param engine Define the engine the buffer is associated with
  86729. * @param data Define the data contained in the buffer
  86730. * @param dynamic Define if the buffer is updatable
  86731. */
  86732. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86733. /**
  86734. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86735. * or just falling back on setUniformXXX calls.
  86736. */
  86737. get useUbo(): boolean;
  86738. /**
  86739. * Indicates if the WebGL underlying uniform buffer is in sync
  86740. * with the javascript cache data.
  86741. */
  86742. get isSync(): boolean;
  86743. /**
  86744. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86745. * Also, a dynamic UniformBuffer will disable cache verification and always
  86746. * update the underlying WebGL uniform buffer to the GPU.
  86747. * @returns if Dynamic, otherwise false
  86748. */
  86749. isDynamic(): boolean;
  86750. /**
  86751. * The data cache on JS side.
  86752. * @returns the underlying data as a float array
  86753. */
  86754. getData(): Float32Array;
  86755. /**
  86756. * The underlying WebGL Uniform buffer.
  86757. * @returns the webgl buffer
  86758. */
  86759. getBuffer(): Nullable<DataBuffer>;
  86760. /**
  86761. * std140 layout specifies how to align data within an UBO structure.
  86762. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86763. * for specs.
  86764. */
  86765. private _fillAlignment;
  86766. /**
  86767. * Adds an uniform in the buffer.
  86768. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86769. * for the layout to be correct !
  86770. * @param name Name of the uniform, as used in the uniform block in the shader.
  86771. * @param size Data size, or data directly.
  86772. */
  86773. addUniform(name: string, size: number | number[]): void;
  86774. /**
  86775. * Adds a Matrix 4x4 to the uniform buffer.
  86776. * @param name Name of the uniform, as used in the uniform block in the shader.
  86777. * @param mat A 4x4 matrix.
  86778. */
  86779. addMatrix(name: string, mat: Matrix): void;
  86780. /**
  86781. * Adds a vec2 to the uniform buffer.
  86782. * @param name Name of the uniform, as used in the uniform block in the shader.
  86783. * @param x Define the x component value of the vec2
  86784. * @param y Define the y component value of the vec2
  86785. */
  86786. addFloat2(name: string, x: number, y: number): void;
  86787. /**
  86788. * Adds a vec3 to the uniform buffer.
  86789. * @param name Name of the uniform, as used in the uniform block in the shader.
  86790. * @param x Define the x component value of the vec3
  86791. * @param y Define the y component value of the vec3
  86792. * @param z Define the z component value of the vec3
  86793. */
  86794. addFloat3(name: string, x: number, y: number, z: number): void;
  86795. /**
  86796. * Adds a vec3 to the uniform buffer.
  86797. * @param name Name of the uniform, as used in the uniform block in the shader.
  86798. * @param color Define the vec3 from a Color
  86799. */
  86800. addColor3(name: string, color: Color3): void;
  86801. /**
  86802. * Adds a vec4 to the uniform buffer.
  86803. * @param name Name of the uniform, as used in the uniform block in the shader.
  86804. * @param color Define the rgb components from a Color
  86805. * @param alpha Define the a component of the vec4
  86806. */
  86807. addColor4(name: string, color: Color3, alpha: number): void;
  86808. /**
  86809. * Adds a vec3 to the uniform buffer.
  86810. * @param name Name of the uniform, as used in the uniform block in the shader.
  86811. * @param vector Define the vec3 components from a Vector
  86812. */
  86813. addVector3(name: string, vector: Vector3): void;
  86814. /**
  86815. * Adds a Matrix 3x3 to the uniform buffer.
  86816. * @param name Name of the uniform, as used in the uniform block in the shader.
  86817. */
  86818. addMatrix3x3(name: string): void;
  86819. /**
  86820. * Adds a Matrix 2x2 to the uniform buffer.
  86821. * @param name Name of the uniform, as used in the uniform block in the shader.
  86822. */
  86823. addMatrix2x2(name: string): void;
  86824. /**
  86825. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86826. */
  86827. create(): void;
  86828. /** @hidden */
  86829. _rebuild(): void;
  86830. /**
  86831. * Updates the WebGL Uniform Buffer on the GPU.
  86832. * If the `dynamic` flag is set to true, no cache comparison is done.
  86833. * Otherwise, the buffer will be updated only if the cache differs.
  86834. */
  86835. update(): void;
  86836. /**
  86837. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86838. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86839. * @param data Define the flattened data
  86840. * @param size Define the size of the data.
  86841. */
  86842. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86843. private _valueCache;
  86844. private _cacheMatrix;
  86845. private _updateMatrix3x3ForUniform;
  86846. private _updateMatrix3x3ForEffect;
  86847. private _updateMatrix2x2ForEffect;
  86848. private _updateMatrix2x2ForUniform;
  86849. private _updateFloatForEffect;
  86850. private _updateFloatForUniform;
  86851. private _updateFloat2ForEffect;
  86852. private _updateFloat2ForUniform;
  86853. private _updateFloat3ForEffect;
  86854. private _updateFloat3ForUniform;
  86855. private _updateFloat4ForEffect;
  86856. private _updateFloat4ForUniform;
  86857. private _updateMatrixForEffect;
  86858. private _updateMatrixForUniform;
  86859. private _updateVector3ForEffect;
  86860. private _updateVector3ForUniform;
  86861. private _updateVector4ForEffect;
  86862. private _updateVector4ForUniform;
  86863. private _updateColor3ForEffect;
  86864. private _updateColor3ForUniform;
  86865. private _updateColor4ForEffect;
  86866. private _updateColor4ForUniform;
  86867. /**
  86868. * Sets a sampler uniform on the effect.
  86869. * @param name Define the name of the sampler.
  86870. * @param texture Define the texture to set in the sampler
  86871. */
  86872. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86873. /**
  86874. * Directly updates the value of the uniform in the cache AND on the GPU.
  86875. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86876. * @param data Define the flattened data
  86877. */
  86878. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86879. /**
  86880. * Binds this uniform buffer to an effect.
  86881. * @param effect Define the effect to bind the buffer to
  86882. * @param name Name of the uniform block in the shader.
  86883. */
  86884. bindToEffect(effect: Effect, name: string): void;
  86885. /**
  86886. * Disposes the uniform buffer.
  86887. */
  86888. dispose(): void;
  86889. }
  86890. }
  86891. declare module BABYLON {
  86892. /**
  86893. * Enum that determines the text-wrapping mode to use.
  86894. */
  86895. export enum InspectableType {
  86896. /**
  86897. * Checkbox for booleans
  86898. */
  86899. Checkbox = 0,
  86900. /**
  86901. * Sliders for numbers
  86902. */
  86903. Slider = 1,
  86904. /**
  86905. * Vector3
  86906. */
  86907. Vector3 = 2,
  86908. /**
  86909. * Quaternions
  86910. */
  86911. Quaternion = 3,
  86912. /**
  86913. * Color3
  86914. */
  86915. Color3 = 4,
  86916. /**
  86917. * String
  86918. */
  86919. String = 5
  86920. }
  86921. /**
  86922. * Interface used to define custom inspectable properties.
  86923. * This interface is used by the inspector to display custom property grids
  86924. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86925. */
  86926. export interface IInspectable {
  86927. /**
  86928. * Gets the label to display
  86929. */
  86930. label: string;
  86931. /**
  86932. * Gets the name of the property to edit
  86933. */
  86934. propertyName: string;
  86935. /**
  86936. * Gets the type of the editor to use
  86937. */
  86938. type: InspectableType;
  86939. /**
  86940. * Gets the minimum value of the property when using in "slider" mode
  86941. */
  86942. min?: number;
  86943. /**
  86944. * Gets the maximum value of the property when using in "slider" mode
  86945. */
  86946. max?: number;
  86947. /**
  86948. * Gets the setp to use when using in "slider" mode
  86949. */
  86950. step?: number;
  86951. }
  86952. }
  86953. declare module BABYLON {
  86954. /**
  86955. * Class used to provide helper for timing
  86956. */
  86957. export class TimingTools {
  86958. /**
  86959. * Polyfill for setImmediate
  86960. * @param action defines the action to execute after the current execution block
  86961. */
  86962. static SetImmediate(action: () => void): void;
  86963. }
  86964. }
  86965. declare module BABYLON {
  86966. /**
  86967. * Class used to enable instatition of objects by class name
  86968. */
  86969. export class InstantiationTools {
  86970. /**
  86971. * Use this object to register external classes like custom textures or material
  86972. * to allow the laoders to instantiate them
  86973. */
  86974. static RegisteredExternalClasses: {
  86975. [key: string]: Object;
  86976. };
  86977. /**
  86978. * Tries to instantiate a new object from a given class name
  86979. * @param className defines the class name to instantiate
  86980. * @returns the new object or null if the system was not able to do the instantiation
  86981. */
  86982. static Instantiate(className: string): any;
  86983. }
  86984. }
  86985. declare module BABYLON {
  86986. /**
  86987. * Define options used to create a depth texture
  86988. */
  86989. export class DepthTextureCreationOptions {
  86990. /** Specifies whether or not a stencil should be allocated in the texture */
  86991. generateStencil?: boolean;
  86992. /** Specifies whether or not bilinear filtering is enable on the texture */
  86993. bilinearFiltering?: boolean;
  86994. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86995. comparisonFunction?: number;
  86996. /** Specifies if the created texture is a cube texture */
  86997. isCube?: boolean;
  86998. }
  86999. }
  87000. declare module BABYLON {
  87001. interface ThinEngine {
  87002. /**
  87003. * Creates a depth stencil cube texture.
  87004. * This is only available in WebGL 2.
  87005. * @param size The size of face edge in the cube texture.
  87006. * @param options The options defining the cube texture.
  87007. * @returns The cube texture
  87008. */
  87009. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87010. /**
  87011. * Creates a cube texture
  87012. * @param rootUrl defines the url where the files to load is located
  87013. * @param scene defines the current scene
  87014. * @param files defines the list of files to load (1 per face)
  87015. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87016. * @param onLoad defines an optional callback raised when the texture is loaded
  87017. * @param onError defines an optional callback raised if there is an issue to load the texture
  87018. * @param format defines the format of the data
  87019. * @param forcedExtension defines the extension to use to pick the right loader
  87020. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87021. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87022. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87023. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87024. * @returns the cube texture as an InternalTexture
  87025. */
  87026. 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;
  87027. /**
  87028. * Creates a cube texture
  87029. * @param rootUrl defines the url where the files to load is located
  87030. * @param scene defines the current scene
  87031. * @param files defines the list of files to load (1 per face)
  87032. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87033. * @param onLoad defines an optional callback raised when the texture is loaded
  87034. * @param onError defines an optional callback raised if there is an issue to load the texture
  87035. * @param format defines the format of the data
  87036. * @param forcedExtension defines the extension to use to pick the right loader
  87037. * @returns the cube texture as an InternalTexture
  87038. */
  87039. 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;
  87040. /**
  87041. * Creates a cube texture
  87042. * @param rootUrl defines the url where the files to load is located
  87043. * @param scene defines the current scene
  87044. * @param files defines the list of files to load (1 per face)
  87045. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87046. * @param onLoad defines an optional callback raised when the texture is loaded
  87047. * @param onError defines an optional callback raised if there is an issue to load the texture
  87048. * @param format defines the format of the data
  87049. * @param forcedExtension defines the extension to use to pick the right loader
  87050. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87051. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87052. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87053. * @returns the cube texture as an InternalTexture
  87054. */
  87055. 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;
  87056. /** @hidden */
  87057. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87058. /** @hidden */
  87059. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87060. /** @hidden */
  87061. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87062. /** @hidden */
  87063. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87064. /**
  87065. * @hidden
  87066. */
  87067. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87068. }
  87069. }
  87070. declare module BABYLON {
  87071. /**
  87072. * Class for creating a cube texture
  87073. */
  87074. export class CubeTexture extends BaseTexture {
  87075. private _delayedOnLoad;
  87076. /**
  87077. * Observable triggered once the texture has been loaded.
  87078. */
  87079. onLoadObservable: Observable<CubeTexture>;
  87080. /**
  87081. * The url of the texture
  87082. */
  87083. url: string;
  87084. /**
  87085. * Gets or sets the center of the bounding box associated with the cube texture.
  87086. * It must define where the camera used to render the texture was set
  87087. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87088. */
  87089. boundingBoxPosition: Vector3;
  87090. private _boundingBoxSize;
  87091. /**
  87092. * Gets or sets the size of the bounding box associated with the cube texture
  87093. * When defined, the cubemap will switch to local mode
  87094. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87095. * @example https://www.babylonjs-playground.com/#RNASML
  87096. */
  87097. set boundingBoxSize(value: Vector3);
  87098. /**
  87099. * Returns the bounding box size
  87100. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87101. */
  87102. get boundingBoxSize(): Vector3;
  87103. protected _rotationY: number;
  87104. /**
  87105. * Sets texture matrix rotation angle around Y axis in radians.
  87106. */
  87107. set rotationY(value: number);
  87108. /**
  87109. * Gets texture matrix rotation angle around Y axis radians.
  87110. */
  87111. get rotationY(): number;
  87112. /**
  87113. * Are mip maps generated for this texture or not.
  87114. */
  87115. get noMipmap(): boolean;
  87116. private _noMipmap;
  87117. private _files;
  87118. protected _forcedExtension: Nullable<string>;
  87119. private _extensions;
  87120. private _textureMatrix;
  87121. private _format;
  87122. private _createPolynomials;
  87123. /**
  87124. * Creates a cube texture from an array of image urls
  87125. * @param files defines an array of image urls
  87126. * @param scene defines the hosting scene
  87127. * @param noMipmap specifies if mip maps are not used
  87128. * @returns a cube texture
  87129. */
  87130. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87131. /**
  87132. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87133. * @param url defines the url of the prefiltered texture
  87134. * @param scene defines the scene the texture is attached to
  87135. * @param forcedExtension defines the extension of the file if different from the url
  87136. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87137. * @return the prefiltered texture
  87138. */
  87139. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87140. /**
  87141. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87142. * as prefiltered data.
  87143. * @param rootUrl defines the url of the texture or the root name of the six images
  87144. * @param null defines the scene or engine the texture is attached to
  87145. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87146. * @param noMipmap defines if mipmaps should be created or not
  87147. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87148. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87149. * @param onError defines a callback triggered in case of error during load
  87150. * @param format defines the internal format to use for the texture once loaded
  87151. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87152. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87153. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87154. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87155. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87156. * @return the cube texture
  87157. */
  87158. 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);
  87159. /**
  87160. * Get the current class name of the texture useful for serialization or dynamic coding.
  87161. * @returns "CubeTexture"
  87162. */
  87163. getClassName(): string;
  87164. /**
  87165. * Update the url (and optional buffer) of this texture if url was null during construction.
  87166. * @param url the url of the texture
  87167. * @param forcedExtension defines the extension to use
  87168. * @param onLoad callback called when the texture is loaded (defaults to null)
  87169. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87170. */
  87171. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87172. /**
  87173. * Delays loading of the cube texture
  87174. * @param forcedExtension defines the extension to use
  87175. */
  87176. delayLoad(forcedExtension?: string): void;
  87177. /**
  87178. * Returns the reflection texture matrix
  87179. * @returns the reflection texture matrix
  87180. */
  87181. getReflectionTextureMatrix(): Matrix;
  87182. /**
  87183. * Sets the reflection texture matrix
  87184. * @param value Reflection texture matrix
  87185. */
  87186. setReflectionTextureMatrix(value: Matrix): void;
  87187. /**
  87188. * Parses text to create a cube texture
  87189. * @param parsedTexture define the serialized text to read from
  87190. * @param scene defines the hosting scene
  87191. * @param rootUrl defines the root url of the cube texture
  87192. * @returns a cube texture
  87193. */
  87194. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87195. /**
  87196. * Makes a clone, or deep copy, of the cube texture
  87197. * @returns a new cube texture
  87198. */
  87199. clone(): CubeTexture;
  87200. }
  87201. }
  87202. declare module BABYLON {
  87203. /**
  87204. * Manages the defines for the Material
  87205. */
  87206. export class MaterialDefines {
  87207. /** @hidden */
  87208. protected _keys: string[];
  87209. private _isDirty;
  87210. /** @hidden */
  87211. _renderId: number;
  87212. /** @hidden */
  87213. _areLightsDirty: boolean;
  87214. /** @hidden */
  87215. _areLightsDisposed: boolean;
  87216. /** @hidden */
  87217. _areAttributesDirty: boolean;
  87218. /** @hidden */
  87219. _areTexturesDirty: boolean;
  87220. /** @hidden */
  87221. _areFresnelDirty: boolean;
  87222. /** @hidden */
  87223. _areMiscDirty: boolean;
  87224. /** @hidden */
  87225. _areImageProcessingDirty: boolean;
  87226. /** @hidden */
  87227. _normals: boolean;
  87228. /** @hidden */
  87229. _uvs: boolean;
  87230. /** @hidden */
  87231. _needNormals: boolean;
  87232. /** @hidden */
  87233. _needUVs: boolean;
  87234. [id: string]: any;
  87235. /**
  87236. * Specifies if the material needs to be re-calculated
  87237. */
  87238. get isDirty(): boolean;
  87239. /**
  87240. * Marks the material to indicate that it has been re-calculated
  87241. */
  87242. markAsProcessed(): void;
  87243. /**
  87244. * Marks the material to indicate that it needs to be re-calculated
  87245. */
  87246. markAsUnprocessed(): void;
  87247. /**
  87248. * Marks the material to indicate all of its defines need to be re-calculated
  87249. */
  87250. markAllAsDirty(): void;
  87251. /**
  87252. * Marks the material to indicate that image processing needs to be re-calculated
  87253. */
  87254. markAsImageProcessingDirty(): void;
  87255. /**
  87256. * Marks the material to indicate the lights need to be re-calculated
  87257. * @param disposed Defines whether the light is dirty due to dispose or not
  87258. */
  87259. markAsLightDirty(disposed?: boolean): void;
  87260. /**
  87261. * Marks the attribute state as changed
  87262. */
  87263. markAsAttributesDirty(): void;
  87264. /**
  87265. * Marks the texture state as changed
  87266. */
  87267. markAsTexturesDirty(): void;
  87268. /**
  87269. * Marks the fresnel state as changed
  87270. */
  87271. markAsFresnelDirty(): void;
  87272. /**
  87273. * Marks the misc state as changed
  87274. */
  87275. markAsMiscDirty(): void;
  87276. /**
  87277. * Rebuilds the material defines
  87278. */
  87279. rebuild(): void;
  87280. /**
  87281. * Specifies if two material defines are equal
  87282. * @param other - A material define instance to compare to
  87283. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87284. */
  87285. isEqual(other: MaterialDefines): boolean;
  87286. /**
  87287. * Clones this instance's defines to another instance
  87288. * @param other - material defines to clone values to
  87289. */
  87290. cloneTo(other: MaterialDefines): void;
  87291. /**
  87292. * Resets the material define values
  87293. */
  87294. reset(): void;
  87295. /**
  87296. * Converts the material define values to a string
  87297. * @returns - String of material define information
  87298. */
  87299. toString(): string;
  87300. }
  87301. }
  87302. declare module BABYLON {
  87303. /**
  87304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87306. * 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;
  87307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87308. */
  87309. export class ColorCurves {
  87310. private _dirty;
  87311. private _tempColor;
  87312. private _globalCurve;
  87313. private _highlightsCurve;
  87314. private _midtonesCurve;
  87315. private _shadowsCurve;
  87316. private _positiveCurve;
  87317. private _negativeCurve;
  87318. private _globalHue;
  87319. private _globalDensity;
  87320. private _globalSaturation;
  87321. private _globalExposure;
  87322. /**
  87323. * Gets the global Hue value.
  87324. * 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).
  87325. */
  87326. get globalHue(): number;
  87327. /**
  87328. * Sets the global Hue value.
  87329. * 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).
  87330. */
  87331. set globalHue(value: number);
  87332. /**
  87333. * Gets the global Density value.
  87334. * 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.
  87335. * Values less than zero provide a filter of opposite hue.
  87336. */
  87337. get globalDensity(): number;
  87338. /**
  87339. * Sets the global Density value.
  87340. * 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.
  87341. * Values less than zero provide a filter of opposite hue.
  87342. */
  87343. set globalDensity(value: number);
  87344. /**
  87345. * Gets the global Saturation value.
  87346. * 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.
  87347. */
  87348. get globalSaturation(): number;
  87349. /**
  87350. * Sets the global Saturation value.
  87351. * 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.
  87352. */
  87353. set globalSaturation(value: number);
  87354. /**
  87355. * Gets the global Exposure value.
  87356. * 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.
  87357. */
  87358. get globalExposure(): number;
  87359. /**
  87360. * Sets the global Exposure value.
  87361. * 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.
  87362. */
  87363. set globalExposure(value: number);
  87364. private _highlightsHue;
  87365. private _highlightsDensity;
  87366. private _highlightsSaturation;
  87367. private _highlightsExposure;
  87368. /**
  87369. * Gets the highlights Hue value.
  87370. * 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).
  87371. */
  87372. get highlightsHue(): number;
  87373. /**
  87374. * Sets the highlights Hue value.
  87375. * 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).
  87376. */
  87377. set highlightsHue(value: number);
  87378. /**
  87379. * Gets the highlights Density value.
  87380. * 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.
  87381. * Values less than zero provide a filter of opposite hue.
  87382. */
  87383. get highlightsDensity(): number;
  87384. /**
  87385. * Sets the highlights Density value.
  87386. * 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.
  87387. * Values less than zero provide a filter of opposite hue.
  87388. */
  87389. set highlightsDensity(value: number);
  87390. /**
  87391. * Gets the highlights Saturation value.
  87392. * 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.
  87393. */
  87394. get highlightsSaturation(): number;
  87395. /**
  87396. * Sets the highlights Saturation value.
  87397. * 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.
  87398. */
  87399. set highlightsSaturation(value: number);
  87400. /**
  87401. * Gets the highlights Exposure value.
  87402. * 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.
  87403. */
  87404. get highlightsExposure(): number;
  87405. /**
  87406. * Sets the highlights Exposure value.
  87407. * 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.
  87408. */
  87409. set highlightsExposure(value: number);
  87410. private _midtonesHue;
  87411. private _midtonesDensity;
  87412. private _midtonesSaturation;
  87413. private _midtonesExposure;
  87414. /**
  87415. * Gets the midtones Hue value.
  87416. * 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).
  87417. */
  87418. get midtonesHue(): number;
  87419. /**
  87420. * Sets the midtones Hue value.
  87421. * 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).
  87422. */
  87423. set midtonesHue(value: number);
  87424. /**
  87425. * Gets the midtones Density value.
  87426. * 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.
  87427. * Values less than zero provide a filter of opposite hue.
  87428. */
  87429. get midtonesDensity(): number;
  87430. /**
  87431. * Sets the midtones Density value.
  87432. * 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.
  87433. * Values less than zero provide a filter of opposite hue.
  87434. */
  87435. set midtonesDensity(value: number);
  87436. /**
  87437. * Gets the midtones Saturation value.
  87438. * 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.
  87439. */
  87440. get midtonesSaturation(): number;
  87441. /**
  87442. * Sets the midtones Saturation value.
  87443. * 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.
  87444. */
  87445. set midtonesSaturation(value: number);
  87446. /**
  87447. * Gets the midtones Exposure value.
  87448. * 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.
  87449. */
  87450. get midtonesExposure(): number;
  87451. /**
  87452. * Sets the midtones Exposure value.
  87453. * 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.
  87454. */
  87455. set midtonesExposure(value: number);
  87456. private _shadowsHue;
  87457. private _shadowsDensity;
  87458. private _shadowsSaturation;
  87459. private _shadowsExposure;
  87460. /**
  87461. * Gets the shadows Hue value.
  87462. * 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).
  87463. */
  87464. get shadowsHue(): number;
  87465. /**
  87466. * Sets the shadows Hue value.
  87467. * 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).
  87468. */
  87469. set shadowsHue(value: number);
  87470. /**
  87471. * Gets the shadows Density value.
  87472. * 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.
  87473. * Values less than zero provide a filter of opposite hue.
  87474. */
  87475. get shadowsDensity(): number;
  87476. /**
  87477. * Sets the shadows Density value.
  87478. * 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.
  87479. * Values less than zero provide a filter of opposite hue.
  87480. */
  87481. set shadowsDensity(value: number);
  87482. /**
  87483. * Gets the shadows Saturation value.
  87484. * 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.
  87485. */
  87486. get shadowsSaturation(): number;
  87487. /**
  87488. * Sets the shadows Saturation value.
  87489. * 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.
  87490. */
  87491. set shadowsSaturation(value: number);
  87492. /**
  87493. * Gets the shadows Exposure value.
  87494. * 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.
  87495. */
  87496. get shadowsExposure(): number;
  87497. /**
  87498. * Sets the shadows Exposure value.
  87499. * 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.
  87500. */
  87501. set shadowsExposure(value: number);
  87502. /**
  87503. * Returns the class name
  87504. * @returns The class name
  87505. */
  87506. getClassName(): string;
  87507. /**
  87508. * Binds the color curves to the shader.
  87509. * @param colorCurves The color curve to bind
  87510. * @param effect The effect to bind to
  87511. * @param positiveUniform The positive uniform shader parameter
  87512. * @param neutralUniform The neutral uniform shader parameter
  87513. * @param negativeUniform The negative uniform shader parameter
  87514. */
  87515. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87516. /**
  87517. * Prepare the list of uniforms associated with the ColorCurves effects.
  87518. * @param uniformsList The list of uniforms used in the effect
  87519. */
  87520. static PrepareUniforms(uniformsList: string[]): void;
  87521. /**
  87522. * Returns color grading data based on a hue, density, saturation and exposure value.
  87523. * @param filterHue The hue of the color filter.
  87524. * @param filterDensity The density of the color filter.
  87525. * @param saturation The saturation.
  87526. * @param exposure The exposure.
  87527. * @param result The result data container.
  87528. */
  87529. private getColorGradingDataToRef;
  87530. /**
  87531. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87532. * @param value The input slider value in range [-100,100].
  87533. * @returns Adjusted value.
  87534. */
  87535. private static applyColorGradingSliderNonlinear;
  87536. /**
  87537. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87538. * @param hue The hue (H) input.
  87539. * @param saturation The saturation (S) input.
  87540. * @param brightness The brightness (B) input.
  87541. * @result An RGBA color represented as Vector4.
  87542. */
  87543. private static fromHSBToRef;
  87544. /**
  87545. * Returns a value clamped between min and max
  87546. * @param value The value to clamp
  87547. * @param min The minimum of value
  87548. * @param max The maximum of value
  87549. * @returns The clamped value.
  87550. */
  87551. private static clamp;
  87552. /**
  87553. * Clones the current color curve instance.
  87554. * @return The cloned curves
  87555. */
  87556. clone(): ColorCurves;
  87557. /**
  87558. * Serializes the current color curve instance to a json representation.
  87559. * @return a JSON representation
  87560. */
  87561. serialize(): any;
  87562. /**
  87563. * Parses the color curve from a json representation.
  87564. * @param source the JSON source to parse
  87565. * @return The parsed curves
  87566. */
  87567. static Parse(source: any): ColorCurves;
  87568. }
  87569. }
  87570. declare module BABYLON {
  87571. /**
  87572. * Interface to follow in your material defines to integrate easily the
  87573. * Image proccessing functions.
  87574. * @hidden
  87575. */
  87576. export interface IImageProcessingConfigurationDefines {
  87577. IMAGEPROCESSING: boolean;
  87578. VIGNETTE: boolean;
  87579. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87580. VIGNETTEBLENDMODEOPAQUE: boolean;
  87581. TONEMAPPING: boolean;
  87582. TONEMAPPING_ACES: boolean;
  87583. CONTRAST: boolean;
  87584. EXPOSURE: boolean;
  87585. COLORCURVES: boolean;
  87586. COLORGRADING: boolean;
  87587. COLORGRADING3D: boolean;
  87588. SAMPLER3DGREENDEPTH: boolean;
  87589. SAMPLER3DBGRMAP: boolean;
  87590. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87591. }
  87592. /**
  87593. * @hidden
  87594. */
  87595. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87596. IMAGEPROCESSING: boolean;
  87597. VIGNETTE: boolean;
  87598. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87599. VIGNETTEBLENDMODEOPAQUE: boolean;
  87600. TONEMAPPING: boolean;
  87601. TONEMAPPING_ACES: boolean;
  87602. CONTRAST: boolean;
  87603. COLORCURVES: boolean;
  87604. COLORGRADING: boolean;
  87605. COLORGRADING3D: boolean;
  87606. SAMPLER3DGREENDEPTH: boolean;
  87607. SAMPLER3DBGRMAP: boolean;
  87608. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87609. EXPOSURE: boolean;
  87610. constructor();
  87611. }
  87612. /**
  87613. * This groups together the common properties used for image processing either in direct forward pass
  87614. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87615. * or not.
  87616. */
  87617. export class ImageProcessingConfiguration {
  87618. /**
  87619. * Default tone mapping applied in BabylonJS.
  87620. */
  87621. static readonly TONEMAPPING_STANDARD: number;
  87622. /**
  87623. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87624. * to other engines rendering to increase portability.
  87625. */
  87626. static readonly TONEMAPPING_ACES: number;
  87627. /**
  87628. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87629. */
  87630. colorCurves: Nullable<ColorCurves>;
  87631. private _colorCurvesEnabled;
  87632. /**
  87633. * Gets wether the color curves effect is enabled.
  87634. */
  87635. get colorCurvesEnabled(): boolean;
  87636. /**
  87637. * Sets wether the color curves effect is enabled.
  87638. */
  87639. set colorCurvesEnabled(value: boolean);
  87640. private _colorGradingTexture;
  87641. /**
  87642. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87643. */
  87644. get colorGradingTexture(): Nullable<BaseTexture>;
  87645. /**
  87646. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87647. */
  87648. set colorGradingTexture(value: Nullable<BaseTexture>);
  87649. private _colorGradingEnabled;
  87650. /**
  87651. * Gets wether the color grading effect is enabled.
  87652. */
  87653. get colorGradingEnabled(): boolean;
  87654. /**
  87655. * Sets wether the color grading effect is enabled.
  87656. */
  87657. set colorGradingEnabled(value: boolean);
  87658. private _colorGradingWithGreenDepth;
  87659. /**
  87660. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87661. */
  87662. get colorGradingWithGreenDepth(): boolean;
  87663. /**
  87664. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87665. */
  87666. set colorGradingWithGreenDepth(value: boolean);
  87667. private _colorGradingBGR;
  87668. /**
  87669. * Gets wether the color grading texture contains BGR values.
  87670. */
  87671. get colorGradingBGR(): boolean;
  87672. /**
  87673. * Sets wether the color grading texture contains BGR values.
  87674. */
  87675. set colorGradingBGR(value: boolean);
  87676. /** @hidden */
  87677. _exposure: number;
  87678. /**
  87679. * Gets the Exposure used in the effect.
  87680. */
  87681. get exposure(): number;
  87682. /**
  87683. * Sets the Exposure used in the effect.
  87684. */
  87685. set exposure(value: number);
  87686. private _toneMappingEnabled;
  87687. /**
  87688. * Gets wether the tone mapping effect is enabled.
  87689. */
  87690. get toneMappingEnabled(): boolean;
  87691. /**
  87692. * Sets wether the tone mapping effect is enabled.
  87693. */
  87694. set toneMappingEnabled(value: boolean);
  87695. private _toneMappingType;
  87696. /**
  87697. * Gets the type of tone mapping effect.
  87698. */
  87699. get toneMappingType(): number;
  87700. /**
  87701. * Sets the type of tone mapping effect used in BabylonJS.
  87702. */
  87703. set toneMappingType(value: number);
  87704. protected _contrast: number;
  87705. /**
  87706. * Gets the contrast used in the effect.
  87707. */
  87708. get contrast(): number;
  87709. /**
  87710. * Sets the contrast used in the effect.
  87711. */
  87712. set contrast(value: number);
  87713. /**
  87714. * Vignette stretch size.
  87715. */
  87716. vignetteStretch: number;
  87717. /**
  87718. * Vignette centre X Offset.
  87719. */
  87720. vignetteCentreX: number;
  87721. /**
  87722. * Vignette centre Y Offset.
  87723. */
  87724. vignetteCentreY: number;
  87725. /**
  87726. * Vignette weight or intensity of the vignette effect.
  87727. */
  87728. vignetteWeight: number;
  87729. /**
  87730. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87731. * if vignetteEnabled is set to true.
  87732. */
  87733. vignetteColor: Color4;
  87734. /**
  87735. * Camera field of view used by the Vignette effect.
  87736. */
  87737. vignetteCameraFov: number;
  87738. private _vignetteBlendMode;
  87739. /**
  87740. * Gets the vignette blend mode allowing different kind of effect.
  87741. */
  87742. get vignetteBlendMode(): number;
  87743. /**
  87744. * Sets the vignette blend mode allowing different kind of effect.
  87745. */
  87746. set vignetteBlendMode(value: number);
  87747. private _vignetteEnabled;
  87748. /**
  87749. * Gets wether the vignette effect is enabled.
  87750. */
  87751. get vignetteEnabled(): boolean;
  87752. /**
  87753. * Sets wether the vignette effect is enabled.
  87754. */
  87755. set vignetteEnabled(value: boolean);
  87756. private _applyByPostProcess;
  87757. /**
  87758. * Gets wether the image processing is applied through a post process or not.
  87759. */
  87760. get applyByPostProcess(): boolean;
  87761. /**
  87762. * Sets wether the image processing is applied through a post process or not.
  87763. */
  87764. set applyByPostProcess(value: boolean);
  87765. private _isEnabled;
  87766. /**
  87767. * Gets wether the image processing is enabled or not.
  87768. */
  87769. get isEnabled(): boolean;
  87770. /**
  87771. * Sets wether the image processing is enabled or not.
  87772. */
  87773. set isEnabled(value: boolean);
  87774. /**
  87775. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87776. */
  87777. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87778. /**
  87779. * Method called each time the image processing information changes requires to recompile the effect.
  87780. */
  87781. protected _updateParameters(): void;
  87782. /**
  87783. * Gets the current class name.
  87784. * @return "ImageProcessingConfiguration"
  87785. */
  87786. getClassName(): string;
  87787. /**
  87788. * Prepare the list of uniforms associated with the Image Processing effects.
  87789. * @param uniforms The list of uniforms used in the effect
  87790. * @param defines the list of defines currently in use
  87791. */
  87792. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87793. /**
  87794. * Prepare the list of samplers associated with the Image Processing effects.
  87795. * @param samplersList The list of uniforms used in the effect
  87796. * @param defines the list of defines currently in use
  87797. */
  87798. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87799. /**
  87800. * Prepare the list of defines associated to the shader.
  87801. * @param defines the list of defines to complete
  87802. * @param forPostProcess Define if we are currently in post process mode or not
  87803. */
  87804. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87805. /**
  87806. * Returns true if all the image processing information are ready.
  87807. * @returns True if ready, otherwise, false
  87808. */
  87809. isReady(): boolean;
  87810. /**
  87811. * Binds the image processing to the shader.
  87812. * @param effect The effect to bind to
  87813. * @param overrideAspectRatio Override the aspect ratio of the effect
  87814. */
  87815. bind(effect: Effect, overrideAspectRatio?: number): void;
  87816. /**
  87817. * Clones the current image processing instance.
  87818. * @return The cloned image processing
  87819. */
  87820. clone(): ImageProcessingConfiguration;
  87821. /**
  87822. * Serializes the current image processing instance to a json representation.
  87823. * @return a JSON representation
  87824. */
  87825. serialize(): any;
  87826. /**
  87827. * Parses the image processing from a json representation.
  87828. * @param source the JSON source to parse
  87829. * @return The parsed image processing
  87830. */
  87831. static Parse(source: any): ImageProcessingConfiguration;
  87832. private static _VIGNETTEMODE_MULTIPLY;
  87833. private static _VIGNETTEMODE_OPAQUE;
  87834. /**
  87835. * Used to apply the vignette as a mix with the pixel color.
  87836. */
  87837. static get VIGNETTEMODE_MULTIPLY(): number;
  87838. /**
  87839. * Used to apply the vignette as a replacement of the pixel color.
  87840. */
  87841. static get VIGNETTEMODE_OPAQUE(): number;
  87842. }
  87843. }
  87844. declare module BABYLON {
  87845. /** @hidden */
  87846. export var postprocessVertexShader: {
  87847. name: string;
  87848. shader: string;
  87849. };
  87850. }
  87851. declare module BABYLON {
  87852. interface ThinEngine {
  87853. /**
  87854. * Creates a new render target texture
  87855. * @param size defines the size of the texture
  87856. * @param options defines the options used to create the texture
  87857. * @returns a new render target texture stored in an InternalTexture
  87858. */
  87859. createRenderTargetTexture(size: number | {
  87860. width: number;
  87861. height: number;
  87862. layers?: number;
  87863. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87864. /**
  87865. * Creates a depth stencil texture.
  87866. * This is only available in WebGL 2 or with the depth texture extension available.
  87867. * @param size The size of face edge in the texture.
  87868. * @param options The options defining the texture.
  87869. * @returns The texture
  87870. */
  87871. createDepthStencilTexture(size: number | {
  87872. width: number;
  87873. height: number;
  87874. layers?: number;
  87875. }, options: DepthTextureCreationOptions): InternalTexture;
  87876. /** @hidden */
  87877. _createDepthStencilTexture(size: number | {
  87878. width: number;
  87879. height: number;
  87880. layers?: number;
  87881. }, options: DepthTextureCreationOptions): InternalTexture;
  87882. }
  87883. }
  87884. declare module BABYLON {
  87885. /**
  87886. * Defines the kind of connection point for node based material
  87887. */
  87888. export enum NodeMaterialBlockConnectionPointTypes {
  87889. /** Float */
  87890. Float = 1,
  87891. /** Int */
  87892. Int = 2,
  87893. /** Vector2 */
  87894. Vector2 = 4,
  87895. /** Vector3 */
  87896. Vector3 = 8,
  87897. /** Vector4 */
  87898. Vector4 = 16,
  87899. /** Color3 */
  87900. Color3 = 32,
  87901. /** Color4 */
  87902. Color4 = 64,
  87903. /** Matrix */
  87904. Matrix = 128,
  87905. /** Custom object */
  87906. Object = 256,
  87907. /** Detect type based on connection */
  87908. AutoDetect = 1024,
  87909. /** Output type that will be defined by input type */
  87910. BasedOnInput = 2048
  87911. }
  87912. }
  87913. declare module BABYLON {
  87914. /**
  87915. * Enum used to define the target of a block
  87916. */
  87917. export enum NodeMaterialBlockTargets {
  87918. /** Vertex shader */
  87919. Vertex = 1,
  87920. /** Fragment shader */
  87921. Fragment = 2,
  87922. /** Neutral */
  87923. Neutral = 4,
  87924. /** Vertex and Fragment */
  87925. VertexAndFragment = 3
  87926. }
  87927. }
  87928. declare module BABYLON {
  87929. /**
  87930. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87931. */
  87932. export enum NodeMaterialBlockConnectionPointMode {
  87933. /** Value is an uniform */
  87934. Uniform = 0,
  87935. /** Value is a mesh attribute */
  87936. Attribute = 1,
  87937. /** Value is a varying between vertex and fragment shaders */
  87938. Varying = 2,
  87939. /** Mode is undefined */
  87940. Undefined = 3
  87941. }
  87942. }
  87943. declare module BABYLON {
  87944. /**
  87945. * Enum used to define system values e.g. values automatically provided by the system
  87946. */
  87947. export enum NodeMaterialSystemValues {
  87948. /** World */
  87949. World = 1,
  87950. /** View */
  87951. View = 2,
  87952. /** Projection */
  87953. Projection = 3,
  87954. /** ViewProjection */
  87955. ViewProjection = 4,
  87956. /** WorldView */
  87957. WorldView = 5,
  87958. /** WorldViewProjection */
  87959. WorldViewProjection = 6,
  87960. /** CameraPosition */
  87961. CameraPosition = 7,
  87962. /** Fog Color */
  87963. FogColor = 8,
  87964. /** Delta time */
  87965. DeltaTime = 9
  87966. }
  87967. }
  87968. declare module BABYLON {
  87969. /** Defines supported spaces */
  87970. export enum Space {
  87971. /** Local (object) space */
  87972. LOCAL = 0,
  87973. /** World space */
  87974. WORLD = 1,
  87975. /** Bone space */
  87976. BONE = 2
  87977. }
  87978. /** Defines the 3 main axes */
  87979. export class Axis {
  87980. /** X axis */
  87981. static X: Vector3;
  87982. /** Y axis */
  87983. static Y: Vector3;
  87984. /** Z axis */
  87985. static Z: Vector3;
  87986. }
  87987. }
  87988. declare module BABYLON {
  87989. /**
  87990. * Represents a camera frustum
  87991. */
  87992. export class Frustum {
  87993. /**
  87994. * Gets the planes representing the frustum
  87995. * @param transform matrix to be applied to the returned planes
  87996. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87997. */
  87998. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87999. /**
  88000. * Gets the near frustum plane transformed by the transform matrix
  88001. * @param transform transformation matrix to be applied to the resulting frustum plane
  88002. * @param frustumPlane the resuling frustum plane
  88003. */
  88004. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88005. /**
  88006. * Gets the far frustum plane transformed by the transform matrix
  88007. * @param transform transformation matrix to be applied to the resulting frustum plane
  88008. * @param frustumPlane the resuling frustum plane
  88009. */
  88010. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88011. /**
  88012. * Gets the left frustum plane transformed by the transform matrix
  88013. * @param transform transformation matrix to be applied to the resulting frustum plane
  88014. * @param frustumPlane the resuling frustum plane
  88015. */
  88016. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88017. /**
  88018. * Gets the right frustum plane transformed by the transform matrix
  88019. * @param transform transformation matrix to be applied to the resulting frustum plane
  88020. * @param frustumPlane the resuling frustum plane
  88021. */
  88022. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88023. /**
  88024. * Gets the top frustum plane transformed by the transform matrix
  88025. * @param transform transformation matrix to be applied to the resulting frustum plane
  88026. * @param frustumPlane the resuling frustum plane
  88027. */
  88028. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88029. /**
  88030. * Gets the bottom frustum plane transformed by the transform matrix
  88031. * @param transform transformation matrix to be applied to the resulting frustum plane
  88032. * @param frustumPlane the resuling frustum plane
  88033. */
  88034. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88035. /**
  88036. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88037. * @param transform transformation matrix to be applied to the resulting frustum planes
  88038. * @param frustumPlanes the resuling frustum planes
  88039. */
  88040. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88041. }
  88042. }
  88043. declare module BABYLON {
  88044. /**
  88045. * Interface for the size containing width and height
  88046. */
  88047. export interface ISize {
  88048. /**
  88049. * Width
  88050. */
  88051. width: number;
  88052. /**
  88053. * Heighht
  88054. */
  88055. height: number;
  88056. }
  88057. /**
  88058. * Size containing widht and height
  88059. */
  88060. export class Size implements ISize {
  88061. /**
  88062. * Width
  88063. */
  88064. width: number;
  88065. /**
  88066. * Height
  88067. */
  88068. height: number;
  88069. /**
  88070. * Creates a Size object from the given width and height (floats).
  88071. * @param width width of the new size
  88072. * @param height height of the new size
  88073. */
  88074. constructor(width: number, height: number);
  88075. /**
  88076. * Returns a string with the Size width and height
  88077. * @returns a string with the Size width and height
  88078. */
  88079. toString(): string;
  88080. /**
  88081. * "Size"
  88082. * @returns the string "Size"
  88083. */
  88084. getClassName(): string;
  88085. /**
  88086. * Returns the Size hash code.
  88087. * @returns a hash code for a unique width and height
  88088. */
  88089. getHashCode(): number;
  88090. /**
  88091. * Updates the current size from the given one.
  88092. * @param src the given size
  88093. */
  88094. copyFrom(src: Size): void;
  88095. /**
  88096. * Updates in place the current Size from the given floats.
  88097. * @param width width of the new size
  88098. * @param height height of the new size
  88099. * @returns the updated Size.
  88100. */
  88101. copyFromFloats(width: number, height: number): Size;
  88102. /**
  88103. * Updates in place the current Size from the given floats.
  88104. * @param width width to set
  88105. * @param height height to set
  88106. * @returns the updated Size.
  88107. */
  88108. set(width: number, height: number): Size;
  88109. /**
  88110. * Multiplies the width and height by numbers
  88111. * @param w factor to multiple the width by
  88112. * @param h factor to multiple the height by
  88113. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88114. */
  88115. multiplyByFloats(w: number, h: number): Size;
  88116. /**
  88117. * Clones the size
  88118. * @returns a new Size copied from the given one.
  88119. */
  88120. clone(): Size;
  88121. /**
  88122. * True if the current Size and the given one width and height are strictly equal.
  88123. * @param other the other size to compare against
  88124. * @returns True if the current Size and the given one width and height are strictly equal.
  88125. */
  88126. equals(other: Size): boolean;
  88127. /**
  88128. * The surface of the Size : width * height (float).
  88129. */
  88130. get surface(): number;
  88131. /**
  88132. * Create a new size of zero
  88133. * @returns a new Size set to (0.0, 0.0)
  88134. */
  88135. static Zero(): Size;
  88136. /**
  88137. * Sums the width and height of two sizes
  88138. * @param otherSize size to add to this size
  88139. * @returns a new Size set as the addition result of the current Size and the given one.
  88140. */
  88141. add(otherSize: Size): Size;
  88142. /**
  88143. * Subtracts the width and height of two
  88144. * @param otherSize size to subtract to this size
  88145. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88146. */
  88147. subtract(otherSize: Size): Size;
  88148. /**
  88149. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88150. * @param start starting size to lerp between
  88151. * @param end end size to lerp between
  88152. * @param amount amount to lerp between the start and end values
  88153. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88154. */
  88155. static Lerp(start: Size, end: Size, amount: number): Size;
  88156. }
  88157. }
  88158. declare module BABYLON {
  88159. /**
  88160. * Contains position and normal vectors for a vertex
  88161. */
  88162. export class PositionNormalVertex {
  88163. /** the position of the vertex (defaut: 0,0,0) */
  88164. position: Vector3;
  88165. /** the normal of the vertex (defaut: 0,1,0) */
  88166. normal: Vector3;
  88167. /**
  88168. * Creates a PositionNormalVertex
  88169. * @param position the position of the vertex (defaut: 0,0,0)
  88170. * @param normal the normal of the vertex (defaut: 0,1,0)
  88171. */
  88172. constructor(
  88173. /** the position of the vertex (defaut: 0,0,0) */
  88174. position?: Vector3,
  88175. /** the normal of the vertex (defaut: 0,1,0) */
  88176. normal?: Vector3);
  88177. /**
  88178. * Clones the PositionNormalVertex
  88179. * @returns the cloned PositionNormalVertex
  88180. */
  88181. clone(): PositionNormalVertex;
  88182. }
  88183. /**
  88184. * Contains position, normal and uv vectors for a vertex
  88185. */
  88186. export class PositionNormalTextureVertex {
  88187. /** the position of the vertex (defaut: 0,0,0) */
  88188. position: Vector3;
  88189. /** the normal of the vertex (defaut: 0,1,0) */
  88190. normal: Vector3;
  88191. /** the uv of the vertex (default: 0,0) */
  88192. uv: Vector2;
  88193. /**
  88194. * Creates a PositionNormalTextureVertex
  88195. * @param position the position of the vertex (defaut: 0,0,0)
  88196. * @param normal the normal of the vertex (defaut: 0,1,0)
  88197. * @param uv the uv of the vertex (default: 0,0)
  88198. */
  88199. constructor(
  88200. /** the position of the vertex (defaut: 0,0,0) */
  88201. position?: Vector3,
  88202. /** the normal of the vertex (defaut: 0,1,0) */
  88203. normal?: Vector3,
  88204. /** the uv of the vertex (default: 0,0) */
  88205. uv?: Vector2);
  88206. /**
  88207. * Clones the PositionNormalTextureVertex
  88208. * @returns the cloned PositionNormalTextureVertex
  88209. */
  88210. clone(): PositionNormalTextureVertex;
  88211. }
  88212. }
  88213. declare module BABYLON {
  88214. /**
  88215. * Enum defining the type of animations supported by InputBlock
  88216. */
  88217. export enum AnimatedInputBlockTypes {
  88218. /** No animation */
  88219. None = 0,
  88220. /** Time based animation. Will only work for floats */
  88221. Time = 1
  88222. }
  88223. }
  88224. declare module BABYLON {
  88225. /**
  88226. * Interface describing all the common properties and methods a shadow light needs to implement.
  88227. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88228. * as well as binding the different shadow properties to the effects.
  88229. */
  88230. export interface IShadowLight extends Light {
  88231. /**
  88232. * The light id in the scene (used in scene.findLighById for instance)
  88233. */
  88234. id: string;
  88235. /**
  88236. * The position the shdow will be casted from.
  88237. */
  88238. position: Vector3;
  88239. /**
  88240. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88241. */
  88242. direction: Vector3;
  88243. /**
  88244. * The transformed position. Position of the light in world space taking parenting in account.
  88245. */
  88246. transformedPosition: Vector3;
  88247. /**
  88248. * The transformed direction. Direction of the light in world space taking parenting in account.
  88249. */
  88250. transformedDirection: Vector3;
  88251. /**
  88252. * The friendly name of the light in the scene.
  88253. */
  88254. name: string;
  88255. /**
  88256. * Defines the shadow projection clipping minimum z value.
  88257. */
  88258. shadowMinZ: number;
  88259. /**
  88260. * Defines the shadow projection clipping maximum z value.
  88261. */
  88262. shadowMaxZ: number;
  88263. /**
  88264. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88265. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88266. */
  88267. computeTransformedInformation(): boolean;
  88268. /**
  88269. * Gets the scene the light belongs to.
  88270. * @returns The scene
  88271. */
  88272. getScene(): Scene;
  88273. /**
  88274. * Callback defining a custom Projection Matrix Builder.
  88275. * This can be used to override the default projection matrix computation.
  88276. */
  88277. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88278. /**
  88279. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88280. * @param matrix The materix to updated with the projection information
  88281. * @param viewMatrix The transform matrix of the light
  88282. * @param renderList The list of mesh to render in the map
  88283. * @returns The current light
  88284. */
  88285. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88286. /**
  88287. * Gets the current depth scale used in ESM.
  88288. * @returns The scale
  88289. */
  88290. getDepthScale(): number;
  88291. /**
  88292. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88293. * @returns true if a cube texture needs to be use
  88294. */
  88295. needCube(): boolean;
  88296. /**
  88297. * Detects if the projection matrix requires to be recomputed this frame.
  88298. * @returns true if it requires to be recomputed otherwise, false.
  88299. */
  88300. needProjectionMatrixCompute(): boolean;
  88301. /**
  88302. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88303. */
  88304. forceProjectionMatrixCompute(): void;
  88305. /**
  88306. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88307. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88308. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88309. */
  88310. getShadowDirection(faceIndex?: number): Vector3;
  88311. /**
  88312. * Gets the minZ used for shadow according to both the scene and the light.
  88313. * @param activeCamera The camera we are returning the min for
  88314. * @returns the depth min z
  88315. */
  88316. getDepthMinZ(activeCamera: Camera): number;
  88317. /**
  88318. * Gets the maxZ used for shadow according to both the scene and the light.
  88319. * @param activeCamera The camera we are returning the max for
  88320. * @returns the depth max z
  88321. */
  88322. getDepthMaxZ(activeCamera: Camera): number;
  88323. }
  88324. /**
  88325. * Base implementation IShadowLight
  88326. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88327. */
  88328. export abstract class ShadowLight extends Light implements IShadowLight {
  88329. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88330. protected _position: Vector3;
  88331. protected _setPosition(value: Vector3): void;
  88332. /**
  88333. * Sets the position the shadow will be casted from. Also use as the light position for both
  88334. * point and spot lights.
  88335. */
  88336. get position(): Vector3;
  88337. /**
  88338. * Sets the position the shadow will be casted from. Also use as the light position for both
  88339. * point and spot lights.
  88340. */
  88341. set position(value: Vector3);
  88342. protected _direction: Vector3;
  88343. protected _setDirection(value: Vector3): void;
  88344. /**
  88345. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88346. * Also use as the light direction on spot and directional lights.
  88347. */
  88348. get direction(): Vector3;
  88349. /**
  88350. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88351. * Also use as the light direction on spot and directional lights.
  88352. */
  88353. set direction(value: Vector3);
  88354. protected _shadowMinZ: number;
  88355. /**
  88356. * Gets the shadow projection clipping minimum z value.
  88357. */
  88358. get shadowMinZ(): number;
  88359. /**
  88360. * Sets the shadow projection clipping minimum z value.
  88361. */
  88362. set shadowMinZ(value: number);
  88363. protected _shadowMaxZ: number;
  88364. /**
  88365. * Sets the shadow projection clipping maximum z value.
  88366. */
  88367. get shadowMaxZ(): number;
  88368. /**
  88369. * Gets the shadow projection clipping maximum z value.
  88370. */
  88371. set shadowMaxZ(value: number);
  88372. /**
  88373. * Callback defining a custom Projection Matrix Builder.
  88374. * This can be used to override the default projection matrix computation.
  88375. */
  88376. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88377. /**
  88378. * The transformed position. Position of the light in world space taking parenting in account.
  88379. */
  88380. transformedPosition: Vector3;
  88381. /**
  88382. * The transformed direction. Direction of the light in world space taking parenting in account.
  88383. */
  88384. transformedDirection: Vector3;
  88385. private _needProjectionMatrixCompute;
  88386. /**
  88387. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88388. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88389. */
  88390. computeTransformedInformation(): boolean;
  88391. /**
  88392. * Return the depth scale used for the shadow map.
  88393. * @returns the depth scale.
  88394. */
  88395. getDepthScale(): number;
  88396. /**
  88397. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88398. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88399. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88400. */
  88401. getShadowDirection(faceIndex?: number): Vector3;
  88402. /**
  88403. * Returns the ShadowLight absolute position in the World.
  88404. * @returns the position vector in world space
  88405. */
  88406. getAbsolutePosition(): Vector3;
  88407. /**
  88408. * Sets the ShadowLight direction toward the passed target.
  88409. * @param target The point to target in local space
  88410. * @returns the updated ShadowLight direction
  88411. */
  88412. setDirectionToTarget(target: Vector3): Vector3;
  88413. /**
  88414. * Returns the light rotation in euler definition.
  88415. * @returns the x y z rotation in local space.
  88416. */
  88417. getRotation(): Vector3;
  88418. /**
  88419. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88420. * @returns true if a cube texture needs to be use
  88421. */
  88422. needCube(): boolean;
  88423. /**
  88424. * Detects if the projection matrix requires to be recomputed this frame.
  88425. * @returns true if it requires to be recomputed otherwise, false.
  88426. */
  88427. needProjectionMatrixCompute(): boolean;
  88428. /**
  88429. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88430. */
  88431. forceProjectionMatrixCompute(): void;
  88432. /** @hidden */
  88433. _initCache(): void;
  88434. /** @hidden */
  88435. _isSynchronized(): boolean;
  88436. /**
  88437. * Computes the world matrix of the node
  88438. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88439. * @returns the world matrix
  88440. */
  88441. computeWorldMatrix(force?: boolean): Matrix;
  88442. /**
  88443. * Gets the minZ used for shadow according to both the scene and the light.
  88444. * @param activeCamera The camera we are returning the min for
  88445. * @returns the depth min z
  88446. */
  88447. getDepthMinZ(activeCamera: Camera): number;
  88448. /**
  88449. * Gets the maxZ used for shadow according to both the scene and the light.
  88450. * @param activeCamera The camera we are returning the max for
  88451. * @returns the depth max z
  88452. */
  88453. getDepthMaxZ(activeCamera: Camera): number;
  88454. /**
  88455. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88456. * @param matrix The materix to updated with the projection information
  88457. * @param viewMatrix The transform matrix of the light
  88458. * @param renderList The list of mesh to render in the map
  88459. * @returns The current light
  88460. */
  88461. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88462. }
  88463. }
  88464. declare module BABYLON {
  88465. /** @hidden */
  88466. export var packingFunctions: {
  88467. name: string;
  88468. shader: string;
  88469. };
  88470. }
  88471. declare module BABYLON {
  88472. /** @hidden */
  88473. export var bayerDitherFunctions: {
  88474. name: string;
  88475. shader: string;
  88476. };
  88477. }
  88478. declare module BABYLON {
  88479. /** @hidden */
  88480. export var shadowMapFragmentDeclaration: {
  88481. name: string;
  88482. shader: string;
  88483. };
  88484. }
  88485. declare module BABYLON {
  88486. /** @hidden */
  88487. export var clipPlaneFragmentDeclaration: {
  88488. name: string;
  88489. shader: string;
  88490. };
  88491. }
  88492. declare module BABYLON {
  88493. /** @hidden */
  88494. export var clipPlaneFragment: {
  88495. name: string;
  88496. shader: string;
  88497. };
  88498. }
  88499. declare module BABYLON {
  88500. /** @hidden */
  88501. export var shadowMapFragment: {
  88502. name: string;
  88503. shader: string;
  88504. };
  88505. }
  88506. declare module BABYLON {
  88507. /** @hidden */
  88508. export var shadowMapPixelShader: {
  88509. name: string;
  88510. shader: string;
  88511. };
  88512. }
  88513. declare module BABYLON {
  88514. /** @hidden */
  88515. export var bonesDeclaration: {
  88516. name: string;
  88517. shader: string;
  88518. };
  88519. }
  88520. declare module BABYLON {
  88521. /** @hidden */
  88522. export var morphTargetsVertexGlobalDeclaration: {
  88523. name: string;
  88524. shader: string;
  88525. };
  88526. }
  88527. declare module BABYLON {
  88528. /** @hidden */
  88529. export var morphTargetsVertexDeclaration: {
  88530. name: string;
  88531. shader: string;
  88532. };
  88533. }
  88534. declare module BABYLON {
  88535. /** @hidden */
  88536. export var instancesDeclaration: {
  88537. name: string;
  88538. shader: string;
  88539. };
  88540. }
  88541. declare module BABYLON {
  88542. /** @hidden */
  88543. export var helperFunctions: {
  88544. name: string;
  88545. shader: string;
  88546. };
  88547. }
  88548. declare module BABYLON {
  88549. /** @hidden */
  88550. export var shadowMapVertexDeclaration: {
  88551. name: string;
  88552. shader: string;
  88553. };
  88554. }
  88555. declare module BABYLON {
  88556. /** @hidden */
  88557. export var clipPlaneVertexDeclaration: {
  88558. name: string;
  88559. shader: string;
  88560. };
  88561. }
  88562. declare module BABYLON {
  88563. /** @hidden */
  88564. export var morphTargetsVertex: {
  88565. name: string;
  88566. shader: string;
  88567. };
  88568. }
  88569. declare module BABYLON {
  88570. /** @hidden */
  88571. export var instancesVertex: {
  88572. name: string;
  88573. shader: string;
  88574. };
  88575. }
  88576. declare module BABYLON {
  88577. /** @hidden */
  88578. export var bonesVertex: {
  88579. name: string;
  88580. shader: string;
  88581. };
  88582. }
  88583. declare module BABYLON {
  88584. /** @hidden */
  88585. export var shadowMapVertexNormalBias: {
  88586. name: string;
  88587. shader: string;
  88588. };
  88589. }
  88590. declare module BABYLON {
  88591. /** @hidden */
  88592. export var shadowMapVertexMetric: {
  88593. name: string;
  88594. shader: string;
  88595. };
  88596. }
  88597. declare module BABYLON {
  88598. /** @hidden */
  88599. export var clipPlaneVertex: {
  88600. name: string;
  88601. shader: string;
  88602. };
  88603. }
  88604. declare module BABYLON {
  88605. /** @hidden */
  88606. export var shadowMapVertexShader: {
  88607. name: string;
  88608. shader: string;
  88609. };
  88610. }
  88611. declare module BABYLON {
  88612. /** @hidden */
  88613. export var depthBoxBlurPixelShader: {
  88614. name: string;
  88615. shader: string;
  88616. };
  88617. }
  88618. declare module BABYLON {
  88619. /** @hidden */
  88620. export var shadowMapFragmentSoftTransparentShadow: {
  88621. name: string;
  88622. shader: string;
  88623. };
  88624. }
  88625. declare module BABYLON {
  88626. /**
  88627. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88628. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88629. */
  88630. export class EffectFallbacks implements IEffectFallbacks {
  88631. private _defines;
  88632. private _currentRank;
  88633. private _maxRank;
  88634. private _mesh;
  88635. /**
  88636. * Removes the fallback from the bound mesh.
  88637. */
  88638. unBindMesh(): void;
  88639. /**
  88640. * Adds a fallback on the specified property.
  88641. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88642. * @param define The name of the define in the shader
  88643. */
  88644. addFallback(rank: number, define: string): void;
  88645. /**
  88646. * Sets the mesh to use CPU skinning when needing to fallback.
  88647. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88648. * @param mesh The mesh to use the fallbacks.
  88649. */
  88650. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88651. /**
  88652. * Checks to see if more fallbacks are still availible.
  88653. */
  88654. get hasMoreFallbacks(): boolean;
  88655. /**
  88656. * Removes the defines that should be removed when falling back.
  88657. * @param currentDefines defines the current define statements for the shader.
  88658. * @param effect defines the current effect we try to compile
  88659. * @returns The resulting defines with defines of the current rank removed.
  88660. */
  88661. reduce(currentDefines: string, effect: Effect): string;
  88662. }
  88663. }
  88664. declare module BABYLON {
  88665. /**
  88666. * Interface used to define Action
  88667. */
  88668. export interface IAction {
  88669. /**
  88670. * Trigger for the action
  88671. */
  88672. trigger: number;
  88673. /** Options of the trigger */
  88674. triggerOptions: any;
  88675. /**
  88676. * Gets the trigger parameters
  88677. * @returns the trigger parameters
  88678. */
  88679. getTriggerParameter(): any;
  88680. /**
  88681. * Internal only - executes current action event
  88682. * @hidden
  88683. */
  88684. _executeCurrent(evt?: ActionEvent): void;
  88685. /**
  88686. * Serialize placeholder for child classes
  88687. * @param parent of child
  88688. * @returns the serialized object
  88689. */
  88690. serialize(parent: any): any;
  88691. /**
  88692. * Internal only
  88693. * @hidden
  88694. */
  88695. _prepare(): void;
  88696. /**
  88697. * Internal only - manager for action
  88698. * @hidden
  88699. */
  88700. _actionManager: AbstractActionManager;
  88701. /**
  88702. * Adds action to chain of actions, may be a DoNothingAction
  88703. * @param action defines the next action to execute
  88704. * @returns The action passed in
  88705. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88706. */
  88707. then(action: IAction): IAction;
  88708. }
  88709. /**
  88710. * The action to be carried out following a trigger
  88711. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88712. */
  88713. export class Action implements IAction {
  88714. /** the trigger, with or without parameters, for the action */
  88715. triggerOptions: any;
  88716. /**
  88717. * Trigger for the action
  88718. */
  88719. trigger: number;
  88720. /**
  88721. * Internal only - manager for action
  88722. * @hidden
  88723. */
  88724. _actionManager: ActionManager;
  88725. private _nextActiveAction;
  88726. private _child;
  88727. private _condition?;
  88728. private _triggerParameter;
  88729. /**
  88730. * An event triggered prior to action being executed.
  88731. */
  88732. onBeforeExecuteObservable: Observable<Action>;
  88733. /**
  88734. * Creates a new Action
  88735. * @param triggerOptions the trigger, with or without parameters, for the action
  88736. * @param condition an optional determinant of action
  88737. */
  88738. constructor(
  88739. /** the trigger, with or without parameters, for the action */
  88740. triggerOptions: any, condition?: Condition);
  88741. /**
  88742. * Internal only
  88743. * @hidden
  88744. */
  88745. _prepare(): void;
  88746. /**
  88747. * Gets the trigger parameters
  88748. * @returns the trigger parameters
  88749. */
  88750. getTriggerParameter(): any;
  88751. /**
  88752. * Internal only - executes current action event
  88753. * @hidden
  88754. */
  88755. _executeCurrent(evt?: ActionEvent): void;
  88756. /**
  88757. * Execute placeholder for child classes
  88758. * @param evt optional action event
  88759. */
  88760. execute(evt?: ActionEvent): void;
  88761. /**
  88762. * Skips to next active action
  88763. */
  88764. skipToNextActiveAction(): void;
  88765. /**
  88766. * Adds action to chain of actions, may be a DoNothingAction
  88767. * @param action defines the next action to execute
  88768. * @returns The action passed in
  88769. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88770. */
  88771. then(action: Action): Action;
  88772. /**
  88773. * Internal only
  88774. * @hidden
  88775. */
  88776. _getProperty(propertyPath: string): string;
  88777. /**
  88778. * Internal only
  88779. * @hidden
  88780. */
  88781. _getEffectiveTarget(target: any, propertyPath: string): any;
  88782. /**
  88783. * Serialize placeholder for child classes
  88784. * @param parent of child
  88785. * @returns the serialized object
  88786. */
  88787. serialize(parent: any): any;
  88788. /**
  88789. * Internal only called by serialize
  88790. * @hidden
  88791. */
  88792. protected _serialize(serializedAction: any, parent?: any): any;
  88793. /**
  88794. * Internal only
  88795. * @hidden
  88796. */
  88797. static _SerializeValueAsString: (value: any) => string;
  88798. /**
  88799. * Internal only
  88800. * @hidden
  88801. */
  88802. static _GetTargetProperty: (target: Scene | Node) => {
  88803. name: string;
  88804. targetType: string;
  88805. value: string;
  88806. };
  88807. }
  88808. }
  88809. declare module BABYLON {
  88810. /**
  88811. * A Condition applied to an Action
  88812. */
  88813. export class Condition {
  88814. /**
  88815. * Internal only - manager for action
  88816. * @hidden
  88817. */
  88818. _actionManager: ActionManager;
  88819. /**
  88820. * Internal only
  88821. * @hidden
  88822. */
  88823. _evaluationId: number;
  88824. /**
  88825. * Internal only
  88826. * @hidden
  88827. */
  88828. _currentResult: boolean;
  88829. /**
  88830. * Creates a new Condition
  88831. * @param actionManager the manager of the action the condition is applied to
  88832. */
  88833. constructor(actionManager: ActionManager);
  88834. /**
  88835. * Check if the current condition is valid
  88836. * @returns a boolean
  88837. */
  88838. isValid(): boolean;
  88839. /**
  88840. * Internal only
  88841. * @hidden
  88842. */
  88843. _getProperty(propertyPath: string): string;
  88844. /**
  88845. * Internal only
  88846. * @hidden
  88847. */
  88848. _getEffectiveTarget(target: any, propertyPath: string): any;
  88849. /**
  88850. * Serialize placeholder for child classes
  88851. * @returns the serialized object
  88852. */
  88853. serialize(): any;
  88854. /**
  88855. * Internal only
  88856. * @hidden
  88857. */
  88858. protected _serialize(serializedCondition: any): any;
  88859. }
  88860. /**
  88861. * Defines specific conditional operators as extensions of Condition
  88862. */
  88863. export class ValueCondition extends Condition {
  88864. /** path to specify the property of the target the conditional operator uses */
  88865. propertyPath: string;
  88866. /** the value compared by the conditional operator against the current value of the property */
  88867. value: any;
  88868. /** the conditional operator, default ValueCondition.IsEqual */
  88869. operator: number;
  88870. /**
  88871. * Internal only
  88872. * @hidden
  88873. */
  88874. private static _IsEqual;
  88875. /**
  88876. * Internal only
  88877. * @hidden
  88878. */
  88879. private static _IsDifferent;
  88880. /**
  88881. * Internal only
  88882. * @hidden
  88883. */
  88884. private static _IsGreater;
  88885. /**
  88886. * Internal only
  88887. * @hidden
  88888. */
  88889. private static _IsLesser;
  88890. /**
  88891. * returns the number for IsEqual
  88892. */
  88893. static get IsEqual(): number;
  88894. /**
  88895. * Returns the number for IsDifferent
  88896. */
  88897. static get IsDifferent(): number;
  88898. /**
  88899. * Returns the number for IsGreater
  88900. */
  88901. static get IsGreater(): number;
  88902. /**
  88903. * Returns the number for IsLesser
  88904. */
  88905. static get IsLesser(): number;
  88906. /**
  88907. * Internal only The action manager for the condition
  88908. * @hidden
  88909. */
  88910. _actionManager: ActionManager;
  88911. /**
  88912. * Internal only
  88913. * @hidden
  88914. */
  88915. private _target;
  88916. /**
  88917. * Internal only
  88918. * @hidden
  88919. */
  88920. private _effectiveTarget;
  88921. /**
  88922. * Internal only
  88923. * @hidden
  88924. */
  88925. private _property;
  88926. /**
  88927. * Creates a new ValueCondition
  88928. * @param actionManager manager for the action the condition applies to
  88929. * @param target for the action
  88930. * @param propertyPath path to specify the property of the target the conditional operator uses
  88931. * @param value the value compared by the conditional operator against the current value of the property
  88932. * @param operator the conditional operator, default ValueCondition.IsEqual
  88933. */
  88934. constructor(actionManager: ActionManager, target: any,
  88935. /** path to specify the property of the target the conditional operator uses */
  88936. propertyPath: string,
  88937. /** the value compared by the conditional operator against the current value of the property */
  88938. value: any,
  88939. /** the conditional operator, default ValueCondition.IsEqual */
  88940. operator?: number);
  88941. /**
  88942. * Compares the given value with the property value for the specified conditional operator
  88943. * @returns the result of the comparison
  88944. */
  88945. isValid(): boolean;
  88946. /**
  88947. * Serialize the ValueCondition into a JSON compatible object
  88948. * @returns serialization object
  88949. */
  88950. serialize(): any;
  88951. /**
  88952. * Gets the name of the conditional operator for the ValueCondition
  88953. * @param operator the conditional operator
  88954. * @returns the name
  88955. */
  88956. static GetOperatorName(operator: number): string;
  88957. }
  88958. /**
  88959. * Defines a predicate condition as an extension of Condition
  88960. */
  88961. export class PredicateCondition extends Condition {
  88962. /** defines the predicate function used to validate the condition */
  88963. predicate: () => boolean;
  88964. /**
  88965. * Internal only - manager for action
  88966. * @hidden
  88967. */
  88968. _actionManager: ActionManager;
  88969. /**
  88970. * Creates a new PredicateCondition
  88971. * @param actionManager manager for the action the condition applies to
  88972. * @param predicate defines the predicate function used to validate the condition
  88973. */
  88974. constructor(actionManager: ActionManager,
  88975. /** defines the predicate function used to validate the condition */
  88976. predicate: () => boolean);
  88977. /**
  88978. * @returns the validity of the predicate condition
  88979. */
  88980. isValid(): boolean;
  88981. }
  88982. /**
  88983. * Defines a state condition as an extension of Condition
  88984. */
  88985. export class StateCondition extends Condition {
  88986. /** Value to compare with target state */
  88987. value: string;
  88988. /**
  88989. * Internal only - manager for action
  88990. * @hidden
  88991. */
  88992. _actionManager: ActionManager;
  88993. /**
  88994. * Internal only
  88995. * @hidden
  88996. */
  88997. private _target;
  88998. /**
  88999. * Creates a new StateCondition
  89000. * @param actionManager manager for the action the condition applies to
  89001. * @param target of the condition
  89002. * @param value to compare with target state
  89003. */
  89004. constructor(actionManager: ActionManager, target: any,
  89005. /** Value to compare with target state */
  89006. value: string);
  89007. /**
  89008. * Gets a boolean indicating if the current condition is met
  89009. * @returns the validity of the state
  89010. */
  89011. isValid(): boolean;
  89012. /**
  89013. * Serialize the StateCondition into a JSON compatible object
  89014. * @returns serialization object
  89015. */
  89016. serialize(): any;
  89017. }
  89018. }
  89019. declare module BABYLON {
  89020. /**
  89021. * This defines an action responsible to toggle a boolean once triggered.
  89022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89023. */
  89024. export class SwitchBooleanAction extends Action {
  89025. /**
  89026. * The path to the boolean property in the target object
  89027. */
  89028. propertyPath: string;
  89029. private _target;
  89030. private _effectiveTarget;
  89031. private _property;
  89032. /**
  89033. * Instantiate the action
  89034. * @param triggerOptions defines the trigger options
  89035. * @param target defines the object containing the boolean
  89036. * @param propertyPath defines the path to the boolean property in the target object
  89037. * @param condition defines the trigger related conditions
  89038. */
  89039. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89040. /** @hidden */
  89041. _prepare(): void;
  89042. /**
  89043. * Execute the action toggle the boolean value.
  89044. */
  89045. execute(): void;
  89046. /**
  89047. * Serializes the actions and its related information.
  89048. * @param parent defines the object to serialize in
  89049. * @returns the serialized object
  89050. */
  89051. serialize(parent: any): any;
  89052. }
  89053. /**
  89054. * This defines an action responsible to set a the state field of the target
  89055. * to a desired value once triggered.
  89056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89057. */
  89058. export class SetStateAction extends Action {
  89059. /**
  89060. * The value to store in the state field.
  89061. */
  89062. value: string;
  89063. private _target;
  89064. /**
  89065. * Instantiate the action
  89066. * @param triggerOptions defines the trigger options
  89067. * @param target defines the object containing the state property
  89068. * @param value defines the value to store in the state field
  89069. * @param condition defines the trigger related conditions
  89070. */
  89071. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89072. /**
  89073. * Execute the action and store the value on the target state property.
  89074. */
  89075. execute(): void;
  89076. /**
  89077. * Serializes the actions and its related information.
  89078. * @param parent defines the object to serialize in
  89079. * @returns the serialized object
  89080. */
  89081. serialize(parent: any): any;
  89082. }
  89083. /**
  89084. * This defines an action responsible to set a property of the target
  89085. * to a desired value once triggered.
  89086. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89087. */
  89088. export class SetValueAction extends Action {
  89089. /**
  89090. * The path of the property to set in the target.
  89091. */
  89092. propertyPath: string;
  89093. /**
  89094. * The value to set in the property
  89095. */
  89096. value: any;
  89097. private _target;
  89098. private _effectiveTarget;
  89099. private _property;
  89100. /**
  89101. * Instantiate the action
  89102. * @param triggerOptions defines the trigger options
  89103. * @param target defines the object containing the property
  89104. * @param propertyPath defines the path of the property to set in the target
  89105. * @param value defines the value to set in the property
  89106. * @param condition defines the trigger related conditions
  89107. */
  89108. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89109. /** @hidden */
  89110. _prepare(): void;
  89111. /**
  89112. * Execute the action and set the targetted property to the desired value.
  89113. */
  89114. execute(): void;
  89115. /**
  89116. * Serializes the actions and its related information.
  89117. * @param parent defines the object to serialize in
  89118. * @returns the serialized object
  89119. */
  89120. serialize(parent: any): any;
  89121. }
  89122. /**
  89123. * This defines an action responsible to increment the target value
  89124. * to a desired value once triggered.
  89125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89126. */
  89127. export class IncrementValueAction extends Action {
  89128. /**
  89129. * The path of the property to increment in the target.
  89130. */
  89131. propertyPath: string;
  89132. /**
  89133. * The value we should increment the property by.
  89134. */
  89135. value: any;
  89136. private _target;
  89137. private _effectiveTarget;
  89138. private _property;
  89139. /**
  89140. * Instantiate the action
  89141. * @param triggerOptions defines the trigger options
  89142. * @param target defines the object containing the property
  89143. * @param propertyPath defines the path of the property to increment in the target
  89144. * @param value defines the value value we should increment the property by
  89145. * @param condition defines the trigger related conditions
  89146. */
  89147. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89148. /** @hidden */
  89149. _prepare(): void;
  89150. /**
  89151. * Execute the action and increment the target of the value amount.
  89152. */
  89153. execute(): void;
  89154. /**
  89155. * Serializes the actions and its related information.
  89156. * @param parent defines the object to serialize in
  89157. * @returns the serialized object
  89158. */
  89159. serialize(parent: any): any;
  89160. }
  89161. /**
  89162. * This defines an action responsible to start an animation once triggered.
  89163. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89164. */
  89165. export class PlayAnimationAction extends Action {
  89166. /**
  89167. * Where the animation should start (animation frame)
  89168. */
  89169. from: number;
  89170. /**
  89171. * Where the animation should stop (animation frame)
  89172. */
  89173. to: number;
  89174. /**
  89175. * Define if the animation should loop or stop after the first play.
  89176. */
  89177. loop?: boolean;
  89178. private _target;
  89179. /**
  89180. * Instantiate the action
  89181. * @param triggerOptions defines the trigger options
  89182. * @param target defines the target animation or animation name
  89183. * @param from defines from where the animation should start (animation frame)
  89184. * @param end defines where the animation should stop (animation frame)
  89185. * @param loop defines if the animation should loop or stop after the first play
  89186. * @param condition defines the trigger related conditions
  89187. */
  89188. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89189. /** @hidden */
  89190. _prepare(): void;
  89191. /**
  89192. * Execute the action and play the animation.
  89193. */
  89194. execute(): void;
  89195. /**
  89196. * Serializes the actions and its related information.
  89197. * @param parent defines the object to serialize in
  89198. * @returns the serialized object
  89199. */
  89200. serialize(parent: any): any;
  89201. }
  89202. /**
  89203. * This defines an action responsible to stop an animation once triggered.
  89204. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89205. */
  89206. export class StopAnimationAction extends Action {
  89207. private _target;
  89208. /**
  89209. * Instantiate the action
  89210. * @param triggerOptions defines the trigger options
  89211. * @param target defines the target animation or animation name
  89212. * @param condition defines the trigger related conditions
  89213. */
  89214. constructor(triggerOptions: any, target: any, condition?: Condition);
  89215. /** @hidden */
  89216. _prepare(): void;
  89217. /**
  89218. * Execute the action and stop the animation.
  89219. */
  89220. execute(): void;
  89221. /**
  89222. * Serializes the actions and its related information.
  89223. * @param parent defines the object to serialize in
  89224. * @returns the serialized object
  89225. */
  89226. serialize(parent: any): any;
  89227. }
  89228. /**
  89229. * This defines an action responsible that does nothing once triggered.
  89230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89231. */
  89232. export class DoNothingAction extends Action {
  89233. /**
  89234. * Instantiate the action
  89235. * @param triggerOptions defines the trigger options
  89236. * @param condition defines the trigger related conditions
  89237. */
  89238. constructor(triggerOptions?: any, condition?: Condition);
  89239. /**
  89240. * Execute the action and do nothing.
  89241. */
  89242. execute(): void;
  89243. /**
  89244. * Serializes the actions and its related information.
  89245. * @param parent defines the object to serialize in
  89246. * @returns the serialized object
  89247. */
  89248. serialize(parent: any): any;
  89249. }
  89250. /**
  89251. * This defines an action responsible to trigger several actions once triggered.
  89252. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89253. */
  89254. export class CombineAction extends Action {
  89255. /**
  89256. * The list of aggregated animations to run.
  89257. */
  89258. children: Action[];
  89259. /**
  89260. * Instantiate the action
  89261. * @param triggerOptions defines the trigger options
  89262. * @param children defines the list of aggregated animations to run
  89263. * @param condition defines the trigger related conditions
  89264. */
  89265. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89266. /** @hidden */
  89267. _prepare(): void;
  89268. /**
  89269. * Execute the action and executes all the aggregated actions.
  89270. */
  89271. execute(evt: ActionEvent): void;
  89272. /**
  89273. * Serializes the actions and its related information.
  89274. * @param parent defines the object to serialize in
  89275. * @returns the serialized object
  89276. */
  89277. serialize(parent: any): any;
  89278. }
  89279. /**
  89280. * This defines an action responsible to run code (external event) once triggered.
  89281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89282. */
  89283. export class ExecuteCodeAction extends Action {
  89284. /**
  89285. * The callback function to run.
  89286. */
  89287. func: (evt: ActionEvent) => void;
  89288. /**
  89289. * Instantiate the action
  89290. * @param triggerOptions defines the trigger options
  89291. * @param func defines the callback function to run
  89292. * @param condition defines the trigger related conditions
  89293. */
  89294. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89295. /**
  89296. * Execute the action and run the attached code.
  89297. */
  89298. execute(evt: ActionEvent): void;
  89299. }
  89300. /**
  89301. * This defines an action responsible to set the parent property of the target once triggered.
  89302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89303. */
  89304. export class SetParentAction extends Action {
  89305. private _parent;
  89306. private _target;
  89307. /**
  89308. * Instantiate the action
  89309. * @param triggerOptions defines the trigger options
  89310. * @param target defines the target containing the parent property
  89311. * @param parent defines from where the animation should start (animation frame)
  89312. * @param condition defines the trigger related conditions
  89313. */
  89314. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89315. /** @hidden */
  89316. _prepare(): void;
  89317. /**
  89318. * Execute the action and set the parent property.
  89319. */
  89320. execute(): void;
  89321. /**
  89322. * Serializes the actions and its related information.
  89323. * @param parent defines the object to serialize in
  89324. * @returns the serialized object
  89325. */
  89326. serialize(parent: any): any;
  89327. }
  89328. }
  89329. declare module BABYLON {
  89330. /**
  89331. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89332. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89334. */
  89335. export class ActionManager extends AbstractActionManager {
  89336. /**
  89337. * Nothing
  89338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89339. */
  89340. static readonly NothingTrigger: number;
  89341. /**
  89342. * On pick
  89343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89344. */
  89345. static readonly OnPickTrigger: number;
  89346. /**
  89347. * On left pick
  89348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89349. */
  89350. static readonly OnLeftPickTrigger: number;
  89351. /**
  89352. * On right pick
  89353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89354. */
  89355. static readonly OnRightPickTrigger: number;
  89356. /**
  89357. * On center pick
  89358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89359. */
  89360. static readonly OnCenterPickTrigger: number;
  89361. /**
  89362. * On pick down
  89363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89364. */
  89365. static readonly OnPickDownTrigger: number;
  89366. /**
  89367. * On double pick
  89368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89369. */
  89370. static readonly OnDoublePickTrigger: number;
  89371. /**
  89372. * On pick up
  89373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89374. */
  89375. static readonly OnPickUpTrigger: number;
  89376. /**
  89377. * On pick out.
  89378. * This trigger will only be raised if you also declared a OnPickDown
  89379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89380. */
  89381. static readonly OnPickOutTrigger: number;
  89382. /**
  89383. * On long press
  89384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89385. */
  89386. static readonly OnLongPressTrigger: number;
  89387. /**
  89388. * On pointer over
  89389. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89390. */
  89391. static readonly OnPointerOverTrigger: number;
  89392. /**
  89393. * On pointer out
  89394. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89395. */
  89396. static readonly OnPointerOutTrigger: number;
  89397. /**
  89398. * On every frame
  89399. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89400. */
  89401. static readonly OnEveryFrameTrigger: number;
  89402. /**
  89403. * On intersection enter
  89404. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89405. */
  89406. static readonly OnIntersectionEnterTrigger: number;
  89407. /**
  89408. * On intersection exit
  89409. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89410. */
  89411. static readonly OnIntersectionExitTrigger: number;
  89412. /**
  89413. * On key down
  89414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89415. */
  89416. static readonly OnKeyDownTrigger: number;
  89417. /**
  89418. * On key up
  89419. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89420. */
  89421. static readonly OnKeyUpTrigger: number;
  89422. private _scene;
  89423. /**
  89424. * Creates a new action manager
  89425. * @param scene defines the hosting scene
  89426. */
  89427. constructor(scene: Scene);
  89428. /**
  89429. * Releases all associated resources
  89430. */
  89431. dispose(): void;
  89432. /**
  89433. * Gets hosting scene
  89434. * @returns the hosting scene
  89435. */
  89436. getScene(): Scene;
  89437. /**
  89438. * Does this action manager handles actions of any of the given triggers
  89439. * @param triggers defines the triggers to be tested
  89440. * @return a boolean indicating whether one (or more) of the triggers is handled
  89441. */
  89442. hasSpecificTriggers(triggers: number[]): boolean;
  89443. /**
  89444. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89445. * speed.
  89446. * @param triggerA defines the trigger to be tested
  89447. * @param triggerB defines the trigger to be tested
  89448. * @return a boolean indicating whether one (or more) of the triggers is handled
  89449. */
  89450. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89451. /**
  89452. * Does this action manager handles actions of a given trigger
  89453. * @param trigger defines the trigger to be tested
  89454. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89455. * @return whether the trigger is handled
  89456. */
  89457. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89458. /**
  89459. * Does this action manager has pointer triggers
  89460. */
  89461. get hasPointerTriggers(): boolean;
  89462. /**
  89463. * Does this action manager has pick triggers
  89464. */
  89465. get hasPickTriggers(): boolean;
  89466. /**
  89467. * Registers an action to this action manager
  89468. * @param action defines the action to be registered
  89469. * @return the action amended (prepared) after registration
  89470. */
  89471. registerAction(action: IAction): Nullable<IAction>;
  89472. /**
  89473. * Unregisters an action to this action manager
  89474. * @param action defines the action to be unregistered
  89475. * @return a boolean indicating whether the action has been unregistered
  89476. */
  89477. unregisterAction(action: IAction): Boolean;
  89478. /**
  89479. * Process a specific trigger
  89480. * @param trigger defines the trigger to process
  89481. * @param evt defines the event details to be processed
  89482. */
  89483. processTrigger(trigger: number, evt?: IActionEvent): void;
  89484. /** @hidden */
  89485. _getEffectiveTarget(target: any, propertyPath: string): any;
  89486. /** @hidden */
  89487. _getProperty(propertyPath: string): string;
  89488. /**
  89489. * Serialize this manager to a JSON object
  89490. * @param name defines the property name to store this manager
  89491. * @returns a JSON representation of this manager
  89492. */
  89493. serialize(name: string): any;
  89494. /**
  89495. * Creates a new ActionManager from a JSON data
  89496. * @param parsedActions defines the JSON data to read from
  89497. * @param object defines the hosting mesh
  89498. * @param scene defines the hosting scene
  89499. */
  89500. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89501. /**
  89502. * Get a trigger name by index
  89503. * @param trigger defines the trigger index
  89504. * @returns a trigger name
  89505. */
  89506. static GetTriggerName(trigger: number): string;
  89507. }
  89508. }
  89509. declare module BABYLON {
  89510. /**
  89511. * Class used to represent a sprite
  89512. * @see https://doc.babylonjs.com/babylon101/sprites
  89513. */
  89514. export class Sprite implements IAnimatable {
  89515. /** defines the name */
  89516. name: string;
  89517. /** Gets or sets the current world position */
  89518. position: Vector3;
  89519. /** Gets or sets the main color */
  89520. color: Color4;
  89521. /** Gets or sets the width */
  89522. width: number;
  89523. /** Gets or sets the height */
  89524. height: number;
  89525. /** Gets or sets rotation angle */
  89526. angle: number;
  89527. /** Gets or sets the cell index in the sprite sheet */
  89528. cellIndex: number;
  89529. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89530. cellRef: string;
  89531. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89532. invertU: boolean;
  89533. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89534. invertV: boolean;
  89535. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89536. disposeWhenFinishedAnimating: boolean;
  89537. /** Gets the list of attached animations */
  89538. animations: Nullable<Array<Animation>>;
  89539. /** Gets or sets a boolean indicating if the sprite can be picked */
  89540. isPickable: boolean;
  89541. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89542. useAlphaForPicking: boolean;
  89543. /** @hidden */
  89544. _xOffset: number;
  89545. /** @hidden */
  89546. _yOffset: number;
  89547. /** @hidden */
  89548. _xSize: number;
  89549. /** @hidden */
  89550. _ySize: number;
  89551. /**
  89552. * Gets or sets the associated action manager
  89553. */
  89554. actionManager: Nullable<ActionManager>;
  89555. /**
  89556. * An event triggered when the control has been disposed
  89557. */
  89558. onDisposeObservable: Observable<Sprite>;
  89559. private _animationStarted;
  89560. private _loopAnimation;
  89561. private _fromIndex;
  89562. private _toIndex;
  89563. private _delay;
  89564. private _direction;
  89565. private _manager;
  89566. private _time;
  89567. private _onAnimationEnd;
  89568. /**
  89569. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89570. */
  89571. isVisible: boolean;
  89572. /**
  89573. * Gets or sets the sprite size
  89574. */
  89575. get size(): number;
  89576. set size(value: number);
  89577. /**
  89578. * Returns a boolean indicating if the animation is started
  89579. */
  89580. get animationStarted(): boolean;
  89581. /**
  89582. * Gets or sets the unique id of the sprite
  89583. */
  89584. uniqueId: number;
  89585. /**
  89586. * Gets the manager of this sprite
  89587. */
  89588. get manager(): ISpriteManager;
  89589. /**
  89590. * Creates a new Sprite
  89591. * @param name defines the name
  89592. * @param manager defines the manager
  89593. */
  89594. constructor(
  89595. /** defines the name */
  89596. name: string, manager: ISpriteManager);
  89597. /**
  89598. * Returns the string "Sprite"
  89599. * @returns "Sprite"
  89600. */
  89601. getClassName(): string;
  89602. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89603. get fromIndex(): number;
  89604. set fromIndex(value: number);
  89605. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89606. get toIndex(): number;
  89607. set toIndex(value: number);
  89608. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89609. get loopAnimation(): boolean;
  89610. set loopAnimation(value: boolean);
  89611. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89612. get delay(): number;
  89613. set delay(value: number);
  89614. /**
  89615. * Starts an animation
  89616. * @param from defines the initial key
  89617. * @param to defines the end key
  89618. * @param loop defines if the animation must loop
  89619. * @param delay defines the start delay (in ms)
  89620. * @param onAnimationEnd defines a callback to call when animation ends
  89621. */
  89622. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89623. /** Stops current animation (if any) */
  89624. stopAnimation(): void;
  89625. /** @hidden */
  89626. _animate(deltaTime: number): void;
  89627. /** Release associated resources */
  89628. dispose(): void;
  89629. /**
  89630. * Serializes the sprite to a JSON object
  89631. * @returns the JSON object
  89632. */
  89633. serialize(): any;
  89634. /**
  89635. * Parses a JSON object to create a new sprite
  89636. * @param parsedSprite The JSON object to parse
  89637. * @param manager defines the hosting manager
  89638. * @returns the new sprite
  89639. */
  89640. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89641. }
  89642. }
  89643. declare module BABYLON {
  89644. /**
  89645. * Information about the result of picking within a scene
  89646. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89647. */
  89648. export class PickingInfo {
  89649. /** @hidden */
  89650. _pickingUnavailable: boolean;
  89651. /**
  89652. * If the pick collided with an object
  89653. */
  89654. hit: boolean;
  89655. /**
  89656. * Distance away where the pick collided
  89657. */
  89658. distance: number;
  89659. /**
  89660. * The location of pick collision
  89661. */
  89662. pickedPoint: Nullable<Vector3>;
  89663. /**
  89664. * The mesh corresponding the the pick collision
  89665. */
  89666. pickedMesh: Nullable<AbstractMesh>;
  89667. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89668. bu: number;
  89669. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89670. bv: number;
  89671. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89672. faceId: number;
  89673. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89674. subMeshFaceId: number;
  89675. /** Id of the the submesh that was picked */
  89676. subMeshId: number;
  89677. /** If a sprite was picked, this will be the sprite the pick collided with */
  89678. pickedSprite: Nullable<Sprite>;
  89679. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  89680. thinInstanceIndex: number;
  89681. /**
  89682. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89683. */
  89684. originMesh: Nullable<AbstractMesh>;
  89685. /**
  89686. * The ray that was used to perform the picking.
  89687. */
  89688. ray: Nullable<Ray>;
  89689. /**
  89690. * Gets the normal correspodning to the face the pick collided with
  89691. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89692. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89693. * @returns The normal correspodning to the face the pick collided with
  89694. */
  89695. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89696. /**
  89697. * Gets the texture coordinates of where the pick occured
  89698. * @returns the vector containing the coordnates of the texture
  89699. */
  89700. getTextureCoordinates(): Nullable<Vector2>;
  89701. }
  89702. }
  89703. declare module BABYLON {
  89704. /**
  89705. * Class representing a ray with position and direction
  89706. */
  89707. export class Ray {
  89708. /** origin point */
  89709. origin: Vector3;
  89710. /** direction */
  89711. direction: Vector3;
  89712. /** length of the ray */
  89713. length: number;
  89714. private static readonly _TmpVector3;
  89715. private _tmpRay;
  89716. /**
  89717. * Creates a new ray
  89718. * @param origin origin point
  89719. * @param direction direction
  89720. * @param length length of the ray
  89721. */
  89722. constructor(
  89723. /** origin point */
  89724. origin: Vector3,
  89725. /** direction */
  89726. direction: Vector3,
  89727. /** length of the ray */
  89728. length?: number);
  89729. /**
  89730. * Checks if the ray intersects a box
  89731. * This does not account for the ray lenght by design to improve perfs.
  89732. * @param minimum bound of the box
  89733. * @param maximum bound of the box
  89734. * @param intersectionTreshold extra extend to be added to the box in all direction
  89735. * @returns if the box was hit
  89736. */
  89737. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89738. /**
  89739. * Checks if the ray intersects a box
  89740. * This does not account for the ray lenght by design to improve perfs.
  89741. * @param box the bounding box to check
  89742. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89743. * @returns if the box was hit
  89744. */
  89745. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89746. /**
  89747. * If the ray hits a sphere
  89748. * @param sphere the bounding sphere to check
  89749. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89750. * @returns true if it hits the sphere
  89751. */
  89752. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89753. /**
  89754. * If the ray hits a triange
  89755. * @param vertex0 triangle vertex
  89756. * @param vertex1 triangle vertex
  89757. * @param vertex2 triangle vertex
  89758. * @returns intersection information if hit
  89759. */
  89760. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89761. /**
  89762. * Checks if ray intersects a plane
  89763. * @param plane the plane to check
  89764. * @returns the distance away it was hit
  89765. */
  89766. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89767. /**
  89768. * Calculate the intercept of a ray on a given axis
  89769. * @param axis to check 'x' | 'y' | 'z'
  89770. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89771. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89772. */
  89773. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89774. /**
  89775. * Checks if ray intersects a mesh
  89776. * @param mesh the mesh to check
  89777. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89778. * @returns picking info of the intersecton
  89779. */
  89780. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89781. /**
  89782. * Checks if ray intersects a mesh
  89783. * @param meshes the meshes to check
  89784. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89785. * @param results array to store result in
  89786. * @returns Array of picking infos
  89787. */
  89788. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89789. private _comparePickingInfo;
  89790. private static smallnum;
  89791. private static rayl;
  89792. /**
  89793. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89794. * @param sega the first point of the segment to test the intersection against
  89795. * @param segb the second point of the segment to test the intersection against
  89796. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89797. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89798. */
  89799. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89800. /**
  89801. * Update the ray from viewport position
  89802. * @param x position
  89803. * @param y y position
  89804. * @param viewportWidth viewport width
  89805. * @param viewportHeight viewport height
  89806. * @param world world matrix
  89807. * @param view view matrix
  89808. * @param projection projection matrix
  89809. * @returns this ray updated
  89810. */
  89811. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89812. /**
  89813. * Creates a ray with origin and direction of 0,0,0
  89814. * @returns the new ray
  89815. */
  89816. static Zero(): Ray;
  89817. /**
  89818. * Creates a new ray from screen space and viewport
  89819. * @param x position
  89820. * @param y y position
  89821. * @param viewportWidth viewport width
  89822. * @param viewportHeight viewport height
  89823. * @param world world matrix
  89824. * @param view view matrix
  89825. * @param projection projection matrix
  89826. * @returns new ray
  89827. */
  89828. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89829. /**
  89830. * 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
  89831. * transformed to the given world matrix.
  89832. * @param origin The origin point
  89833. * @param end The end point
  89834. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89835. * @returns the new ray
  89836. */
  89837. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89838. /**
  89839. * Transforms a ray by a matrix
  89840. * @param ray ray to transform
  89841. * @param matrix matrix to apply
  89842. * @returns the resulting new ray
  89843. */
  89844. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89845. /**
  89846. * Transforms a ray by a matrix
  89847. * @param ray ray to transform
  89848. * @param matrix matrix to apply
  89849. * @param result ray to store result in
  89850. */
  89851. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89852. /**
  89853. * Unproject a ray from screen space to object space
  89854. * @param sourceX defines the screen space x coordinate to use
  89855. * @param sourceY defines the screen space y coordinate to use
  89856. * @param viewportWidth defines the current width of the viewport
  89857. * @param viewportHeight defines the current height of the viewport
  89858. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89859. * @param view defines the view matrix to use
  89860. * @param projection defines the projection matrix to use
  89861. */
  89862. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89863. }
  89864. /**
  89865. * Type used to define predicate used to select faces when a mesh intersection is detected
  89866. */
  89867. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89868. interface Scene {
  89869. /** @hidden */
  89870. _tempPickingRay: Nullable<Ray>;
  89871. /** @hidden */
  89872. _cachedRayForTransform: Ray;
  89873. /** @hidden */
  89874. _pickWithRayInverseMatrix: Matrix;
  89875. /** @hidden */
  89876. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89877. /** @hidden */
  89878. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89879. /** @hidden */
  89880. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89881. }
  89882. }
  89883. declare module BABYLON {
  89884. /**
  89885. * Groups all the scene component constants in one place to ease maintenance.
  89886. * @hidden
  89887. */
  89888. export class SceneComponentConstants {
  89889. static readonly NAME_EFFECTLAYER: string;
  89890. static readonly NAME_LAYER: string;
  89891. static readonly NAME_LENSFLARESYSTEM: string;
  89892. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89893. static readonly NAME_PARTICLESYSTEM: string;
  89894. static readonly NAME_GAMEPAD: string;
  89895. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89896. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89897. static readonly NAME_PREPASSRENDERER: string;
  89898. static readonly NAME_DEPTHRENDERER: string;
  89899. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89900. static readonly NAME_SPRITE: string;
  89901. static readonly NAME_OUTLINERENDERER: string;
  89902. static readonly NAME_PROCEDURALTEXTURE: string;
  89903. static readonly NAME_SHADOWGENERATOR: string;
  89904. static readonly NAME_OCTREE: string;
  89905. static readonly NAME_PHYSICSENGINE: string;
  89906. static readonly NAME_AUDIO: string;
  89907. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89908. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89909. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89910. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89911. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89912. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89913. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89914. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89915. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89916. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89917. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89918. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89919. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89920. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89921. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89922. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89923. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89924. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89925. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89926. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89927. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89928. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89929. static readonly STEP_AFTERRENDER_AUDIO: number;
  89930. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89931. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89932. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89933. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89934. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89935. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89936. static readonly STEP_POINTERMOVE_SPRITE: number;
  89937. static readonly STEP_POINTERDOWN_SPRITE: number;
  89938. static readonly STEP_POINTERUP_SPRITE: number;
  89939. }
  89940. /**
  89941. * This represents a scene component.
  89942. *
  89943. * This is used to decouple the dependency the scene is having on the different workloads like
  89944. * layers, post processes...
  89945. */
  89946. export interface ISceneComponent {
  89947. /**
  89948. * The name of the component. Each component must have a unique name.
  89949. */
  89950. name: string;
  89951. /**
  89952. * The scene the component belongs to.
  89953. */
  89954. scene: Scene;
  89955. /**
  89956. * Register the component to one instance of a scene.
  89957. */
  89958. register(): void;
  89959. /**
  89960. * Rebuilds the elements related to this component in case of
  89961. * context lost for instance.
  89962. */
  89963. rebuild(): void;
  89964. /**
  89965. * Disposes the component and the associated ressources.
  89966. */
  89967. dispose(): void;
  89968. }
  89969. /**
  89970. * This represents a SERIALIZABLE scene component.
  89971. *
  89972. * This extends Scene Component to add Serialization methods on top.
  89973. */
  89974. export interface ISceneSerializableComponent extends ISceneComponent {
  89975. /**
  89976. * Adds all the elements from the container to the scene
  89977. * @param container the container holding the elements
  89978. */
  89979. addFromContainer(container: AbstractScene): void;
  89980. /**
  89981. * Removes all the elements in the container from the scene
  89982. * @param container contains the elements to remove
  89983. * @param dispose if the removed element should be disposed (default: false)
  89984. */
  89985. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89986. /**
  89987. * Serializes the component data to the specified json object
  89988. * @param serializationObject The object to serialize to
  89989. */
  89990. serialize(serializationObject: any): void;
  89991. }
  89992. /**
  89993. * Strong typing of a Mesh related stage step action
  89994. */
  89995. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89996. /**
  89997. * Strong typing of a Evaluate Sub Mesh related stage step action
  89998. */
  89999. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90000. /**
  90001. * Strong typing of a Active Mesh related stage step action
  90002. */
  90003. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90004. /**
  90005. * Strong typing of a Camera related stage step action
  90006. */
  90007. export type CameraStageAction = (camera: Camera) => void;
  90008. /**
  90009. * Strong typing of a Camera Frame buffer related stage step action
  90010. */
  90011. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90012. /**
  90013. * Strong typing of a Render Target related stage step action
  90014. */
  90015. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90016. /**
  90017. * Strong typing of a RenderingGroup related stage step action
  90018. */
  90019. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90020. /**
  90021. * Strong typing of a Mesh Render related stage step action
  90022. */
  90023. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90024. /**
  90025. * Strong typing of a simple stage step action
  90026. */
  90027. export type SimpleStageAction = () => void;
  90028. /**
  90029. * Strong typing of a render target action.
  90030. */
  90031. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90032. /**
  90033. * Strong typing of a pointer move action.
  90034. */
  90035. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90036. /**
  90037. * Strong typing of a pointer up/down action.
  90038. */
  90039. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90040. /**
  90041. * Representation of a stage in the scene (Basically a list of ordered steps)
  90042. * @hidden
  90043. */
  90044. export class Stage<T extends Function> extends Array<{
  90045. index: number;
  90046. component: ISceneComponent;
  90047. action: T;
  90048. }> {
  90049. /**
  90050. * Hide ctor from the rest of the world.
  90051. * @param items The items to add.
  90052. */
  90053. private constructor();
  90054. /**
  90055. * Creates a new Stage.
  90056. * @returns A new instance of a Stage
  90057. */
  90058. static Create<T extends Function>(): Stage<T>;
  90059. /**
  90060. * Registers a step in an ordered way in the targeted stage.
  90061. * @param index Defines the position to register the step in
  90062. * @param component Defines the component attached to the step
  90063. * @param action Defines the action to launch during the step
  90064. */
  90065. registerStep(index: number, component: ISceneComponent, action: T): void;
  90066. /**
  90067. * Clears all the steps from the stage.
  90068. */
  90069. clear(): void;
  90070. }
  90071. }
  90072. declare module BABYLON {
  90073. interface Scene {
  90074. /** @hidden */
  90075. _pointerOverSprite: Nullable<Sprite>;
  90076. /** @hidden */
  90077. _pickedDownSprite: Nullable<Sprite>;
  90078. /** @hidden */
  90079. _tempSpritePickingRay: Nullable<Ray>;
  90080. /**
  90081. * All of the sprite managers added to this scene
  90082. * @see https://doc.babylonjs.com/babylon101/sprites
  90083. */
  90084. spriteManagers: Array<ISpriteManager>;
  90085. /**
  90086. * An event triggered when sprites rendering is about to start
  90087. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90088. */
  90089. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90090. /**
  90091. * An event triggered when sprites rendering is done
  90092. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90093. */
  90094. onAfterSpritesRenderingObservable: Observable<Scene>;
  90095. /** @hidden */
  90096. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90097. /** Launch a ray to try to pick a sprite in the scene
  90098. * @param x position on screen
  90099. * @param y position on screen
  90100. * @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
  90101. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90102. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90103. * @returns a PickingInfo
  90104. */
  90105. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90106. /** Use the given ray to pick a sprite in the scene
  90107. * @param ray The ray (in world space) to use to pick meshes
  90108. * @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
  90109. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90110. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90111. * @returns a PickingInfo
  90112. */
  90113. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90114. /** @hidden */
  90115. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90116. /** Launch a ray to try to pick sprites in the scene
  90117. * @param x position on screen
  90118. * @param y position on screen
  90119. * @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
  90120. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90121. * @returns a PickingInfo array
  90122. */
  90123. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90124. /** Use the given ray to pick sprites in the scene
  90125. * @param ray The ray (in world space) to use to pick meshes
  90126. * @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
  90127. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90128. * @returns a PickingInfo array
  90129. */
  90130. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90131. /**
  90132. * Force the sprite under the pointer
  90133. * @param sprite defines the sprite to use
  90134. */
  90135. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90136. /**
  90137. * Gets the sprite under the pointer
  90138. * @returns a Sprite or null if no sprite is under the pointer
  90139. */
  90140. getPointerOverSprite(): Nullable<Sprite>;
  90141. }
  90142. /**
  90143. * Defines the sprite scene component responsible to manage sprites
  90144. * in a given scene.
  90145. */
  90146. export class SpriteSceneComponent implements ISceneComponent {
  90147. /**
  90148. * The component name helpfull to identify the component in the list of scene components.
  90149. */
  90150. readonly name: string;
  90151. /**
  90152. * The scene the component belongs to.
  90153. */
  90154. scene: Scene;
  90155. /** @hidden */
  90156. private _spritePredicate;
  90157. /**
  90158. * Creates a new instance of the component for the given scene
  90159. * @param scene Defines the scene to register the component in
  90160. */
  90161. constructor(scene: Scene);
  90162. /**
  90163. * Registers the component in a given scene
  90164. */
  90165. register(): void;
  90166. /**
  90167. * Rebuilds the elements related to this component in case of
  90168. * context lost for instance.
  90169. */
  90170. rebuild(): void;
  90171. /**
  90172. * Disposes the component and the associated ressources.
  90173. */
  90174. dispose(): void;
  90175. private _pickSpriteButKeepRay;
  90176. private _pointerMove;
  90177. private _pointerDown;
  90178. private _pointerUp;
  90179. }
  90180. }
  90181. declare module BABYLON {
  90182. /** @hidden */
  90183. export var fogFragmentDeclaration: {
  90184. name: string;
  90185. shader: string;
  90186. };
  90187. }
  90188. declare module BABYLON {
  90189. /** @hidden */
  90190. export var fogFragment: {
  90191. name: string;
  90192. shader: string;
  90193. };
  90194. }
  90195. declare module BABYLON {
  90196. /** @hidden */
  90197. export var spritesPixelShader: {
  90198. name: string;
  90199. shader: string;
  90200. };
  90201. }
  90202. declare module BABYLON {
  90203. /** @hidden */
  90204. export var fogVertexDeclaration: {
  90205. name: string;
  90206. shader: string;
  90207. };
  90208. }
  90209. declare module BABYLON {
  90210. /** @hidden */
  90211. export var spritesVertexShader: {
  90212. name: string;
  90213. shader: string;
  90214. };
  90215. }
  90216. declare module BABYLON {
  90217. /**
  90218. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90219. */
  90220. export interface ISpriteManager extends IDisposable {
  90221. /**
  90222. * Gets manager's name
  90223. */
  90224. name: string;
  90225. /**
  90226. * Restricts the camera to viewing objects with the same layerMask.
  90227. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90228. */
  90229. layerMask: number;
  90230. /**
  90231. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90232. */
  90233. isPickable: boolean;
  90234. /**
  90235. * Gets the hosting scene
  90236. */
  90237. scene: Scene;
  90238. /**
  90239. * Specifies the rendering group id for this mesh (0 by default)
  90240. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90241. */
  90242. renderingGroupId: number;
  90243. /**
  90244. * Defines the list of sprites managed by the manager.
  90245. */
  90246. sprites: Array<Sprite>;
  90247. /**
  90248. * Gets or sets the spritesheet texture
  90249. */
  90250. texture: Texture;
  90251. /** Defines the default width of a cell in the spritesheet */
  90252. cellWidth: number;
  90253. /** Defines the default height of a cell in the spritesheet */
  90254. cellHeight: number;
  90255. /**
  90256. * Tests the intersection of a sprite with a specific ray.
  90257. * @param ray The ray we are sending to test the collision
  90258. * @param camera The camera space we are sending rays in
  90259. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90260. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90261. * @returns picking info or null.
  90262. */
  90263. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90264. /**
  90265. * Intersects the sprites with a ray
  90266. * @param ray defines the ray to intersect with
  90267. * @param camera defines the current active camera
  90268. * @param predicate defines a predicate used to select candidate sprites
  90269. * @returns null if no hit or a PickingInfo array
  90270. */
  90271. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90272. /**
  90273. * Renders the list of sprites on screen.
  90274. */
  90275. render(): void;
  90276. }
  90277. /**
  90278. * Class used to manage multiple sprites on the same spritesheet
  90279. * @see https://doc.babylonjs.com/babylon101/sprites
  90280. */
  90281. export class SpriteManager implements ISpriteManager {
  90282. /** defines the manager's name */
  90283. name: string;
  90284. /** Define the Url to load snippets */
  90285. static SnippetUrl: string;
  90286. /** Snippet ID if the manager was created from the snippet server */
  90287. snippetId: string;
  90288. /** Gets the list of sprites */
  90289. sprites: Sprite[];
  90290. /** Gets or sets the rendering group id (0 by default) */
  90291. renderingGroupId: number;
  90292. /** Gets or sets camera layer mask */
  90293. layerMask: number;
  90294. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90295. fogEnabled: boolean;
  90296. /** Gets or sets a boolean indicating if the sprites are pickable */
  90297. isPickable: boolean;
  90298. /** Defines the default width of a cell in the spritesheet */
  90299. cellWidth: number;
  90300. /** Defines the default height of a cell in the spritesheet */
  90301. cellHeight: number;
  90302. /** Associative array from JSON sprite data file */
  90303. private _cellData;
  90304. /** Array of sprite names from JSON sprite data file */
  90305. private _spriteMap;
  90306. /** True when packed cell data from JSON file is ready*/
  90307. private _packedAndReady;
  90308. private _textureContent;
  90309. private _useInstancing;
  90310. /**
  90311. * An event triggered when the manager is disposed.
  90312. */
  90313. onDisposeObservable: Observable<SpriteManager>;
  90314. private _onDisposeObserver;
  90315. /**
  90316. * Callback called when the manager is disposed
  90317. */
  90318. set onDispose(callback: () => void);
  90319. private _capacity;
  90320. private _fromPacked;
  90321. private _spriteTexture;
  90322. private _epsilon;
  90323. private _scene;
  90324. private _vertexData;
  90325. private _buffer;
  90326. private _vertexBuffers;
  90327. private _spriteBuffer;
  90328. private _indexBuffer;
  90329. private _effectBase;
  90330. private _effectFog;
  90331. private _vertexBufferSize;
  90332. /**
  90333. * Gets or sets the unique id of the sprite
  90334. */
  90335. uniqueId: number;
  90336. /**
  90337. * Gets the array of sprites
  90338. */
  90339. get children(): Sprite[];
  90340. /**
  90341. * Gets the hosting scene
  90342. */
  90343. get scene(): Scene;
  90344. /**
  90345. * Gets the capacity of the manager
  90346. */
  90347. get capacity(): number;
  90348. /**
  90349. * Gets or sets the spritesheet texture
  90350. */
  90351. get texture(): Texture;
  90352. set texture(value: Texture);
  90353. private _blendMode;
  90354. /**
  90355. * Blend mode use to render the particle, it can be any of
  90356. * the static Constants.ALPHA_x properties provided in this class.
  90357. * Default value is Constants.ALPHA_COMBINE
  90358. */
  90359. get blendMode(): number;
  90360. set blendMode(blendMode: number);
  90361. /** Disables writing to the depth buffer when rendering the sprites.
  90362. * It can be handy to disable depth writing when using textures without alpha channel
  90363. * and setting some specific blend modes.
  90364. */
  90365. disableDepthWrite: boolean;
  90366. /**
  90367. * Creates a new sprite manager
  90368. * @param name defines the manager's name
  90369. * @param imgUrl defines the sprite sheet url
  90370. * @param capacity defines the maximum allowed number of sprites
  90371. * @param cellSize defines the size of a sprite cell
  90372. * @param scene defines the hosting scene
  90373. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90374. * @param samplingMode defines the smapling mode to use with spritesheet
  90375. * @param fromPacked set to false; do not alter
  90376. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90377. */
  90378. constructor(
  90379. /** defines the manager's name */
  90380. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90381. /**
  90382. * Returns the string "SpriteManager"
  90383. * @returns "SpriteManager"
  90384. */
  90385. getClassName(): string;
  90386. private _makePacked;
  90387. private _appendSpriteVertex;
  90388. private _checkTextureAlpha;
  90389. /**
  90390. * Intersects the sprites with a ray
  90391. * @param ray defines the ray to intersect with
  90392. * @param camera defines the current active camera
  90393. * @param predicate defines a predicate used to select candidate sprites
  90394. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90395. * @returns null if no hit or a PickingInfo
  90396. */
  90397. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90398. /**
  90399. * Intersects the sprites with a ray
  90400. * @param ray defines the ray to intersect with
  90401. * @param camera defines the current active camera
  90402. * @param predicate defines a predicate used to select candidate sprites
  90403. * @returns null if no hit or a PickingInfo array
  90404. */
  90405. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90406. /**
  90407. * Render all child sprites
  90408. */
  90409. render(): void;
  90410. /**
  90411. * Release associated resources
  90412. */
  90413. dispose(): void;
  90414. /**
  90415. * Serializes the sprite manager to a JSON object
  90416. * @param serializeTexture defines if the texture must be serialized as well
  90417. * @returns the JSON object
  90418. */
  90419. serialize(serializeTexture?: boolean): any;
  90420. /**
  90421. * Parses a JSON object to create a new sprite manager.
  90422. * @param parsedManager The JSON object to parse
  90423. * @param scene The scene to create the sprite managerin
  90424. * @param rootUrl The root url to use to load external dependencies like texture
  90425. * @returns the new sprite manager
  90426. */
  90427. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90428. /**
  90429. * Creates a sprite manager from a snippet saved in a remote file
  90430. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90431. * @param url defines the url to load from
  90432. * @param scene defines the hosting scene
  90433. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90434. * @returns a promise that will resolve to the new sprite manager
  90435. */
  90436. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90437. /**
  90438. * Creates a sprite manager from a snippet saved by the sprite editor
  90439. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90440. * @param scene defines the hosting scene
  90441. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90442. * @returns a promise that will resolve to the new sprite manager
  90443. */
  90444. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90445. }
  90446. }
  90447. declare module BABYLON {
  90448. /** Interface used by value gradients (color, factor, ...) */
  90449. export interface IValueGradient {
  90450. /**
  90451. * Gets or sets the gradient value (between 0 and 1)
  90452. */
  90453. gradient: number;
  90454. }
  90455. /** Class used to store color4 gradient */
  90456. export class ColorGradient implements IValueGradient {
  90457. /**
  90458. * Gets or sets the gradient value (between 0 and 1)
  90459. */
  90460. gradient: number;
  90461. /**
  90462. * Gets or sets first associated color
  90463. */
  90464. color1: Color4;
  90465. /**
  90466. * Gets or sets second associated color
  90467. */
  90468. color2?: Color4 | undefined;
  90469. /**
  90470. * Creates a new color4 gradient
  90471. * @param gradient gets or sets the gradient value (between 0 and 1)
  90472. * @param color1 gets or sets first associated color
  90473. * @param color2 gets or sets first second color
  90474. */
  90475. constructor(
  90476. /**
  90477. * Gets or sets the gradient value (between 0 and 1)
  90478. */
  90479. gradient: number,
  90480. /**
  90481. * Gets or sets first associated color
  90482. */
  90483. color1: Color4,
  90484. /**
  90485. * Gets or sets second associated color
  90486. */
  90487. color2?: Color4 | undefined);
  90488. /**
  90489. * Will get a color picked randomly between color1 and color2.
  90490. * If color2 is undefined then color1 will be used
  90491. * @param result defines the target Color4 to store the result in
  90492. */
  90493. getColorToRef(result: Color4): void;
  90494. }
  90495. /** Class used to store color 3 gradient */
  90496. export class Color3Gradient implements IValueGradient {
  90497. /**
  90498. * Gets or sets the gradient value (between 0 and 1)
  90499. */
  90500. gradient: number;
  90501. /**
  90502. * Gets or sets the associated color
  90503. */
  90504. color: Color3;
  90505. /**
  90506. * Creates a new color3 gradient
  90507. * @param gradient gets or sets the gradient value (between 0 and 1)
  90508. * @param color gets or sets associated color
  90509. */
  90510. constructor(
  90511. /**
  90512. * Gets or sets the gradient value (between 0 and 1)
  90513. */
  90514. gradient: number,
  90515. /**
  90516. * Gets or sets the associated color
  90517. */
  90518. color: Color3);
  90519. }
  90520. /** Class used to store factor gradient */
  90521. export class FactorGradient implements IValueGradient {
  90522. /**
  90523. * Gets or sets the gradient value (between 0 and 1)
  90524. */
  90525. gradient: number;
  90526. /**
  90527. * Gets or sets first associated factor
  90528. */
  90529. factor1: number;
  90530. /**
  90531. * Gets or sets second associated factor
  90532. */
  90533. factor2?: number | undefined;
  90534. /**
  90535. * Creates a new factor gradient
  90536. * @param gradient gets or sets the gradient value (between 0 and 1)
  90537. * @param factor1 gets or sets first associated factor
  90538. * @param factor2 gets or sets second associated factor
  90539. */
  90540. constructor(
  90541. /**
  90542. * Gets or sets the gradient value (between 0 and 1)
  90543. */
  90544. gradient: number,
  90545. /**
  90546. * Gets or sets first associated factor
  90547. */
  90548. factor1: number,
  90549. /**
  90550. * Gets or sets second associated factor
  90551. */
  90552. factor2?: number | undefined);
  90553. /**
  90554. * Will get a number picked randomly between factor1 and factor2.
  90555. * If factor2 is undefined then factor1 will be used
  90556. * @returns the picked number
  90557. */
  90558. getFactor(): number;
  90559. }
  90560. /**
  90561. * Helper used to simplify some generic gradient tasks
  90562. */
  90563. export class GradientHelper {
  90564. /**
  90565. * Gets the current gradient from an array of IValueGradient
  90566. * @param ratio defines the current ratio to get
  90567. * @param gradients defines the array of IValueGradient
  90568. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90569. */
  90570. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90571. }
  90572. }
  90573. declare module BABYLON {
  90574. interface ThinEngine {
  90575. /**
  90576. * Creates a raw texture
  90577. * @param data defines the data to store in the texture
  90578. * @param width defines the width of the texture
  90579. * @param height defines the height of the texture
  90580. * @param format defines the format of the data
  90581. * @param generateMipMaps defines if the engine should generate the mip levels
  90582. * @param invertY defines if data must be stored with Y axis inverted
  90583. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90584. * @param compression defines the compression used (null by default)
  90585. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90586. * @returns the raw texture inside an InternalTexture
  90587. */
  90588. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90589. /**
  90590. * Update a raw texture
  90591. * @param texture defines the texture to update
  90592. * @param data defines the data to store in the texture
  90593. * @param format defines the format of the data
  90594. * @param invertY defines if data must be stored with Y axis inverted
  90595. */
  90596. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90597. /**
  90598. * Update a raw texture
  90599. * @param texture defines the texture to update
  90600. * @param data defines the data to store in the texture
  90601. * @param format defines the format of the data
  90602. * @param invertY defines if data must be stored with Y axis inverted
  90603. * @param compression defines the compression used (null by default)
  90604. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90605. */
  90606. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90607. /**
  90608. * Creates a new raw cube texture
  90609. * @param data defines the array of data to use to create each face
  90610. * @param size defines the size of the textures
  90611. * @param format defines the format of the data
  90612. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90613. * @param generateMipMaps defines if the engine should generate the mip levels
  90614. * @param invertY defines if data must be stored with Y axis inverted
  90615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90616. * @param compression defines the compression used (null by default)
  90617. * @returns the cube texture as an InternalTexture
  90618. */
  90619. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90620. /**
  90621. * Update a raw cube texture
  90622. * @param texture defines the texture to udpdate
  90623. * @param data defines the data to store
  90624. * @param format defines the data format
  90625. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90626. * @param invertY defines if data must be stored with Y axis inverted
  90627. */
  90628. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90629. /**
  90630. * Update a raw cube texture
  90631. * @param texture defines the texture to udpdate
  90632. * @param data defines the data to store
  90633. * @param format defines the data format
  90634. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90635. * @param invertY defines if data must be stored with Y axis inverted
  90636. * @param compression defines the compression used (null by default)
  90637. */
  90638. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90639. /**
  90640. * Update a raw cube texture
  90641. * @param texture defines the texture to udpdate
  90642. * @param data defines the data to store
  90643. * @param format defines the data format
  90644. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90645. * @param invertY defines if data must be stored with Y axis inverted
  90646. * @param compression defines the compression used (null by default)
  90647. * @param level defines which level of the texture to update
  90648. */
  90649. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90650. /**
  90651. * Creates a new raw cube texture from a specified url
  90652. * @param url defines the url where the data is located
  90653. * @param scene defines the current scene
  90654. * @param size defines the size of the textures
  90655. * @param format defines the format of the data
  90656. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90657. * @param noMipmap defines if the engine should avoid generating the mip levels
  90658. * @param callback defines a callback used to extract texture data from loaded data
  90659. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90660. * @param onLoad defines a callback called when texture is loaded
  90661. * @param onError defines a callback called if there is an error
  90662. * @returns the cube texture as an InternalTexture
  90663. */
  90664. 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;
  90665. /**
  90666. * Creates a new raw cube texture from a specified url
  90667. * @param url defines the url where the data is located
  90668. * @param scene defines the current scene
  90669. * @param size defines the size of the textures
  90670. * @param format defines the format of the data
  90671. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90672. * @param noMipmap defines if the engine should avoid generating the mip levels
  90673. * @param callback defines a callback used to extract texture data from loaded data
  90674. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90675. * @param onLoad defines a callback called when texture is loaded
  90676. * @param onError defines a callback called if there is an error
  90677. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90678. * @param invertY defines if data must be stored with Y axis inverted
  90679. * @returns the cube texture as an InternalTexture
  90680. */
  90681. 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;
  90682. /**
  90683. * Creates a new raw 3D texture
  90684. * @param data defines the data used to create the texture
  90685. * @param width defines the width of the texture
  90686. * @param height defines the height of the texture
  90687. * @param depth defines the depth of the texture
  90688. * @param format defines the format of the texture
  90689. * @param generateMipMaps defines if the engine must generate mip levels
  90690. * @param invertY defines if data must be stored with Y axis inverted
  90691. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90692. * @param compression defines the compressed used (can be null)
  90693. * @param textureType defines the compressed used (can be null)
  90694. * @returns a new raw 3D texture (stored in an InternalTexture)
  90695. */
  90696. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90697. /**
  90698. * Update a raw 3D texture
  90699. * @param texture defines the texture to update
  90700. * @param data defines the data to store
  90701. * @param format defines the data format
  90702. * @param invertY defines if data must be stored with Y axis inverted
  90703. */
  90704. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90705. /**
  90706. * Update a raw 3D texture
  90707. * @param texture defines the texture to update
  90708. * @param data defines the data to store
  90709. * @param format defines the data format
  90710. * @param invertY defines if data must be stored with Y axis inverted
  90711. * @param compression defines the used compression (can be null)
  90712. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90713. */
  90714. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90715. /**
  90716. * Creates a new raw 2D array texture
  90717. * @param data defines the data used to create the texture
  90718. * @param width defines the width of the texture
  90719. * @param height defines the height of the texture
  90720. * @param depth defines the number of layers of the texture
  90721. * @param format defines the format of the texture
  90722. * @param generateMipMaps defines if the engine must generate mip levels
  90723. * @param invertY defines if data must be stored with Y axis inverted
  90724. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90725. * @param compression defines the compressed used (can be null)
  90726. * @param textureType defines the compressed used (can be null)
  90727. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90728. */
  90729. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90730. /**
  90731. * Update a raw 2D array texture
  90732. * @param texture defines the texture to update
  90733. * @param data defines the data to store
  90734. * @param format defines the data format
  90735. * @param invertY defines if data must be stored with Y axis inverted
  90736. */
  90737. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90738. /**
  90739. * Update a raw 2D array texture
  90740. * @param texture defines the texture to update
  90741. * @param data defines the data to store
  90742. * @param format defines the data format
  90743. * @param invertY defines if data must be stored with Y axis inverted
  90744. * @param compression defines the used compression (can be null)
  90745. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90746. */
  90747. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90748. }
  90749. }
  90750. declare module BABYLON {
  90751. /**
  90752. * Raw texture can help creating a texture directly from an array of data.
  90753. * This can be super useful if you either get the data from an uncompressed source or
  90754. * if you wish to create your texture pixel by pixel.
  90755. */
  90756. export class RawTexture extends Texture {
  90757. /**
  90758. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90759. */
  90760. format: number;
  90761. /**
  90762. * Instantiates a new RawTexture.
  90763. * Raw texture can help creating a texture directly from an array of data.
  90764. * This can be super useful if you either get the data from an uncompressed source or
  90765. * if you wish to create your texture pixel by pixel.
  90766. * @param data define the array of data to use to create the texture
  90767. * @param width define the width of the texture
  90768. * @param height define the height of the texture
  90769. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90770. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90771. * @param generateMipMaps define whether mip maps should be generated or not
  90772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90774. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90775. */
  90776. constructor(data: ArrayBufferView, width: number, height: number,
  90777. /**
  90778. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90779. */
  90780. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90781. /**
  90782. * Updates the texture underlying data.
  90783. * @param data Define the new data of the texture
  90784. */
  90785. update(data: ArrayBufferView): void;
  90786. /**
  90787. * Creates a luminance texture from some data.
  90788. * @param data Define the texture data
  90789. * @param width Define the width of the texture
  90790. * @param height Define the height of the texture
  90791. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90795. * @returns the luminance texture
  90796. */
  90797. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90798. /**
  90799. * Creates a luminance alpha texture from some data.
  90800. * @param data Define the texture data
  90801. * @param width Define the width of the texture
  90802. * @param height Define the height of the texture
  90803. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90804. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90807. * @returns the luminance alpha texture
  90808. */
  90809. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90810. /**
  90811. * Creates an alpha texture from some data.
  90812. * @param data Define the texture data
  90813. * @param width Define the width of the texture
  90814. * @param height Define the height of the texture
  90815. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90819. * @returns the alpha texture
  90820. */
  90821. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90822. /**
  90823. * Creates a RGB texture from some data.
  90824. * @param data Define the texture data
  90825. * @param width Define the width of the texture
  90826. * @param height Define the height of the texture
  90827. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90828. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90829. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90830. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90831. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90832. * @returns the RGB alpha texture
  90833. */
  90834. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90835. /**
  90836. * Creates a RGBA texture from some data.
  90837. * @param data Define the texture data
  90838. * @param width Define the width of the texture
  90839. * @param height Define the height of the texture
  90840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90844. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90845. * @returns the RGBA texture
  90846. */
  90847. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90848. /**
  90849. * Creates a R texture from some data.
  90850. * @param data Define the texture data
  90851. * @param width Define the width of the texture
  90852. * @param height Define the height of the texture
  90853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90858. * @returns the R texture
  90859. */
  90860. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90861. }
  90862. }
  90863. declare module BABYLON {
  90864. interface ThinEngine {
  90865. /**
  90866. * Update a dynamic index buffer
  90867. * @param indexBuffer defines the target index buffer
  90868. * @param indices defines the data to update
  90869. * @param offset defines the offset in the target index buffer where update should start
  90870. */
  90871. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90872. /**
  90873. * Updates a dynamic vertex buffer.
  90874. * @param vertexBuffer the vertex buffer to update
  90875. * @param data the data used to update the vertex buffer
  90876. * @param byteOffset the byte offset of the data
  90877. * @param byteLength the byte length of the data
  90878. */
  90879. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90880. }
  90881. }
  90882. declare module BABYLON {
  90883. interface AbstractScene {
  90884. /**
  90885. * The list of procedural textures added to the scene
  90886. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90887. */
  90888. proceduralTextures: Array<ProceduralTexture>;
  90889. }
  90890. /**
  90891. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90892. * in a given scene.
  90893. */
  90894. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90895. /**
  90896. * The component name helpfull to identify the component in the list of scene components.
  90897. */
  90898. readonly name: string;
  90899. /**
  90900. * The scene the component belongs to.
  90901. */
  90902. scene: Scene;
  90903. /**
  90904. * Creates a new instance of the component for the given scene
  90905. * @param scene Defines the scene to register the component in
  90906. */
  90907. constructor(scene: Scene);
  90908. /**
  90909. * Registers the component in a given scene
  90910. */
  90911. register(): void;
  90912. /**
  90913. * Rebuilds the elements related to this component in case of
  90914. * context lost for instance.
  90915. */
  90916. rebuild(): void;
  90917. /**
  90918. * Disposes the component and the associated ressources.
  90919. */
  90920. dispose(): void;
  90921. private _beforeClear;
  90922. }
  90923. }
  90924. declare module BABYLON {
  90925. interface ThinEngine {
  90926. /**
  90927. * Creates a new render target cube texture
  90928. * @param size defines the size of the texture
  90929. * @param options defines the options used to create the texture
  90930. * @returns a new render target cube texture stored in an InternalTexture
  90931. */
  90932. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90933. }
  90934. }
  90935. declare module BABYLON {
  90936. /** @hidden */
  90937. export var proceduralVertexShader: {
  90938. name: string;
  90939. shader: string;
  90940. };
  90941. }
  90942. declare module BABYLON {
  90943. /**
  90944. * 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.
  90945. * This is the base class of any Procedural texture and contains most of the shareable code.
  90946. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90947. */
  90948. export class ProceduralTexture extends Texture {
  90949. isCube: boolean;
  90950. /**
  90951. * Define if the texture is enabled or not (disabled texture will not render)
  90952. */
  90953. isEnabled: boolean;
  90954. /**
  90955. * Define if the texture must be cleared before rendering (default is true)
  90956. */
  90957. autoClear: boolean;
  90958. /**
  90959. * Callback called when the texture is generated
  90960. */
  90961. onGenerated: () => void;
  90962. /**
  90963. * Event raised when the texture is generated
  90964. */
  90965. onGeneratedObservable: Observable<ProceduralTexture>;
  90966. /** @hidden */
  90967. _generateMipMaps: boolean;
  90968. /** @hidden **/
  90969. _effect: Effect;
  90970. /** @hidden */
  90971. _textures: {
  90972. [key: string]: Texture;
  90973. };
  90974. /** @hidden */
  90975. protected _fallbackTexture: Nullable<Texture>;
  90976. private _size;
  90977. private _currentRefreshId;
  90978. private _frameId;
  90979. private _refreshRate;
  90980. private _vertexBuffers;
  90981. private _indexBuffer;
  90982. private _uniforms;
  90983. private _samplers;
  90984. private _fragment;
  90985. private _floats;
  90986. private _ints;
  90987. private _floatsArrays;
  90988. private _colors3;
  90989. private _colors4;
  90990. private _vectors2;
  90991. private _vectors3;
  90992. private _matrices;
  90993. private _fallbackTextureUsed;
  90994. private _fullEngine;
  90995. private _cachedDefines;
  90996. private _contentUpdateId;
  90997. private _contentData;
  90998. /**
  90999. * Instantiates a new procedural texture.
  91000. * 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.
  91001. * This is the base class of any Procedural texture and contains most of the shareable code.
  91002. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91003. * @param name Define the name of the texture
  91004. * @param size Define the size of the texture to create
  91005. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91006. * @param scene Define the scene the texture belongs to
  91007. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91008. * @param generateMipMaps Define if the texture should creates mip maps or not
  91009. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91010. */
  91011. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91012. /**
  91013. * The effect that is created when initializing the post process.
  91014. * @returns The created effect corresponding the the postprocess.
  91015. */
  91016. getEffect(): Effect;
  91017. /**
  91018. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91019. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91020. */
  91021. getContent(): Nullable<ArrayBufferView>;
  91022. private _createIndexBuffer;
  91023. /** @hidden */
  91024. _rebuild(): void;
  91025. /**
  91026. * Resets the texture in order to recreate its associated resources.
  91027. * This can be called in case of context loss
  91028. */
  91029. reset(): void;
  91030. protected _getDefines(): string;
  91031. /**
  91032. * Is the texture ready to be used ? (rendered at least once)
  91033. * @returns true if ready, otherwise, false.
  91034. */
  91035. isReady(): boolean;
  91036. /**
  91037. * Resets the refresh counter of the texture and start bak from scratch.
  91038. * Could be useful to regenerate the texture if it is setup to render only once.
  91039. */
  91040. resetRefreshCounter(): void;
  91041. /**
  91042. * Set the fragment shader to use in order to render the texture.
  91043. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91044. */
  91045. setFragment(fragment: any): void;
  91046. /**
  91047. * Define the refresh rate of the texture or the rendering frequency.
  91048. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91049. */
  91050. get refreshRate(): number;
  91051. set refreshRate(value: number);
  91052. /** @hidden */
  91053. _shouldRender(): boolean;
  91054. /**
  91055. * Get the size the texture is rendering at.
  91056. * @returns the size (texture is always squared)
  91057. */
  91058. getRenderSize(): number;
  91059. /**
  91060. * Resize the texture to new value.
  91061. * @param size Define the new size the texture should have
  91062. * @param generateMipMaps Define whether the new texture should create mip maps
  91063. */
  91064. resize(size: number, generateMipMaps: boolean): void;
  91065. private _checkUniform;
  91066. /**
  91067. * Set a texture in the shader program used to render.
  91068. * @param name Define the name of the uniform samplers as defined in the shader
  91069. * @param texture Define the texture to bind to this sampler
  91070. * @return the texture itself allowing "fluent" like uniform updates
  91071. */
  91072. setTexture(name: string, texture: Texture): ProceduralTexture;
  91073. /**
  91074. * Set a float in the shader.
  91075. * @param name Define the name of the uniform as defined in the shader
  91076. * @param value Define the value to give to the uniform
  91077. * @return the texture itself allowing "fluent" like uniform updates
  91078. */
  91079. setFloat(name: string, value: number): ProceduralTexture;
  91080. /**
  91081. * Set a int in the shader.
  91082. * @param name Define the name of the uniform as defined in the shader
  91083. * @param value Define the value to give to the uniform
  91084. * @return the texture itself allowing "fluent" like uniform updates
  91085. */
  91086. setInt(name: string, value: number): ProceduralTexture;
  91087. /**
  91088. * Set an array of floats in the shader.
  91089. * @param name Define the name of the uniform as defined in the shader
  91090. * @param value Define the value to give to the uniform
  91091. * @return the texture itself allowing "fluent" like uniform updates
  91092. */
  91093. setFloats(name: string, value: number[]): ProceduralTexture;
  91094. /**
  91095. * Set a vec3 in the shader from a Color3.
  91096. * @param name Define the name of the uniform as defined in the shader
  91097. * @param value Define the value to give to the uniform
  91098. * @return the texture itself allowing "fluent" like uniform updates
  91099. */
  91100. setColor3(name: string, value: Color3): ProceduralTexture;
  91101. /**
  91102. * Set a vec4 in the shader from a Color4.
  91103. * @param name Define the name of the uniform as defined in the shader
  91104. * @param value Define the value to give to the uniform
  91105. * @return the texture itself allowing "fluent" like uniform updates
  91106. */
  91107. setColor4(name: string, value: Color4): ProceduralTexture;
  91108. /**
  91109. * Set a vec2 in the shader from a Vector2.
  91110. * @param name Define the name of the uniform as defined in the shader
  91111. * @param value Define the value to give to the uniform
  91112. * @return the texture itself allowing "fluent" like uniform updates
  91113. */
  91114. setVector2(name: string, value: Vector2): ProceduralTexture;
  91115. /**
  91116. * Set a vec3 in the shader from a Vector3.
  91117. * @param name Define the name of the uniform as defined in the shader
  91118. * @param value Define the value to give to the uniform
  91119. * @return the texture itself allowing "fluent" like uniform updates
  91120. */
  91121. setVector3(name: string, value: Vector3): ProceduralTexture;
  91122. /**
  91123. * Set a mat4 in the shader from a MAtrix.
  91124. * @param name Define the name of the uniform as defined in the shader
  91125. * @param value Define the value to give to the uniform
  91126. * @return the texture itself allowing "fluent" like uniform updates
  91127. */
  91128. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91129. /**
  91130. * Render the texture to its associated render target.
  91131. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91132. */
  91133. render(useCameraPostProcess?: boolean): void;
  91134. /**
  91135. * Clone the texture.
  91136. * @returns the cloned texture
  91137. */
  91138. clone(): ProceduralTexture;
  91139. /**
  91140. * Dispose the texture and release its asoociated resources.
  91141. */
  91142. dispose(): void;
  91143. }
  91144. }
  91145. declare module BABYLON {
  91146. /**
  91147. * This represents the base class for particle system in Babylon.
  91148. * 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.
  91149. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91150. * @example https://doc.babylonjs.com/babylon101/particles
  91151. */
  91152. export class BaseParticleSystem {
  91153. /**
  91154. * Source color is added to the destination color without alpha affecting the result
  91155. */
  91156. static BLENDMODE_ONEONE: number;
  91157. /**
  91158. * Blend current color and particle color using particle’s alpha
  91159. */
  91160. static BLENDMODE_STANDARD: number;
  91161. /**
  91162. * Add current color and particle color multiplied by particle’s alpha
  91163. */
  91164. static BLENDMODE_ADD: number;
  91165. /**
  91166. * Multiply current color with particle color
  91167. */
  91168. static BLENDMODE_MULTIPLY: number;
  91169. /**
  91170. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91171. */
  91172. static BLENDMODE_MULTIPLYADD: number;
  91173. /**
  91174. * List of animations used by the particle system.
  91175. */
  91176. animations: Animation[];
  91177. /**
  91178. * Gets or sets the unique id of the particle system
  91179. */
  91180. uniqueId: number;
  91181. /**
  91182. * The id of the Particle system.
  91183. */
  91184. id: string;
  91185. /**
  91186. * The friendly name of the Particle system.
  91187. */
  91188. name: string;
  91189. /**
  91190. * Snippet ID if the particle system was created from the snippet server
  91191. */
  91192. snippetId: string;
  91193. /**
  91194. * The rendering group used by the Particle system to chose when to render.
  91195. */
  91196. renderingGroupId: number;
  91197. /**
  91198. * The emitter represents the Mesh or position we are attaching the particle system to.
  91199. */
  91200. emitter: Nullable<AbstractMesh | Vector3>;
  91201. /**
  91202. * The maximum number of particles to emit per frame
  91203. */
  91204. emitRate: number;
  91205. /**
  91206. * If you want to launch only a few particles at once, that can be done, as well.
  91207. */
  91208. manualEmitCount: number;
  91209. /**
  91210. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91211. */
  91212. updateSpeed: number;
  91213. /**
  91214. * The amount of time the particle system is running (depends of the overall update speed).
  91215. */
  91216. targetStopDuration: number;
  91217. /**
  91218. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91219. */
  91220. disposeOnStop: boolean;
  91221. /**
  91222. * Minimum power of emitting particles.
  91223. */
  91224. minEmitPower: number;
  91225. /**
  91226. * Maximum power of emitting particles.
  91227. */
  91228. maxEmitPower: number;
  91229. /**
  91230. * Minimum life time of emitting particles.
  91231. */
  91232. minLifeTime: number;
  91233. /**
  91234. * Maximum life time of emitting particles.
  91235. */
  91236. maxLifeTime: number;
  91237. /**
  91238. * Minimum Size of emitting particles.
  91239. */
  91240. minSize: number;
  91241. /**
  91242. * Maximum Size of emitting particles.
  91243. */
  91244. maxSize: number;
  91245. /**
  91246. * Minimum scale of emitting particles on X axis.
  91247. */
  91248. minScaleX: number;
  91249. /**
  91250. * Maximum scale of emitting particles on X axis.
  91251. */
  91252. maxScaleX: number;
  91253. /**
  91254. * Minimum scale of emitting particles on Y axis.
  91255. */
  91256. minScaleY: number;
  91257. /**
  91258. * Maximum scale of emitting particles on Y axis.
  91259. */
  91260. maxScaleY: number;
  91261. /**
  91262. * Gets or sets the minimal initial rotation in radians.
  91263. */
  91264. minInitialRotation: number;
  91265. /**
  91266. * Gets or sets the maximal initial rotation in radians.
  91267. */
  91268. maxInitialRotation: number;
  91269. /**
  91270. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91271. */
  91272. minAngularSpeed: number;
  91273. /**
  91274. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91275. */
  91276. maxAngularSpeed: number;
  91277. /**
  91278. * The texture used to render each particle. (this can be a spritesheet)
  91279. */
  91280. particleTexture: Nullable<BaseTexture>;
  91281. /**
  91282. * The layer mask we are rendering the particles through.
  91283. */
  91284. layerMask: number;
  91285. /**
  91286. * This can help using your own shader to render the particle system.
  91287. * The according effect will be created
  91288. */
  91289. customShader: any;
  91290. /**
  91291. * By default particle system starts as soon as they are created. This prevents the
  91292. * automatic start to happen and let you decide when to start emitting particles.
  91293. */
  91294. preventAutoStart: boolean;
  91295. private _noiseTexture;
  91296. /**
  91297. * Gets or sets a texture used to add random noise to particle positions
  91298. */
  91299. get noiseTexture(): Nullable<ProceduralTexture>;
  91300. set noiseTexture(value: Nullable<ProceduralTexture>);
  91301. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91302. noiseStrength: Vector3;
  91303. /**
  91304. * Callback triggered when the particle animation is ending.
  91305. */
  91306. onAnimationEnd: Nullable<() => void>;
  91307. /**
  91308. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91309. */
  91310. blendMode: number;
  91311. /**
  91312. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91313. * to override the particles.
  91314. */
  91315. forceDepthWrite: boolean;
  91316. /** 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 */
  91317. preWarmCycles: number;
  91318. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91319. preWarmStepOffset: number;
  91320. /**
  91321. * 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)
  91322. */
  91323. spriteCellChangeSpeed: number;
  91324. /**
  91325. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91326. */
  91327. startSpriteCellID: number;
  91328. /**
  91329. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91330. */
  91331. endSpriteCellID: number;
  91332. /**
  91333. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91334. */
  91335. spriteCellWidth: number;
  91336. /**
  91337. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91338. */
  91339. spriteCellHeight: number;
  91340. /**
  91341. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91342. */
  91343. spriteRandomStartCell: boolean;
  91344. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91345. translationPivot: Vector2;
  91346. /** @hidden */
  91347. protected _isAnimationSheetEnabled: boolean;
  91348. /**
  91349. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91350. */
  91351. beginAnimationOnStart: boolean;
  91352. /**
  91353. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91354. */
  91355. beginAnimationFrom: number;
  91356. /**
  91357. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91358. */
  91359. beginAnimationTo: number;
  91360. /**
  91361. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91362. */
  91363. beginAnimationLoop: boolean;
  91364. /**
  91365. * Gets or sets a world offset applied to all particles
  91366. */
  91367. worldOffset: Vector3;
  91368. /**
  91369. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91370. */
  91371. get isAnimationSheetEnabled(): boolean;
  91372. set isAnimationSheetEnabled(value: boolean);
  91373. /**
  91374. * Get hosting scene
  91375. * @returns the scene
  91376. */
  91377. getScene(): Nullable<Scene>;
  91378. /**
  91379. * You can use gravity if you want to give an orientation to your particles.
  91380. */
  91381. gravity: Vector3;
  91382. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91383. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91384. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91385. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91386. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91387. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91388. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91389. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91390. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91391. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91392. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91393. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91394. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91395. /**
  91396. * Defines the delay in milliseconds before starting the system (0 by default)
  91397. */
  91398. startDelay: number;
  91399. /**
  91400. * Gets the current list of drag gradients.
  91401. * You must use addDragGradient and removeDragGradient to udpate this list
  91402. * @returns the list of drag gradients
  91403. */
  91404. getDragGradients(): Nullable<Array<FactorGradient>>;
  91405. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91406. limitVelocityDamping: number;
  91407. /**
  91408. * Gets the current list of limit velocity gradients.
  91409. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91410. * @returns the list of limit velocity gradients
  91411. */
  91412. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91413. /**
  91414. * Gets the current list of color gradients.
  91415. * You must use addColorGradient and removeColorGradient to udpate this list
  91416. * @returns the list of color gradients
  91417. */
  91418. getColorGradients(): Nullable<Array<ColorGradient>>;
  91419. /**
  91420. * Gets the current list of size gradients.
  91421. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91422. * @returns the list of size gradients
  91423. */
  91424. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91425. /**
  91426. * Gets the current list of color remap gradients.
  91427. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91428. * @returns the list of color remap gradients
  91429. */
  91430. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91431. /**
  91432. * Gets the current list of alpha remap gradients.
  91433. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91434. * @returns the list of alpha remap gradients
  91435. */
  91436. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91437. /**
  91438. * Gets the current list of life time gradients.
  91439. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91440. * @returns the list of life time gradients
  91441. */
  91442. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91443. /**
  91444. * Gets the current list of angular speed gradients.
  91445. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91446. * @returns the list of angular speed gradients
  91447. */
  91448. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91449. /**
  91450. * Gets the current list of velocity gradients.
  91451. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91452. * @returns the list of velocity gradients
  91453. */
  91454. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91455. /**
  91456. * Gets the current list of start size gradients.
  91457. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91458. * @returns the list of start size gradients
  91459. */
  91460. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91461. /**
  91462. * Gets the current list of emit rate gradients.
  91463. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91464. * @returns the list of emit rate gradients
  91465. */
  91466. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91467. /**
  91468. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91469. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91470. */
  91471. get direction1(): Vector3;
  91472. set direction1(value: Vector3);
  91473. /**
  91474. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91475. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91476. */
  91477. get direction2(): Vector3;
  91478. set direction2(value: Vector3);
  91479. /**
  91480. * 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.
  91481. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91482. */
  91483. get minEmitBox(): Vector3;
  91484. set minEmitBox(value: Vector3);
  91485. /**
  91486. * 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.
  91487. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91488. */
  91489. get maxEmitBox(): Vector3;
  91490. set maxEmitBox(value: Vector3);
  91491. /**
  91492. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91493. */
  91494. color1: Color4;
  91495. /**
  91496. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91497. */
  91498. color2: Color4;
  91499. /**
  91500. * Color the particle will have at the end of its lifetime
  91501. */
  91502. colorDead: Color4;
  91503. /**
  91504. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91505. */
  91506. textureMask: Color4;
  91507. /**
  91508. * The particle emitter type defines the emitter used by the particle system.
  91509. * It can be for example box, sphere, or cone...
  91510. */
  91511. particleEmitterType: IParticleEmitterType;
  91512. /** @hidden */
  91513. _isSubEmitter: boolean;
  91514. /**
  91515. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91516. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91517. */
  91518. billboardMode: number;
  91519. protected _isBillboardBased: boolean;
  91520. /**
  91521. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91522. */
  91523. get isBillboardBased(): boolean;
  91524. set isBillboardBased(value: boolean);
  91525. /**
  91526. * The scene the particle system belongs to.
  91527. */
  91528. protected _scene: Nullable<Scene>;
  91529. /**
  91530. * The engine the particle system belongs to.
  91531. */
  91532. protected _engine: ThinEngine;
  91533. /**
  91534. * Local cache of defines for image processing.
  91535. */
  91536. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91537. /**
  91538. * Default configuration related to image processing available in the standard Material.
  91539. */
  91540. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  91541. /**
  91542. * Gets the image processing configuration used either in this material.
  91543. */
  91544. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  91545. /**
  91546. * Sets the Default image processing configuration used either in the this material.
  91547. *
  91548. * If sets to null, the scene one is in use.
  91549. */
  91550. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  91551. /**
  91552. * Attaches a new image processing configuration to the Standard Material.
  91553. * @param configuration
  91554. */
  91555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91556. /** @hidden */
  91557. protected _reset(): void;
  91558. /** @hidden */
  91559. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91560. /**
  91561. * Instantiates a particle system.
  91562. * 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.
  91563. * @param name The name of the particle system
  91564. */
  91565. constructor(name: string);
  91566. /**
  91567. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91570. * @returns the emitter
  91571. */
  91572. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91573. /**
  91574. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91575. * @param radius The radius of the hemisphere to emit from
  91576. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91577. * @returns the emitter
  91578. */
  91579. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91580. /**
  91581. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91582. * @param radius The radius of the sphere to emit from
  91583. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91584. * @returns the emitter
  91585. */
  91586. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91587. /**
  91588. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91589. * @param radius The radius of the sphere to emit from
  91590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91592. * @returns the emitter
  91593. */
  91594. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91595. /**
  91596. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91597. * @param radius The radius of the emission cylinder
  91598. * @param height The height of the emission cylinder
  91599. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91600. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91601. * @returns the emitter
  91602. */
  91603. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91604. /**
  91605. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91606. * @param radius The radius of the cylinder to emit from
  91607. * @param height The height of the emission cylinder
  91608. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91611. * @returns the emitter
  91612. */
  91613. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91614. /**
  91615. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91616. * @param radius The radius of the cone to emit from
  91617. * @param angle The base angle of the cone
  91618. * @returns the emitter
  91619. */
  91620. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91621. /**
  91622. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91625. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91626. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91627. * @returns the emitter
  91628. */
  91629. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91630. }
  91631. }
  91632. declare module BABYLON {
  91633. /**
  91634. * Type of sub emitter
  91635. */
  91636. export enum SubEmitterType {
  91637. /**
  91638. * Attached to the particle over it's lifetime
  91639. */
  91640. ATTACHED = 0,
  91641. /**
  91642. * Created when the particle dies
  91643. */
  91644. END = 1
  91645. }
  91646. /**
  91647. * Sub emitter class used to emit particles from an existing particle
  91648. */
  91649. export class SubEmitter {
  91650. /**
  91651. * the particle system to be used by the sub emitter
  91652. */
  91653. particleSystem: ParticleSystem;
  91654. /**
  91655. * Type of the submitter (Default: END)
  91656. */
  91657. type: SubEmitterType;
  91658. /**
  91659. * 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)
  91660. * Note: This only is supported when using an emitter of type Mesh
  91661. */
  91662. inheritDirection: boolean;
  91663. /**
  91664. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91665. */
  91666. inheritedVelocityAmount: number;
  91667. /**
  91668. * Creates a sub emitter
  91669. * @param particleSystem the particle system to be used by the sub emitter
  91670. */
  91671. constructor(
  91672. /**
  91673. * the particle system to be used by the sub emitter
  91674. */
  91675. particleSystem: ParticleSystem);
  91676. /**
  91677. * Clones the sub emitter
  91678. * @returns the cloned sub emitter
  91679. */
  91680. clone(): SubEmitter;
  91681. /**
  91682. * Serialize current object to a JSON object
  91683. * @returns the serialized object
  91684. */
  91685. serialize(): any;
  91686. /** @hidden */
  91687. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  91688. /**
  91689. * Creates a new SubEmitter from a serialized JSON version
  91690. * @param serializationObject defines the JSON object to read from
  91691. * @param sceneOrEngine defines the hosting scene or the hosting engine
  91692. * @param rootUrl defines the rootUrl for data loading
  91693. * @returns a new SubEmitter
  91694. */
  91695. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  91696. /** Release associated resources */
  91697. dispose(): void;
  91698. }
  91699. }
  91700. declare module BABYLON {
  91701. /** @hidden */
  91702. export var imageProcessingDeclaration: {
  91703. name: string;
  91704. shader: string;
  91705. };
  91706. }
  91707. declare module BABYLON {
  91708. /** @hidden */
  91709. export var imageProcessingFunctions: {
  91710. name: string;
  91711. shader: string;
  91712. };
  91713. }
  91714. declare module BABYLON {
  91715. /** @hidden */
  91716. export var particlesPixelShader: {
  91717. name: string;
  91718. shader: string;
  91719. };
  91720. }
  91721. declare module BABYLON {
  91722. /** @hidden */
  91723. export var particlesVertexShader: {
  91724. name: string;
  91725. shader: string;
  91726. };
  91727. }
  91728. declare module BABYLON {
  91729. /**
  91730. * Interface used to define entities containing multiple clip planes
  91731. */
  91732. export interface IClipPlanesHolder {
  91733. /**
  91734. * Gets or sets the active clipplane 1
  91735. */
  91736. clipPlane: Nullable<Plane>;
  91737. /**
  91738. * Gets or sets the active clipplane 2
  91739. */
  91740. clipPlane2: Nullable<Plane>;
  91741. /**
  91742. * Gets or sets the active clipplane 3
  91743. */
  91744. clipPlane3: Nullable<Plane>;
  91745. /**
  91746. * Gets or sets the active clipplane 4
  91747. */
  91748. clipPlane4: Nullable<Plane>;
  91749. /**
  91750. * Gets or sets the active clipplane 5
  91751. */
  91752. clipPlane5: Nullable<Plane>;
  91753. /**
  91754. * Gets or sets the active clipplane 6
  91755. */
  91756. clipPlane6: Nullable<Plane>;
  91757. }
  91758. }
  91759. declare module BABYLON {
  91760. /**
  91761. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  91762. *
  91763. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  91764. *
  91765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  91766. */
  91767. export class ThinMaterialHelper {
  91768. /**
  91769. * Binds the clip plane information from the holder to the effect.
  91770. * @param effect The effect we are binding the data to
  91771. * @param holder The entity containing the clip plane information
  91772. */
  91773. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  91774. }
  91775. }
  91776. declare module BABYLON {
  91777. interface ThinEngine {
  91778. /**
  91779. * Sets alpha constants used by some alpha blending modes
  91780. * @param r defines the red component
  91781. * @param g defines the green component
  91782. * @param b defines the blue component
  91783. * @param a defines the alpha component
  91784. */
  91785. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91786. /**
  91787. * Sets the current alpha mode
  91788. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91789. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91790. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91791. */
  91792. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91793. /**
  91794. * Gets the current alpha mode
  91795. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91796. * @returns the current alpha mode
  91797. */
  91798. getAlphaMode(): number;
  91799. /**
  91800. * Sets the current alpha equation
  91801. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  91802. */
  91803. setAlphaEquation(equation: number): void;
  91804. /**
  91805. * Gets the current alpha equation.
  91806. * @returns the current alpha equation
  91807. */
  91808. getAlphaEquation(): number;
  91809. }
  91810. }
  91811. declare module BABYLON {
  91812. /**
  91813. * This represents a particle system in Babylon.
  91814. * 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.
  91815. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91816. * @example https://doc.babylonjs.com/babylon101/particles
  91817. */
  91818. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91819. /**
  91820. * Billboard mode will only apply to Y axis
  91821. */
  91822. static readonly BILLBOARDMODE_Y: number;
  91823. /**
  91824. * Billboard mode will apply to all axes
  91825. */
  91826. static readonly BILLBOARDMODE_ALL: number;
  91827. /**
  91828. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91829. */
  91830. static readonly BILLBOARDMODE_STRETCHED: number;
  91831. /**
  91832. * This function can be defined to provide custom update for active particles.
  91833. * This function will be called instead of regular update (age, position, color, etc.).
  91834. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91835. */
  91836. updateFunction: (particles: Particle[]) => void;
  91837. private _emitterWorldMatrix;
  91838. /**
  91839. * This function can be defined to specify initial direction for every new particle.
  91840. * It by default use the emitterType defined function
  91841. */
  91842. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91843. /**
  91844. * This function can be defined to specify initial position for every new particle.
  91845. * It by default use the emitterType defined function
  91846. */
  91847. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91848. /**
  91849. * @hidden
  91850. */
  91851. _inheritedVelocityOffset: Vector3;
  91852. /**
  91853. * An event triggered when the system is disposed
  91854. */
  91855. onDisposeObservable: Observable<IParticleSystem>;
  91856. private _onDisposeObserver;
  91857. /**
  91858. * Sets a callback that will be triggered when the system is disposed
  91859. */
  91860. set onDispose(callback: () => void);
  91861. private _particles;
  91862. private _epsilon;
  91863. private _capacity;
  91864. private _stockParticles;
  91865. private _newPartsExcess;
  91866. private _vertexData;
  91867. private _vertexBuffer;
  91868. private _vertexBuffers;
  91869. private _spriteBuffer;
  91870. private _indexBuffer;
  91871. private _effect;
  91872. private _customEffect;
  91873. private _cachedDefines;
  91874. private _scaledColorStep;
  91875. private _colorDiff;
  91876. private _scaledDirection;
  91877. private _scaledGravity;
  91878. private _currentRenderId;
  91879. private _alive;
  91880. private _useInstancing;
  91881. private _started;
  91882. private _stopped;
  91883. private _actualFrame;
  91884. private _scaledUpdateSpeed;
  91885. private _vertexBufferSize;
  91886. /** @hidden */
  91887. _currentEmitRateGradient: Nullable<FactorGradient>;
  91888. /** @hidden */
  91889. _currentEmitRate1: number;
  91890. /** @hidden */
  91891. _currentEmitRate2: number;
  91892. /** @hidden */
  91893. _currentStartSizeGradient: Nullable<FactorGradient>;
  91894. /** @hidden */
  91895. _currentStartSize1: number;
  91896. /** @hidden */
  91897. _currentStartSize2: number;
  91898. private readonly _rawTextureWidth;
  91899. private _rampGradientsTexture;
  91900. private _useRampGradients;
  91901. /** Gets or sets a matrix to use to compute projection */
  91902. defaultProjectionMatrix: Matrix;
  91903. /** Gets or sets a matrix to use to compute view */
  91904. defaultViewMatrix: Matrix;
  91905. /** Gets or sets a boolean indicating that ramp gradients must be used
  91906. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91907. */
  91908. get useRampGradients(): boolean;
  91909. set useRampGradients(value: boolean);
  91910. /**
  91911. * 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.
  91912. * 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: [])
  91913. */
  91914. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91915. private _subEmitters;
  91916. /**
  91917. * @hidden
  91918. * If the particle systems emitter should be disposed when the particle system is disposed
  91919. */
  91920. _disposeEmitterOnDispose: boolean;
  91921. /**
  91922. * The current active Sub-systems, this property is used by the root particle system only.
  91923. */
  91924. activeSubSystems: Array<ParticleSystem>;
  91925. /**
  91926. * Specifies if the particles are updated in emitter local space or world space
  91927. */
  91928. isLocal: boolean;
  91929. private _rootParticleSystem;
  91930. /**
  91931. * Gets the current list of active particles
  91932. */
  91933. get particles(): Particle[];
  91934. /**
  91935. * Gets the number of particles active at the same time.
  91936. * @returns The number of active particles.
  91937. */
  91938. getActiveCount(): number;
  91939. /**
  91940. * Returns the string "ParticleSystem"
  91941. * @returns a string containing the class name
  91942. */
  91943. getClassName(): string;
  91944. /**
  91945. * Gets a boolean indicating that the system is stopping
  91946. * @returns true if the system is currently stopping
  91947. */
  91948. isStopping(): boolean;
  91949. /**
  91950. * Gets the custom effect used to render the particles
  91951. * @param blendMode Blend mode for which the effect should be retrieved
  91952. * @returns The effect
  91953. */
  91954. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91955. /**
  91956. * Sets the custom effect used to render the particles
  91957. * @param effect The effect to set
  91958. * @param blendMode Blend mode for which the effect should be set
  91959. */
  91960. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91961. /** @hidden */
  91962. private _onBeforeDrawParticlesObservable;
  91963. /**
  91964. * Observable that will be called just before the particles are drawn
  91965. */
  91966. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91967. /**
  91968. * Gets the name of the particle vertex shader
  91969. */
  91970. get vertexShaderName(): string;
  91971. /**
  91972. * Instantiates a particle system.
  91973. * 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.
  91974. * @param name The name of the particle system
  91975. * @param capacity The max number of particles alive at the same time
  91976. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  91977. * @param customEffect a custom effect used to change the way particles are rendered by default
  91978. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91979. * @param epsilon Offset used to render the particles
  91980. */
  91981. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91982. private _addFactorGradient;
  91983. private _removeFactorGradient;
  91984. /**
  91985. * Adds a new life time gradient
  91986. * @param gradient defines the gradient to use (between 0 and 1)
  91987. * @param factor defines the life time factor to affect to the specified gradient
  91988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91989. * @returns the current particle system
  91990. */
  91991. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91992. /**
  91993. * Remove a specific life time gradient
  91994. * @param gradient defines the gradient to remove
  91995. * @returns the current particle system
  91996. */
  91997. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91998. /**
  91999. * Adds a new size gradient
  92000. * @param gradient defines the gradient to use (between 0 and 1)
  92001. * @param factor defines the size factor to affect to the specified gradient
  92002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92003. * @returns the current particle system
  92004. */
  92005. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92006. /**
  92007. * Remove a specific size gradient
  92008. * @param gradient defines the gradient to remove
  92009. * @returns the current particle system
  92010. */
  92011. removeSizeGradient(gradient: number): IParticleSystem;
  92012. /**
  92013. * Adds a new color remap gradient
  92014. * @param gradient defines the gradient to use (between 0 and 1)
  92015. * @param min defines the color remap minimal range
  92016. * @param max defines the color remap maximal range
  92017. * @returns the current particle system
  92018. */
  92019. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92020. /**
  92021. * Remove a specific color remap gradient
  92022. * @param gradient defines the gradient to remove
  92023. * @returns the current particle system
  92024. */
  92025. removeColorRemapGradient(gradient: number): IParticleSystem;
  92026. /**
  92027. * Adds a new alpha remap gradient
  92028. * @param gradient defines the gradient to use (between 0 and 1)
  92029. * @param min defines the alpha remap minimal range
  92030. * @param max defines the alpha remap maximal range
  92031. * @returns the current particle system
  92032. */
  92033. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92034. /**
  92035. * Remove a specific alpha remap gradient
  92036. * @param gradient defines the gradient to remove
  92037. * @returns the current particle system
  92038. */
  92039. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92040. /**
  92041. * Adds a new angular speed gradient
  92042. * @param gradient defines the gradient to use (between 0 and 1)
  92043. * @param factor defines the angular speed to affect to the specified gradient
  92044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92045. * @returns the current particle system
  92046. */
  92047. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92048. /**
  92049. * Remove a specific angular speed gradient
  92050. * @param gradient defines the gradient to remove
  92051. * @returns the current particle system
  92052. */
  92053. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92054. /**
  92055. * Adds a new velocity gradient
  92056. * @param gradient defines the gradient to use (between 0 and 1)
  92057. * @param factor defines the velocity to affect to the specified gradient
  92058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92059. * @returns the current particle system
  92060. */
  92061. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92062. /**
  92063. * Remove a specific velocity gradient
  92064. * @param gradient defines the gradient to remove
  92065. * @returns the current particle system
  92066. */
  92067. removeVelocityGradient(gradient: number): IParticleSystem;
  92068. /**
  92069. * Adds a new limit velocity gradient
  92070. * @param gradient defines the gradient to use (between 0 and 1)
  92071. * @param factor defines the limit velocity value to affect to the specified gradient
  92072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92073. * @returns the current particle system
  92074. */
  92075. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92076. /**
  92077. * Remove a specific limit velocity gradient
  92078. * @param gradient defines the gradient to remove
  92079. * @returns the current particle system
  92080. */
  92081. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92082. /**
  92083. * Adds a new drag gradient
  92084. * @param gradient defines the gradient to use (between 0 and 1)
  92085. * @param factor defines the drag value to affect to the specified gradient
  92086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92087. * @returns the current particle system
  92088. */
  92089. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92090. /**
  92091. * Remove a specific drag gradient
  92092. * @param gradient defines the gradient to remove
  92093. * @returns the current particle system
  92094. */
  92095. removeDragGradient(gradient: number): IParticleSystem;
  92096. /**
  92097. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92098. * @param gradient defines the gradient to use (between 0 and 1)
  92099. * @param factor defines the emit rate value to affect to the specified gradient
  92100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92101. * @returns the current particle system
  92102. */
  92103. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92104. /**
  92105. * Remove a specific emit rate gradient
  92106. * @param gradient defines the gradient to remove
  92107. * @returns the current particle system
  92108. */
  92109. removeEmitRateGradient(gradient: number): IParticleSystem;
  92110. /**
  92111. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92112. * @param gradient defines the gradient to use (between 0 and 1)
  92113. * @param factor defines the start size value to affect to the specified gradient
  92114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92115. * @returns the current particle system
  92116. */
  92117. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92118. /**
  92119. * Remove a specific start size gradient
  92120. * @param gradient defines the gradient to remove
  92121. * @returns the current particle system
  92122. */
  92123. removeStartSizeGradient(gradient: number): IParticleSystem;
  92124. private _createRampGradientTexture;
  92125. /**
  92126. * Gets the current list of ramp gradients.
  92127. * You must use addRampGradient and removeRampGradient to udpate this list
  92128. * @returns the list of ramp gradients
  92129. */
  92130. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92131. /** Force the system to rebuild all gradients that need to be resync */
  92132. forceRefreshGradients(): void;
  92133. private _syncRampGradientTexture;
  92134. /**
  92135. * Adds a new ramp gradient used to remap particle colors
  92136. * @param gradient defines the gradient to use (between 0 and 1)
  92137. * @param color defines the color to affect to the specified gradient
  92138. * @returns the current particle system
  92139. */
  92140. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92141. /**
  92142. * Remove a specific ramp gradient
  92143. * @param gradient defines the gradient to remove
  92144. * @returns the current particle system
  92145. */
  92146. removeRampGradient(gradient: number): ParticleSystem;
  92147. /**
  92148. * Adds a new color gradient
  92149. * @param gradient defines the gradient to use (between 0 and 1)
  92150. * @param color1 defines the color to affect to the specified gradient
  92151. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92152. * @returns this particle system
  92153. */
  92154. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92155. /**
  92156. * Remove a specific color gradient
  92157. * @param gradient defines the gradient to remove
  92158. * @returns this particle system
  92159. */
  92160. removeColorGradient(gradient: number): IParticleSystem;
  92161. private _fetchR;
  92162. protected _reset(): void;
  92163. private _resetEffect;
  92164. private _createVertexBuffers;
  92165. private _createIndexBuffer;
  92166. /**
  92167. * Gets the maximum number of particles active at the same time.
  92168. * @returns The max number of active particles.
  92169. */
  92170. getCapacity(): number;
  92171. /**
  92172. * Gets whether there are still active particles in the system.
  92173. * @returns True if it is alive, otherwise false.
  92174. */
  92175. isAlive(): boolean;
  92176. /**
  92177. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92178. * @returns True if it has been started, otherwise false.
  92179. */
  92180. isStarted(): boolean;
  92181. private _prepareSubEmitterInternalArray;
  92182. /**
  92183. * Starts the particle system and begins to emit
  92184. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92185. */
  92186. start(delay?: number): void;
  92187. /**
  92188. * Stops the particle system.
  92189. * @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.
  92190. */
  92191. stop(stopSubEmitters?: boolean): void;
  92192. /**
  92193. * Remove all active particles
  92194. */
  92195. reset(): void;
  92196. /**
  92197. * @hidden (for internal use only)
  92198. */
  92199. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92200. /**
  92201. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92202. * Its lifetime will start back at 0.
  92203. */
  92204. recycleParticle: (particle: Particle) => void;
  92205. private _stopSubEmitters;
  92206. private _createParticle;
  92207. private _removeFromRoot;
  92208. private _emitFromParticle;
  92209. private _update;
  92210. /** @hidden */
  92211. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92212. /** @hidden */
  92213. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92214. /**
  92215. * Fill the defines array according to the current settings of the particle system
  92216. * @param defines Array to be updated
  92217. * @param blendMode blend mode to take into account when updating the array
  92218. */
  92219. fillDefines(defines: Array<string>, blendMode: number): void;
  92220. /**
  92221. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92222. * @param uniforms Uniforms array to fill
  92223. * @param attributes Attributes array to fill
  92224. * @param samplers Samplers array to fill
  92225. */
  92226. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92227. /** @hidden */
  92228. private _getEffect;
  92229. /**
  92230. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92231. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92232. */
  92233. animate(preWarmOnly?: boolean): void;
  92234. private _appendParticleVertices;
  92235. /**
  92236. * Rebuilds the particle system.
  92237. */
  92238. rebuild(): void;
  92239. /**
  92240. * Is this system ready to be used/rendered
  92241. * @return true if the system is ready
  92242. */
  92243. isReady(): boolean;
  92244. private _render;
  92245. /**
  92246. * Renders the particle system in its current state.
  92247. * @returns the current number of particles
  92248. */
  92249. render(): number;
  92250. /**
  92251. * Disposes the particle system and free the associated resources
  92252. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92253. */
  92254. dispose(disposeTexture?: boolean): void;
  92255. /**
  92256. * Clones the particle system.
  92257. * @param name The name of the cloned object
  92258. * @param newEmitter The new emitter to use
  92259. * @returns the cloned particle system
  92260. */
  92261. clone(name: string, newEmitter: any): ParticleSystem;
  92262. /**
  92263. * Serializes the particle system to a JSON object
  92264. * @param serializeTexture defines if the texture must be serialized as well
  92265. * @returns the JSON object
  92266. */
  92267. serialize(serializeTexture?: boolean): any;
  92268. /** @hidden */
  92269. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92270. /** @hidden */
  92271. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92272. /**
  92273. * Parses a JSON object to create a particle system.
  92274. * @param parsedParticleSystem The JSON object to parse
  92275. * @param sceneOrEngine The scene or the engine to create the particle system in
  92276. * @param rootUrl The root url to use to load external dependencies like texture
  92277. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92278. * @returns the Parsed particle system
  92279. */
  92280. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92281. }
  92282. }
  92283. declare module BABYLON {
  92284. /**
  92285. * A particle represents one of the element emitted by a particle system.
  92286. * This is mainly define by its coordinates, direction, velocity and age.
  92287. */
  92288. export class Particle {
  92289. /**
  92290. * The particle system the particle belongs to.
  92291. */
  92292. particleSystem: ParticleSystem;
  92293. private static _Count;
  92294. /**
  92295. * Unique ID of the particle
  92296. */
  92297. id: number;
  92298. /**
  92299. * The world position of the particle in the scene.
  92300. */
  92301. position: Vector3;
  92302. /**
  92303. * The world direction of the particle in the scene.
  92304. */
  92305. direction: Vector3;
  92306. /**
  92307. * The color of the particle.
  92308. */
  92309. color: Color4;
  92310. /**
  92311. * The color change of the particle per step.
  92312. */
  92313. colorStep: Color4;
  92314. /**
  92315. * Defines how long will the life of the particle be.
  92316. */
  92317. lifeTime: number;
  92318. /**
  92319. * The current age of the particle.
  92320. */
  92321. age: number;
  92322. /**
  92323. * The current size of the particle.
  92324. */
  92325. size: number;
  92326. /**
  92327. * The current scale of the particle.
  92328. */
  92329. scale: Vector2;
  92330. /**
  92331. * The current angle of the particle.
  92332. */
  92333. angle: number;
  92334. /**
  92335. * Defines how fast is the angle changing.
  92336. */
  92337. angularSpeed: number;
  92338. /**
  92339. * Defines the cell index used by the particle to be rendered from a sprite.
  92340. */
  92341. cellIndex: number;
  92342. /**
  92343. * The information required to support color remapping
  92344. */
  92345. remapData: Vector4;
  92346. /** @hidden */
  92347. _randomCellOffset?: number;
  92348. /** @hidden */
  92349. _initialDirection: Nullable<Vector3>;
  92350. /** @hidden */
  92351. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92352. /** @hidden */
  92353. _initialStartSpriteCellID: number;
  92354. /** @hidden */
  92355. _initialEndSpriteCellID: number;
  92356. /** @hidden */
  92357. _currentColorGradient: Nullable<ColorGradient>;
  92358. /** @hidden */
  92359. _currentColor1: Color4;
  92360. /** @hidden */
  92361. _currentColor2: Color4;
  92362. /** @hidden */
  92363. _currentSizeGradient: Nullable<FactorGradient>;
  92364. /** @hidden */
  92365. _currentSize1: number;
  92366. /** @hidden */
  92367. _currentSize2: number;
  92368. /** @hidden */
  92369. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92370. /** @hidden */
  92371. _currentAngularSpeed1: number;
  92372. /** @hidden */
  92373. _currentAngularSpeed2: number;
  92374. /** @hidden */
  92375. _currentVelocityGradient: Nullable<FactorGradient>;
  92376. /** @hidden */
  92377. _currentVelocity1: number;
  92378. /** @hidden */
  92379. _currentVelocity2: number;
  92380. /** @hidden */
  92381. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92382. /** @hidden */
  92383. _currentLimitVelocity1: number;
  92384. /** @hidden */
  92385. _currentLimitVelocity2: number;
  92386. /** @hidden */
  92387. _currentDragGradient: Nullable<FactorGradient>;
  92388. /** @hidden */
  92389. _currentDrag1: number;
  92390. /** @hidden */
  92391. _currentDrag2: number;
  92392. /** @hidden */
  92393. _randomNoiseCoordinates1: Vector3;
  92394. /** @hidden */
  92395. _randomNoiseCoordinates2: Vector3;
  92396. /** @hidden */
  92397. _localPosition?: Vector3;
  92398. /**
  92399. * Creates a new instance Particle
  92400. * @param particleSystem the particle system the particle belongs to
  92401. */
  92402. constructor(
  92403. /**
  92404. * The particle system the particle belongs to.
  92405. */
  92406. particleSystem: ParticleSystem);
  92407. private updateCellInfoFromSystem;
  92408. /**
  92409. * Defines how the sprite cell index is updated for the particle
  92410. */
  92411. updateCellIndex(): void;
  92412. /** @hidden */
  92413. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92414. /** @hidden */
  92415. _inheritParticleInfoToSubEmitters(): void;
  92416. /** @hidden */
  92417. _reset(): void;
  92418. /**
  92419. * Copy the properties of particle to another one.
  92420. * @param other the particle to copy the information to.
  92421. */
  92422. copyTo(other: Particle): void;
  92423. }
  92424. }
  92425. declare module BABYLON {
  92426. /**
  92427. * Particle emitter represents a volume emitting particles.
  92428. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92429. */
  92430. export interface IParticleEmitterType {
  92431. /**
  92432. * Called by the particle System when the direction is computed for the created particle.
  92433. * @param worldMatrix is the world matrix of the particle system
  92434. * @param directionToUpdate is the direction vector to update with the result
  92435. * @param particle is the particle we are computed the direction for
  92436. * @param isLocal defines if the direction should be set in local space
  92437. */
  92438. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92439. /**
  92440. * Called by the particle System when the position is computed for the created particle.
  92441. * @param worldMatrix is the world matrix of the particle system
  92442. * @param positionToUpdate is the position vector to update with the result
  92443. * @param particle is the particle we are computed the position for
  92444. * @param isLocal defines if the position should be set in local space
  92445. */
  92446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92447. /**
  92448. * Clones the current emitter and returns a copy of it
  92449. * @returns the new emitter
  92450. */
  92451. clone(): IParticleEmitterType;
  92452. /**
  92453. * Called by the GPUParticleSystem to setup the update shader
  92454. * @param effect defines the update shader
  92455. */
  92456. applyToShader(effect: Effect): void;
  92457. /**
  92458. * Returns a string to use to update the GPU particles update shader
  92459. * @returns the effect defines string
  92460. */
  92461. getEffectDefines(): string;
  92462. /**
  92463. * Returns a string representing the class name
  92464. * @returns a string containing the class name
  92465. */
  92466. getClassName(): string;
  92467. /**
  92468. * Serializes the particle system to a JSON object.
  92469. * @returns the JSON object
  92470. */
  92471. serialize(): any;
  92472. /**
  92473. * Parse properties from a JSON object
  92474. * @param serializationObject defines the JSON object
  92475. * @param scene defines the hosting scene
  92476. */
  92477. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92478. }
  92479. }
  92480. declare module BABYLON {
  92481. /**
  92482. * Particle emitter emitting particles from the inside of a box.
  92483. * It emits the particles randomly between 2 given directions.
  92484. */
  92485. export class BoxParticleEmitter implements IParticleEmitterType {
  92486. /**
  92487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92488. */
  92489. direction1: Vector3;
  92490. /**
  92491. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92492. */
  92493. direction2: Vector3;
  92494. /**
  92495. * 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.
  92496. */
  92497. minEmitBox: Vector3;
  92498. /**
  92499. * 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.
  92500. */
  92501. maxEmitBox: Vector3;
  92502. /**
  92503. * Creates a new instance BoxParticleEmitter
  92504. */
  92505. constructor();
  92506. /**
  92507. * Called by the particle System when the direction is computed for the created particle.
  92508. * @param worldMatrix is the world matrix of the particle system
  92509. * @param directionToUpdate is the direction vector to update with the result
  92510. * @param particle is the particle we are computed the direction for
  92511. * @param isLocal defines if the direction should be set in local space
  92512. */
  92513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92514. /**
  92515. * Called by the particle System when the position is computed for the created particle.
  92516. * @param worldMatrix is the world matrix of the particle system
  92517. * @param positionToUpdate is the position vector to update with the result
  92518. * @param particle is the particle we are computed the position for
  92519. * @param isLocal defines if the position should be set in local space
  92520. */
  92521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92522. /**
  92523. * Clones the current emitter and returns a copy of it
  92524. * @returns the new emitter
  92525. */
  92526. clone(): BoxParticleEmitter;
  92527. /**
  92528. * Called by the GPUParticleSystem to setup the update shader
  92529. * @param effect defines the update shader
  92530. */
  92531. applyToShader(effect: Effect): void;
  92532. /**
  92533. * Returns a string to use to update the GPU particles update shader
  92534. * @returns a string containng the defines string
  92535. */
  92536. getEffectDefines(): string;
  92537. /**
  92538. * Returns the string "BoxParticleEmitter"
  92539. * @returns a string containing the class name
  92540. */
  92541. getClassName(): string;
  92542. /**
  92543. * Serializes the particle system to a JSON object.
  92544. * @returns the JSON object
  92545. */
  92546. serialize(): any;
  92547. /**
  92548. * Parse properties from a JSON object
  92549. * @param serializationObject defines the JSON object
  92550. */
  92551. parse(serializationObject: any): void;
  92552. }
  92553. }
  92554. declare module BABYLON {
  92555. /**
  92556. * Particle emitter emitting particles from the inside of a cone.
  92557. * It emits the particles alongside the cone volume from the base to the particle.
  92558. * The emission direction might be randomized.
  92559. */
  92560. export class ConeParticleEmitter implements IParticleEmitterType {
  92561. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92562. directionRandomizer: number;
  92563. private _radius;
  92564. private _angle;
  92565. private _height;
  92566. /**
  92567. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92568. */
  92569. radiusRange: number;
  92570. /**
  92571. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92572. */
  92573. heightRange: number;
  92574. /**
  92575. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92576. */
  92577. emitFromSpawnPointOnly: boolean;
  92578. /**
  92579. * Gets or sets the radius of the emission cone
  92580. */
  92581. get radius(): number;
  92582. set radius(value: number);
  92583. /**
  92584. * Gets or sets the angle of the emission cone
  92585. */
  92586. get angle(): number;
  92587. set angle(value: number);
  92588. private _buildHeight;
  92589. /**
  92590. * Creates a new instance ConeParticleEmitter
  92591. * @param radius the radius of the emission cone (1 by default)
  92592. * @param angle the cone base angle (PI by default)
  92593. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92594. */
  92595. constructor(radius?: number, angle?: number,
  92596. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92597. directionRandomizer?: number);
  92598. /**
  92599. * Called by the particle System when the direction is computed for the created particle.
  92600. * @param worldMatrix is the world matrix of the particle system
  92601. * @param directionToUpdate is the direction vector to update with the result
  92602. * @param particle is the particle we are computed the direction for
  92603. * @param isLocal defines if the direction should be set in local space
  92604. */
  92605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92606. /**
  92607. * Called by the particle System when the position is computed for the created particle.
  92608. * @param worldMatrix is the world matrix of the particle system
  92609. * @param positionToUpdate is the position vector to update with the result
  92610. * @param particle is the particle we are computed the position for
  92611. * @param isLocal defines if the position should be set in local space
  92612. */
  92613. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92614. /**
  92615. * Clones the current emitter and returns a copy of it
  92616. * @returns the new emitter
  92617. */
  92618. clone(): ConeParticleEmitter;
  92619. /**
  92620. * Called by the GPUParticleSystem to setup the update shader
  92621. * @param effect defines the update shader
  92622. */
  92623. applyToShader(effect: Effect): void;
  92624. /**
  92625. * Returns a string to use to update the GPU particles update shader
  92626. * @returns a string containng the defines string
  92627. */
  92628. getEffectDefines(): string;
  92629. /**
  92630. * Returns the string "ConeParticleEmitter"
  92631. * @returns a string containing the class name
  92632. */
  92633. getClassName(): string;
  92634. /**
  92635. * Serializes the particle system to a JSON object.
  92636. * @returns the JSON object
  92637. */
  92638. serialize(): any;
  92639. /**
  92640. * Parse properties from a JSON object
  92641. * @param serializationObject defines the JSON object
  92642. */
  92643. parse(serializationObject: any): void;
  92644. }
  92645. }
  92646. declare module BABYLON {
  92647. /**
  92648. * Particle emitter emitting particles from the inside of a cylinder.
  92649. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92650. */
  92651. export class CylinderParticleEmitter implements IParticleEmitterType {
  92652. /**
  92653. * The radius of the emission cylinder.
  92654. */
  92655. radius: number;
  92656. /**
  92657. * The height of the emission cylinder.
  92658. */
  92659. height: number;
  92660. /**
  92661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92662. */
  92663. radiusRange: number;
  92664. /**
  92665. * How much to randomize the particle direction [0-1].
  92666. */
  92667. directionRandomizer: number;
  92668. /**
  92669. * Creates a new instance CylinderParticleEmitter
  92670. * @param radius the radius of the emission cylinder (1 by default)
  92671. * @param height the height of the emission cylinder (1 by default)
  92672. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92673. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92674. */
  92675. constructor(
  92676. /**
  92677. * The radius of the emission cylinder.
  92678. */
  92679. radius?: number,
  92680. /**
  92681. * The height of the emission cylinder.
  92682. */
  92683. height?: number,
  92684. /**
  92685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92686. */
  92687. radiusRange?: number,
  92688. /**
  92689. * How much to randomize the particle direction [0-1].
  92690. */
  92691. directionRandomizer?: number);
  92692. /**
  92693. * Called by the particle System when the direction is computed for the created particle.
  92694. * @param worldMatrix is the world matrix of the particle system
  92695. * @param directionToUpdate is the direction vector to update with the result
  92696. * @param particle is the particle we are computed the direction for
  92697. * @param isLocal defines if the direction should be set in local space
  92698. */
  92699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92700. /**
  92701. * Called by the particle System when the position is computed for the created particle.
  92702. * @param worldMatrix is the world matrix of the particle system
  92703. * @param positionToUpdate is the position vector to update with the result
  92704. * @param particle is the particle we are computed the position for
  92705. * @param isLocal defines if the position should be set in local space
  92706. */
  92707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92708. /**
  92709. * Clones the current emitter and returns a copy of it
  92710. * @returns the new emitter
  92711. */
  92712. clone(): CylinderParticleEmitter;
  92713. /**
  92714. * Called by the GPUParticleSystem to setup the update shader
  92715. * @param effect defines the update shader
  92716. */
  92717. applyToShader(effect: Effect): void;
  92718. /**
  92719. * Returns a string to use to update the GPU particles update shader
  92720. * @returns a string containng the defines string
  92721. */
  92722. getEffectDefines(): string;
  92723. /**
  92724. * Returns the string "CylinderParticleEmitter"
  92725. * @returns a string containing the class name
  92726. */
  92727. getClassName(): string;
  92728. /**
  92729. * Serializes the particle system to a JSON object.
  92730. * @returns the JSON object
  92731. */
  92732. serialize(): any;
  92733. /**
  92734. * Parse properties from a JSON object
  92735. * @param serializationObject defines the JSON object
  92736. */
  92737. parse(serializationObject: any): void;
  92738. }
  92739. /**
  92740. * Particle emitter emitting particles from the inside of a cylinder.
  92741. * It emits the particles randomly between two vectors.
  92742. */
  92743. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92744. /**
  92745. * The min limit of the emission direction.
  92746. */
  92747. direction1: Vector3;
  92748. /**
  92749. * The max limit of the emission direction.
  92750. */
  92751. direction2: Vector3;
  92752. /**
  92753. * Creates a new instance CylinderDirectedParticleEmitter
  92754. * @param radius the radius of the emission cylinder (1 by default)
  92755. * @param height the height of the emission cylinder (1 by default)
  92756. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92757. * @param direction1 the min limit of the emission direction (up vector by default)
  92758. * @param direction2 the max limit of the emission direction (up vector by default)
  92759. */
  92760. constructor(radius?: number, height?: number, radiusRange?: number,
  92761. /**
  92762. * The min limit of the emission direction.
  92763. */
  92764. direction1?: Vector3,
  92765. /**
  92766. * The max limit of the emission direction.
  92767. */
  92768. direction2?: Vector3);
  92769. /**
  92770. * Called by the particle System when the direction is computed for the created particle.
  92771. * @param worldMatrix is the world matrix of the particle system
  92772. * @param directionToUpdate is the direction vector to update with the result
  92773. * @param particle is the particle we are computed the direction for
  92774. */
  92775. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92776. /**
  92777. * Clones the current emitter and returns a copy of it
  92778. * @returns the new emitter
  92779. */
  92780. clone(): CylinderDirectedParticleEmitter;
  92781. /**
  92782. * Called by the GPUParticleSystem to setup the update shader
  92783. * @param effect defines the update shader
  92784. */
  92785. applyToShader(effect: Effect): void;
  92786. /**
  92787. * Returns a string to use to update the GPU particles update shader
  92788. * @returns a string containng the defines string
  92789. */
  92790. getEffectDefines(): string;
  92791. /**
  92792. * Returns the string "CylinderDirectedParticleEmitter"
  92793. * @returns a string containing the class name
  92794. */
  92795. getClassName(): string;
  92796. /**
  92797. * Serializes the particle system to a JSON object.
  92798. * @returns the JSON object
  92799. */
  92800. serialize(): any;
  92801. /**
  92802. * Parse properties from a JSON object
  92803. * @param serializationObject defines the JSON object
  92804. */
  92805. parse(serializationObject: any): void;
  92806. }
  92807. }
  92808. declare module BABYLON {
  92809. /**
  92810. * Particle emitter emitting particles from the inside of a hemisphere.
  92811. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92812. */
  92813. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92814. /**
  92815. * The radius of the emission hemisphere.
  92816. */
  92817. radius: number;
  92818. /**
  92819. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92820. */
  92821. radiusRange: number;
  92822. /**
  92823. * How much to randomize the particle direction [0-1].
  92824. */
  92825. directionRandomizer: number;
  92826. /**
  92827. * Creates a new instance HemisphericParticleEmitter
  92828. * @param radius the radius of the emission hemisphere (1 by default)
  92829. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92830. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92831. */
  92832. constructor(
  92833. /**
  92834. * The radius of the emission hemisphere.
  92835. */
  92836. radius?: number,
  92837. /**
  92838. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92839. */
  92840. radiusRange?: number,
  92841. /**
  92842. * How much to randomize the particle direction [0-1].
  92843. */
  92844. directionRandomizer?: number);
  92845. /**
  92846. * Called by the particle System when the direction is computed for the created particle.
  92847. * @param worldMatrix is the world matrix of the particle system
  92848. * @param directionToUpdate is the direction vector to update with the result
  92849. * @param particle is the particle we are computed the direction for
  92850. * @param isLocal defines if the direction should be set in local space
  92851. */
  92852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92853. /**
  92854. * Called by the particle System when the position is computed for the created particle.
  92855. * @param worldMatrix is the world matrix of the particle system
  92856. * @param positionToUpdate is the position vector to update with the result
  92857. * @param particle is the particle we are computed the position for
  92858. * @param isLocal defines if the position should be set in local space
  92859. */
  92860. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92861. /**
  92862. * Clones the current emitter and returns a copy of it
  92863. * @returns the new emitter
  92864. */
  92865. clone(): HemisphericParticleEmitter;
  92866. /**
  92867. * Called by the GPUParticleSystem to setup the update shader
  92868. * @param effect defines the update shader
  92869. */
  92870. applyToShader(effect: Effect): void;
  92871. /**
  92872. * Returns a string to use to update the GPU particles update shader
  92873. * @returns a string containng the defines string
  92874. */
  92875. getEffectDefines(): string;
  92876. /**
  92877. * Returns the string "HemisphericParticleEmitter"
  92878. * @returns a string containing the class name
  92879. */
  92880. getClassName(): string;
  92881. /**
  92882. * Serializes the particle system to a JSON object.
  92883. * @returns the JSON object
  92884. */
  92885. serialize(): any;
  92886. /**
  92887. * Parse properties from a JSON object
  92888. * @param serializationObject defines the JSON object
  92889. */
  92890. parse(serializationObject: any): void;
  92891. }
  92892. }
  92893. declare module BABYLON {
  92894. /**
  92895. * Particle emitter emitting particles from a point.
  92896. * It emits the particles randomly between 2 given directions.
  92897. */
  92898. export class PointParticleEmitter implements IParticleEmitterType {
  92899. /**
  92900. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92901. */
  92902. direction1: Vector3;
  92903. /**
  92904. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92905. */
  92906. direction2: Vector3;
  92907. /**
  92908. * Creates a new instance PointParticleEmitter
  92909. */
  92910. constructor();
  92911. /**
  92912. * Called by the particle System when the direction is computed for the created particle.
  92913. * @param worldMatrix is the world matrix of the particle system
  92914. * @param directionToUpdate is the direction vector to update with the result
  92915. * @param particle is the particle we are computed the direction for
  92916. * @param isLocal defines if the direction should be set in local space
  92917. */
  92918. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92919. /**
  92920. * Called by the particle System when the position is computed for the created particle.
  92921. * @param worldMatrix is the world matrix of the particle system
  92922. * @param positionToUpdate is the position vector to update with the result
  92923. * @param particle is the particle we are computed the position for
  92924. * @param isLocal defines if the position should be set in local space
  92925. */
  92926. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92927. /**
  92928. * Clones the current emitter and returns a copy of it
  92929. * @returns the new emitter
  92930. */
  92931. clone(): PointParticleEmitter;
  92932. /**
  92933. * Called by the GPUParticleSystem to setup the update shader
  92934. * @param effect defines the update shader
  92935. */
  92936. applyToShader(effect: Effect): void;
  92937. /**
  92938. * Returns a string to use to update the GPU particles update shader
  92939. * @returns a string containng the defines string
  92940. */
  92941. getEffectDefines(): string;
  92942. /**
  92943. * Returns the string "PointParticleEmitter"
  92944. * @returns a string containing the class name
  92945. */
  92946. getClassName(): string;
  92947. /**
  92948. * Serializes the particle system to a JSON object.
  92949. * @returns the JSON object
  92950. */
  92951. serialize(): any;
  92952. /**
  92953. * Parse properties from a JSON object
  92954. * @param serializationObject defines the JSON object
  92955. */
  92956. parse(serializationObject: any): void;
  92957. }
  92958. }
  92959. declare module BABYLON {
  92960. /**
  92961. * Particle emitter emitting particles from the inside of a sphere.
  92962. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92963. */
  92964. export class SphereParticleEmitter implements IParticleEmitterType {
  92965. /**
  92966. * The radius of the emission sphere.
  92967. */
  92968. radius: number;
  92969. /**
  92970. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92971. */
  92972. radiusRange: number;
  92973. /**
  92974. * How much to randomize the particle direction [0-1].
  92975. */
  92976. directionRandomizer: number;
  92977. /**
  92978. * Creates a new instance SphereParticleEmitter
  92979. * @param radius the radius of the emission sphere (1 by default)
  92980. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92981. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92982. */
  92983. constructor(
  92984. /**
  92985. * The radius of the emission sphere.
  92986. */
  92987. radius?: number,
  92988. /**
  92989. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92990. */
  92991. radiusRange?: number,
  92992. /**
  92993. * How much to randomize the particle direction [0-1].
  92994. */
  92995. directionRandomizer?: number);
  92996. /**
  92997. * Called by the particle System when the direction is computed for the created particle.
  92998. * @param worldMatrix is the world matrix of the particle system
  92999. * @param directionToUpdate is the direction vector to update with the result
  93000. * @param particle is the particle we are computed the direction for
  93001. * @param isLocal defines if the direction should be set in local space
  93002. */
  93003. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93004. /**
  93005. * Called by the particle System when the position is computed for the created particle.
  93006. * @param worldMatrix is the world matrix of the particle system
  93007. * @param positionToUpdate is the position vector to update with the result
  93008. * @param particle is the particle we are computed the position for
  93009. * @param isLocal defines if the position should be set in local space
  93010. */
  93011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93012. /**
  93013. * Clones the current emitter and returns a copy of it
  93014. * @returns the new emitter
  93015. */
  93016. clone(): SphereParticleEmitter;
  93017. /**
  93018. * Called by the GPUParticleSystem to setup the update shader
  93019. * @param effect defines the update shader
  93020. */
  93021. applyToShader(effect: Effect): void;
  93022. /**
  93023. * Returns a string to use to update the GPU particles update shader
  93024. * @returns a string containng the defines string
  93025. */
  93026. getEffectDefines(): string;
  93027. /**
  93028. * Returns the string "SphereParticleEmitter"
  93029. * @returns a string containing the class name
  93030. */
  93031. getClassName(): string;
  93032. /**
  93033. * Serializes the particle system to a JSON object.
  93034. * @returns the JSON object
  93035. */
  93036. serialize(): any;
  93037. /**
  93038. * Parse properties from a JSON object
  93039. * @param serializationObject defines the JSON object
  93040. */
  93041. parse(serializationObject: any): void;
  93042. }
  93043. /**
  93044. * Particle emitter emitting particles from the inside of a sphere.
  93045. * It emits the particles randomly between two vectors.
  93046. */
  93047. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93048. /**
  93049. * The min limit of the emission direction.
  93050. */
  93051. direction1: Vector3;
  93052. /**
  93053. * The max limit of the emission direction.
  93054. */
  93055. direction2: Vector3;
  93056. /**
  93057. * Creates a new instance SphereDirectedParticleEmitter
  93058. * @param radius the radius of the emission sphere (1 by default)
  93059. * @param direction1 the min limit of the emission direction (up vector by default)
  93060. * @param direction2 the max limit of the emission direction (up vector by default)
  93061. */
  93062. constructor(radius?: number,
  93063. /**
  93064. * The min limit of the emission direction.
  93065. */
  93066. direction1?: Vector3,
  93067. /**
  93068. * The max limit of the emission direction.
  93069. */
  93070. direction2?: Vector3);
  93071. /**
  93072. * Called by the particle System when the direction is computed for the created particle.
  93073. * @param worldMatrix is the world matrix of the particle system
  93074. * @param directionToUpdate is the direction vector to update with the result
  93075. * @param particle is the particle we are computed the direction for
  93076. */
  93077. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93078. /**
  93079. * Clones the current emitter and returns a copy of it
  93080. * @returns the new emitter
  93081. */
  93082. clone(): SphereDirectedParticleEmitter;
  93083. /**
  93084. * Called by the GPUParticleSystem to setup the update shader
  93085. * @param effect defines the update shader
  93086. */
  93087. applyToShader(effect: Effect): void;
  93088. /**
  93089. * Returns a string to use to update the GPU particles update shader
  93090. * @returns a string containng the defines string
  93091. */
  93092. getEffectDefines(): string;
  93093. /**
  93094. * Returns the string "SphereDirectedParticleEmitter"
  93095. * @returns a string containing the class name
  93096. */
  93097. getClassName(): string;
  93098. /**
  93099. * Serializes the particle system to a JSON object.
  93100. * @returns the JSON object
  93101. */
  93102. serialize(): any;
  93103. /**
  93104. * Parse properties from a JSON object
  93105. * @param serializationObject defines the JSON object
  93106. */
  93107. parse(serializationObject: any): void;
  93108. }
  93109. }
  93110. declare module BABYLON {
  93111. /**
  93112. * Particle emitter emitting particles from a custom list of positions.
  93113. */
  93114. export class CustomParticleEmitter implements IParticleEmitterType {
  93115. /**
  93116. * Gets or sets the position generator that will create the inital position of each particle.
  93117. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93118. */
  93119. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93120. /**
  93121. * Gets or sets the destination generator that will create the final destination of each particle.
  93122. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93123. */
  93124. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93125. /**
  93126. * Creates a new instance CustomParticleEmitter
  93127. */
  93128. constructor();
  93129. /**
  93130. * Called by the particle System when the direction is computed for the created particle.
  93131. * @param worldMatrix is the world matrix of the particle system
  93132. * @param directionToUpdate is the direction vector to update with the result
  93133. * @param particle is the particle we are computed the direction for
  93134. * @param isLocal defines if the direction should be set in local space
  93135. */
  93136. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93137. /**
  93138. * Called by the particle System when the position is computed for the created particle.
  93139. * @param worldMatrix is the world matrix of the particle system
  93140. * @param positionToUpdate is the position vector to update with the result
  93141. * @param particle is the particle we are computed the position for
  93142. * @param isLocal defines if the position should be set in local space
  93143. */
  93144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93145. /**
  93146. * Clones the current emitter and returns a copy of it
  93147. * @returns the new emitter
  93148. */
  93149. clone(): CustomParticleEmitter;
  93150. /**
  93151. * Called by the GPUParticleSystem to setup the update shader
  93152. * @param effect defines the update shader
  93153. */
  93154. applyToShader(effect: Effect): void;
  93155. /**
  93156. * Returns a string to use to update the GPU particles update shader
  93157. * @returns a string containng the defines string
  93158. */
  93159. getEffectDefines(): string;
  93160. /**
  93161. * Returns the string "PointParticleEmitter"
  93162. * @returns a string containing the class name
  93163. */
  93164. getClassName(): string;
  93165. /**
  93166. * Serializes the particle system to a JSON object.
  93167. * @returns the JSON object
  93168. */
  93169. serialize(): any;
  93170. /**
  93171. * Parse properties from a JSON object
  93172. * @param serializationObject defines the JSON object
  93173. */
  93174. parse(serializationObject: any): void;
  93175. }
  93176. }
  93177. declare module BABYLON {
  93178. /**
  93179. * Particle emitter emitting particles from the inside of a box.
  93180. * It emits the particles randomly between 2 given directions.
  93181. */
  93182. export class MeshParticleEmitter implements IParticleEmitterType {
  93183. private _indices;
  93184. private _positions;
  93185. private _normals;
  93186. private _storedNormal;
  93187. private _mesh;
  93188. /**
  93189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93190. */
  93191. direction1: Vector3;
  93192. /**
  93193. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93194. */
  93195. direction2: Vector3;
  93196. /**
  93197. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93198. */
  93199. useMeshNormalsForDirection: boolean;
  93200. /** Defines the mesh to use as source */
  93201. get mesh(): Nullable<AbstractMesh>;
  93202. set mesh(value: Nullable<AbstractMesh>);
  93203. /**
  93204. * Creates a new instance MeshParticleEmitter
  93205. * @param mesh defines the mesh to use as source
  93206. */
  93207. constructor(mesh?: Nullable<AbstractMesh>);
  93208. /**
  93209. * Called by the particle System when the direction is computed for the created particle.
  93210. * @param worldMatrix is the world matrix of the particle system
  93211. * @param directionToUpdate is the direction vector to update with the result
  93212. * @param particle is the particle we are computed the direction for
  93213. * @param isLocal defines if the direction should be set in local space
  93214. */
  93215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93216. /**
  93217. * Called by the particle System when the position is computed for the created particle.
  93218. * @param worldMatrix is the world matrix of the particle system
  93219. * @param positionToUpdate is the position vector to update with the result
  93220. * @param particle is the particle we are computed the position for
  93221. * @param isLocal defines if the position should be set in local space
  93222. */
  93223. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93224. /**
  93225. * Clones the current emitter and returns a copy of it
  93226. * @returns the new emitter
  93227. */
  93228. clone(): MeshParticleEmitter;
  93229. /**
  93230. * Called by the GPUParticleSystem to setup the update shader
  93231. * @param effect defines the update shader
  93232. */
  93233. applyToShader(effect: Effect): void;
  93234. /**
  93235. * Returns a string to use to update the GPU particles update shader
  93236. * @returns a string containng the defines string
  93237. */
  93238. getEffectDefines(): string;
  93239. /**
  93240. * Returns the string "BoxParticleEmitter"
  93241. * @returns a string containing the class name
  93242. */
  93243. getClassName(): string;
  93244. /**
  93245. * Serializes the particle system to a JSON object.
  93246. * @returns the JSON object
  93247. */
  93248. serialize(): any;
  93249. /**
  93250. * Parse properties from a JSON object
  93251. * @param serializationObject defines the JSON object
  93252. * @param scene defines the hosting scene
  93253. */
  93254. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93255. }
  93256. }
  93257. declare module BABYLON {
  93258. /**
  93259. * Interface representing a particle system in Babylon.js.
  93260. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93261. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93262. */
  93263. export interface IParticleSystem {
  93264. /**
  93265. * List of animations used by the particle system.
  93266. */
  93267. animations: Animation[];
  93268. /**
  93269. * The id of the Particle system.
  93270. */
  93271. id: string;
  93272. /**
  93273. * The name of the Particle system.
  93274. */
  93275. name: string;
  93276. /**
  93277. * The emitter represents the Mesh or position we are attaching the particle system to.
  93278. */
  93279. emitter: Nullable<AbstractMesh | Vector3>;
  93280. /**
  93281. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93282. */
  93283. isBillboardBased: boolean;
  93284. /**
  93285. * The rendering group used by the Particle system to chose when to render.
  93286. */
  93287. renderingGroupId: number;
  93288. /**
  93289. * The layer mask we are rendering the particles through.
  93290. */
  93291. layerMask: number;
  93292. /**
  93293. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93294. */
  93295. updateSpeed: number;
  93296. /**
  93297. * The amount of time the particle system is running (depends of the overall update speed).
  93298. */
  93299. targetStopDuration: number;
  93300. /**
  93301. * The texture used to render each particle. (this can be a spritesheet)
  93302. */
  93303. particleTexture: Nullable<BaseTexture>;
  93304. /**
  93305. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93306. */
  93307. blendMode: number;
  93308. /**
  93309. * Minimum life time of emitting particles.
  93310. */
  93311. minLifeTime: number;
  93312. /**
  93313. * Maximum life time of emitting particles.
  93314. */
  93315. maxLifeTime: number;
  93316. /**
  93317. * Minimum Size of emitting particles.
  93318. */
  93319. minSize: number;
  93320. /**
  93321. * Maximum Size of emitting particles.
  93322. */
  93323. maxSize: number;
  93324. /**
  93325. * Minimum scale of emitting particles on X axis.
  93326. */
  93327. minScaleX: number;
  93328. /**
  93329. * Maximum scale of emitting particles on X axis.
  93330. */
  93331. maxScaleX: number;
  93332. /**
  93333. * Minimum scale of emitting particles on Y axis.
  93334. */
  93335. minScaleY: number;
  93336. /**
  93337. * Maximum scale of emitting particles on Y axis.
  93338. */
  93339. maxScaleY: number;
  93340. /**
  93341. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93342. */
  93343. color1: Color4;
  93344. /**
  93345. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93346. */
  93347. color2: Color4;
  93348. /**
  93349. * Color the particle will have at the end of its lifetime.
  93350. */
  93351. colorDead: Color4;
  93352. /**
  93353. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93354. */
  93355. emitRate: number;
  93356. /**
  93357. * You can use gravity if you want to give an orientation to your particles.
  93358. */
  93359. gravity: Vector3;
  93360. /**
  93361. * Minimum power of emitting particles.
  93362. */
  93363. minEmitPower: number;
  93364. /**
  93365. * Maximum power of emitting particles.
  93366. */
  93367. maxEmitPower: number;
  93368. /**
  93369. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93370. */
  93371. minAngularSpeed: number;
  93372. /**
  93373. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93374. */
  93375. maxAngularSpeed: number;
  93376. /**
  93377. * Gets or sets the minimal initial rotation in radians.
  93378. */
  93379. minInitialRotation: number;
  93380. /**
  93381. * Gets or sets the maximal initial rotation in radians.
  93382. */
  93383. maxInitialRotation: number;
  93384. /**
  93385. * The particle emitter type defines the emitter used by the particle system.
  93386. * It can be for example box, sphere, or cone...
  93387. */
  93388. particleEmitterType: Nullable<IParticleEmitterType>;
  93389. /**
  93390. * Defines the delay in milliseconds before starting the system (0 by default)
  93391. */
  93392. startDelay: number;
  93393. /**
  93394. * 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
  93395. */
  93396. preWarmCycles: number;
  93397. /**
  93398. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93399. */
  93400. preWarmStepOffset: number;
  93401. /**
  93402. * 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)
  93403. */
  93404. spriteCellChangeSpeed: number;
  93405. /**
  93406. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93407. */
  93408. startSpriteCellID: number;
  93409. /**
  93410. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93411. */
  93412. endSpriteCellID: number;
  93413. /**
  93414. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93415. */
  93416. spriteCellWidth: number;
  93417. /**
  93418. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93419. */
  93420. spriteCellHeight: number;
  93421. /**
  93422. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93423. */
  93424. spriteRandomStartCell: boolean;
  93425. /**
  93426. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93427. */
  93428. isAnimationSheetEnabled: boolean;
  93429. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93430. translationPivot: Vector2;
  93431. /**
  93432. * Gets or sets a texture used to add random noise to particle positions
  93433. */
  93434. noiseTexture: Nullable<BaseTexture>;
  93435. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93436. noiseStrength: Vector3;
  93437. /**
  93438. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93439. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93440. */
  93441. billboardMode: number;
  93442. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93443. limitVelocityDamping: number;
  93444. /**
  93445. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93446. */
  93447. beginAnimationOnStart: boolean;
  93448. /**
  93449. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93450. */
  93451. beginAnimationFrom: number;
  93452. /**
  93453. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93454. */
  93455. beginAnimationTo: number;
  93456. /**
  93457. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93458. */
  93459. beginAnimationLoop: boolean;
  93460. /**
  93461. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93462. */
  93463. disposeOnStop: boolean;
  93464. /**
  93465. * Specifies if the particles are updated in emitter local space or world space
  93466. */
  93467. isLocal: boolean;
  93468. /** Snippet ID if the particle system was created from the snippet server */
  93469. snippetId: string;
  93470. /** Gets or sets a matrix to use to compute projection */
  93471. defaultProjectionMatrix: Matrix;
  93472. /**
  93473. * Gets the maximum number of particles active at the same time.
  93474. * @returns The max number of active particles.
  93475. */
  93476. getCapacity(): number;
  93477. /**
  93478. * Gets the number of particles active at the same time.
  93479. * @returns The number of active particles.
  93480. */
  93481. getActiveCount(): number;
  93482. /**
  93483. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93484. * @returns True if it has been started, otherwise false.
  93485. */
  93486. isStarted(): boolean;
  93487. /**
  93488. * Animates the particle system for this frame.
  93489. */
  93490. animate(): void;
  93491. /**
  93492. * Renders the particle system in its current state.
  93493. * @returns the current number of particles
  93494. */
  93495. render(): number;
  93496. /**
  93497. * Dispose the particle system and frees its associated resources.
  93498. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93499. */
  93500. dispose(disposeTexture?: boolean): void;
  93501. /**
  93502. * An event triggered when the system is disposed
  93503. */
  93504. onDisposeObservable: Observable<IParticleSystem>;
  93505. /**
  93506. * Clones the particle system.
  93507. * @param name The name of the cloned object
  93508. * @param newEmitter The new emitter to use
  93509. * @returns the cloned particle system
  93510. */
  93511. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  93512. /**
  93513. * Serializes the particle system to a JSON object
  93514. * @param serializeTexture defines if the texture must be serialized as well
  93515. * @returns the JSON object
  93516. */
  93517. serialize(serializeTexture: boolean): any;
  93518. /**
  93519. * Rebuild the particle system
  93520. */
  93521. rebuild(): void;
  93522. /** Force the system to rebuild all gradients that need to be resync */
  93523. forceRefreshGradients(): void;
  93524. /**
  93525. * Starts the particle system and begins to emit
  93526. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  93527. */
  93528. start(delay?: number): void;
  93529. /**
  93530. * Stops the particle system.
  93531. */
  93532. stop(): void;
  93533. /**
  93534. * Remove all active particles
  93535. */
  93536. reset(): void;
  93537. /**
  93538. * Gets a boolean indicating that the system is stopping
  93539. * @returns true if the system is currently stopping
  93540. */
  93541. isStopping(): boolean;
  93542. /**
  93543. * Is this system ready to be used/rendered
  93544. * @return true if the system is ready
  93545. */
  93546. isReady(): boolean;
  93547. /**
  93548. * Returns the string "ParticleSystem"
  93549. * @returns a string containing the class name
  93550. */
  93551. getClassName(): string;
  93552. /**
  93553. * Gets the custom effect used to render the particles
  93554. * @param blendMode Blend mode for which the effect should be retrieved
  93555. * @returns The effect
  93556. */
  93557. getCustomEffect(blendMode: number): Nullable<Effect>;
  93558. /**
  93559. * Sets the custom effect used to render the particles
  93560. * @param effect The effect to set
  93561. * @param blendMode Blend mode for which the effect should be set
  93562. */
  93563. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93564. /**
  93565. * Fill the defines array according to the current settings of the particle system
  93566. * @param defines Array to be updated
  93567. * @param blendMode blend mode to take into account when updating the array
  93568. */
  93569. fillDefines(defines: Array<string>, blendMode: number): void;
  93570. /**
  93571. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93572. * @param uniforms Uniforms array to fill
  93573. * @param attributes Attributes array to fill
  93574. * @param samplers Samplers array to fill
  93575. */
  93576. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93577. /**
  93578. * Observable that will be called just before the particles are drawn
  93579. */
  93580. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93581. /**
  93582. * Gets the name of the particle vertex shader
  93583. */
  93584. vertexShaderName: string;
  93585. /**
  93586. * Adds a new color gradient
  93587. * @param gradient defines the gradient to use (between 0 and 1)
  93588. * @param color1 defines the color to affect to the specified gradient
  93589. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93590. * @returns the current particle system
  93591. */
  93592. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93593. /**
  93594. * Remove a specific color gradient
  93595. * @param gradient defines the gradient to remove
  93596. * @returns the current particle system
  93597. */
  93598. removeColorGradient(gradient: number): IParticleSystem;
  93599. /**
  93600. * Adds a new size gradient
  93601. * @param gradient defines the gradient to use (between 0 and 1)
  93602. * @param factor defines the size factor to affect to the specified gradient
  93603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93604. * @returns the current particle system
  93605. */
  93606. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93607. /**
  93608. * Remove a specific size gradient
  93609. * @param gradient defines the gradient to remove
  93610. * @returns the current particle system
  93611. */
  93612. removeSizeGradient(gradient: number): IParticleSystem;
  93613. /**
  93614. * Gets the current list of color gradients.
  93615. * You must use addColorGradient and removeColorGradient to udpate this list
  93616. * @returns the list of color gradients
  93617. */
  93618. getColorGradients(): Nullable<Array<ColorGradient>>;
  93619. /**
  93620. * Gets the current list of size gradients.
  93621. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93622. * @returns the list of size gradients
  93623. */
  93624. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93625. /**
  93626. * Gets the current list of angular speed gradients.
  93627. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93628. * @returns the list of angular speed gradients
  93629. */
  93630. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93631. /**
  93632. * Adds a new angular speed gradient
  93633. * @param gradient defines the gradient to use (between 0 and 1)
  93634. * @param factor defines the angular speed to affect to the specified gradient
  93635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93636. * @returns the current particle system
  93637. */
  93638. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93639. /**
  93640. * Remove a specific angular speed gradient
  93641. * @param gradient defines the gradient to remove
  93642. * @returns the current particle system
  93643. */
  93644. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93645. /**
  93646. * Gets the current list of velocity gradients.
  93647. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93648. * @returns the list of velocity gradients
  93649. */
  93650. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93651. /**
  93652. * Adds a new velocity gradient
  93653. * @param gradient defines the gradient to use (between 0 and 1)
  93654. * @param factor defines the velocity to affect to the specified gradient
  93655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93656. * @returns the current particle system
  93657. */
  93658. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93659. /**
  93660. * Remove a specific velocity gradient
  93661. * @param gradient defines the gradient to remove
  93662. * @returns the current particle system
  93663. */
  93664. removeVelocityGradient(gradient: number): IParticleSystem;
  93665. /**
  93666. * Gets the current list of limit velocity gradients.
  93667. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93668. * @returns the list of limit velocity gradients
  93669. */
  93670. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93671. /**
  93672. * Adds a new limit velocity gradient
  93673. * @param gradient defines the gradient to use (between 0 and 1)
  93674. * @param factor defines the limit velocity to affect to the specified gradient
  93675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93676. * @returns the current particle system
  93677. */
  93678. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93679. /**
  93680. * Remove a specific limit velocity gradient
  93681. * @param gradient defines the gradient to remove
  93682. * @returns the current particle system
  93683. */
  93684. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93685. /**
  93686. * Adds a new drag gradient
  93687. * @param gradient defines the gradient to use (between 0 and 1)
  93688. * @param factor defines the drag to affect to the specified gradient
  93689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93690. * @returns the current particle system
  93691. */
  93692. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93693. /**
  93694. * Remove a specific drag gradient
  93695. * @param gradient defines the gradient to remove
  93696. * @returns the current particle system
  93697. */
  93698. removeDragGradient(gradient: number): IParticleSystem;
  93699. /**
  93700. * Gets the current list of drag gradients.
  93701. * You must use addDragGradient and removeDragGradient to udpate this list
  93702. * @returns the list of drag gradients
  93703. */
  93704. getDragGradients(): Nullable<Array<FactorGradient>>;
  93705. /**
  93706. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93707. * @param gradient defines the gradient to use (between 0 and 1)
  93708. * @param factor defines the emit rate to affect to the specified gradient
  93709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93710. * @returns the current particle system
  93711. */
  93712. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93713. /**
  93714. * Remove a specific emit rate gradient
  93715. * @param gradient defines the gradient to remove
  93716. * @returns the current particle system
  93717. */
  93718. removeEmitRateGradient(gradient: number): IParticleSystem;
  93719. /**
  93720. * Gets the current list of emit rate gradients.
  93721. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93722. * @returns the list of emit rate gradients
  93723. */
  93724. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93725. /**
  93726. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93727. * @param gradient defines the gradient to use (between 0 and 1)
  93728. * @param factor defines the start size to affect to the specified gradient
  93729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93730. * @returns the current particle system
  93731. */
  93732. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93733. /**
  93734. * Remove a specific start size gradient
  93735. * @param gradient defines the gradient to remove
  93736. * @returns the current particle system
  93737. */
  93738. removeStartSizeGradient(gradient: number): IParticleSystem;
  93739. /**
  93740. * Gets the current list of start size gradients.
  93741. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93742. * @returns the list of start size gradients
  93743. */
  93744. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93745. /**
  93746. * Adds a new life time gradient
  93747. * @param gradient defines the gradient to use (between 0 and 1)
  93748. * @param factor defines the life time factor to affect to the specified gradient
  93749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93750. * @returns the current particle system
  93751. */
  93752. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93753. /**
  93754. * Remove a specific life time gradient
  93755. * @param gradient defines the gradient to remove
  93756. * @returns the current particle system
  93757. */
  93758. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93759. /**
  93760. * Gets the current list of life time gradients.
  93761. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93762. * @returns the list of life time gradients
  93763. */
  93764. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93765. /**
  93766. * Gets the current list of color gradients.
  93767. * You must use addColorGradient and removeColorGradient to udpate this list
  93768. * @returns the list of color gradients
  93769. */
  93770. getColorGradients(): Nullable<Array<ColorGradient>>;
  93771. /**
  93772. * Adds a new ramp gradient used to remap particle colors
  93773. * @param gradient defines the gradient to use (between 0 and 1)
  93774. * @param color defines the color to affect to the specified gradient
  93775. * @returns the current particle system
  93776. */
  93777. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93778. /**
  93779. * Gets the current list of ramp gradients.
  93780. * You must use addRampGradient and removeRampGradient to udpate this list
  93781. * @returns the list of ramp gradients
  93782. */
  93783. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93784. /** Gets or sets a boolean indicating that ramp gradients must be used
  93785. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93786. */
  93787. useRampGradients: boolean;
  93788. /**
  93789. * Adds a new color remap gradient
  93790. * @param gradient defines the gradient to use (between 0 and 1)
  93791. * @param min defines the color remap minimal range
  93792. * @param max defines the color remap maximal range
  93793. * @returns the current particle system
  93794. */
  93795. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93796. /**
  93797. * Gets the current list of color remap gradients.
  93798. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93799. * @returns the list of color remap gradients
  93800. */
  93801. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93802. /**
  93803. * Adds a new alpha remap gradient
  93804. * @param gradient defines the gradient to use (between 0 and 1)
  93805. * @param min defines the alpha remap minimal range
  93806. * @param max defines the alpha remap maximal range
  93807. * @returns the current particle system
  93808. */
  93809. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93810. /**
  93811. * Gets the current list of alpha remap gradients.
  93812. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93813. * @returns the list of alpha remap gradients
  93814. */
  93815. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93816. /**
  93817. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93820. * @returns the emitter
  93821. */
  93822. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93823. /**
  93824. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93825. * @param radius The radius of the hemisphere to emit from
  93826. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93827. * @returns the emitter
  93828. */
  93829. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93830. /**
  93831. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93832. * @param radius The radius of the sphere to emit from
  93833. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93834. * @returns the emitter
  93835. */
  93836. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93837. /**
  93838. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93839. * @param radius The radius of the sphere to emit from
  93840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93842. * @returns the emitter
  93843. */
  93844. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93845. /**
  93846. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93847. * @param radius The radius of the emission cylinder
  93848. * @param height The height of the emission cylinder
  93849. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93850. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93851. * @returns the emitter
  93852. */
  93853. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93854. /**
  93855. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93856. * @param radius The radius of the cylinder to emit from
  93857. * @param height The height of the emission cylinder
  93858. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93861. * @returns the emitter
  93862. */
  93863. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93864. /**
  93865. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93866. * @param radius The radius of the cone to emit from
  93867. * @param angle The base angle of the cone
  93868. * @returns the emitter
  93869. */
  93870. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93871. /**
  93872. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93873. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93874. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93875. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93876. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93877. * @returns the emitter
  93878. */
  93879. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93880. /**
  93881. * Get hosting scene
  93882. * @returns the scene
  93883. */
  93884. getScene(): Nullable<Scene>;
  93885. }
  93886. }
  93887. declare module BABYLON {
  93888. /**
  93889. * 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.
  93890. * @see https://doc.babylonjs.com/how_to/transformnode
  93891. */
  93892. export class TransformNode extends Node {
  93893. /**
  93894. * Object will not rotate to face the camera
  93895. */
  93896. static BILLBOARDMODE_NONE: number;
  93897. /**
  93898. * Object will rotate to face the camera but only on the x axis
  93899. */
  93900. static BILLBOARDMODE_X: number;
  93901. /**
  93902. * Object will rotate to face the camera but only on the y axis
  93903. */
  93904. static BILLBOARDMODE_Y: number;
  93905. /**
  93906. * Object will rotate to face the camera but only on the z axis
  93907. */
  93908. static BILLBOARDMODE_Z: number;
  93909. /**
  93910. * Object will rotate to face the camera
  93911. */
  93912. static BILLBOARDMODE_ALL: number;
  93913. /**
  93914. * Object will rotate to face the camera's position instead of orientation
  93915. */
  93916. static BILLBOARDMODE_USE_POSITION: number;
  93917. private static _TmpRotation;
  93918. private static _TmpScaling;
  93919. private static _TmpTranslation;
  93920. private _forward;
  93921. private _forwardInverted;
  93922. private _up;
  93923. private _right;
  93924. private _rightInverted;
  93925. private _position;
  93926. private _rotation;
  93927. private _rotationQuaternion;
  93928. protected _scaling: Vector3;
  93929. protected _isDirty: boolean;
  93930. private _transformToBoneReferal;
  93931. private _isAbsoluteSynced;
  93932. private _billboardMode;
  93933. /**
  93934. * Gets or sets the billboard mode. Default is 0.
  93935. *
  93936. * | Value | Type | Description |
  93937. * | --- | --- | --- |
  93938. * | 0 | BILLBOARDMODE_NONE | |
  93939. * | 1 | BILLBOARDMODE_X | |
  93940. * | 2 | BILLBOARDMODE_Y | |
  93941. * | 4 | BILLBOARDMODE_Z | |
  93942. * | 7 | BILLBOARDMODE_ALL | |
  93943. *
  93944. */
  93945. get billboardMode(): number;
  93946. set billboardMode(value: number);
  93947. private _preserveParentRotationForBillboard;
  93948. /**
  93949. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93950. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93951. */
  93952. get preserveParentRotationForBillboard(): boolean;
  93953. set preserveParentRotationForBillboard(value: boolean);
  93954. /**
  93955. * 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
  93956. */
  93957. scalingDeterminant: number;
  93958. private _infiniteDistance;
  93959. /**
  93960. * Gets or sets the distance of the object to max, often used by skybox
  93961. */
  93962. get infiniteDistance(): boolean;
  93963. set infiniteDistance(value: boolean);
  93964. /**
  93965. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93966. * By default the system will update normals to compensate
  93967. */
  93968. ignoreNonUniformScaling: boolean;
  93969. /**
  93970. * 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
  93971. */
  93972. reIntegrateRotationIntoRotationQuaternion: boolean;
  93973. /** @hidden */
  93974. _poseMatrix: Nullable<Matrix>;
  93975. /** @hidden */
  93976. _localMatrix: Matrix;
  93977. private _usePivotMatrix;
  93978. private _absolutePosition;
  93979. private _absoluteScaling;
  93980. private _absoluteRotationQuaternion;
  93981. private _pivotMatrix;
  93982. private _pivotMatrixInverse;
  93983. protected _postMultiplyPivotMatrix: boolean;
  93984. protected _isWorldMatrixFrozen: boolean;
  93985. /** @hidden */
  93986. _indexInSceneTransformNodesArray: number;
  93987. /**
  93988. * An event triggered after the world matrix is updated
  93989. */
  93990. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93991. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93992. /**
  93993. * Gets a string identifying the name of the class
  93994. * @returns "TransformNode" string
  93995. */
  93996. getClassName(): string;
  93997. /**
  93998. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93999. */
  94000. get position(): Vector3;
  94001. set position(newPosition: Vector3);
  94002. /**
  94003. * 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)).
  94004. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94005. */
  94006. get rotation(): Vector3;
  94007. set rotation(newRotation: Vector3);
  94008. /**
  94009. * 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)).
  94010. */
  94011. get scaling(): Vector3;
  94012. set scaling(newScaling: Vector3);
  94013. /**
  94014. * 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).
  94015. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94016. */
  94017. get rotationQuaternion(): Nullable<Quaternion>;
  94018. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94019. /**
  94020. * The forward direction of that transform in world space.
  94021. */
  94022. get forward(): Vector3;
  94023. /**
  94024. * The up direction of that transform in world space.
  94025. */
  94026. get up(): Vector3;
  94027. /**
  94028. * The right direction of that transform in world space.
  94029. */
  94030. get right(): Vector3;
  94031. /**
  94032. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94033. * @param matrix the matrix to copy the pose from
  94034. * @returns this TransformNode.
  94035. */
  94036. updatePoseMatrix(matrix: Matrix): TransformNode;
  94037. /**
  94038. * Returns the mesh Pose matrix.
  94039. * @returns the pose matrix
  94040. */
  94041. getPoseMatrix(): Matrix;
  94042. /** @hidden */
  94043. _isSynchronized(): boolean;
  94044. /** @hidden */
  94045. _initCache(): void;
  94046. /**
  94047. * Flag the transform node as dirty (Forcing it to update everything)
  94048. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94049. * @returns this transform node
  94050. */
  94051. markAsDirty(property: string): TransformNode;
  94052. /**
  94053. * Returns the current mesh absolute position.
  94054. * Returns a Vector3.
  94055. */
  94056. get absolutePosition(): Vector3;
  94057. /**
  94058. * Returns the current mesh absolute scaling.
  94059. * Returns a Vector3.
  94060. */
  94061. get absoluteScaling(): Vector3;
  94062. /**
  94063. * Returns the current mesh absolute rotation.
  94064. * Returns a Quaternion.
  94065. */
  94066. get absoluteRotationQuaternion(): Quaternion;
  94067. /**
  94068. * Sets a new matrix to apply before all other transformation
  94069. * @param matrix defines the transform matrix
  94070. * @returns the current TransformNode
  94071. */
  94072. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94073. /**
  94074. * Sets a new pivot matrix to the current node
  94075. * @param matrix defines the new pivot matrix to use
  94076. * @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
  94077. * @returns the current TransformNode
  94078. */
  94079. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94080. /**
  94081. * Returns the mesh pivot matrix.
  94082. * Default : Identity.
  94083. * @returns the matrix
  94084. */
  94085. getPivotMatrix(): Matrix;
  94086. /**
  94087. * Instantiate (when possible) or clone that node with its hierarchy
  94088. * @param newParent defines the new parent to use for the instance (or clone)
  94089. * @param options defines options to configure how copy is done
  94090. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94091. * @returns an instance (or a clone) of the current node with its hiearchy
  94092. */
  94093. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94094. doNotInstantiate: boolean;
  94095. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94096. /**
  94097. * Prevents the World matrix to be computed any longer
  94098. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94099. * @returns the TransformNode.
  94100. */
  94101. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94102. /**
  94103. * Allows back the World matrix computation.
  94104. * @returns the TransformNode.
  94105. */
  94106. unfreezeWorldMatrix(): this;
  94107. /**
  94108. * True if the World matrix has been frozen.
  94109. */
  94110. get isWorldMatrixFrozen(): boolean;
  94111. /**
  94112. * Retuns the mesh absolute position in the World.
  94113. * @returns a Vector3.
  94114. */
  94115. getAbsolutePosition(): Vector3;
  94116. /**
  94117. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94118. * @param absolutePosition the absolute position to set
  94119. * @returns the TransformNode.
  94120. */
  94121. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94122. /**
  94123. * Sets the mesh position in its local space.
  94124. * @param vector3 the position to set in localspace
  94125. * @returns the TransformNode.
  94126. */
  94127. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94128. /**
  94129. * Returns the mesh position in the local space from the current World matrix values.
  94130. * @returns a new Vector3.
  94131. */
  94132. getPositionExpressedInLocalSpace(): Vector3;
  94133. /**
  94134. * Translates the mesh along the passed Vector3 in its local space.
  94135. * @param vector3 the distance to translate in localspace
  94136. * @returns the TransformNode.
  94137. */
  94138. locallyTranslate(vector3: Vector3): TransformNode;
  94139. private static _lookAtVectorCache;
  94140. /**
  94141. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94142. * @param targetPoint the position (must be in same space as current mesh) to look at
  94143. * @param yawCor optional yaw (y-axis) correction in radians
  94144. * @param pitchCor optional pitch (x-axis) correction in radians
  94145. * @param rollCor optional roll (z-axis) correction in radians
  94146. * @param space the choosen space of the target
  94147. * @returns the TransformNode.
  94148. */
  94149. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94150. /**
  94151. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94152. * This Vector3 is expressed in the World space.
  94153. * @param localAxis axis to rotate
  94154. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94155. */
  94156. getDirection(localAxis: Vector3): Vector3;
  94157. /**
  94158. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94159. * localAxis is expressed in the mesh local space.
  94160. * result is computed in the Wordl space from the mesh World matrix.
  94161. * @param localAxis axis to rotate
  94162. * @param result the resulting transformnode
  94163. * @returns this TransformNode.
  94164. */
  94165. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94166. /**
  94167. * Sets this transform node rotation to the given local axis.
  94168. * @param localAxis the axis in local space
  94169. * @param yawCor optional yaw (y-axis) correction in radians
  94170. * @param pitchCor optional pitch (x-axis) correction in radians
  94171. * @param rollCor optional roll (z-axis) correction in radians
  94172. * @returns this TransformNode
  94173. */
  94174. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94175. /**
  94176. * Sets a new pivot point to the current node
  94177. * @param point defines the new pivot point to use
  94178. * @param space defines if the point is in world or local space (local by default)
  94179. * @returns the current TransformNode
  94180. */
  94181. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94182. /**
  94183. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94184. * @returns the pivot point
  94185. */
  94186. getPivotPoint(): Vector3;
  94187. /**
  94188. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94189. * @param result the vector3 to store the result
  94190. * @returns this TransformNode.
  94191. */
  94192. getPivotPointToRef(result: Vector3): TransformNode;
  94193. /**
  94194. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94195. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94196. */
  94197. getAbsolutePivotPoint(): Vector3;
  94198. /**
  94199. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94200. * @param result vector3 to store the result
  94201. * @returns this TransformNode.
  94202. */
  94203. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94204. /**
  94205. * Defines the passed node as the parent of the current node.
  94206. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94207. * @see https://doc.babylonjs.com/how_to/parenting
  94208. * @param node the node ot set as the parent
  94209. * @returns this TransformNode.
  94210. */
  94211. setParent(node: Nullable<Node>): TransformNode;
  94212. private _nonUniformScaling;
  94213. /**
  94214. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94215. */
  94216. get nonUniformScaling(): boolean;
  94217. /** @hidden */
  94218. _updateNonUniformScalingState(value: boolean): boolean;
  94219. /**
  94220. * Attach the current TransformNode to another TransformNode associated with a bone
  94221. * @param bone Bone affecting the TransformNode
  94222. * @param affectedTransformNode TransformNode associated with the bone
  94223. * @returns this object
  94224. */
  94225. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94226. /**
  94227. * Detach the transform node if its associated with a bone
  94228. * @returns this object
  94229. */
  94230. detachFromBone(): TransformNode;
  94231. private static _rotationAxisCache;
  94232. /**
  94233. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94234. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94235. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94236. * The passed axis is also normalized.
  94237. * @param axis the axis to rotate around
  94238. * @param amount the amount to rotate in radians
  94239. * @param space Space to rotate in (Default: local)
  94240. * @returns the TransformNode.
  94241. */
  94242. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94243. /**
  94244. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94245. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94246. * The passed axis is also normalized. .
  94247. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94248. * @param point the point to rotate around
  94249. * @param axis the axis to rotate around
  94250. * @param amount the amount to rotate in radians
  94251. * @returns the TransformNode
  94252. */
  94253. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94254. /**
  94255. * Translates the mesh along the axis vector for the passed distance in the given space.
  94256. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94257. * @param axis the axis to translate in
  94258. * @param distance the distance to translate
  94259. * @param space Space to rotate in (Default: local)
  94260. * @returns the TransformNode.
  94261. */
  94262. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94263. /**
  94264. * Adds a rotation step to the mesh current rotation.
  94265. * x, y, z are Euler angles expressed in radians.
  94266. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94267. * This means this rotation is made in the mesh local space only.
  94268. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94269. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94270. * ```javascript
  94271. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94272. * ```
  94273. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94274. * 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.
  94275. * @param x Rotation to add
  94276. * @param y Rotation to add
  94277. * @param z Rotation to add
  94278. * @returns the TransformNode.
  94279. */
  94280. addRotation(x: number, y: number, z: number): TransformNode;
  94281. /**
  94282. * @hidden
  94283. */
  94284. protected _getEffectiveParent(): Nullable<Node>;
  94285. /**
  94286. * Computes the world matrix of the node
  94287. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94288. * @returns the world matrix
  94289. */
  94290. computeWorldMatrix(force?: boolean): Matrix;
  94291. /**
  94292. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94293. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94294. */
  94295. resetLocalMatrix(independentOfChildren?: boolean): void;
  94296. protected _afterComputeWorldMatrix(): void;
  94297. /**
  94298. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94299. * @param func callback function to add
  94300. *
  94301. * @returns the TransformNode.
  94302. */
  94303. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94304. /**
  94305. * Removes a registered callback function.
  94306. * @param func callback function to remove
  94307. * @returns the TransformNode.
  94308. */
  94309. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94310. /**
  94311. * Gets the position of the current mesh in camera space
  94312. * @param camera defines the camera to use
  94313. * @returns a position
  94314. */
  94315. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94316. /**
  94317. * Returns the distance from the mesh to the active camera
  94318. * @param camera defines the camera to use
  94319. * @returns the distance
  94320. */
  94321. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94322. /**
  94323. * Clone the current transform node
  94324. * @param name Name of the new clone
  94325. * @param newParent New parent for the clone
  94326. * @param doNotCloneChildren Do not clone children hierarchy
  94327. * @returns the new transform node
  94328. */
  94329. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94330. /**
  94331. * Serializes the objects information.
  94332. * @param currentSerializationObject defines the object to serialize in
  94333. * @returns the serialized object
  94334. */
  94335. serialize(currentSerializationObject?: any): any;
  94336. /**
  94337. * Returns a new TransformNode object parsed from the source provided.
  94338. * @param parsedTransformNode is the source.
  94339. * @param scene the scne the object belongs to
  94340. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94341. * @returns a new TransformNode object parsed from the source provided.
  94342. */
  94343. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94344. /**
  94345. * Get all child-transformNodes of this node
  94346. * @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
  94347. * @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
  94348. * @returns an array of TransformNode
  94349. */
  94350. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94351. /**
  94352. * Releases resources associated with this transform node.
  94353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94355. */
  94356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94357. /**
  94358. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94359. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94360. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94361. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94362. * @returns the current mesh
  94363. */
  94364. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94365. private _syncAbsoluteScalingAndRotation;
  94366. }
  94367. }
  94368. declare module BABYLON {
  94369. /**
  94370. * Class used to override all child animations of a given target
  94371. */
  94372. export class AnimationPropertiesOverride {
  94373. /**
  94374. * Gets or sets a value indicating if animation blending must be used
  94375. */
  94376. enableBlending: boolean;
  94377. /**
  94378. * Gets or sets the blending speed to use when enableBlending is true
  94379. */
  94380. blendingSpeed: number;
  94381. /**
  94382. * Gets or sets the default loop mode to use
  94383. */
  94384. loopMode: number;
  94385. }
  94386. }
  94387. declare module BABYLON {
  94388. /**
  94389. * Class used to store bone information
  94390. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94391. */
  94392. export class Bone extends Node {
  94393. /**
  94394. * defines the bone name
  94395. */
  94396. name: string;
  94397. private static _tmpVecs;
  94398. private static _tmpQuat;
  94399. private static _tmpMats;
  94400. /**
  94401. * Gets the list of child bones
  94402. */
  94403. children: Bone[];
  94404. /** Gets the animations associated with this bone */
  94405. animations: Animation[];
  94406. /**
  94407. * Gets or sets bone length
  94408. */
  94409. length: number;
  94410. /**
  94411. * @hidden Internal only
  94412. * Set this value to map this bone to a different index in the transform matrices
  94413. * Set this value to -1 to exclude the bone from the transform matrices
  94414. */
  94415. _index: Nullable<number>;
  94416. private _skeleton;
  94417. private _localMatrix;
  94418. private _restPose;
  94419. private _bindPose;
  94420. private _baseMatrix;
  94421. private _absoluteTransform;
  94422. private _invertedAbsoluteTransform;
  94423. private _parent;
  94424. private _scalingDeterminant;
  94425. private _worldTransform;
  94426. private _localScaling;
  94427. private _localRotation;
  94428. private _localPosition;
  94429. private _needToDecompose;
  94430. private _needToCompose;
  94431. /** @hidden */
  94432. _linkedTransformNode: Nullable<TransformNode>;
  94433. /** @hidden */
  94434. _waitingTransformNodeId: Nullable<string>;
  94435. /** @hidden */
  94436. get _matrix(): Matrix;
  94437. /** @hidden */
  94438. set _matrix(value: Matrix);
  94439. /**
  94440. * Create a new bone
  94441. * @param name defines the bone name
  94442. * @param skeleton defines the parent skeleton
  94443. * @param parentBone defines the parent (can be null if the bone is the root)
  94444. * @param localMatrix defines the local matrix
  94445. * @param restPose defines the rest pose matrix
  94446. * @param baseMatrix defines the base matrix
  94447. * @param index defines index of the bone in the hiearchy
  94448. */
  94449. constructor(
  94450. /**
  94451. * defines the bone name
  94452. */
  94453. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94454. /**
  94455. * Gets the current object class name.
  94456. * @return the class name
  94457. */
  94458. getClassName(): string;
  94459. /**
  94460. * Gets the parent skeleton
  94461. * @returns a skeleton
  94462. */
  94463. getSkeleton(): Skeleton;
  94464. /**
  94465. * Gets parent bone
  94466. * @returns a bone or null if the bone is the root of the bone hierarchy
  94467. */
  94468. getParent(): Nullable<Bone>;
  94469. /**
  94470. * Returns an array containing the root bones
  94471. * @returns an array containing the root bones
  94472. */
  94473. getChildren(): Array<Bone>;
  94474. /**
  94475. * Gets the node index in matrix array generated for rendering
  94476. * @returns the node index
  94477. */
  94478. getIndex(): number;
  94479. /**
  94480. * Sets the parent bone
  94481. * @param parent defines the parent (can be null if the bone is the root)
  94482. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94483. */
  94484. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94485. /**
  94486. * Gets the local matrix
  94487. * @returns a matrix
  94488. */
  94489. getLocalMatrix(): Matrix;
  94490. /**
  94491. * Gets the base matrix (initial matrix which remains unchanged)
  94492. * @returns a matrix
  94493. */
  94494. getBaseMatrix(): Matrix;
  94495. /**
  94496. * Gets the rest pose matrix
  94497. * @returns a matrix
  94498. */
  94499. getRestPose(): Matrix;
  94500. /**
  94501. * Sets the rest pose matrix
  94502. * @param matrix the local-space rest pose to set for this bone
  94503. */
  94504. setRestPose(matrix: Matrix): void;
  94505. /**
  94506. * Gets the bind pose matrix
  94507. * @returns the bind pose matrix
  94508. */
  94509. getBindPose(): Matrix;
  94510. /**
  94511. * Sets the bind pose matrix
  94512. * @param matrix the local-space bind pose to set for this bone
  94513. */
  94514. setBindPose(matrix: Matrix): void;
  94515. /**
  94516. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  94517. */
  94518. getWorldMatrix(): Matrix;
  94519. /**
  94520. * Sets the local matrix to rest pose matrix
  94521. */
  94522. returnToRest(): void;
  94523. /**
  94524. * Gets the inverse of the absolute transform matrix.
  94525. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  94526. * @returns a matrix
  94527. */
  94528. getInvertedAbsoluteTransform(): Matrix;
  94529. /**
  94530. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  94531. * @returns a matrix
  94532. */
  94533. getAbsoluteTransform(): Matrix;
  94534. /**
  94535. * Links with the given transform node.
  94536. * The local matrix of this bone is copied from the transform node every frame.
  94537. * @param transformNode defines the transform node to link to
  94538. */
  94539. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  94540. /**
  94541. * Gets the node used to drive the bone's transformation
  94542. * @returns a transform node or null
  94543. */
  94544. getTransformNode(): Nullable<TransformNode>;
  94545. /** Gets or sets current position (in local space) */
  94546. get position(): Vector3;
  94547. set position(newPosition: Vector3);
  94548. /** Gets or sets current rotation (in local space) */
  94549. get rotation(): Vector3;
  94550. set rotation(newRotation: Vector3);
  94551. /** Gets or sets current rotation quaternion (in local space) */
  94552. get rotationQuaternion(): Quaternion;
  94553. set rotationQuaternion(newRotation: Quaternion);
  94554. /** Gets or sets current scaling (in local space) */
  94555. get scaling(): Vector3;
  94556. set scaling(newScaling: Vector3);
  94557. /**
  94558. * Gets the animation properties override
  94559. */
  94560. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94561. private _decompose;
  94562. private _compose;
  94563. /**
  94564. * Update the base and local matrices
  94565. * @param matrix defines the new base or local matrix
  94566. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94567. * @param updateLocalMatrix defines if the local matrix should be updated
  94568. */
  94569. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94570. /** @hidden */
  94571. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94572. /**
  94573. * Flag the bone as dirty (Forcing it to update everything)
  94574. */
  94575. markAsDirty(): void;
  94576. /** @hidden */
  94577. _markAsDirtyAndCompose(): void;
  94578. private _markAsDirtyAndDecompose;
  94579. /**
  94580. * Translate the bone in local or world space
  94581. * @param vec The amount to translate the bone
  94582. * @param space The space that the translation is in
  94583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94584. */
  94585. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94586. /**
  94587. * Set the postion of the bone in local or world space
  94588. * @param position The position to set the bone
  94589. * @param space The space that the position is in
  94590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94591. */
  94592. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94593. /**
  94594. * Set the absolute position of the bone (world space)
  94595. * @param position The position to set the bone
  94596. * @param mesh The mesh that this bone is attached to
  94597. */
  94598. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94599. /**
  94600. * Scale the bone on the x, y and z axes (in local space)
  94601. * @param x The amount to scale the bone on the x axis
  94602. * @param y The amount to scale the bone on the y axis
  94603. * @param z The amount to scale the bone on the z axis
  94604. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94605. */
  94606. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94607. /**
  94608. * Set the bone scaling in local space
  94609. * @param scale defines the scaling vector
  94610. */
  94611. setScale(scale: Vector3): void;
  94612. /**
  94613. * Gets the current scaling in local space
  94614. * @returns the current scaling vector
  94615. */
  94616. getScale(): Vector3;
  94617. /**
  94618. * Gets the current scaling in local space and stores it in a target vector
  94619. * @param result defines the target vector
  94620. */
  94621. getScaleToRef(result: Vector3): void;
  94622. /**
  94623. * Set the yaw, pitch, and roll of the bone in local or world space
  94624. * @param yaw The rotation of the bone on the y axis
  94625. * @param pitch The rotation of the bone on the x axis
  94626. * @param roll The rotation of the bone on the z axis
  94627. * @param space The space that the axes of rotation are in
  94628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94629. */
  94630. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94631. /**
  94632. * Add a rotation to the bone on an axis in local or world space
  94633. * @param axis The axis to rotate the bone on
  94634. * @param amount The amount to rotate the bone
  94635. * @param space The space that the axis is in
  94636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94637. */
  94638. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94639. /**
  94640. * Set the rotation of the bone to a particular axis angle in local or world space
  94641. * @param axis The axis to rotate the bone on
  94642. * @param angle The angle that the bone should be rotated to
  94643. * @param space The space that the axis is in
  94644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94645. */
  94646. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94647. /**
  94648. * Set the euler rotation of the bone in local of world space
  94649. * @param rotation The euler rotation that the bone should be set to
  94650. * @param space The space that the rotation is in
  94651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94652. */
  94653. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94654. /**
  94655. * Set the quaternion rotation of the bone in local of world space
  94656. * @param quat The quaternion rotation that the bone should be set to
  94657. * @param space The space that the rotation is in
  94658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94659. */
  94660. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94661. /**
  94662. * Set the rotation matrix of the bone in local of world space
  94663. * @param rotMat The rotation matrix that the bone should be set to
  94664. * @param space The space that the rotation is in
  94665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94666. */
  94667. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94668. private _rotateWithMatrix;
  94669. private _getNegativeRotationToRef;
  94670. /**
  94671. * Get the position of the bone in local or world space
  94672. * @param space The space that the returned position is in
  94673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94674. * @returns The position of the bone
  94675. */
  94676. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94677. /**
  94678. * Copy the position of the bone to a vector3 in local or world space
  94679. * @param space The space that the returned position is in
  94680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94681. * @param result The vector3 to copy the position to
  94682. */
  94683. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94684. /**
  94685. * Get the absolute position of the bone (world space)
  94686. * @param mesh The mesh that this bone is attached to
  94687. * @returns The absolute position of the bone
  94688. */
  94689. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94690. /**
  94691. * Copy the absolute position of the bone (world space) to the result param
  94692. * @param mesh The mesh that this bone is attached to
  94693. * @param result The vector3 to copy the absolute position to
  94694. */
  94695. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94696. /**
  94697. * Compute the absolute transforms of this bone and its children
  94698. */
  94699. computeAbsoluteTransforms(): void;
  94700. /**
  94701. * Get the world direction from an axis that is in the local space of the bone
  94702. * @param localAxis The local direction that is used to compute the world direction
  94703. * @param mesh The mesh that this bone is attached to
  94704. * @returns The world direction
  94705. */
  94706. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94707. /**
  94708. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94709. * @param localAxis The local direction that is used to compute the world direction
  94710. * @param mesh The mesh that this bone is attached to
  94711. * @param result The vector3 that the world direction will be copied to
  94712. */
  94713. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94714. /**
  94715. * Get the euler rotation of the bone in local or world space
  94716. * @param space The space that the rotation should be in
  94717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94718. * @returns The euler rotation
  94719. */
  94720. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94721. /**
  94722. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94723. * @param space The space that the rotation should be in
  94724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94725. * @param result The vector3 that the rotation should be copied to
  94726. */
  94727. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94728. /**
  94729. * Get the quaternion rotation of the bone in either local or world space
  94730. * @param space The space that the rotation should be in
  94731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94732. * @returns The quaternion rotation
  94733. */
  94734. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94735. /**
  94736. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94737. * @param space The space that the rotation should be in
  94738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94739. * @param result The quaternion that the rotation should be copied to
  94740. */
  94741. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94742. /**
  94743. * Get the rotation matrix of the bone in local or world space
  94744. * @param space The space that the rotation should be in
  94745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94746. * @returns The rotation matrix
  94747. */
  94748. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94749. /**
  94750. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94751. * @param space The space that the rotation should be in
  94752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94753. * @param result The quaternion that the rotation should be copied to
  94754. */
  94755. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94756. /**
  94757. * Get the world position of a point that is in the local space of the bone
  94758. * @param position The local position
  94759. * @param mesh The mesh that this bone is attached to
  94760. * @returns The world position
  94761. */
  94762. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94763. /**
  94764. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94765. * @param position The local position
  94766. * @param mesh The mesh that this bone is attached to
  94767. * @param result The vector3 that the world position should be copied to
  94768. */
  94769. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94770. /**
  94771. * Get the local position of a point that is in world space
  94772. * @param position The world position
  94773. * @param mesh The mesh that this bone is attached to
  94774. * @returns The local position
  94775. */
  94776. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94777. /**
  94778. * Get the local position of a point that is in world space and copy it to the result param
  94779. * @param position The world position
  94780. * @param mesh The mesh that this bone is attached to
  94781. * @param result The vector3 that the local position should be copied to
  94782. */
  94783. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94784. }
  94785. }
  94786. declare module BABYLON {
  94787. /**
  94788. * Defines a runtime animation
  94789. */
  94790. export class RuntimeAnimation {
  94791. private _events;
  94792. /**
  94793. * The current frame of the runtime animation
  94794. */
  94795. private _currentFrame;
  94796. /**
  94797. * The animation used by the runtime animation
  94798. */
  94799. private _animation;
  94800. /**
  94801. * The target of the runtime animation
  94802. */
  94803. private _target;
  94804. /**
  94805. * The initiating animatable
  94806. */
  94807. private _host;
  94808. /**
  94809. * The original value of the runtime animation
  94810. */
  94811. private _originalValue;
  94812. /**
  94813. * The original blend value of the runtime animation
  94814. */
  94815. private _originalBlendValue;
  94816. /**
  94817. * The offsets cache of the runtime animation
  94818. */
  94819. private _offsetsCache;
  94820. /**
  94821. * The high limits cache of the runtime animation
  94822. */
  94823. private _highLimitsCache;
  94824. /**
  94825. * Specifies if the runtime animation has been stopped
  94826. */
  94827. private _stopped;
  94828. /**
  94829. * The blending factor of the runtime animation
  94830. */
  94831. private _blendingFactor;
  94832. /**
  94833. * The BabylonJS scene
  94834. */
  94835. private _scene;
  94836. /**
  94837. * The current value of the runtime animation
  94838. */
  94839. private _currentValue;
  94840. /** @hidden */
  94841. _animationState: _IAnimationState;
  94842. /**
  94843. * The active target of the runtime animation
  94844. */
  94845. private _activeTargets;
  94846. private _currentActiveTarget;
  94847. private _directTarget;
  94848. /**
  94849. * The target path of the runtime animation
  94850. */
  94851. private _targetPath;
  94852. /**
  94853. * The weight of the runtime animation
  94854. */
  94855. private _weight;
  94856. /**
  94857. * The ratio offset of the runtime animation
  94858. */
  94859. private _ratioOffset;
  94860. /**
  94861. * The previous delay of the runtime animation
  94862. */
  94863. private _previousDelay;
  94864. /**
  94865. * The previous ratio of the runtime animation
  94866. */
  94867. private _previousRatio;
  94868. private _enableBlending;
  94869. private _keys;
  94870. private _minFrame;
  94871. private _maxFrame;
  94872. private _minValue;
  94873. private _maxValue;
  94874. private _targetIsArray;
  94875. /**
  94876. * Gets the current frame of the runtime animation
  94877. */
  94878. get currentFrame(): number;
  94879. /**
  94880. * Gets the weight of the runtime animation
  94881. */
  94882. get weight(): number;
  94883. /**
  94884. * Gets the current value of the runtime animation
  94885. */
  94886. get currentValue(): any;
  94887. /**
  94888. * Gets the target path of the runtime animation
  94889. */
  94890. get targetPath(): string;
  94891. /**
  94892. * Gets the actual target of the runtime animation
  94893. */
  94894. get target(): any;
  94895. /**
  94896. * Gets the additive state of the runtime animation
  94897. */
  94898. get isAdditive(): boolean;
  94899. /** @hidden */
  94900. _onLoop: () => void;
  94901. /**
  94902. * Create a new RuntimeAnimation object
  94903. * @param target defines the target of the animation
  94904. * @param animation defines the source animation object
  94905. * @param scene defines the hosting scene
  94906. * @param host defines the initiating Animatable
  94907. */
  94908. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94909. private _preparePath;
  94910. /**
  94911. * Gets the animation from the runtime animation
  94912. */
  94913. get animation(): Animation;
  94914. /**
  94915. * Resets the runtime animation to the beginning
  94916. * @param restoreOriginal defines whether to restore the target property to the original value
  94917. */
  94918. reset(restoreOriginal?: boolean): void;
  94919. /**
  94920. * Specifies if the runtime animation is stopped
  94921. * @returns Boolean specifying if the runtime animation is stopped
  94922. */
  94923. isStopped(): boolean;
  94924. /**
  94925. * Disposes of the runtime animation
  94926. */
  94927. dispose(): void;
  94928. /**
  94929. * Apply the interpolated value to the target
  94930. * @param currentValue defines the value computed by the animation
  94931. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94932. */
  94933. setValue(currentValue: any, weight: number): void;
  94934. private _getOriginalValues;
  94935. private _setValue;
  94936. /**
  94937. * Gets the loop pmode of the runtime animation
  94938. * @returns Loop Mode
  94939. */
  94940. private _getCorrectLoopMode;
  94941. /**
  94942. * Move the current animation to a given frame
  94943. * @param frame defines the frame to move to
  94944. */
  94945. goToFrame(frame: number): void;
  94946. /**
  94947. * @hidden Internal use only
  94948. */
  94949. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94950. /**
  94951. * Execute the current animation
  94952. * @param delay defines the delay to add to the current frame
  94953. * @param from defines the lower bound of the animation range
  94954. * @param to defines the upper bound of the animation range
  94955. * @param loop defines if the current animation must loop
  94956. * @param speedRatio defines the current speed ratio
  94957. * @param weight defines the weight of the animation (default is -1 so no weight)
  94958. * @param onLoop optional callback called when animation loops
  94959. * @returns a boolean indicating if the animation is running
  94960. */
  94961. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94962. }
  94963. }
  94964. declare module BABYLON {
  94965. /**
  94966. * Class used to store an actual running animation
  94967. */
  94968. export class Animatable {
  94969. /** defines the target object */
  94970. target: any;
  94971. /** defines the starting frame number (default is 0) */
  94972. fromFrame: number;
  94973. /** defines the ending frame number (default is 100) */
  94974. toFrame: number;
  94975. /** defines if the animation must loop (default is false) */
  94976. loopAnimation: boolean;
  94977. /** defines a callback to call when animation ends if it is not looping */
  94978. onAnimationEnd?: (() => void) | null | undefined;
  94979. /** defines a callback to call when animation loops */
  94980. onAnimationLoop?: (() => void) | null | undefined;
  94981. /** defines whether the animation should be evaluated additively */
  94982. isAdditive: boolean;
  94983. private _localDelayOffset;
  94984. private _pausedDelay;
  94985. private _runtimeAnimations;
  94986. private _paused;
  94987. private _scene;
  94988. private _speedRatio;
  94989. private _weight;
  94990. private _syncRoot;
  94991. /**
  94992. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94993. * This will only apply for non looping animation (default is true)
  94994. */
  94995. disposeOnEnd: boolean;
  94996. /**
  94997. * Gets a boolean indicating if the animation has started
  94998. */
  94999. animationStarted: boolean;
  95000. /**
  95001. * Observer raised when the animation ends
  95002. */
  95003. onAnimationEndObservable: Observable<Animatable>;
  95004. /**
  95005. * Observer raised when the animation loops
  95006. */
  95007. onAnimationLoopObservable: Observable<Animatable>;
  95008. /**
  95009. * Gets the root Animatable used to synchronize and normalize animations
  95010. */
  95011. get syncRoot(): Nullable<Animatable>;
  95012. /**
  95013. * Gets the current frame of the first RuntimeAnimation
  95014. * Used to synchronize Animatables
  95015. */
  95016. get masterFrame(): number;
  95017. /**
  95018. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95019. */
  95020. get weight(): number;
  95021. set weight(value: number);
  95022. /**
  95023. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95024. */
  95025. get speedRatio(): number;
  95026. set speedRatio(value: number);
  95027. /**
  95028. * Creates a new Animatable
  95029. * @param scene defines the hosting scene
  95030. * @param target defines the target object
  95031. * @param fromFrame defines the starting frame number (default is 0)
  95032. * @param toFrame defines the ending frame number (default is 100)
  95033. * @param loopAnimation defines if the animation must loop (default is false)
  95034. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95035. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95036. * @param animations defines a group of animation to add to the new Animatable
  95037. * @param onAnimationLoop defines a callback to call when animation loops
  95038. * @param isAdditive defines whether the animation should be evaluated additively
  95039. */
  95040. constructor(scene: Scene,
  95041. /** defines the target object */
  95042. target: any,
  95043. /** defines the starting frame number (default is 0) */
  95044. fromFrame?: number,
  95045. /** defines the ending frame number (default is 100) */
  95046. toFrame?: number,
  95047. /** defines if the animation must loop (default is false) */
  95048. loopAnimation?: boolean, speedRatio?: number,
  95049. /** defines a callback to call when animation ends if it is not looping */
  95050. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95051. /** defines a callback to call when animation loops */
  95052. onAnimationLoop?: (() => void) | null | undefined,
  95053. /** defines whether the animation should be evaluated additively */
  95054. isAdditive?: boolean);
  95055. /**
  95056. * Synchronize and normalize current Animatable with a source Animatable
  95057. * This is useful when using animation weights and when animations are not of the same length
  95058. * @param root defines the root Animatable to synchronize with
  95059. * @returns the current Animatable
  95060. */
  95061. syncWith(root: Animatable): Animatable;
  95062. /**
  95063. * Gets the list of runtime animations
  95064. * @returns an array of RuntimeAnimation
  95065. */
  95066. getAnimations(): RuntimeAnimation[];
  95067. /**
  95068. * Adds more animations to the current animatable
  95069. * @param target defines the target of the animations
  95070. * @param animations defines the new animations to add
  95071. */
  95072. appendAnimations(target: any, animations: Animation[]): void;
  95073. /**
  95074. * Gets the source animation for a specific property
  95075. * @param property defines the propertyu to look for
  95076. * @returns null or the source animation for the given property
  95077. */
  95078. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95079. /**
  95080. * Gets the runtime animation for a specific property
  95081. * @param property defines the propertyu to look for
  95082. * @returns null or the runtime animation for the given property
  95083. */
  95084. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95085. /**
  95086. * Resets the animatable to its original state
  95087. */
  95088. reset(): void;
  95089. /**
  95090. * Allows the animatable to blend with current running animations
  95091. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95092. * @param blendingSpeed defines the blending speed to use
  95093. */
  95094. enableBlending(blendingSpeed: number): void;
  95095. /**
  95096. * Disable animation blending
  95097. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95098. */
  95099. disableBlending(): void;
  95100. /**
  95101. * Jump directly to a given frame
  95102. * @param frame defines the frame to jump to
  95103. */
  95104. goToFrame(frame: number): void;
  95105. /**
  95106. * Pause the animation
  95107. */
  95108. pause(): void;
  95109. /**
  95110. * Restart the animation
  95111. */
  95112. restart(): void;
  95113. private _raiseOnAnimationEnd;
  95114. /**
  95115. * Stop and delete the current animation
  95116. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95117. * @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)
  95118. */
  95119. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95120. /**
  95121. * Wait asynchronously for the animation to end
  95122. * @returns a promise which will be fullfilled when the animation ends
  95123. */
  95124. waitAsync(): Promise<Animatable>;
  95125. /** @hidden */
  95126. _animate(delay: number): boolean;
  95127. }
  95128. interface Scene {
  95129. /** @hidden */
  95130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95131. /** @hidden */
  95132. _processLateAnimationBindingsForMatrices(holder: {
  95133. totalWeight: number;
  95134. totalAdditiveWeight: number;
  95135. animations: RuntimeAnimation[];
  95136. additiveAnimations: RuntimeAnimation[];
  95137. originalValue: Matrix;
  95138. }): any;
  95139. /** @hidden */
  95140. _processLateAnimationBindingsForQuaternions(holder: {
  95141. totalWeight: number;
  95142. totalAdditiveWeight: number;
  95143. animations: RuntimeAnimation[];
  95144. additiveAnimations: RuntimeAnimation[];
  95145. originalValue: Quaternion;
  95146. }, refQuaternion: Quaternion): Quaternion;
  95147. /** @hidden */
  95148. _processLateAnimationBindings(): void;
  95149. /**
  95150. * Will start the animation sequence of a given target
  95151. * @param target defines the target
  95152. * @param from defines from which frame should animation start
  95153. * @param to defines until which frame should animation run.
  95154. * @param weight defines the weight to apply to the animation (1.0 by default)
  95155. * @param loop defines if the animation loops
  95156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95157. * @param onAnimationEnd defines the function to be executed when the animation ends
  95158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95160. * @param onAnimationLoop defines the callback to call when an animation loops
  95161. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95162. * @returns the animatable object created for this animation
  95163. */
  95164. 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;
  95165. /**
  95166. * Will start the animation sequence of a given target
  95167. * @param target defines the target
  95168. * @param from defines from which frame should animation start
  95169. * @param to defines until which frame should animation run.
  95170. * @param loop defines if the animation loops
  95171. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95172. * @param onAnimationEnd defines the function to be executed when the animation ends
  95173. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95174. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95175. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95176. * @param onAnimationLoop defines the callback to call when an animation loops
  95177. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95178. * @returns the animatable object created for this animation
  95179. */
  95180. 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;
  95181. /**
  95182. * Will start the animation sequence of a given target and its hierarchy
  95183. * @param target defines the target
  95184. * @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.
  95185. * @param from defines from which frame should animation start
  95186. * @param to defines until which frame should animation run.
  95187. * @param loop defines if the animation loops
  95188. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95189. * @param onAnimationEnd defines the function to be executed when the animation ends
  95190. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95191. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95192. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95193. * @param onAnimationLoop defines the callback to call when an animation loops
  95194. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95195. * @returns the list of created animatables
  95196. */
  95197. 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[];
  95198. /**
  95199. * Begin a new animation on a given node
  95200. * @param target defines the target where the animation will take place
  95201. * @param animations defines the list of animations to start
  95202. * @param from defines the initial value
  95203. * @param to defines the final value
  95204. * @param loop defines if you want animation to loop (off by default)
  95205. * @param speedRatio defines the speed ratio to apply to all animations
  95206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95207. * @param onAnimationLoop defines the callback to call when an animation loops
  95208. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95209. * @returns the list of created animatables
  95210. */
  95211. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95212. /**
  95213. * Begin a new animation on a given node and its hierarchy
  95214. * @param target defines the root node where the animation will take place
  95215. * @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.
  95216. * @param animations defines the list of animations to start
  95217. * @param from defines the initial value
  95218. * @param to defines the final value
  95219. * @param loop defines if you want animation to loop (off by default)
  95220. * @param speedRatio defines the speed ratio to apply to all animations
  95221. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95222. * @param onAnimationLoop defines the callback to call when an animation loops
  95223. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95224. * @returns the list of animatables created for all nodes
  95225. */
  95226. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95227. /**
  95228. * Gets the animatable associated with a specific target
  95229. * @param target defines the target of the animatable
  95230. * @returns the required animatable if found
  95231. */
  95232. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95233. /**
  95234. * Gets all animatables associated with a given target
  95235. * @param target defines the target to look animatables for
  95236. * @returns an array of Animatables
  95237. */
  95238. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95239. /**
  95240. * Stops and removes all animations that have been applied to the scene
  95241. */
  95242. stopAllAnimations(): void;
  95243. /**
  95244. * Gets the current delta time used by animation engine
  95245. */
  95246. deltaTime: number;
  95247. }
  95248. interface Bone {
  95249. /**
  95250. * Copy an animation range from another bone
  95251. * @param source defines the source bone
  95252. * @param rangeName defines the range name to copy
  95253. * @param frameOffset defines the frame offset
  95254. * @param rescaleAsRequired defines if rescaling must be applied if required
  95255. * @param skelDimensionsRatio defines the scaling ratio
  95256. * @returns true if operation was successful
  95257. */
  95258. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95259. }
  95260. }
  95261. declare module BABYLON {
  95262. /**
  95263. * Class used to handle skinning animations
  95264. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95265. */
  95266. export class Skeleton implements IAnimatable {
  95267. /** defines the skeleton name */
  95268. name: string;
  95269. /** defines the skeleton Id */
  95270. id: string;
  95271. /**
  95272. * Defines the list of child bones
  95273. */
  95274. bones: Bone[];
  95275. /**
  95276. * Defines an estimate of the dimension of the skeleton at rest
  95277. */
  95278. dimensionsAtRest: Vector3;
  95279. /**
  95280. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95281. */
  95282. needInitialSkinMatrix: boolean;
  95283. /**
  95284. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95285. */
  95286. overrideMesh: Nullable<AbstractMesh>;
  95287. /**
  95288. * Gets the list of animations attached to this skeleton
  95289. */
  95290. animations: Array<Animation>;
  95291. private _scene;
  95292. private _isDirty;
  95293. private _transformMatrices;
  95294. private _transformMatrixTexture;
  95295. private _meshesWithPoseMatrix;
  95296. private _animatables;
  95297. private _identity;
  95298. private _synchronizedWithMesh;
  95299. private _ranges;
  95300. private _lastAbsoluteTransformsUpdateId;
  95301. private _canUseTextureForBones;
  95302. private _uniqueId;
  95303. /** @hidden */
  95304. _numBonesWithLinkedTransformNode: number;
  95305. /** @hidden */
  95306. _hasWaitingData: Nullable<boolean>;
  95307. /**
  95308. * Specifies if the skeleton should be serialized
  95309. */
  95310. doNotSerialize: boolean;
  95311. private _useTextureToStoreBoneMatrices;
  95312. /**
  95313. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95314. * Please note that this option is not available if the hardware does not support it
  95315. */
  95316. get useTextureToStoreBoneMatrices(): boolean;
  95317. set useTextureToStoreBoneMatrices(value: boolean);
  95318. private _animationPropertiesOverride;
  95319. /**
  95320. * Gets or sets the animation properties override
  95321. */
  95322. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95323. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95324. /**
  95325. * List of inspectable custom properties (used by the Inspector)
  95326. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95327. */
  95328. inspectableCustomProperties: IInspectable[];
  95329. /**
  95330. * An observable triggered before computing the skeleton's matrices
  95331. */
  95332. onBeforeComputeObservable: Observable<Skeleton>;
  95333. /**
  95334. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95335. */
  95336. get isUsingTextureForMatrices(): boolean;
  95337. /**
  95338. * Gets the unique ID of this skeleton
  95339. */
  95340. get uniqueId(): number;
  95341. /**
  95342. * Creates a new skeleton
  95343. * @param name defines the skeleton name
  95344. * @param id defines the skeleton Id
  95345. * @param scene defines the hosting scene
  95346. */
  95347. constructor(
  95348. /** defines the skeleton name */
  95349. name: string,
  95350. /** defines the skeleton Id */
  95351. id: string, scene: Scene);
  95352. /**
  95353. * Gets the current object class name.
  95354. * @return the class name
  95355. */
  95356. getClassName(): string;
  95357. /**
  95358. * Returns an array containing the root bones
  95359. * @returns an array containing the root bones
  95360. */
  95361. getChildren(): Array<Bone>;
  95362. /**
  95363. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95364. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95365. * @returns a Float32Array containing matrices data
  95366. */
  95367. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95368. /**
  95369. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95370. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95371. * @returns a raw texture containing the data
  95372. */
  95373. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95374. /**
  95375. * Gets the current hosting scene
  95376. * @returns a scene object
  95377. */
  95378. getScene(): Scene;
  95379. /**
  95380. * Gets a string representing the current skeleton data
  95381. * @param fullDetails defines a boolean indicating if we want a verbose version
  95382. * @returns a string representing the current skeleton data
  95383. */
  95384. toString(fullDetails?: boolean): string;
  95385. /**
  95386. * Get bone's index searching by name
  95387. * @param name defines bone's name to search for
  95388. * @return the indice of the bone. Returns -1 if not found
  95389. */
  95390. getBoneIndexByName(name: string): number;
  95391. /**
  95392. * Creater a new animation range
  95393. * @param name defines the name of the range
  95394. * @param from defines the start key
  95395. * @param to defines the end key
  95396. */
  95397. createAnimationRange(name: string, from: number, to: number): void;
  95398. /**
  95399. * Delete a specific animation range
  95400. * @param name defines the name of the range
  95401. * @param deleteFrames defines if frames must be removed as well
  95402. */
  95403. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95404. /**
  95405. * Gets a specific animation range
  95406. * @param name defines the name of the range to look for
  95407. * @returns the requested animation range or null if not found
  95408. */
  95409. getAnimationRange(name: string): Nullable<AnimationRange>;
  95410. /**
  95411. * Gets the list of all animation ranges defined on this skeleton
  95412. * @returns an array
  95413. */
  95414. getAnimationRanges(): Nullable<AnimationRange>[];
  95415. /**
  95416. * Copy animation range from a source skeleton.
  95417. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95418. * @param source defines the source skeleton
  95419. * @param name defines the name of the range to copy
  95420. * @param rescaleAsRequired defines if rescaling must be applied if required
  95421. * @returns true if operation was successful
  95422. */
  95423. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95424. /**
  95425. * Forces the skeleton to go to rest pose
  95426. */
  95427. returnToRest(): void;
  95428. private _getHighestAnimationFrame;
  95429. /**
  95430. * Begin a specific animation range
  95431. * @param name defines the name of the range to start
  95432. * @param loop defines if looping must be turned on (false by default)
  95433. * @param speedRatio defines the speed ratio to apply (1 by default)
  95434. * @param onAnimationEnd defines a callback which will be called when animation will end
  95435. * @returns a new animatable
  95436. */
  95437. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95438. /**
  95439. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95440. * @param skeleton defines the Skeleton containing the animation range to convert
  95441. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95442. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95443. * @returns the original skeleton
  95444. */
  95445. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95446. /** @hidden */
  95447. _markAsDirty(): void;
  95448. /** @hidden */
  95449. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95450. /** @hidden */
  95451. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95452. private _computeTransformMatrices;
  95453. /**
  95454. * Build all resources required to render a skeleton
  95455. */
  95456. prepare(): void;
  95457. /**
  95458. * Gets the list of animatables currently running for this skeleton
  95459. * @returns an array of animatables
  95460. */
  95461. getAnimatables(): IAnimatable[];
  95462. /**
  95463. * Clone the current skeleton
  95464. * @param name defines the name of the new skeleton
  95465. * @param id defines the id of the new skeleton
  95466. * @returns the new skeleton
  95467. */
  95468. clone(name: string, id?: string): Skeleton;
  95469. /**
  95470. * Enable animation blending for this skeleton
  95471. * @param blendingSpeed defines the blending speed to apply
  95472. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95473. */
  95474. enableBlending(blendingSpeed?: number): void;
  95475. /**
  95476. * Releases all resources associated with the current skeleton
  95477. */
  95478. dispose(): void;
  95479. /**
  95480. * Serialize the skeleton in a JSON object
  95481. * @returns a JSON object
  95482. */
  95483. serialize(): any;
  95484. /**
  95485. * Creates a new skeleton from serialized data
  95486. * @param parsedSkeleton defines the serialized data
  95487. * @param scene defines the hosting scene
  95488. * @returns a new skeleton
  95489. */
  95490. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95491. /**
  95492. * Compute all node absolute transforms
  95493. * @param forceUpdate defines if computation must be done even if cache is up to date
  95494. */
  95495. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95496. /**
  95497. * Gets the root pose matrix
  95498. * @returns a matrix
  95499. */
  95500. getPoseMatrix(): Nullable<Matrix>;
  95501. /**
  95502. * Sorts bones per internal index
  95503. */
  95504. sortBones(): void;
  95505. private _sortBones;
  95506. }
  95507. }
  95508. declare module BABYLON {
  95509. /**
  95510. * Creates an instance based on a source mesh.
  95511. */
  95512. export class InstancedMesh extends AbstractMesh {
  95513. private _sourceMesh;
  95514. private _currentLOD;
  95515. /** @hidden */
  95516. _indexInSourceMeshInstanceArray: number;
  95517. constructor(name: string, source: Mesh);
  95518. /**
  95519. * Returns the string "InstancedMesh".
  95520. */
  95521. getClassName(): string;
  95522. /** Gets the list of lights affecting that mesh */
  95523. get lightSources(): Light[];
  95524. _resyncLightSources(): void;
  95525. _resyncLightSource(light: Light): void;
  95526. _removeLightSource(light: Light, dispose: boolean): void;
  95527. /**
  95528. * If the source mesh receives shadows
  95529. */
  95530. get receiveShadows(): boolean;
  95531. /**
  95532. * The material of the source mesh
  95533. */
  95534. get material(): Nullable<Material>;
  95535. /**
  95536. * Visibility of the source mesh
  95537. */
  95538. get visibility(): number;
  95539. /**
  95540. * Skeleton of the source mesh
  95541. */
  95542. get skeleton(): Nullable<Skeleton>;
  95543. /**
  95544. * Rendering ground id of the source mesh
  95545. */
  95546. get renderingGroupId(): number;
  95547. set renderingGroupId(value: number);
  95548. /**
  95549. * Returns the total number of vertices (integer).
  95550. */
  95551. getTotalVertices(): number;
  95552. /**
  95553. * Returns a positive integer : the total number of indices in this mesh geometry.
  95554. * @returns the numner of indices or zero if the mesh has no geometry.
  95555. */
  95556. getTotalIndices(): number;
  95557. /**
  95558. * The source mesh of the instance
  95559. */
  95560. get sourceMesh(): Mesh;
  95561. /**
  95562. * Creates a new InstancedMesh object from the mesh model.
  95563. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95564. * @param name defines the name of the new instance
  95565. * @returns a new InstancedMesh
  95566. */
  95567. createInstance(name: string): InstancedMesh;
  95568. /**
  95569. * Is this node ready to be used/rendered
  95570. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95571. * @return {boolean} is it ready
  95572. */
  95573. isReady(completeCheck?: boolean): boolean;
  95574. /**
  95575. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95576. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95577. * @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.
  95578. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95579. */
  95580. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95581. /**
  95582. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95583. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95584. * The `data` are either a numeric array either a Float32Array.
  95585. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95586. * 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).
  95587. * Note that a new underlying VertexBuffer object is created each call.
  95588. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95589. *
  95590. * Possible `kind` values :
  95591. * - VertexBuffer.PositionKind
  95592. * - VertexBuffer.UVKind
  95593. * - VertexBuffer.UV2Kind
  95594. * - VertexBuffer.UV3Kind
  95595. * - VertexBuffer.UV4Kind
  95596. * - VertexBuffer.UV5Kind
  95597. * - VertexBuffer.UV6Kind
  95598. * - VertexBuffer.ColorKind
  95599. * - VertexBuffer.MatricesIndicesKind
  95600. * - VertexBuffer.MatricesIndicesExtraKind
  95601. * - VertexBuffer.MatricesWeightsKind
  95602. * - VertexBuffer.MatricesWeightsExtraKind
  95603. *
  95604. * Returns the Mesh.
  95605. */
  95606. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95607. /**
  95608. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95609. * If the mesh has no geometry, it is simply returned as it is.
  95610. * The `data` are either a numeric array either a Float32Array.
  95611. * No new underlying VertexBuffer object is created.
  95612. * 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.
  95613. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95614. *
  95615. * Possible `kind` values :
  95616. * - VertexBuffer.PositionKind
  95617. * - VertexBuffer.UVKind
  95618. * - VertexBuffer.UV2Kind
  95619. * - VertexBuffer.UV3Kind
  95620. * - VertexBuffer.UV4Kind
  95621. * - VertexBuffer.UV5Kind
  95622. * - VertexBuffer.UV6Kind
  95623. * - VertexBuffer.ColorKind
  95624. * - VertexBuffer.MatricesIndicesKind
  95625. * - VertexBuffer.MatricesIndicesExtraKind
  95626. * - VertexBuffer.MatricesWeightsKind
  95627. * - VertexBuffer.MatricesWeightsExtraKind
  95628. *
  95629. * Returns the Mesh.
  95630. */
  95631. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95632. /**
  95633. * Sets the mesh indices.
  95634. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95635. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95636. * This method creates a new index buffer each call.
  95637. * Returns the Mesh.
  95638. */
  95639. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95640. /**
  95641. * Boolean : True if the mesh owns the requested kind of data.
  95642. */
  95643. isVerticesDataPresent(kind: string): boolean;
  95644. /**
  95645. * Returns an array of indices (IndicesArray).
  95646. */
  95647. getIndices(): Nullable<IndicesArray>;
  95648. get _positions(): Nullable<Vector3[]>;
  95649. /**
  95650. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95651. * This means the mesh underlying bounding box and sphere are recomputed.
  95652. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95653. * @returns the current mesh
  95654. */
  95655. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95656. /** @hidden */
  95657. _preActivate(): InstancedMesh;
  95658. /** @hidden */
  95659. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95660. /** @hidden */
  95661. _postActivate(): void;
  95662. getWorldMatrix(): Matrix;
  95663. get isAnInstance(): boolean;
  95664. /**
  95665. * Returns the current associated LOD AbstractMesh.
  95666. */
  95667. getLOD(camera: Camera): AbstractMesh;
  95668. /** @hidden */
  95669. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95670. /** @hidden */
  95671. _syncSubMeshes(): InstancedMesh;
  95672. /** @hidden */
  95673. _generatePointsArray(): boolean;
  95674. /** @hidden */
  95675. _updateBoundingInfo(): AbstractMesh;
  95676. /**
  95677. * Creates a new InstancedMesh from the current mesh.
  95678. * - name (string) : the cloned mesh name
  95679. * - newParent (optional Node) : the optional Node to parent the clone to.
  95680. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95681. *
  95682. * Returns the clone.
  95683. */
  95684. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95685. /**
  95686. * Disposes the InstancedMesh.
  95687. * Returns nothing.
  95688. */
  95689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95690. }
  95691. interface Mesh {
  95692. /**
  95693. * Register a custom buffer that will be instanced
  95694. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95695. * @param kind defines the buffer kind
  95696. * @param stride defines the stride in floats
  95697. */
  95698. registerInstancedBuffer(kind: string, stride: number): void;
  95699. /**
  95700. * true to use the edge renderer for all instances of this mesh
  95701. */
  95702. edgesShareWithInstances: boolean;
  95703. /** @hidden */
  95704. _userInstancedBuffersStorage: {
  95705. data: {
  95706. [key: string]: Float32Array;
  95707. };
  95708. sizes: {
  95709. [key: string]: number;
  95710. };
  95711. vertexBuffers: {
  95712. [key: string]: Nullable<VertexBuffer>;
  95713. };
  95714. strides: {
  95715. [key: string]: number;
  95716. };
  95717. };
  95718. }
  95719. interface AbstractMesh {
  95720. /**
  95721. * Object used to store instanced buffers defined by user
  95722. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95723. */
  95724. instancedBuffers: {
  95725. [key: string]: any;
  95726. };
  95727. }
  95728. }
  95729. declare module BABYLON {
  95730. /**
  95731. * Defines the options associated with the creation of a shader material.
  95732. */
  95733. export interface IShaderMaterialOptions {
  95734. /**
  95735. * Does the material work in alpha blend mode
  95736. */
  95737. needAlphaBlending: boolean;
  95738. /**
  95739. * Does the material work in alpha test mode
  95740. */
  95741. needAlphaTesting: boolean;
  95742. /**
  95743. * The list of attribute names used in the shader
  95744. */
  95745. attributes: string[];
  95746. /**
  95747. * The list of unifrom names used in the shader
  95748. */
  95749. uniforms: string[];
  95750. /**
  95751. * The list of UBO names used in the shader
  95752. */
  95753. uniformBuffers: string[];
  95754. /**
  95755. * The list of sampler names used in the shader
  95756. */
  95757. samplers: string[];
  95758. /**
  95759. * The list of defines used in the shader
  95760. */
  95761. defines: string[];
  95762. }
  95763. /**
  95764. * 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.
  95765. *
  95766. * This returned material effects how the mesh will look based on the code in the shaders.
  95767. *
  95768. * @see https://doc.babylonjs.com/how_to/shader_material
  95769. */
  95770. export class ShaderMaterial extends Material {
  95771. private _shaderPath;
  95772. private _options;
  95773. private _textures;
  95774. private _textureArrays;
  95775. private _floats;
  95776. private _ints;
  95777. private _floatsArrays;
  95778. private _colors3;
  95779. private _colors3Arrays;
  95780. private _colors4;
  95781. private _colors4Arrays;
  95782. private _vectors2;
  95783. private _vectors3;
  95784. private _vectors4;
  95785. private _matrices;
  95786. private _matrixArrays;
  95787. private _matrices3x3;
  95788. private _matrices2x2;
  95789. private _vectors2Arrays;
  95790. private _vectors3Arrays;
  95791. private _vectors4Arrays;
  95792. private _cachedWorldViewMatrix;
  95793. private _cachedWorldViewProjectionMatrix;
  95794. private _renderId;
  95795. private _multiview;
  95796. private _cachedDefines;
  95797. /** Define the Url to load snippets */
  95798. static SnippetUrl: string;
  95799. /** Snippet ID if the material was created from the snippet server */
  95800. snippetId: string;
  95801. /**
  95802. * Instantiate a new shader material.
  95803. * 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.
  95804. * This returned material effects how the mesh will look based on the code in the shaders.
  95805. * @see https://doc.babylonjs.com/how_to/shader_material
  95806. * @param name Define the name of the material in the scene
  95807. * @param scene Define the scene the material belongs to
  95808. * @param shaderPath Defines the route to the shader code in one of three ways:
  95809. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95810. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95811. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95812. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95813. * @param options Define the options used to create the shader
  95814. */
  95815. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95816. /**
  95817. * Gets the shader path used to define the shader code
  95818. * It can be modified to trigger a new compilation
  95819. */
  95820. get shaderPath(): any;
  95821. /**
  95822. * Sets the shader path used to define the shader code
  95823. * It can be modified to trigger a new compilation
  95824. */
  95825. set shaderPath(shaderPath: any);
  95826. /**
  95827. * Gets the options used to compile the shader.
  95828. * They can be modified to trigger a new compilation
  95829. */
  95830. get options(): IShaderMaterialOptions;
  95831. /**
  95832. * Gets the current class name of the material e.g. "ShaderMaterial"
  95833. * Mainly use in serialization.
  95834. * @returns the class name
  95835. */
  95836. getClassName(): string;
  95837. /**
  95838. * Specifies if the material will require alpha blending
  95839. * @returns a boolean specifying if alpha blending is needed
  95840. */
  95841. needAlphaBlending(): boolean;
  95842. /**
  95843. * Specifies if this material should be rendered in alpha test mode
  95844. * @returns a boolean specifying if an alpha test is needed.
  95845. */
  95846. needAlphaTesting(): boolean;
  95847. private _checkUniform;
  95848. /**
  95849. * Set a texture in the shader.
  95850. * @param name Define the name of the uniform samplers as defined in the shader
  95851. * @param texture Define the texture to bind to this sampler
  95852. * @return the material itself allowing "fluent" like uniform updates
  95853. */
  95854. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95855. /**
  95856. * Set a texture array in the shader.
  95857. * @param name Define the name of the uniform sampler array as defined in the shader
  95858. * @param textures Define the list of textures to bind to this sampler
  95859. * @return the material itself allowing "fluent" like uniform updates
  95860. */
  95861. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95862. /**
  95863. * Set a float in the shader.
  95864. * @param name Define the name of the uniform as defined in the shader
  95865. * @param value Define the value to give to the uniform
  95866. * @return the material itself allowing "fluent" like uniform updates
  95867. */
  95868. setFloat(name: string, value: number): ShaderMaterial;
  95869. /**
  95870. * Set a int in the shader.
  95871. * @param name Define the name of the uniform as defined in the shader
  95872. * @param value Define the value to give to the uniform
  95873. * @return the material itself allowing "fluent" like uniform updates
  95874. */
  95875. setInt(name: string, value: number): ShaderMaterial;
  95876. /**
  95877. * Set an array of floats in the shader.
  95878. * @param name Define the name of the uniform as defined in the shader
  95879. * @param value Define the value to give to the uniform
  95880. * @return the material itself allowing "fluent" like uniform updates
  95881. */
  95882. setFloats(name: string, value: number[]): ShaderMaterial;
  95883. /**
  95884. * Set a vec3 in the shader from a Color3.
  95885. * @param name Define the name of the uniform as defined in the shader
  95886. * @param value Define the value to give to the uniform
  95887. * @return the material itself allowing "fluent" like uniform updates
  95888. */
  95889. setColor3(name: string, value: Color3): ShaderMaterial;
  95890. /**
  95891. * Set a vec3 array in the shader from a Color3 array.
  95892. * @param name Define the name of the uniform as defined in the shader
  95893. * @param value Define the value to give to the uniform
  95894. * @return the material itself allowing "fluent" like uniform updates
  95895. */
  95896. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95897. /**
  95898. * Set a vec4 in the shader from a Color4.
  95899. * @param name Define the name of the uniform as defined in the shader
  95900. * @param value Define the value to give to the uniform
  95901. * @return the material itself allowing "fluent" like uniform updates
  95902. */
  95903. setColor4(name: string, value: Color4): ShaderMaterial;
  95904. /**
  95905. * Set a vec4 array in the shader from a Color4 array.
  95906. * @param name Define the name of the uniform as defined in the shader
  95907. * @param value Define the value to give to the uniform
  95908. * @return the material itself allowing "fluent" like uniform updates
  95909. */
  95910. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95911. /**
  95912. * Set a vec2 in the shader from a Vector2.
  95913. * @param name Define the name of the uniform as defined in the shader
  95914. * @param value Define the value to give to the uniform
  95915. * @return the material itself allowing "fluent" like uniform updates
  95916. */
  95917. setVector2(name: string, value: Vector2): ShaderMaterial;
  95918. /**
  95919. * Set a vec3 in the shader from a Vector3.
  95920. * @param name Define the name of the uniform as defined in the shader
  95921. * @param value Define the value to give to the uniform
  95922. * @return the material itself allowing "fluent" like uniform updates
  95923. */
  95924. setVector3(name: string, value: Vector3): ShaderMaterial;
  95925. /**
  95926. * Set a vec4 in the shader from a Vector4.
  95927. * @param name Define the name of the uniform as defined in the shader
  95928. * @param value Define the value to give to the uniform
  95929. * @return the material itself allowing "fluent" like uniform updates
  95930. */
  95931. setVector4(name: string, value: Vector4): ShaderMaterial;
  95932. /**
  95933. * Set a mat4 in the shader from a Matrix.
  95934. * @param name Define the name of the uniform as defined in the shader
  95935. * @param value Define the value to give to the uniform
  95936. * @return the material itself allowing "fluent" like uniform updates
  95937. */
  95938. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95939. /**
  95940. * Set a float32Array in the shader from a matrix array.
  95941. * @param name Define the name of the uniform as defined in the shader
  95942. * @param value Define the value to give to the uniform
  95943. * @return the material itself allowing "fluent" like uniform updates
  95944. */
  95945. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95946. /**
  95947. * Set a mat3 in the shader from a Float32Array.
  95948. * @param name Define the name of the uniform as defined in the shader
  95949. * @param value Define the value to give to the uniform
  95950. * @return the material itself allowing "fluent" like uniform updates
  95951. */
  95952. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95953. /**
  95954. * Set a mat2 in the shader from a Float32Array.
  95955. * @param name Define the name of the uniform as defined in the shader
  95956. * @param value Define the value to give to the uniform
  95957. * @return the material itself allowing "fluent" like uniform updates
  95958. */
  95959. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95960. /**
  95961. * Set a vec2 array in the shader from a number array.
  95962. * @param name Define the name of the uniform as defined in the shader
  95963. * @param value Define the value to give to the uniform
  95964. * @return the material itself allowing "fluent" like uniform updates
  95965. */
  95966. setArray2(name: string, value: number[]): ShaderMaterial;
  95967. /**
  95968. * Set a vec3 array in the shader from a number array.
  95969. * @param name Define the name of the uniform as defined in the shader
  95970. * @param value Define the value to give to the uniform
  95971. * @return the material itself allowing "fluent" like uniform updates
  95972. */
  95973. setArray3(name: string, value: number[]): ShaderMaterial;
  95974. /**
  95975. * Set a vec4 array in the shader from a number array.
  95976. * @param name Define the name of the uniform as defined in the shader
  95977. * @param value Define the value to give to the uniform
  95978. * @return the material itself allowing "fluent" like uniform updates
  95979. */
  95980. setArray4(name: string, value: number[]): ShaderMaterial;
  95981. private _checkCache;
  95982. /**
  95983. * Specifies that the submesh is ready to be used
  95984. * @param mesh defines the mesh to check
  95985. * @param subMesh defines which submesh to check
  95986. * @param useInstances specifies that instances should be used
  95987. * @returns a boolean indicating that the submesh is ready or not
  95988. */
  95989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95990. /**
  95991. * Checks if the material is ready to render the requested mesh
  95992. * @param mesh Define the mesh to render
  95993. * @param useInstances Define whether or not the material is used with instances
  95994. * @returns true if ready, otherwise false
  95995. */
  95996. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95997. /**
  95998. * Binds the world matrix to the material
  95999. * @param world defines the world transformation matrix
  96000. * @param effectOverride - If provided, use this effect instead of internal effect
  96001. */
  96002. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96003. /**
  96004. * Binds the submesh to this material by preparing the effect and shader to draw
  96005. * @param world defines the world transformation matrix
  96006. * @param mesh defines the mesh containing the submesh
  96007. * @param subMesh defines the submesh to bind the material to
  96008. */
  96009. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96010. /**
  96011. * Binds the material to the mesh
  96012. * @param world defines the world transformation matrix
  96013. * @param mesh defines the mesh to bind the material to
  96014. * @param effectOverride - If provided, use this effect instead of internal effect
  96015. */
  96016. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96017. protected _afterBind(mesh?: Mesh): void;
  96018. /**
  96019. * Gets the active textures from the material
  96020. * @returns an array of textures
  96021. */
  96022. getActiveTextures(): BaseTexture[];
  96023. /**
  96024. * Specifies if the material uses a texture
  96025. * @param texture defines the texture to check against the material
  96026. * @returns a boolean specifying if the material uses the texture
  96027. */
  96028. hasTexture(texture: BaseTexture): boolean;
  96029. /**
  96030. * Makes a duplicate of the material, and gives it a new name
  96031. * @param name defines the new name for the duplicated material
  96032. * @returns the cloned material
  96033. */
  96034. clone(name: string): ShaderMaterial;
  96035. /**
  96036. * Disposes the material
  96037. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96038. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96039. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96040. */
  96041. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96042. /**
  96043. * Serializes this material in a JSON representation
  96044. * @returns the serialized material object
  96045. */
  96046. serialize(): any;
  96047. /**
  96048. * Creates a shader material from parsed shader material data
  96049. * @param source defines the JSON represnetation of the material
  96050. * @param scene defines the hosting scene
  96051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96052. * @returns a new material
  96053. */
  96054. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96055. /**
  96056. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96057. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96058. * @param url defines the url to load from
  96059. * @param scene defines the hosting scene
  96060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96061. * @returns a promise that will resolve to the new ShaderMaterial
  96062. */
  96063. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96064. /**
  96065. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96066. * @param snippetId defines the snippet to load
  96067. * @param scene defines the hosting scene
  96068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96069. * @returns a promise that will resolve to the new ShaderMaterial
  96070. */
  96071. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96072. }
  96073. }
  96074. declare module BABYLON {
  96075. /** @hidden */
  96076. export var colorPixelShader: {
  96077. name: string;
  96078. shader: string;
  96079. };
  96080. }
  96081. declare module BABYLON {
  96082. /** @hidden */
  96083. export var colorVertexShader: {
  96084. name: string;
  96085. shader: string;
  96086. };
  96087. }
  96088. declare module BABYLON {
  96089. /**
  96090. * Line mesh
  96091. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96092. */
  96093. export class LinesMesh extends Mesh {
  96094. /**
  96095. * If vertex color should be applied to the mesh
  96096. */
  96097. readonly useVertexColor?: boolean | undefined;
  96098. /**
  96099. * If vertex alpha should be applied to the mesh
  96100. */
  96101. readonly useVertexAlpha?: boolean | undefined;
  96102. /**
  96103. * Color of the line (Default: White)
  96104. */
  96105. color: Color3;
  96106. /**
  96107. * Alpha of the line (Default: 1)
  96108. */
  96109. alpha: number;
  96110. /**
  96111. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96112. * This margin is expressed in world space coordinates, so its value may vary.
  96113. * Default value is 0.1
  96114. */
  96115. intersectionThreshold: number;
  96116. private _colorShader;
  96117. private color4;
  96118. /**
  96119. * Creates a new LinesMesh
  96120. * @param name defines the name
  96121. * @param scene defines the hosting scene
  96122. * @param parent defines the parent mesh if any
  96123. * @param source defines the optional source LinesMesh used to clone data from
  96124. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96125. * When false, achieved by calling a clone(), also passing False.
  96126. * This will make creation of children, recursive.
  96127. * @param useVertexColor defines if this LinesMesh supports vertex color
  96128. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96129. */
  96130. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96131. /**
  96132. * If vertex color should be applied to the mesh
  96133. */
  96134. useVertexColor?: boolean | undefined,
  96135. /**
  96136. * If vertex alpha should be applied to the mesh
  96137. */
  96138. useVertexAlpha?: boolean | undefined);
  96139. private _addClipPlaneDefine;
  96140. private _removeClipPlaneDefine;
  96141. isReady(): boolean;
  96142. /**
  96143. * Returns the string "LineMesh"
  96144. */
  96145. getClassName(): string;
  96146. /**
  96147. * @hidden
  96148. */
  96149. get material(): Material;
  96150. /**
  96151. * @hidden
  96152. */
  96153. set material(value: Material);
  96154. /**
  96155. * @hidden
  96156. */
  96157. get checkCollisions(): boolean;
  96158. /** @hidden */
  96159. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96160. /** @hidden */
  96161. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96162. /**
  96163. * Disposes of the line mesh
  96164. * @param doNotRecurse If children should be disposed
  96165. */
  96166. dispose(doNotRecurse?: boolean): void;
  96167. /**
  96168. * Returns a new LineMesh object cloned from the current one.
  96169. */
  96170. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96171. /**
  96172. * Creates a new InstancedLinesMesh object from the mesh model.
  96173. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96174. * @param name defines the name of the new instance
  96175. * @returns a new InstancedLinesMesh
  96176. */
  96177. createInstance(name: string): InstancedLinesMesh;
  96178. }
  96179. /**
  96180. * Creates an instance based on a source LinesMesh
  96181. */
  96182. export class InstancedLinesMesh extends InstancedMesh {
  96183. /**
  96184. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96185. * This margin is expressed in world space coordinates, so its value may vary.
  96186. * Initilized with the intersectionThreshold value of the source LinesMesh
  96187. */
  96188. intersectionThreshold: number;
  96189. constructor(name: string, source: LinesMesh);
  96190. /**
  96191. * Returns the string "InstancedLinesMesh".
  96192. */
  96193. getClassName(): string;
  96194. }
  96195. }
  96196. declare module BABYLON {
  96197. /** @hidden */
  96198. export var linePixelShader: {
  96199. name: string;
  96200. shader: string;
  96201. };
  96202. }
  96203. declare module BABYLON {
  96204. /** @hidden */
  96205. export var lineVertexShader: {
  96206. name: string;
  96207. shader: string;
  96208. };
  96209. }
  96210. declare module BABYLON {
  96211. interface Scene {
  96212. /** @hidden */
  96213. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96214. }
  96215. interface AbstractMesh {
  96216. /**
  96217. * Gets the edgesRenderer associated with the mesh
  96218. */
  96219. edgesRenderer: Nullable<EdgesRenderer>;
  96220. }
  96221. interface LinesMesh {
  96222. /**
  96223. * Enables the edge rendering mode on the mesh.
  96224. * This mode makes the mesh edges visible
  96225. * @param epsilon defines the maximal distance between two angles to detect a face
  96226. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96227. * @returns the currentAbstractMesh
  96228. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96229. */
  96230. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96231. }
  96232. interface InstancedLinesMesh {
  96233. /**
  96234. * Enables the edge rendering mode on the mesh.
  96235. * This mode makes the mesh edges visible
  96236. * @param epsilon defines the maximal distance between two angles to detect a face
  96237. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96238. * @returns the current InstancedLinesMesh
  96239. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96240. */
  96241. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96242. }
  96243. /**
  96244. * Defines the minimum contract an Edges renderer should follow.
  96245. */
  96246. export interface IEdgesRenderer extends IDisposable {
  96247. /**
  96248. * Gets or sets a boolean indicating if the edgesRenderer is active
  96249. */
  96250. isEnabled: boolean;
  96251. /**
  96252. * Renders the edges of the attached mesh,
  96253. */
  96254. render(): void;
  96255. /**
  96256. * Checks wether or not the edges renderer is ready to render.
  96257. * @return true if ready, otherwise false.
  96258. */
  96259. isReady(): boolean;
  96260. /**
  96261. * List of instances to render in case the source mesh has instances
  96262. */
  96263. customInstances: SmartArray<Matrix>;
  96264. }
  96265. /**
  96266. * Defines the additional options of the edges renderer
  96267. */
  96268. export interface IEdgesRendererOptions {
  96269. /**
  96270. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96271. * If not defined, the default value is true
  96272. */
  96273. useAlternateEdgeFinder?: boolean;
  96274. /**
  96275. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96276. * If not defined, the default value is true.
  96277. * 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)
  96278. * This option is used only if useAlternateEdgeFinder = true
  96279. */
  96280. useFastVertexMerger?: boolean;
  96281. /**
  96282. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96283. * The default value is 1e-6
  96284. * This option is used only if useAlternateEdgeFinder = true
  96285. */
  96286. epsilonVertexMerge?: number;
  96287. /**
  96288. * 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
  96289. * 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.
  96290. * This option is used only if useAlternateEdgeFinder = true
  96291. */
  96292. applyTessellation?: boolean;
  96293. /**
  96294. * 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
  96295. * The default value is 1e-6
  96296. * This option is used only if useAlternateEdgeFinder = true
  96297. */
  96298. epsilonVertexAligned?: number;
  96299. }
  96300. /**
  96301. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96302. */
  96303. export class EdgesRenderer implements IEdgesRenderer {
  96304. /**
  96305. * Define the size of the edges with an orthographic camera
  96306. */
  96307. edgesWidthScalerForOrthographic: number;
  96308. /**
  96309. * Define the size of the edges with a perspective camera
  96310. */
  96311. edgesWidthScalerForPerspective: number;
  96312. protected _source: AbstractMesh;
  96313. protected _linesPositions: number[];
  96314. protected _linesNormals: number[];
  96315. protected _linesIndices: number[];
  96316. protected _epsilon: number;
  96317. protected _indicesCount: number;
  96318. protected _lineShader: ShaderMaterial;
  96319. protected _ib: DataBuffer;
  96320. protected _buffers: {
  96321. [key: string]: Nullable<VertexBuffer>;
  96322. };
  96323. protected _buffersForInstances: {
  96324. [key: string]: Nullable<VertexBuffer>;
  96325. };
  96326. protected _checkVerticesInsteadOfIndices: boolean;
  96327. protected _options: Nullable<IEdgesRendererOptions>;
  96328. private _meshRebuildObserver;
  96329. private _meshDisposeObserver;
  96330. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96331. isEnabled: boolean;
  96332. /**
  96333. * List of instances to render in case the source mesh has instances
  96334. */
  96335. customInstances: SmartArray<Matrix>;
  96336. private static GetShader;
  96337. /**
  96338. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96339. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96340. * @param source Mesh used to create edges
  96341. * @param epsilon sum of angles in adjacency to check for edge
  96342. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96343. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96344. * @param options The options to apply when generating the edges
  96345. */
  96346. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96347. protected _prepareRessources(): void;
  96348. /** @hidden */
  96349. _rebuild(): void;
  96350. /**
  96351. * Releases the required resources for the edges renderer
  96352. */
  96353. dispose(): void;
  96354. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96355. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96356. /**
  96357. * Checks if the pair of p0 and p1 is en edge
  96358. * @param faceIndex
  96359. * @param edge
  96360. * @param faceNormals
  96361. * @param p0
  96362. * @param p1
  96363. * @private
  96364. */
  96365. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96366. /**
  96367. * push line into the position, normal and index buffer
  96368. * @protected
  96369. */
  96370. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96371. /**
  96372. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96373. */
  96374. private _tessellateTriangle;
  96375. private _generateEdgesLinesAlternate;
  96376. /**
  96377. * Generates lines edges from adjacencjes
  96378. * @private
  96379. */
  96380. _generateEdgesLines(): void;
  96381. /**
  96382. * Checks wether or not the edges renderer is ready to render.
  96383. * @return true if ready, otherwise false.
  96384. */
  96385. isReady(): boolean;
  96386. /**
  96387. * Renders the edges of the attached mesh,
  96388. */
  96389. render(): void;
  96390. }
  96391. /**
  96392. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96393. */
  96394. export class LineEdgesRenderer extends EdgesRenderer {
  96395. /**
  96396. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96397. * @param source LineMesh used to generate edges
  96398. * @param epsilon not important (specified angle for edge detection)
  96399. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96400. */
  96401. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96402. /**
  96403. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96404. */
  96405. _generateEdgesLines(): void;
  96406. }
  96407. }
  96408. declare module BABYLON {
  96409. /**
  96410. * This represents the object necessary to create a rendering group.
  96411. * This is exclusively used and created by the rendering manager.
  96412. * To modify the behavior, you use the available helpers in your scene or meshes.
  96413. * @hidden
  96414. */
  96415. export class RenderingGroup {
  96416. index: number;
  96417. private static _zeroVector;
  96418. private _scene;
  96419. private _opaqueSubMeshes;
  96420. private _transparentSubMeshes;
  96421. private _alphaTestSubMeshes;
  96422. private _depthOnlySubMeshes;
  96423. private _particleSystems;
  96424. private _spriteManagers;
  96425. private _opaqueSortCompareFn;
  96426. private _alphaTestSortCompareFn;
  96427. private _transparentSortCompareFn;
  96428. private _renderOpaque;
  96429. private _renderAlphaTest;
  96430. private _renderTransparent;
  96431. /** @hidden */
  96432. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96433. onBeforeTransparentRendering: () => void;
  96434. /**
  96435. * Set the opaque sort comparison function.
  96436. * If null the sub meshes will be render in the order they were created
  96437. */
  96438. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96439. /**
  96440. * Set the alpha test sort comparison function.
  96441. * If null the sub meshes will be render in the order they were created
  96442. */
  96443. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96444. /**
  96445. * Set the transparent sort comparison function.
  96446. * If null the sub meshes will be render in the order they were created
  96447. */
  96448. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96449. /**
  96450. * Creates a new rendering group.
  96451. * @param index The rendering group index
  96452. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96453. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96454. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96455. */
  96456. 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>);
  96457. /**
  96458. * Render all the sub meshes contained in the group.
  96459. * @param customRenderFunction Used to override the default render behaviour of the group.
  96460. * @returns true if rendered some submeshes.
  96461. */
  96462. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96463. /**
  96464. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96465. * @param subMeshes The submeshes to render
  96466. */
  96467. private renderOpaqueSorted;
  96468. /**
  96469. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96470. * @param subMeshes The submeshes to render
  96471. */
  96472. private renderAlphaTestSorted;
  96473. /**
  96474. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96475. * @param subMeshes The submeshes to render
  96476. */
  96477. private renderTransparentSorted;
  96478. /**
  96479. * Renders the submeshes in a specified order.
  96480. * @param subMeshes The submeshes to sort before render
  96481. * @param sortCompareFn The comparison function use to sort
  96482. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96483. * @param transparent Specifies to activate blending if true
  96484. */
  96485. private static renderSorted;
  96486. /**
  96487. * Renders the submeshes in the order they were dispatched (no sort applied).
  96488. * @param subMeshes The submeshes to render
  96489. */
  96490. private static renderUnsorted;
  96491. /**
  96492. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96493. * are rendered back to front if in the same alpha index.
  96494. *
  96495. * @param a The first submesh
  96496. * @param b The second submesh
  96497. * @returns The result of the comparison
  96498. */
  96499. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96500. /**
  96501. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96502. * are rendered back to front.
  96503. *
  96504. * @param a The first submesh
  96505. * @param b The second submesh
  96506. * @returns The result of the comparison
  96507. */
  96508. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  96509. /**
  96510. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96511. * are rendered front to back (prevent overdraw).
  96512. *
  96513. * @param a The first submesh
  96514. * @param b The second submesh
  96515. * @returns The result of the comparison
  96516. */
  96517. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  96518. /**
  96519. * Resets the different lists of submeshes to prepare a new frame.
  96520. */
  96521. prepare(): void;
  96522. dispose(): void;
  96523. /**
  96524. * Inserts the submesh in its correct queue depending on its material.
  96525. * @param subMesh The submesh to dispatch
  96526. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96527. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96528. */
  96529. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96530. dispatchSprites(spriteManager: ISpriteManager): void;
  96531. dispatchParticles(particleSystem: IParticleSystem): void;
  96532. private _renderParticles;
  96533. private _renderSprites;
  96534. }
  96535. }
  96536. declare module BABYLON {
  96537. /**
  96538. * Interface describing the different options available in the rendering manager
  96539. * regarding Auto Clear between groups.
  96540. */
  96541. export interface IRenderingManagerAutoClearSetup {
  96542. /**
  96543. * Defines whether or not autoclear is enable.
  96544. */
  96545. autoClear: boolean;
  96546. /**
  96547. * Defines whether or not to autoclear the depth buffer.
  96548. */
  96549. depth: boolean;
  96550. /**
  96551. * Defines whether or not to autoclear the stencil buffer.
  96552. */
  96553. stencil: boolean;
  96554. }
  96555. /**
  96556. * This class is used by the onRenderingGroupObservable
  96557. */
  96558. export class RenderingGroupInfo {
  96559. /**
  96560. * The Scene that being rendered
  96561. */
  96562. scene: Scene;
  96563. /**
  96564. * The camera currently used for the rendering pass
  96565. */
  96566. camera: Nullable<Camera>;
  96567. /**
  96568. * The ID of the renderingGroup being processed
  96569. */
  96570. renderingGroupId: number;
  96571. }
  96572. /**
  96573. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96574. * It is enable to manage the different groups as well as the different necessary sort functions.
  96575. * This should not be used directly aside of the few static configurations
  96576. */
  96577. export class RenderingManager {
  96578. /**
  96579. * The max id used for rendering groups (not included)
  96580. */
  96581. static MAX_RENDERINGGROUPS: number;
  96582. /**
  96583. * The min id used for rendering groups (included)
  96584. */
  96585. static MIN_RENDERINGGROUPS: number;
  96586. /**
  96587. * Used to globally prevent autoclearing scenes.
  96588. */
  96589. static AUTOCLEAR: boolean;
  96590. /**
  96591. * @hidden
  96592. */
  96593. _useSceneAutoClearSetup: boolean;
  96594. private _scene;
  96595. private _renderingGroups;
  96596. private _depthStencilBufferAlreadyCleaned;
  96597. private _autoClearDepthStencil;
  96598. private _customOpaqueSortCompareFn;
  96599. private _customAlphaTestSortCompareFn;
  96600. private _customTransparentSortCompareFn;
  96601. private _renderingGroupInfo;
  96602. /**
  96603. * Instantiates a new rendering group for a particular scene
  96604. * @param scene Defines the scene the groups belongs to
  96605. */
  96606. constructor(scene: Scene);
  96607. private _clearDepthStencilBuffer;
  96608. /**
  96609. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96610. * @hidden
  96611. */
  96612. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96613. /**
  96614. * Resets the different information of the group to prepare a new frame
  96615. * @hidden
  96616. */
  96617. reset(): void;
  96618. /**
  96619. * Dispose and release the group and its associated resources.
  96620. * @hidden
  96621. */
  96622. dispose(): void;
  96623. /**
  96624. * Clear the info related to rendering groups preventing retention points during dispose.
  96625. */
  96626. freeRenderingGroups(): void;
  96627. private _prepareRenderingGroup;
  96628. /**
  96629. * Add a sprite manager to the rendering manager in order to render it this frame.
  96630. * @param spriteManager Define the sprite manager to render
  96631. */
  96632. dispatchSprites(spriteManager: ISpriteManager): void;
  96633. /**
  96634. * Add a particle system to the rendering manager in order to render it this frame.
  96635. * @param particleSystem Define the particle system to render
  96636. */
  96637. dispatchParticles(particleSystem: IParticleSystem): void;
  96638. /**
  96639. * Add a submesh to the manager in order to render it this frame
  96640. * @param subMesh The submesh to dispatch
  96641. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96642. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96643. */
  96644. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96645. /**
  96646. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96647. * This allowed control for front to back rendering or reversly depending of the special needs.
  96648. *
  96649. * @param renderingGroupId The rendering group id corresponding to its index
  96650. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96651. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96652. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96653. */
  96654. 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;
  96655. /**
  96656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96657. *
  96658. * @param renderingGroupId The rendering group id corresponding to its index
  96659. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96660. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96661. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96662. */
  96663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96664. /**
  96665. * Gets the current auto clear configuration for one rendering group of the rendering
  96666. * manager.
  96667. * @param index the rendering group index to get the information for
  96668. * @returns The auto clear setup for the requested rendering group
  96669. */
  96670. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96671. }
  96672. }
  96673. declare module BABYLON {
  96674. /**
  96675. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96676. */
  96677. export interface ICustomShaderOptions {
  96678. /**
  96679. * Gets or sets the custom shader name to use
  96680. */
  96681. shaderName: string;
  96682. /**
  96683. * The list of attribute names used in the shader
  96684. */
  96685. attributes?: string[];
  96686. /**
  96687. * The list of unifrom names used in the shader
  96688. */
  96689. uniforms?: string[];
  96690. /**
  96691. * The list of sampler names used in the shader
  96692. */
  96693. samplers?: string[];
  96694. /**
  96695. * The list of defines used in the shader
  96696. */
  96697. defines?: string[];
  96698. }
  96699. /**
  96700. * Interface to implement to create a shadow generator compatible with BJS.
  96701. */
  96702. export interface IShadowGenerator {
  96703. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96704. id: string;
  96705. /**
  96706. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96707. * @returns The render target texture if present otherwise, null
  96708. */
  96709. getShadowMap(): Nullable<RenderTargetTexture>;
  96710. /**
  96711. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96712. * @param subMesh The submesh we want to render in the shadow map
  96713. * @param useInstances Defines wether will draw in the map using instances
  96714. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96715. * @returns true if ready otherwise, false
  96716. */
  96717. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96718. /**
  96719. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96720. * @param defines Defines of the material we want to update
  96721. * @param lightIndex Index of the light in the enabled light list of the material
  96722. */
  96723. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96724. /**
  96725. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96726. * defined in the generator but impacting the effect).
  96727. * It implies the unifroms available on the materials are the standard BJS ones.
  96728. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96729. * @param effect The effect we are binfing the information for
  96730. */
  96731. bindShadowLight(lightIndex: string, effect: Effect): void;
  96732. /**
  96733. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96734. * (eq to shadow prjection matrix * light transform matrix)
  96735. * @returns The transform matrix used to create the shadow map
  96736. */
  96737. getTransformMatrix(): Matrix;
  96738. /**
  96739. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96740. * Cube and 2D textures for instance.
  96741. */
  96742. recreateShadowMap(): void;
  96743. /**
  96744. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96745. * @param onCompiled Callback triggered at the and of the effects compilation
  96746. * @param options Sets of optional options forcing the compilation with different modes
  96747. */
  96748. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96749. useInstances: boolean;
  96750. }>): void;
  96751. /**
  96752. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96753. * @param options Sets of optional options forcing the compilation with different modes
  96754. * @returns A promise that resolves when the compilation completes
  96755. */
  96756. forceCompilationAsync(options?: Partial<{
  96757. useInstances: boolean;
  96758. }>): Promise<void>;
  96759. /**
  96760. * Serializes the shadow generator setup to a json object.
  96761. * @returns The serialized JSON object
  96762. */
  96763. serialize(): any;
  96764. /**
  96765. * Disposes the Shadow map and related Textures and effects.
  96766. */
  96767. dispose(): void;
  96768. }
  96769. /**
  96770. * Default implementation IShadowGenerator.
  96771. * This is the main object responsible of generating shadows in the framework.
  96772. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96773. */
  96774. export class ShadowGenerator implements IShadowGenerator {
  96775. /**
  96776. * Name of the shadow generator class
  96777. */
  96778. static CLASSNAME: string;
  96779. /**
  96780. * Shadow generator mode None: no filtering applied.
  96781. */
  96782. static readonly FILTER_NONE: number;
  96783. /**
  96784. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96785. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96786. */
  96787. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96788. /**
  96789. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96790. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96791. */
  96792. static readonly FILTER_POISSONSAMPLING: number;
  96793. /**
  96794. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96795. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96796. */
  96797. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96798. /**
  96799. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96800. * edge artifacts on steep falloff.
  96801. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96802. */
  96803. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96804. /**
  96805. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96806. * edge artifacts on steep falloff.
  96807. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96808. */
  96809. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96810. /**
  96811. * Shadow generator mode PCF: Percentage Closer Filtering
  96812. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96813. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96814. */
  96815. static readonly FILTER_PCF: number;
  96816. /**
  96817. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96818. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96819. * Contact Hardening
  96820. */
  96821. static readonly FILTER_PCSS: number;
  96822. /**
  96823. * Reserved for PCF and PCSS
  96824. * Highest Quality.
  96825. *
  96826. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96827. *
  96828. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96829. */
  96830. static readonly QUALITY_HIGH: number;
  96831. /**
  96832. * Reserved for PCF and PCSS
  96833. * Good tradeoff for quality/perf cross devices
  96834. *
  96835. * Execute PCF on a 3*3 kernel.
  96836. *
  96837. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96838. */
  96839. static readonly QUALITY_MEDIUM: number;
  96840. /**
  96841. * Reserved for PCF and PCSS
  96842. * The lowest quality but the fastest.
  96843. *
  96844. * Execute PCF on a 1*1 kernel.
  96845. *
  96846. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96847. */
  96848. static readonly QUALITY_LOW: number;
  96849. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96850. id: string;
  96851. /** Gets or sets the custom shader name to use */
  96852. customShaderOptions: ICustomShaderOptions;
  96853. /**
  96854. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96855. */
  96856. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96857. /**
  96858. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96859. */
  96860. onAfterShadowMapRenderObservable: Observable<Effect>;
  96861. /**
  96862. * Observable triggered before a mesh is rendered in the shadow map.
  96863. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96864. */
  96865. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96866. /**
  96867. * Observable triggered after a mesh is rendered in the shadow map.
  96868. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96869. */
  96870. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96871. protected _bias: number;
  96872. /**
  96873. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96874. */
  96875. get bias(): number;
  96876. /**
  96877. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96878. */
  96879. set bias(bias: number);
  96880. protected _normalBias: number;
  96881. /**
  96882. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96883. */
  96884. get normalBias(): number;
  96885. /**
  96886. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96887. */
  96888. set normalBias(normalBias: number);
  96889. protected _blurBoxOffset: number;
  96890. /**
  96891. * Gets the blur box offset: offset applied during the blur pass.
  96892. * Only useful if useKernelBlur = false
  96893. */
  96894. get blurBoxOffset(): number;
  96895. /**
  96896. * Sets the blur box offset: offset applied during the blur pass.
  96897. * Only useful if useKernelBlur = false
  96898. */
  96899. set blurBoxOffset(value: number);
  96900. protected _blurScale: number;
  96901. /**
  96902. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96903. * 2 means half of the size.
  96904. */
  96905. get blurScale(): number;
  96906. /**
  96907. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96908. * 2 means half of the size.
  96909. */
  96910. set blurScale(value: number);
  96911. protected _blurKernel: number;
  96912. /**
  96913. * Gets the blur kernel: kernel size of the blur pass.
  96914. * Only useful if useKernelBlur = true
  96915. */
  96916. get blurKernel(): number;
  96917. /**
  96918. * Sets the blur kernel: kernel size of the blur pass.
  96919. * Only useful if useKernelBlur = true
  96920. */
  96921. set blurKernel(value: number);
  96922. protected _useKernelBlur: boolean;
  96923. /**
  96924. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96925. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96926. */
  96927. get useKernelBlur(): boolean;
  96928. /**
  96929. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96930. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96931. */
  96932. set useKernelBlur(value: boolean);
  96933. protected _depthScale: number;
  96934. /**
  96935. * Gets the depth scale used in ESM mode.
  96936. */
  96937. get depthScale(): number;
  96938. /**
  96939. * Sets the depth scale used in ESM mode.
  96940. * This can override the scale stored on the light.
  96941. */
  96942. set depthScale(value: number);
  96943. protected _validateFilter(filter: number): number;
  96944. protected _filter: number;
  96945. /**
  96946. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96947. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96948. */
  96949. get filter(): number;
  96950. /**
  96951. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96952. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96953. */
  96954. set filter(value: number);
  96955. /**
  96956. * Gets if the current filter is set to Poisson Sampling.
  96957. */
  96958. get usePoissonSampling(): boolean;
  96959. /**
  96960. * Sets the current filter to Poisson Sampling.
  96961. */
  96962. set usePoissonSampling(value: boolean);
  96963. /**
  96964. * Gets if the current filter is set to ESM.
  96965. */
  96966. get useExponentialShadowMap(): boolean;
  96967. /**
  96968. * Sets the current filter is to ESM.
  96969. */
  96970. set useExponentialShadowMap(value: boolean);
  96971. /**
  96972. * Gets if the current filter is set to filtered ESM.
  96973. */
  96974. get useBlurExponentialShadowMap(): boolean;
  96975. /**
  96976. * Gets if the current filter is set to filtered ESM.
  96977. */
  96978. set useBlurExponentialShadowMap(value: boolean);
  96979. /**
  96980. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96981. * exponential to prevent steep falloff artifacts).
  96982. */
  96983. get useCloseExponentialShadowMap(): boolean;
  96984. /**
  96985. * Sets the current filter to "close ESM" (using the inverse of the
  96986. * exponential to prevent steep falloff artifacts).
  96987. */
  96988. set useCloseExponentialShadowMap(value: boolean);
  96989. /**
  96990. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96991. * exponential to prevent steep falloff artifacts).
  96992. */
  96993. get useBlurCloseExponentialShadowMap(): boolean;
  96994. /**
  96995. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96996. * exponential to prevent steep falloff artifacts).
  96997. */
  96998. set useBlurCloseExponentialShadowMap(value: boolean);
  96999. /**
  97000. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97001. */
  97002. get usePercentageCloserFiltering(): boolean;
  97003. /**
  97004. * Sets the current filter to "PCF" (percentage closer filtering).
  97005. */
  97006. set usePercentageCloserFiltering(value: boolean);
  97007. protected _filteringQuality: number;
  97008. /**
  97009. * Gets the PCF or PCSS Quality.
  97010. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97011. */
  97012. get filteringQuality(): number;
  97013. /**
  97014. * Sets the PCF or PCSS Quality.
  97015. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97016. */
  97017. set filteringQuality(filteringQuality: number);
  97018. /**
  97019. * Gets if the current filter is set to "PCSS" (contact hardening).
  97020. */
  97021. get useContactHardeningShadow(): boolean;
  97022. /**
  97023. * Sets the current filter to "PCSS" (contact hardening).
  97024. */
  97025. set useContactHardeningShadow(value: boolean);
  97026. protected _contactHardeningLightSizeUVRatio: number;
  97027. /**
  97028. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97029. * Using a ratio helps keeping shape stability independently of the map size.
  97030. *
  97031. * It does not account for the light projection as it was having too much
  97032. * instability during the light setup or during light position changes.
  97033. *
  97034. * Only valid if useContactHardeningShadow is true.
  97035. */
  97036. get contactHardeningLightSizeUVRatio(): number;
  97037. /**
  97038. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97039. * Using a ratio helps keeping shape stability independently of the map size.
  97040. *
  97041. * It does not account for the light projection as it was having too much
  97042. * instability during the light setup or during light position changes.
  97043. *
  97044. * Only valid if useContactHardeningShadow is true.
  97045. */
  97046. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97047. protected _darkness: number;
  97048. /** Gets or sets the actual darkness of a shadow */
  97049. get darkness(): number;
  97050. set darkness(value: number);
  97051. /**
  97052. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97053. * 0 means strongest and 1 would means no shadow.
  97054. * @returns the darkness.
  97055. */
  97056. getDarkness(): number;
  97057. /**
  97058. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97059. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97060. * @returns the shadow generator allowing fluent coding.
  97061. */
  97062. setDarkness(darkness: number): ShadowGenerator;
  97063. protected _transparencyShadow: boolean;
  97064. /** Gets or sets the ability to have transparent shadow */
  97065. get transparencyShadow(): boolean;
  97066. set transparencyShadow(value: boolean);
  97067. /**
  97068. * Sets the ability to have transparent shadow (boolean).
  97069. * @param transparent True if transparent else False
  97070. * @returns the shadow generator allowing fluent coding
  97071. */
  97072. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97073. /**
  97074. * Enables or disables shadows with varying strength based on the transparency
  97075. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97076. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97077. * mesh.visibility * alphaTexture.a
  97078. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97079. */
  97080. enableSoftTransparentShadow: boolean;
  97081. protected _shadowMap: Nullable<RenderTargetTexture>;
  97082. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97083. /**
  97084. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97085. * @returns The render target texture if present otherwise, null
  97086. */
  97087. getShadowMap(): Nullable<RenderTargetTexture>;
  97088. /**
  97089. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97090. * @returns The render target texture if the shadow map is present otherwise, null
  97091. */
  97092. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97093. /**
  97094. * Gets the class name of that object
  97095. * @returns "ShadowGenerator"
  97096. */
  97097. getClassName(): string;
  97098. /**
  97099. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97100. * @param mesh Mesh to add
  97101. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97102. * @returns the Shadow Generator itself
  97103. */
  97104. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97105. /**
  97106. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97107. * @param mesh Mesh to remove
  97108. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97109. * @returns the Shadow Generator itself
  97110. */
  97111. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97112. /**
  97113. * Controls the extent to which the shadows fade out at the edge of the frustum
  97114. */
  97115. frustumEdgeFalloff: number;
  97116. protected _light: IShadowLight;
  97117. /**
  97118. * Returns the associated light object.
  97119. * @returns the light generating the shadow
  97120. */
  97121. getLight(): IShadowLight;
  97122. /**
  97123. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97124. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97125. * It might on the other hand introduce peter panning.
  97126. */
  97127. forceBackFacesOnly: boolean;
  97128. protected _scene: Scene;
  97129. protected _lightDirection: Vector3;
  97130. protected _effect: Effect;
  97131. protected _viewMatrix: Matrix;
  97132. protected _projectionMatrix: Matrix;
  97133. protected _transformMatrix: Matrix;
  97134. protected _cachedPosition: Vector3;
  97135. protected _cachedDirection: Vector3;
  97136. protected _cachedDefines: string;
  97137. protected _currentRenderID: number;
  97138. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97139. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97140. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97141. protected _blurPostProcesses: PostProcess[];
  97142. protected _mapSize: number;
  97143. protected _currentFaceIndex: number;
  97144. protected _currentFaceIndexCache: number;
  97145. protected _textureType: number;
  97146. protected _defaultTextureMatrix: Matrix;
  97147. protected _storedUniqueId: Nullable<number>;
  97148. /** @hidden */
  97149. static _SceneComponentInitialization: (scene: Scene) => void;
  97150. /**
  97151. * Creates a ShadowGenerator object.
  97152. * A ShadowGenerator is the required tool to use the shadows.
  97153. * Each light casting shadows needs to use its own ShadowGenerator.
  97154. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97155. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97156. * @param light The light object generating the shadows.
  97157. * @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.
  97158. */
  97159. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97160. protected _initializeGenerator(): void;
  97161. protected _createTargetRenderTexture(): void;
  97162. protected _initializeShadowMap(): void;
  97163. protected _initializeBlurRTTAndPostProcesses(): void;
  97164. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97165. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97166. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97167. protected _applyFilterValues(): void;
  97168. /**
  97169. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97170. * @param onCompiled Callback triggered at the and of the effects compilation
  97171. * @param options Sets of optional options forcing the compilation with different modes
  97172. */
  97173. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97174. useInstances: boolean;
  97175. }>): void;
  97176. /**
  97177. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97178. * @param options Sets of optional options forcing the compilation with different modes
  97179. * @returns A promise that resolves when the compilation completes
  97180. */
  97181. forceCompilationAsync(options?: Partial<{
  97182. useInstances: boolean;
  97183. }>): Promise<void>;
  97184. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97185. private _prepareShadowDefines;
  97186. /**
  97187. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97188. * @param subMesh The submesh we want to render in the shadow map
  97189. * @param useInstances Defines wether will draw in the map using instances
  97190. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97191. * @returns true if ready otherwise, false
  97192. */
  97193. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97194. /**
  97195. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97196. * @param defines Defines of the material we want to update
  97197. * @param lightIndex Index of the light in the enabled light list of the material
  97198. */
  97199. prepareDefines(defines: any, lightIndex: number): void;
  97200. /**
  97201. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97202. * defined in the generator but impacting the effect).
  97203. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97204. * @param effect The effect we are binfing the information for
  97205. */
  97206. bindShadowLight(lightIndex: string, effect: Effect): void;
  97207. /**
  97208. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97209. * (eq to shadow prjection matrix * light transform matrix)
  97210. * @returns The transform matrix used to create the shadow map
  97211. */
  97212. getTransformMatrix(): Matrix;
  97213. /**
  97214. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97215. * Cube and 2D textures for instance.
  97216. */
  97217. recreateShadowMap(): void;
  97218. protected _disposeBlurPostProcesses(): void;
  97219. protected _disposeRTTandPostProcesses(): void;
  97220. /**
  97221. * Disposes the ShadowGenerator.
  97222. * Returns nothing.
  97223. */
  97224. dispose(): void;
  97225. /**
  97226. * Serializes the shadow generator setup to a json object.
  97227. * @returns The serialized JSON object
  97228. */
  97229. serialize(): any;
  97230. /**
  97231. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97232. * @param parsedShadowGenerator The JSON object to parse
  97233. * @param scene The scene to create the shadow map for
  97234. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97235. * @returns The parsed shadow generator
  97236. */
  97237. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97238. }
  97239. }
  97240. declare module BABYLON {
  97241. /**
  97242. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97243. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97244. * 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.
  97245. */
  97246. export abstract class Light extends Node {
  97247. /**
  97248. * Falloff Default: light is falling off following the material specification:
  97249. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97250. */
  97251. static readonly FALLOFF_DEFAULT: number;
  97252. /**
  97253. * Falloff Physical: light is falling off following the inverse squared distance law.
  97254. */
  97255. static readonly FALLOFF_PHYSICAL: number;
  97256. /**
  97257. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97258. * to enhance interoperability with other engines.
  97259. */
  97260. static readonly FALLOFF_GLTF: number;
  97261. /**
  97262. * Falloff Standard: light is falling off like in the standard material
  97263. * to enhance interoperability with other materials.
  97264. */
  97265. static readonly FALLOFF_STANDARD: number;
  97266. /**
  97267. * If every light affecting the material is in this lightmapMode,
  97268. * material.lightmapTexture adds or multiplies
  97269. * (depends on material.useLightmapAsShadowmap)
  97270. * after every other light calculations.
  97271. */
  97272. static readonly LIGHTMAP_DEFAULT: number;
  97273. /**
  97274. * material.lightmapTexture as only diffuse lighting from this light
  97275. * adds only specular lighting from this light
  97276. * adds dynamic shadows
  97277. */
  97278. static readonly LIGHTMAP_SPECULAR: number;
  97279. /**
  97280. * material.lightmapTexture as only lighting
  97281. * no light calculation from this light
  97282. * only adds dynamic shadows from this light
  97283. */
  97284. static readonly LIGHTMAP_SHADOWSONLY: number;
  97285. /**
  97286. * Each light type uses the default quantity according to its type:
  97287. * point/spot lights use luminous intensity
  97288. * directional lights use illuminance
  97289. */
  97290. static readonly INTENSITYMODE_AUTOMATIC: number;
  97291. /**
  97292. * lumen (lm)
  97293. */
  97294. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97295. /**
  97296. * candela (lm/sr)
  97297. */
  97298. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97299. /**
  97300. * lux (lm/m^2)
  97301. */
  97302. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97303. /**
  97304. * nit (cd/m^2)
  97305. */
  97306. static readonly INTENSITYMODE_LUMINANCE: number;
  97307. /**
  97308. * Light type const id of the point light.
  97309. */
  97310. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97311. /**
  97312. * Light type const id of the directional light.
  97313. */
  97314. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97315. /**
  97316. * Light type const id of the spot light.
  97317. */
  97318. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97319. /**
  97320. * Light type const id of the hemispheric light.
  97321. */
  97322. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97323. /**
  97324. * Diffuse gives the basic color to an object.
  97325. */
  97326. diffuse: Color3;
  97327. /**
  97328. * Specular produces a highlight color on an object.
  97329. * Note: This is note affecting PBR materials.
  97330. */
  97331. specular: Color3;
  97332. /**
  97333. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97334. * falling off base on range or angle.
  97335. * This can be set to any values in Light.FALLOFF_x.
  97336. *
  97337. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97338. * other types of materials.
  97339. */
  97340. falloffType: number;
  97341. /**
  97342. * Strength of the light.
  97343. * Note: By default it is define in the framework own unit.
  97344. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97345. */
  97346. intensity: number;
  97347. private _range;
  97348. protected _inverseSquaredRange: number;
  97349. /**
  97350. * Defines how far from the source the light is impacting in scene units.
  97351. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97352. */
  97353. get range(): number;
  97354. /**
  97355. * Defines how far from the source the light is impacting in scene units.
  97356. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97357. */
  97358. set range(value: number);
  97359. /**
  97360. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97361. * of light.
  97362. */
  97363. private _photometricScale;
  97364. private _intensityMode;
  97365. /**
  97366. * Gets the photometric scale used to interpret the intensity.
  97367. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97368. */
  97369. get intensityMode(): number;
  97370. /**
  97371. * Sets the photometric scale used to interpret the intensity.
  97372. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97373. */
  97374. set intensityMode(value: number);
  97375. private _radius;
  97376. /**
  97377. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97378. */
  97379. get radius(): number;
  97380. /**
  97381. * sets the light radius used by PBR Materials to simulate soft area lights.
  97382. */
  97383. set radius(value: number);
  97384. private _renderPriority;
  97385. /**
  97386. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97387. * exceeding the number allowed of the materials.
  97388. */
  97389. renderPriority: number;
  97390. private _shadowEnabled;
  97391. /**
  97392. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97393. * the current shadow generator.
  97394. */
  97395. get shadowEnabled(): boolean;
  97396. /**
  97397. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97398. * the current shadow generator.
  97399. */
  97400. set shadowEnabled(value: boolean);
  97401. private _includedOnlyMeshes;
  97402. /**
  97403. * Gets the only meshes impacted by this light.
  97404. */
  97405. get includedOnlyMeshes(): AbstractMesh[];
  97406. /**
  97407. * Sets the only meshes impacted by this light.
  97408. */
  97409. set includedOnlyMeshes(value: AbstractMesh[]);
  97410. private _excludedMeshes;
  97411. /**
  97412. * Gets the meshes not impacted by this light.
  97413. */
  97414. get excludedMeshes(): AbstractMesh[];
  97415. /**
  97416. * Sets the meshes not impacted by this light.
  97417. */
  97418. set excludedMeshes(value: AbstractMesh[]);
  97419. private _excludeWithLayerMask;
  97420. /**
  97421. * Gets the layer id use to find what meshes are not impacted by the light.
  97422. * Inactive if 0
  97423. */
  97424. get excludeWithLayerMask(): number;
  97425. /**
  97426. * Sets the layer id use to find what meshes are not impacted by the light.
  97427. * Inactive if 0
  97428. */
  97429. set excludeWithLayerMask(value: number);
  97430. private _includeOnlyWithLayerMask;
  97431. /**
  97432. * Gets the layer id use to find what meshes are impacted by the light.
  97433. * Inactive if 0
  97434. */
  97435. get includeOnlyWithLayerMask(): number;
  97436. /**
  97437. * Sets the layer id use to find what meshes are impacted by the light.
  97438. * Inactive if 0
  97439. */
  97440. set includeOnlyWithLayerMask(value: number);
  97441. private _lightmapMode;
  97442. /**
  97443. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97444. */
  97445. get lightmapMode(): number;
  97446. /**
  97447. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97448. */
  97449. set lightmapMode(value: number);
  97450. /**
  97451. * Shadow generator associted to the light.
  97452. * @hidden Internal use only.
  97453. */
  97454. _shadowGenerator: Nullable<IShadowGenerator>;
  97455. /**
  97456. * @hidden Internal use only.
  97457. */
  97458. _excludedMeshesIds: string[];
  97459. /**
  97460. * @hidden Internal use only.
  97461. */
  97462. _includedOnlyMeshesIds: string[];
  97463. /**
  97464. * The current light unifom buffer.
  97465. * @hidden Internal use only.
  97466. */
  97467. _uniformBuffer: UniformBuffer;
  97468. /** @hidden */
  97469. _renderId: number;
  97470. /**
  97471. * Creates a Light object in the scene.
  97472. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97473. * @param name The firendly name of the light
  97474. * @param scene The scene the light belongs too
  97475. */
  97476. constructor(name: string, scene: Scene);
  97477. protected abstract _buildUniformLayout(): void;
  97478. /**
  97479. * Sets the passed Effect "effect" with the Light information.
  97480. * @param effect The effect to update
  97481. * @param lightIndex The index of the light in the effect to update
  97482. * @returns The light
  97483. */
  97484. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97485. /**
  97486. * Sets the passed Effect "effect" with the Light textures.
  97487. * @param effect The effect to update
  97488. * @param lightIndex The index of the light in the effect to update
  97489. * @returns The light
  97490. */
  97491. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97492. /**
  97493. * Binds the lights information from the scene to the effect for the given mesh.
  97494. * @param lightIndex Light index
  97495. * @param scene The scene where the light belongs to
  97496. * @param effect The effect we are binding the data to
  97497. * @param useSpecular Defines if specular is supported
  97498. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97499. */
  97500. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97501. /**
  97502. * Sets the passed Effect "effect" with the Light information.
  97503. * @param effect The effect to update
  97504. * @param lightDataUniformName The uniform used to store light data (position or direction)
  97505. * @returns The light
  97506. */
  97507. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  97508. /**
  97509. * Returns the string "Light".
  97510. * @returns the class name
  97511. */
  97512. getClassName(): string;
  97513. /** @hidden */
  97514. readonly _isLight: boolean;
  97515. /**
  97516. * Converts the light information to a readable string for debug purpose.
  97517. * @param fullDetails Supports for multiple levels of logging within scene loading
  97518. * @returns the human readable light info
  97519. */
  97520. toString(fullDetails?: boolean): string;
  97521. /** @hidden */
  97522. protected _syncParentEnabledState(): void;
  97523. /**
  97524. * Set the enabled state of this node.
  97525. * @param value - the new enabled state
  97526. */
  97527. setEnabled(value: boolean): void;
  97528. /**
  97529. * Returns the Light associated shadow generator if any.
  97530. * @return the associated shadow generator.
  97531. */
  97532. getShadowGenerator(): Nullable<IShadowGenerator>;
  97533. /**
  97534. * Returns a Vector3, the absolute light position in the World.
  97535. * @returns the world space position of the light
  97536. */
  97537. getAbsolutePosition(): Vector3;
  97538. /**
  97539. * Specifies if the light will affect the passed mesh.
  97540. * @param mesh The mesh to test against the light
  97541. * @return true the mesh is affected otherwise, false.
  97542. */
  97543. canAffectMesh(mesh: AbstractMesh): boolean;
  97544. /**
  97545. * Sort function to order lights for rendering.
  97546. * @param a First Light object to compare to second.
  97547. * @param b Second Light object to compare first.
  97548. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97549. */
  97550. static CompareLightsPriority(a: Light, b: Light): number;
  97551. /**
  97552. * Releases resources associated with this node.
  97553. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97554. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97555. */
  97556. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97557. /**
  97558. * Returns the light type ID (integer).
  97559. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97560. */
  97561. getTypeID(): number;
  97562. /**
  97563. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97564. * @returns the scaled intensity in intensity mode unit
  97565. */
  97566. getScaledIntensity(): number;
  97567. /**
  97568. * Returns a new Light object, named "name", from the current one.
  97569. * @param name The name of the cloned light
  97570. * @param newParent The parent of this light, if it has one
  97571. * @returns the new created light
  97572. */
  97573. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97574. /**
  97575. * Serializes the current light into a Serialization object.
  97576. * @returns the serialized object.
  97577. */
  97578. serialize(): any;
  97579. /**
  97580. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97581. * This new light is named "name" and added to the passed scene.
  97582. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97583. * @param name The friendly name of the light
  97584. * @param scene The scene the new light will belong to
  97585. * @returns the constructor function
  97586. */
  97587. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97588. /**
  97589. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97590. * @param parsedLight The JSON representation of the light
  97591. * @param scene The scene to create the parsed light in
  97592. * @returns the created light after parsing
  97593. */
  97594. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97595. private _hookArrayForExcluded;
  97596. private _hookArrayForIncludedOnly;
  97597. private _resyncMeshes;
  97598. /**
  97599. * Forces the meshes to update their light related information in their rendering used effects
  97600. * @hidden Internal Use Only
  97601. */
  97602. _markMeshesAsLightDirty(): void;
  97603. /**
  97604. * Recomputes the cached photometric scale if needed.
  97605. */
  97606. private _computePhotometricScale;
  97607. /**
  97608. * Returns the Photometric Scale according to the light type and intensity mode.
  97609. */
  97610. private _getPhotometricScale;
  97611. /**
  97612. * Reorder the light in the scene according to their defined priority.
  97613. * @hidden Internal Use Only
  97614. */
  97615. _reorderLightsInScene(): void;
  97616. /**
  97617. * Prepares the list of defines specific to the light type.
  97618. * @param defines the list of defines
  97619. * @param lightIndex defines the index of the light for the effect
  97620. */
  97621. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97622. }
  97623. }
  97624. declare module BABYLON {
  97625. /**
  97626. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97627. * This is the base of the follow, arc rotate cameras and Free camera
  97628. * @see https://doc.babylonjs.com/features/cameras
  97629. */
  97630. export class TargetCamera extends Camera {
  97631. private static _RigCamTransformMatrix;
  97632. private static _TargetTransformMatrix;
  97633. private static _TargetFocalPoint;
  97634. private _tmpUpVector;
  97635. private _tmpTargetVector;
  97636. /**
  97637. * Define the current direction the camera is moving to
  97638. */
  97639. cameraDirection: Vector3;
  97640. /**
  97641. * Define the current rotation the camera is rotating to
  97642. */
  97643. cameraRotation: Vector2;
  97644. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97645. ignoreParentScaling: boolean;
  97646. /**
  97647. * When set, the up vector of the camera will be updated by the rotation of the camera
  97648. */
  97649. updateUpVectorFromRotation: boolean;
  97650. private _tmpQuaternion;
  97651. /**
  97652. * Define the current rotation of the camera
  97653. */
  97654. rotation: Vector3;
  97655. /**
  97656. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97657. */
  97658. rotationQuaternion: Quaternion;
  97659. /**
  97660. * Define the current speed of the camera
  97661. */
  97662. speed: number;
  97663. /**
  97664. * Add constraint to the camera to prevent it to move freely in all directions and
  97665. * around all axis.
  97666. */
  97667. noRotationConstraint: boolean;
  97668. /**
  97669. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97670. * panning
  97671. */
  97672. invertRotation: boolean;
  97673. /**
  97674. * Speed multiplier for inverse camera panning
  97675. */
  97676. inverseRotationSpeed: number;
  97677. /**
  97678. * Define the current target of the camera as an object or a position.
  97679. */
  97680. lockedTarget: any;
  97681. /** @hidden */
  97682. _currentTarget: Vector3;
  97683. /** @hidden */
  97684. _initialFocalDistance: number;
  97685. /** @hidden */
  97686. _viewMatrix: Matrix;
  97687. /** @hidden */
  97688. _camMatrix: Matrix;
  97689. /** @hidden */
  97690. _cameraTransformMatrix: Matrix;
  97691. /** @hidden */
  97692. _cameraRotationMatrix: Matrix;
  97693. /** @hidden */
  97694. _referencePoint: Vector3;
  97695. /** @hidden */
  97696. _transformedReferencePoint: Vector3;
  97697. /** @hidden */
  97698. _reset: () => void;
  97699. private _defaultUp;
  97700. /**
  97701. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97702. * This is the base of the follow, arc rotate cameras and Free camera
  97703. * @see https://doc.babylonjs.com/features/cameras
  97704. * @param name Defines the name of the camera in the scene
  97705. * @param position Defines the start position of the camera in the scene
  97706. * @param scene Defines the scene the camera belongs to
  97707. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97708. */
  97709. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97710. /**
  97711. * Gets the position in front of the camera at a given distance.
  97712. * @param distance The distance from the camera we want the position to be
  97713. * @returns the position
  97714. */
  97715. getFrontPosition(distance: number): Vector3;
  97716. /** @hidden */
  97717. _getLockedTargetPosition(): Nullable<Vector3>;
  97718. private _storedPosition;
  97719. private _storedRotation;
  97720. private _storedRotationQuaternion;
  97721. /**
  97722. * Store current camera state of the camera (fov, position, rotation, etc..)
  97723. * @returns the camera
  97724. */
  97725. storeState(): Camera;
  97726. /**
  97727. * Restored camera state. You must call storeState() first
  97728. * @returns whether it was successful or not
  97729. * @hidden
  97730. */
  97731. _restoreStateValues(): boolean;
  97732. /** @hidden */
  97733. _initCache(): void;
  97734. /** @hidden */
  97735. _updateCache(ignoreParentClass?: boolean): void;
  97736. /** @hidden */
  97737. _isSynchronizedViewMatrix(): boolean;
  97738. /** @hidden */
  97739. _computeLocalCameraSpeed(): number;
  97740. /**
  97741. * Defines the target the camera should look at.
  97742. * @param target Defines the new target as a Vector or a mesh
  97743. */
  97744. setTarget(target: Vector3): void;
  97745. /**
  97746. * Defines the target point of the camera.
  97747. * The camera looks towards it form the radius distance.
  97748. */
  97749. get target(): Vector3;
  97750. set target(value: Vector3);
  97751. /**
  97752. * Return the current target position of the camera. This value is expressed in local space.
  97753. * @returns the target position
  97754. */
  97755. getTarget(): Vector3;
  97756. /** @hidden */
  97757. _decideIfNeedsToMove(): boolean;
  97758. /** @hidden */
  97759. _updatePosition(): void;
  97760. /** @hidden */
  97761. _checkInputs(): void;
  97762. protected _updateCameraRotationMatrix(): void;
  97763. /**
  97764. * 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)
  97765. * @returns the current camera
  97766. */
  97767. private _rotateUpVectorWithCameraRotationMatrix;
  97768. private _cachedRotationZ;
  97769. private _cachedQuaternionRotationZ;
  97770. /** @hidden */
  97771. _getViewMatrix(): Matrix;
  97772. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97773. /**
  97774. * @hidden
  97775. */
  97776. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97777. /**
  97778. * @hidden
  97779. */
  97780. _updateRigCameras(): void;
  97781. private _getRigCamPositionAndTarget;
  97782. /**
  97783. * Gets the current object class name.
  97784. * @return the class name
  97785. */
  97786. getClassName(): string;
  97787. }
  97788. }
  97789. declare module BABYLON {
  97790. /**
  97791. * Gather the list of keyboard event types as constants.
  97792. */
  97793. export class KeyboardEventTypes {
  97794. /**
  97795. * The keydown event is fired when a key becomes active (pressed).
  97796. */
  97797. static readonly KEYDOWN: number;
  97798. /**
  97799. * The keyup event is fired when a key has been released.
  97800. */
  97801. static readonly KEYUP: number;
  97802. }
  97803. /**
  97804. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97805. */
  97806. export class KeyboardInfo {
  97807. /**
  97808. * Defines the type of event (KeyboardEventTypes)
  97809. */
  97810. type: number;
  97811. /**
  97812. * Defines the related dom event
  97813. */
  97814. event: KeyboardEvent;
  97815. /**
  97816. * Instantiates a new keyboard info.
  97817. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97818. * @param type Defines the type of event (KeyboardEventTypes)
  97819. * @param event Defines the related dom event
  97820. */
  97821. constructor(
  97822. /**
  97823. * Defines the type of event (KeyboardEventTypes)
  97824. */
  97825. type: number,
  97826. /**
  97827. * Defines the related dom event
  97828. */
  97829. event: KeyboardEvent);
  97830. }
  97831. /**
  97832. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97833. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97834. */
  97835. export class KeyboardInfoPre extends KeyboardInfo {
  97836. /**
  97837. * Defines the type of event (KeyboardEventTypes)
  97838. */
  97839. type: number;
  97840. /**
  97841. * Defines the related dom event
  97842. */
  97843. event: KeyboardEvent;
  97844. /**
  97845. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97846. */
  97847. skipOnPointerObservable: boolean;
  97848. /**
  97849. * Instantiates a new keyboard pre info.
  97850. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97851. * @param type Defines the type of event (KeyboardEventTypes)
  97852. * @param event Defines the related dom event
  97853. */
  97854. constructor(
  97855. /**
  97856. * Defines the type of event (KeyboardEventTypes)
  97857. */
  97858. type: number,
  97859. /**
  97860. * Defines the related dom event
  97861. */
  97862. event: KeyboardEvent);
  97863. }
  97864. }
  97865. declare module BABYLON {
  97866. /**
  97867. * Manage the keyboard inputs to control the movement of a free camera.
  97868. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97869. */
  97870. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97871. /**
  97872. * Defines the camera the input is attached to.
  97873. */
  97874. camera: FreeCamera;
  97875. /**
  97876. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97877. */
  97878. keysUp: number[];
  97879. /**
  97880. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97881. */
  97882. keysUpward: number[];
  97883. /**
  97884. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97885. */
  97886. keysDown: number[];
  97887. /**
  97888. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97889. */
  97890. keysDownward: number[];
  97891. /**
  97892. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97893. */
  97894. keysLeft: number[];
  97895. /**
  97896. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97897. */
  97898. keysRight: number[];
  97899. private _keys;
  97900. private _onCanvasBlurObserver;
  97901. private _onKeyboardObserver;
  97902. private _engine;
  97903. private _scene;
  97904. /**
  97905. * Attach the input controls to a specific dom element to get the input from.
  97906. * @param element Defines the element the controls should be listened from
  97907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97908. */
  97909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97910. /**
  97911. * Detach the current controls from the specified dom element.
  97912. * @param element Defines the element to stop listening the inputs from
  97913. */
  97914. detachControl(element: Nullable<HTMLElement>): void;
  97915. /**
  97916. * Update the current camera state depending on the inputs that have been used this frame.
  97917. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97918. */
  97919. checkInputs(): void;
  97920. /**
  97921. * Gets the class name of the current intput.
  97922. * @returns the class name
  97923. */
  97924. getClassName(): string;
  97925. /** @hidden */
  97926. _onLostFocus(): void;
  97927. /**
  97928. * Get the friendly name associated with the input class.
  97929. * @returns the input friendly name
  97930. */
  97931. getSimpleName(): string;
  97932. }
  97933. }
  97934. declare module BABYLON {
  97935. /**
  97936. * Gather the list of pointer event types as constants.
  97937. */
  97938. export class PointerEventTypes {
  97939. /**
  97940. * 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.
  97941. */
  97942. static readonly POINTERDOWN: number;
  97943. /**
  97944. * The pointerup event is fired when a pointer is no longer active.
  97945. */
  97946. static readonly POINTERUP: number;
  97947. /**
  97948. * The pointermove event is fired when a pointer changes coordinates.
  97949. */
  97950. static readonly POINTERMOVE: number;
  97951. /**
  97952. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97953. */
  97954. static readonly POINTERWHEEL: number;
  97955. /**
  97956. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97957. */
  97958. static readonly POINTERPICK: number;
  97959. /**
  97960. * The pointertap event is fired when a the object has been touched and released without drag.
  97961. */
  97962. static readonly POINTERTAP: number;
  97963. /**
  97964. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97965. */
  97966. static readonly POINTERDOUBLETAP: number;
  97967. }
  97968. /**
  97969. * Base class of pointer info types.
  97970. */
  97971. export class PointerInfoBase {
  97972. /**
  97973. * Defines the type of event (PointerEventTypes)
  97974. */
  97975. type: number;
  97976. /**
  97977. * Defines the related dom event
  97978. */
  97979. event: PointerEvent | MouseWheelEvent;
  97980. /**
  97981. * Instantiates the base class of pointers info.
  97982. * @param type Defines the type of event (PointerEventTypes)
  97983. * @param event Defines the related dom event
  97984. */
  97985. constructor(
  97986. /**
  97987. * Defines the type of event (PointerEventTypes)
  97988. */
  97989. type: number,
  97990. /**
  97991. * Defines the related dom event
  97992. */
  97993. event: PointerEvent | MouseWheelEvent);
  97994. }
  97995. /**
  97996. * This class is used to store pointer related info for the onPrePointerObservable event.
  97997. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97998. */
  97999. export class PointerInfoPre extends PointerInfoBase {
  98000. /**
  98001. * Ray from a pointer if availible (eg. 6dof controller)
  98002. */
  98003. ray: Nullable<Ray>;
  98004. /**
  98005. * Defines the local position of the pointer on the canvas.
  98006. */
  98007. localPosition: Vector2;
  98008. /**
  98009. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98010. */
  98011. skipOnPointerObservable: boolean;
  98012. /**
  98013. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98014. * @param type Defines the type of event (PointerEventTypes)
  98015. * @param event Defines the related dom event
  98016. * @param localX Defines the local x coordinates of the pointer when the event occured
  98017. * @param localY Defines the local y coordinates of the pointer when the event occured
  98018. */
  98019. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98020. }
  98021. /**
  98022. * This type contains all the data related to a pointer event in Babylon.js.
  98023. * 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.
  98024. */
  98025. export class PointerInfo extends PointerInfoBase {
  98026. /**
  98027. * Defines the picking info associated to the info (if any)\
  98028. */
  98029. pickInfo: Nullable<PickingInfo>;
  98030. /**
  98031. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98032. * @param type Defines the type of event (PointerEventTypes)
  98033. * @param event Defines the related dom event
  98034. * @param pickInfo Defines the picking info associated to the info (if any)\
  98035. */
  98036. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98037. /**
  98038. * Defines the picking info associated to the info (if any)\
  98039. */
  98040. pickInfo: Nullable<PickingInfo>);
  98041. }
  98042. /**
  98043. * Data relating to a touch event on the screen.
  98044. */
  98045. export interface PointerTouch {
  98046. /**
  98047. * X coordinate of touch.
  98048. */
  98049. x: number;
  98050. /**
  98051. * Y coordinate of touch.
  98052. */
  98053. y: number;
  98054. /**
  98055. * Id of touch. Unique for each finger.
  98056. */
  98057. pointerId: number;
  98058. /**
  98059. * Event type passed from DOM.
  98060. */
  98061. type: any;
  98062. }
  98063. }
  98064. declare module BABYLON {
  98065. /**
  98066. * Manage the mouse inputs to control the movement of a free camera.
  98067. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98068. */
  98069. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98070. /**
  98071. * Define if touch is enabled in the mouse input
  98072. */
  98073. touchEnabled: boolean;
  98074. /**
  98075. * Defines the camera the input is attached to.
  98076. */
  98077. camera: FreeCamera;
  98078. /**
  98079. * Defines the buttons associated with the input to handle camera move.
  98080. */
  98081. buttons: number[];
  98082. /**
  98083. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98084. */
  98085. angularSensibility: number;
  98086. private _pointerInput;
  98087. private _onMouseMove;
  98088. private _observer;
  98089. private previousPosition;
  98090. /**
  98091. * Observable for when a pointer move event occurs containing the move offset
  98092. */
  98093. onPointerMovedObservable: Observable<{
  98094. offsetX: number;
  98095. offsetY: number;
  98096. }>;
  98097. /**
  98098. * @hidden
  98099. * If the camera should be rotated automatically based on pointer movement
  98100. */
  98101. _allowCameraRotation: boolean;
  98102. /**
  98103. * Manage the mouse inputs to control the movement of a free camera.
  98104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98105. * @param touchEnabled Defines if touch is enabled or not
  98106. */
  98107. constructor(
  98108. /**
  98109. * Define if touch is enabled in the mouse input
  98110. */
  98111. touchEnabled?: boolean);
  98112. /**
  98113. * Attach the input controls to a specific dom element to get the input from.
  98114. * @param element Defines the element the controls should be listened from
  98115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98116. */
  98117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98118. /**
  98119. * Called on JS contextmenu event.
  98120. * Override this method to provide functionality.
  98121. */
  98122. protected onContextMenu(evt: PointerEvent): void;
  98123. /**
  98124. * Detach the current controls from the specified dom element.
  98125. * @param element Defines the element to stop listening the inputs from
  98126. */
  98127. detachControl(element: Nullable<HTMLElement>): void;
  98128. /**
  98129. * Gets the class name of the current intput.
  98130. * @returns the class name
  98131. */
  98132. getClassName(): string;
  98133. /**
  98134. * Get the friendly name associated with the input class.
  98135. * @returns the input friendly name
  98136. */
  98137. getSimpleName(): string;
  98138. }
  98139. }
  98140. declare module BABYLON {
  98141. /**
  98142. * Manage the touch inputs to control the movement of a free camera.
  98143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98144. */
  98145. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98146. /**
  98147. * Define if mouse events can be treated as touch events
  98148. */
  98149. allowMouse: boolean;
  98150. /**
  98151. * Defines the camera the input is attached to.
  98152. */
  98153. camera: FreeCamera;
  98154. /**
  98155. * Defines the touch sensibility for rotation.
  98156. * The higher the faster.
  98157. */
  98158. touchAngularSensibility: number;
  98159. /**
  98160. * Defines the touch sensibility for move.
  98161. * The higher the faster.
  98162. */
  98163. touchMoveSensibility: number;
  98164. private _offsetX;
  98165. private _offsetY;
  98166. private _pointerPressed;
  98167. private _pointerInput;
  98168. private _observer;
  98169. private _onLostFocus;
  98170. /**
  98171. * Manage the touch inputs to control the movement of a free camera.
  98172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98173. * @param allowMouse Defines if mouse events can be treated as touch events
  98174. */
  98175. constructor(
  98176. /**
  98177. * Define if mouse events can be treated as touch events
  98178. */
  98179. allowMouse?: boolean);
  98180. /**
  98181. * Attach the input controls to a specific dom element to get the input from.
  98182. * @param element Defines the element the controls should be listened from
  98183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98184. */
  98185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98186. /**
  98187. * Detach the current controls from the specified dom element.
  98188. * @param element Defines the element to stop listening the inputs from
  98189. */
  98190. detachControl(element: Nullable<HTMLElement>): void;
  98191. /**
  98192. * Update the current camera state depending on the inputs that have been used this frame.
  98193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98194. */
  98195. checkInputs(): void;
  98196. /**
  98197. * Gets the class name of the current intput.
  98198. * @returns the class name
  98199. */
  98200. getClassName(): string;
  98201. /**
  98202. * Get the friendly name associated with the input class.
  98203. * @returns the input friendly name
  98204. */
  98205. getSimpleName(): string;
  98206. }
  98207. }
  98208. declare module BABYLON {
  98209. /**
  98210. * Default Inputs manager for the FreeCamera.
  98211. * It groups all the default supported inputs for ease of use.
  98212. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98213. */
  98214. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98215. /**
  98216. * @hidden
  98217. */
  98218. _mouseInput: Nullable<FreeCameraMouseInput>;
  98219. /**
  98220. * Instantiates a new FreeCameraInputsManager.
  98221. * @param camera Defines the camera the inputs belong to
  98222. */
  98223. constructor(camera: FreeCamera);
  98224. /**
  98225. * Add keyboard input support to the input manager.
  98226. * @returns the current input manager
  98227. */
  98228. addKeyboard(): FreeCameraInputsManager;
  98229. /**
  98230. * Add mouse input support to the input manager.
  98231. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98232. * @returns the current input manager
  98233. */
  98234. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98235. /**
  98236. * Removes the mouse input support from the manager
  98237. * @returns the current input manager
  98238. */
  98239. removeMouse(): FreeCameraInputsManager;
  98240. /**
  98241. * Add touch input support to the input manager.
  98242. * @returns the current input manager
  98243. */
  98244. addTouch(): FreeCameraInputsManager;
  98245. /**
  98246. * Remove all attached input methods from a camera
  98247. */
  98248. clear(): void;
  98249. }
  98250. }
  98251. declare module BABYLON {
  98252. /**
  98253. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98254. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98255. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98256. */
  98257. export class FreeCamera extends TargetCamera {
  98258. /**
  98259. * Define the collision ellipsoid of the camera.
  98260. * This is helpful to simulate a camera body like the player body around the camera
  98261. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98262. */
  98263. ellipsoid: Vector3;
  98264. /**
  98265. * Define an offset for the position of the ellipsoid around the camera.
  98266. * This can be helpful to determine the center of the body near the gravity center of the body
  98267. * instead of its head.
  98268. */
  98269. ellipsoidOffset: Vector3;
  98270. /**
  98271. * Enable or disable collisions of the camera with the rest of the scene objects.
  98272. */
  98273. checkCollisions: boolean;
  98274. /**
  98275. * Enable or disable gravity on the camera.
  98276. */
  98277. applyGravity: boolean;
  98278. /**
  98279. * Define the input manager associated to the camera.
  98280. */
  98281. inputs: FreeCameraInputsManager;
  98282. /**
  98283. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98284. * Higher values reduce sensitivity.
  98285. */
  98286. get angularSensibility(): number;
  98287. /**
  98288. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98289. * Higher values reduce sensitivity.
  98290. */
  98291. set angularSensibility(value: number);
  98292. /**
  98293. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98294. */
  98295. get keysUp(): number[];
  98296. set keysUp(value: number[]);
  98297. /**
  98298. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98299. */
  98300. get keysUpward(): number[];
  98301. set keysUpward(value: number[]);
  98302. /**
  98303. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98304. */
  98305. get keysDown(): number[];
  98306. set keysDown(value: number[]);
  98307. /**
  98308. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98309. */
  98310. get keysDownward(): number[];
  98311. set keysDownward(value: number[]);
  98312. /**
  98313. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98314. */
  98315. get keysLeft(): number[];
  98316. set keysLeft(value: number[]);
  98317. /**
  98318. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98319. */
  98320. get keysRight(): number[];
  98321. set keysRight(value: number[]);
  98322. /**
  98323. * Event raised when the camera collide with a mesh in the scene.
  98324. */
  98325. onCollide: (collidedMesh: AbstractMesh) => void;
  98326. private _collider;
  98327. private _needMoveForGravity;
  98328. private _oldPosition;
  98329. private _diffPosition;
  98330. private _newPosition;
  98331. /** @hidden */
  98332. _localDirection: Vector3;
  98333. /** @hidden */
  98334. _transformedDirection: Vector3;
  98335. /**
  98336. * Instantiates a Free Camera.
  98337. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98338. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98339. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98340. * @param name Define the name of the camera in the scene
  98341. * @param position Define the start position of the camera in the scene
  98342. * @param scene Define the scene the camera belongs to
  98343. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98344. */
  98345. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98346. /**
  98347. * Attached controls to the current camera.
  98348. * @param element Defines the element the controls should be listened from
  98349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98350. */
  98351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98352. /**
  98353. * Detach the current controls from the camera.
  98354. * The camera will stop reacting to inputs.
  98355. * @param element Defines the element to stop listening the inputs from
  98356. */
  98357. detachControl(element: HTMLElement): void;
  98358. private _collisionMask;
  98359. /**
  98360. * Define a collision mask to limit the list of object the camera can collide with
  98361. */
  98362. get collisionMask(): number;
  98363. set collisionMask(mask: number);
  98364. /** @hidden */
  98365. _collideWithWorld(displacement: Vector3): void;
  98366. private _onCollisionPositionChange;
  98367. /** @hidden */
  98368. _checkInputs(): void;
  98369. /** @hidden */
  98370. _decideIfNeedsToMove(): boolean;
  98371. /** @hidden */
  98372. _updatePosition(): void;
  98373. /**
  98374. * Destroy the camera and release the current resources hold by it.
  98375. */
  98376. dispose(): void;
  98377. /**
  98378. * Gets the current object class name.
  98379. * @return the class name
  98380. */
  98381. getClassName(): string;
  98382. }
  98383. }
  98384. declare module BABYLON {
  98385. /**
  98386. * Represents a gamepad control stick position
  98387. */
  98388. export class StickValues {
  98389. /**
  98390. * The x component of the control stick
  98391. */
  98392. x: number;
  98393. /**
  98394. * The y component of the control stick
  98395. */
  98396. y: number;
  98397. /**
  98398. * Initializes the gamepad x and y control stick values
  98399. * @param x The x component of the gamepad control stick value
  98400. * @param y The y component of the gamepad control stick value
  98401. */
  98402. constructor(
  98403. /**
  98404. * The x component of the control stick
  98405. */
  98406. x: number,
  98407. /**
  98408. * The y component of the control stick
  98409. */
  98410. y: number);
  98411. }
  98412. /**
  98413. * An interface which manages callbacks for gamepad button changes
  98414. */
  98415. export interface GamepadButtonChanges {
  98416. /**
  98417. * Called when a gamepad has been changed
  98418. */
  98419. changed: boolean;
  98420. /**
  98421. * Called when a gamepad press event has been triggered
  98422. */
  98423. pressChanged: boolean;
  98424. /**
  98425. * Called when a touch event has been triggered
  98426. */
  98427. touchChanged: boolean;
  98428. /**
  98429. * Called when a value has changed
  98430. */
  98431. valueChanged: boolean;
  98432. }
  98433. /**
  98434. * Represents a gamepad
  98435. */
  98436. export class Gamepad {
  98437. /**
  98438. * The id of the gamepad
  98439. */
  98440. id: string;
  98441. /**
  98442. * The index of the gamepad
  98443. */
  98444. index: number;
  98445. /**
  98446. * The browser gamepad
  98447. */
  98448. browserGamepad: any;
  98449. /**
  98450. * Specifies what type of gamepad this represents
  98451. */
  98452. type: number;
  98453. private _leftStick;
  98454. private _rightStick;
  98455. /** @hidden */
  98456. _isConnected: boolean;
  98457. private _leftStickAxisX;
  98458. private _leftStickAxisY;
  98459. private _rightStickAxisX;
  98460. private _rightStickAxisY;
  98461. /**
  98462. * Triggered when the left control stick has been changed
  98463. */
  98464. private _onleftstickchanged;
  98465. /**
  98466. * Triggered when the right control stick has been changed
  98467. */
  98468. private _onrightstickchanged;
  98469. /**
  98470. * Represents a gamepad controller
  98471. */
  98472. static GAMEPAD: number;
  98473. /**
  98474. * Represents a generic controller
  98475. */
  98476. static GENERIC: number;
  98477. /**
  98478. * Represents an XBox controller
  98479. */
  98480. static XBOX: number;
  98481. /**
  98482. * Represents a pose-enabled controller
  98483. */
  98484. static POSE_ENABLED: number;
  98485. /**
  98486. * Represents an Dual Shock controller
  98487. */
  98488. static DUALSHOCK: number;
  98489. /**
  98490. * Specifies whether the left control stick should be Y-inverted
  98491. */
  98492. protected _invertLeftStickY: boolean;
  98493. /**
  98494. * Specifies if the gamepad has been connected
  98495. */
  98496. get isConnected(): boolean;
  98497. /**
  98498. * Initializes the gamepad
  98499. * @param id The id of the gamepad
  98500. * @param index The index of the gamepad
  98501. * @param browserGamepad The browser gamepad
  98502. * @param leftStickX The x component of the left joystick
  98503. * @param leftStickY The y component of the left joystick
  98504. * @param rightStickX The x component of the right joystick
  98505. * @param rightStickY The y component of the right joystick
  98506. */
  98507. constructor(
  98508. /**
  98509. * The id of the gamepad
  98510. */
  98511. id: string,
  98512. /**
  98513. * The index of the gamepad
  98514. */
  98515. index: number,
  98516. /**
  98517. * The browser gamepad
  98518. */
  98519. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  98520. /**
  98521. * Callback triggered when the left joystick has changed
  98522. * @param callback
  98523. */
  98524. onleftstickchanged(callback: (values: StickValues) => void): void;
  98525. /**
  98526. * Callback triggered when the right joystick has changed
  98527. * @param callback
  98528. */
  98529. onrightstickchanged(callback: (values: StickValues) => void): void;
  98530. /**
  98531. * Gets the left joystick
  98532. */
  98533. get leftStick(): StickValues;
  98534. /**
  98535. * Sets the left joystick values
  98536. */
  98537. set leftStick(newValues: StickValues);
  98538. /**
  98539. * Gets the right joystick
  98540. */
  98541. get rightStick(): StickValues;
  98542. /**
  98543. * Sets the right joystick value
  98544. */
  98545. set rightStick(newValues: StickValues);
  98546. /**
  98547. * Updates the gamepad joystick positions
  98548. */
  98549. update(): void;
  98550. /**
  98551. * Disposes the gamepad
  98552. */
  98553. dispose(): void;
  98554. }
  98555. /**
  98556. * Represents a generic gamepad
  98557. */
  98558. export class GenericPad extends Gamepad {
  98559. private _buttons;
  98560. private _onbuttondown;
  98561. private _onbuttonup;
  98562. /**
  98563. * Observable triggered when a button has been pressed
  98564. */
  98565. onButtonDownObservable: Observable<number>;
  98566. /**
  98567. * Observable triggered when a button has been released
  98568. */
  98569. onButtonUpObservable: Observable<number>;
  98570. /**
  98571. * Callback triggered when a button has been pressed
  98572. * @param callback Called when a button has been pressed
  98573. */
  98574. onbuttondown(callback: (buttonPressed: number) => void): void;
  98575. /**
  98576. * Callback triggered when a button has been released
  98577. * @param callback Called when a button has been released
  98578. */
  98579. onbuttonup(callback: (buttonReleased: number) => void): void;
  98580. /**
  98581. * Initializes the generic gamepad
  98582. * @param id The id of the generic gamepad
  98583. * @param index The index of the generic gamepad
  98584. * @param browserGamepad The browser gamepad
  98585. */
  98586. constructor(id: string, index: number, browserGamepad: any);
  98587. private _setButtonValue;
  98588. /**
  98589. * Updates the generic gamepad
  98590. */
  98591. update(): void;
  98592. /**
  98593. * Disposes the generic gamepad
  98594. */
  98595. dispose(): void;
  98596. }
  98597. }
  98598. declare module BABYLON {
  98599. /**
  98600. * Defines the types of pose enabled controllers that are supported
  98601. */
  98602. export enum PoseEnabledControllerType {
  98603. /**
  98604. * HTC Vive
  98605. */
  98606. VIVE = 0,
  98607. /**
  98608. * Oculus Rift
  98609. */
  98610. OCULUS = 1,
  98611. /**
  98612. * Windows mixed reality
  98613. */
  98614. WINDOWS = 2,
  98615. /**
  98616. * Samsung gear VR
  98617. */
  98618. GEAR_VR = 3,
  98619. /**
  98620. * Google Daydream
  98621. */
  98622. DAYDREAM = 4,
  98623. /**
  98624. * Generic
  98625. */
  98626. GENERIC = 5
  98627. }
  98628. /**
  98629. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98630. */
  98631. export interface MutableGamepadButton {
  98632. /**
  98633. * Value of the button/trigger
  98634. */
  98635. value: number;
  98636. /**
  98637. * If the button/trigger is currently touched
  98638. */
  98639. touched: boolean;
  98640. /**
  98641. * If the button/trigger is currently pressed
  98642. */
  98643. pressed: boolean;
  98644. }
  98645. /**
  98646. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98647. * @hidden
  98648. */
  98649. export interface ExtendedGamepadButton extends GamepadButton {
  98650. /**
  98651. * If the button/trigger is currently pressed
  98652. */
  98653. readonly pressed: boolean;
  98654. /**
  98655. * If the button/trigger is currently touched
  98656. */
  98657. readonly touched: boolean;
  98658. /**
  98659. * Value of the button/trigger
  98660. */
  98661. readonly value: number;
  98662. }
  98663. /** @hidden */
  98664. export interface _GamePadFactory {
  98665. /**
  98666. * Returns whether or not the current gamepad can be created for this type of controller.
  98667. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98668. * @returns true if it can be created, otherwise false
  98669. */
  98670. canCreate(gamepadInfo: any): boolean;
  98671. /**
  98672. * Creates a new instance of the Gamepad.
  98673. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98674. * @returns the new gamepad instance
  98675. */
  98676. create(gamepadInfo: any): Gamepad;
  98677. }
  98678. /**
  98679. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98680. */
  98681. export class PoseEnabledControllerHelper {
  98682. /** @hidden */
  98683. static _ControllerFactories: _GamePadFactory[];
  98684. /** @hidden */
  98685. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98686. /**
  98687. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98688. * @param vrGamepad the gamepad to initialized
  98689. * @returns a vr controller of the type the gamepad identified as
  98690. */
  98691. static InitiateController(vrGamepad: any): Gamepad;
  98692. }
  98693. /**
  98694. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98695. */
  98696. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98697. /**
  98698. * If the controller is used in a webXR session
  98699. */
  98700. isXR: boolean;
  98701. private _deviceRoomPosition;
  98702. private _deviceRoomRotationQuaternion;
  98703. /**
  98704. * The device position in babylon space
  98705. */
  98706. devicePosition: Vector3;
  98707. /**
  98708. * The device rotation in babylon space
  98709. */
  98710. deviceRotationQuaternion: Quaternion;
  98711. /**
  98712. * The scale factor of the device in babylon space
  98713. */
  98714. deviceScaleFactor: number;
  98715. /**
  98716. * (Likely devicePosition should be used instead) The device position in its room space
  98717. */
  98718. position: Vector3;
  98719. /**
  98720. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98721. */
  98722. rotationQuaternion: Quaternion;
  98723. /**
  98724. * The type of controller (Eg. Windows mixed reality)
  98725. */
  98726. controllerType: PoseEnabledControllerType;
  98727. protected _calculatedPosition: Vector3;
  98728. private _calculatedRotation;
  98729. /**
  98730. * The raw pose from the device
  98731. */
  98732. rawPose: DevicePose;
  98733. private _trackPosition;
  98734. private _maxRotationDistFromHeadset;
  98735. private _draggedRoomRotation;
  98736. /**
  98737. * @hidden
  98738. */
  98739. _disableTrackPosition(fixedPosition: Vector3): void;
  98740. /**
  98741. * Internal, the mesh attached to the controller
  98742. * @hidden
  98743. */
  98744. _mesh: Nullable<AbstractMesh>;
  98745. private _poseControlledCamera;
  98746. private _leftHandSystemQuaternion;
  98747. /**
  98748. * Internal, matrix used to convert room space to babylon space
  98749. * @hidden
  98750. */
  98751. _deviceToWorld: Matrix;
  98752. /**
  98753. * Node to be used when casting a ray from the controller
  98754. * @hidden
  98755. */
  98756. _pointingPoseNode: Nullable<TransformNode>;
  98757. /**
  98758. * Name of the child mesh that can be used to cast a ray from the controller
  98759. */
  98760. static readonly POINTING_POSE: string;
  98761. /**
  98762. * Creates a new PoseEnabledController from a gamepad
  98763. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98764. */
  98765. constructor(browserGamepad: any);
  98766. private _workingMatrix;
  98767. /**
  98768. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98769. */
  98770. update(): void;
  98771. /**
  98772. * Updates only the pose device and mesh without doing any button event checking
  98773. */
  98774. protected _updatePoseAndMesh(): void;
  98775. /**
  98776. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98777. * @param poseData raw pose fromthe device
  98778. */
  98779. updateFromDevice(poseData: DevicePose): void;
  98780. /**
  98781. * @hidden
  98782. */
  98783. _meshAttachedObservable: Observable<AbstractMesh>;
  98784. /**
  98785. * Attaches a mesh to the controller
  98786. * @param mesh the mesh to be attached
  98787. */
  98788. attachToMesh(mesh: AbstractMesh): void;
  98789. /**
  98790. * Attaches the controllers mesh to a camera
  98791. * @param camera the camera the mesh should be attached to
  98792. */
  98793. attachToPoseControlledCamera(camera: TargetCamera): void;
  98794. /**
  98795. * Disposes of the controller
  98796. */
  98797. dispose(): void;
  98798. /**
  98799. * The mesh that is attached to the controller
  98800. */
  98801. get mesh(): Nullable<AbstractMesh>;
  98802. /**
  98803. * Gets the ray of the controller in the direction the controller is pointing
  98804. * @param length the length the resulting ray should be
  98805. * @returns a ray in the direction the controller is pointing
  98806. */
  98807. getForwardRay(length?: number): Ray;
  98808. }
  98809. }
  98810. declare module BABYLON {
  98811. /**
  98812. * Defines the WebVRController object that represents controllers tracked in 3D space
  98813. */
  98814. export abstract class WebVRController extends PoseEnabledController {
  98815. /**
  98816. * Internal, the default controller model for the controller
  98817. */
  98818. protected _defaultModel: Nullable<AbstractMesh>;
  98819. /**
  98820. * Fired when the trigger state has changed
  98821. */
  98822. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98823. /**
  98824. * Fired when the main button state has changed
  98825. */
  98826. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98827. /**
  98828. * Fired when the secondary button state has changed
  98829. */
  98830. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98831. /**
  98832. * Fired when the pad state has changed
  98833. */
  98834. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98835. /**
  98836. * Fired when controllers stick values have changed
  98837. */
  98838. onPadValuesChangedObservable: Observable<StickValues>;
  98839. /**
  98840. * Array of button availible on the controller
  98841. */
  98842. protected _buttons: Array<MutableGamepadButton>;
  98843. private _onButtonStateChange;
  98844. /**
  98845. * Fired when a controller button's state has changed
  98846. * @param callback the callback containing the button that was modified
  98847. */
  98848. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98849. /**
  98850. * X and Y axis corresponding to the controllers joystick
  98851. */
  98852. pad: StickValues;
  98853. /**
  98854. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98855. */
  98856. hand: string;
  98857. /**
  98858. * The default controller model for the controller
  98859. */
  98860. get defaultModel(): Nullable<AbstractMesh>;
  98861. /**
  98862. * Creates a new WebVRController from a gamepad
  98863. * @param vrGamepad the gamepad that the WebVRController should be created from
  98864. */
  98865. constructor(vrGamepad: any);
  98866. /**
  98867. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98868. */
  98869. update(): void;
  98870. /**
  98871. * Function to be called when a button is modified
  98872. */
  98873. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98874. /**
  98875. * Loads a mesh and attaches it to the controller
  98876. * @param scene the scene the mesh should be added to
  98877. * @param meshLoaded callback for when the mesh has been loaded
  98878. */
  98879. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98880. private _setButtonValue;
  98881. private _changes;
  98882. private _checkChanges;
  98883. /**
  98884. * Disposes of th webVRCOntroller
  98885. */
  98886. dispose(): void;
  98887. }
  98888. }
  98889. declare module BABYLON {
  98890. /**
  98891. * The HemisphericLight simulates the ambient environment light,
  98892. * so the passed direction is the light reflection direction, not the incoming direction.
  98893. */
  98894. export class HemisphericLight extends Light {
  98895. /**
  98896. * The groundColor is the light in the opposite direction to the one specified during creation.
  98897. * 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.
  98898. */
  98899. groundColor: Color3;
  98900. /**
  98901. * The light reflection direction, not the incoming direction.
  98902. */
  98903. direction: Vector3;
  98904. /**
  98905. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98906. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98907. * The HemisphericLight can't cast shadows.
  98908. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98909. * @param name The friendly name of the light
  98910. * @param direction The direction of the light reflection
  98911. * @param scene The scene the light belongs to
  98912. */
  98913. constructor(name: string, direction: Vector3, scene: Scene);
  98914. protected _buildUniformLayout(): void;
  98915. /**
  98916. * Returns the string "HemisphericLight".
  98917. * @return The class name
  98918. */
  98919. getClassName(): string;
  98920. /**
  98921. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98922. * Returns the updated direction.
  98923. * @param target The target the direction should point to
  98924. * @return The computed direction
  98925. */
  98926. setDirectionToTarget(target: Vector3): Vector3;
  98927. /**
  98928. * Returns the shadow generator associated to the light.
  98929. * @returns Always null for hemispheric lights because it does not support shadows.
  98930. */
  98931. getShadowGenerator(): Nullable<IShadowGenerator>;
  98932. /**
  98933. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98934. * @param effect The effect to update
  98935. * @param lightIndex The index of the light in the effect to update
  98936. * @returns The hemispheric light
  98937. */
  98938. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98939. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98940. /**
  98941. * Computes the world matrix of the node
  98942. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98943. * @param useWasUpdatedFlag defines a reserved property
  98944. * @returns the world matrix
  98945. */
  98946. computeWorldMatrix(): Matrix;
  98947. /**
  98948. * Returns the integer 3.
  98949. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98950. */
  98951. getTypeID(): number;
  98952. /**
  98953. * Prepares the list of defines specific to the light type.
  98954. * @param defines the list of defines
  98955. * @param lightIndex defines the index of the light for the effect
  98956. */
  98957. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98958. }
  98959. }
  98960. declare module BABYLON {
  98961. /** @hidden */
  98962. export var vrMultiviewToSingleviewPixelShader: {
  98963. name: string;
  98964. shader: string;
  98965. };
  98966. }
  98967. declare module BABYLON {
  98968. /**
  98969. * Renders to multiple views with a single draw call
  98970. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98971. */
  98972. export class MultiviewRenderTarget extends RenderTargetTexture {
  98973. /**
  98974. * Creates a multiview render target
  98975. * @param scene scene used with the render target
  98976. * @param size the size of the render target (used for each view)
  98977. */
  98978. constructor(scene: Scene, size?: number | {
  98979. width: number;
  98980. height: number;
  98981. } | {
  98982. ratio: number;
  98983. });
  98984. /**
  98985. * @hidden
  98986. * @param faceIndex the face index, if its a cube texture
  98987. */
  98988. _bindFrameBuffer(faceIndex?: number): void;
  98989. /**
  98990. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98991. * @returns the view count
  98992. */
  98993. getViewCount(): number;
  98994. }
  98995. }
  98996. declare module BABYLON {
  98997. interface Engine {
  98998. /**
  98999. * Creates a new multiview render target
  99000. * @param width defines the width of the texture
  99001. * @param height defines the height of the texture
  99002. * @returns the created multiview texture
  99003. */
  99004. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99005. /**
  99006. * Binds a multiview framebuffer to be drawn to
  99007. * @param multiviewTexture texture to bind
  99008. */
  99009. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99010. }
  99011. interface Camera {
  99012. /**
  99013. * @hidden
  99014. * 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)
  99015. */
  99016. _useMultiviewToSingleView: boolean;
  99017. /**
  99018. * @hidden
  99019. * 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)
  99020. */
  99021. _multiviewTexture: Nullable<RenderTargetTexture>;
  99022. /**
  99023. * @hidden
  99024. * ensures the multiview texture of the camera exists and has the specified width/height
  99025. * @param width height to set on the multiview texture
  99026. * @param height width to set on the multiview texture
  99027. */
  99028. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99029. }
  99030. interface Scene {
  99031. /** @hidden */
  99032. _transformMatrixR: Matrix;
  99033. /** @hidden */
  99034. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99035. /** @hidden */
  99036. _createMultiviewUbo(): void;
  99037. /** @hidden */
  99038. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99039. /** @hidden */
  99040. _renderMultiviewToSingleView(camera: Camera): void;
  99041. }
  99042. }
  99043. declare module BABYLON {
  99044. /**
  99045. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99046. * This will not be used for webXR as it supports displaying texture arrays directly
  99047. */
  99048. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99049. /**
  99050. * Gets a string identifying the name of the class
  99051. * @returns "VRMultiviewToSingleviewPostProcess" string
  99052. */
  99053. getClassName(): string;
  99054. /**
  99055. * Initializes a VRMultiviewToSingleview
  99056. * @param name name of the post process
  99057. * @param camera camera to be applied to
  99058. * @param scaleFactor scaling factor to the size of the output texture
  99059. */
  99060. constructor(name: string, camera: Camera, scaleFactor: number);
  99061. }
  99062. }
  99063. declare module BABYLON {
  99064. /**
  99065. * Interface used to define additional presentation attributes
  99066. */
  99067. export interface IVRPresentationAttributes {
  99068. /**
  99069. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99070. */
  99071. highRefreshRate: boolean;
  99072. /**
  99073. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99074. */
  99075. foveationLevel: number;
  99076. }
  99077. interface Engine {
  99078. /** @hidden */
  99079. _vrDisplay: any;
  99080. /** @hidden */
  99081. _vrSupported: boolean;
  99082. /** @hidden */
  99083. _oldSize: Size;
  99084. /** @hidden */
  99085. _oldHardwareScaleFactor: number;
  99086. /** @hidden */
  99087. _vrExclusivePointerMode: boolean;
  99088. /** @hidden */
  99089. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99090. /** @hidden */
  99091. _onVRDisplayPointerRestricted: () => void;
  99092. /** @hidden */
  99093. _onVRDisplayPointerUnrestricted: () => void;
  99094. /** @hidden */
  99095. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99096. /** @hidden */
  99097. _onVrDisplayDisconnect: Nullable<() => void>;
  99098. /** @hidden */
  99099. _onVrDisplayPresentChange: Nullable<() => void>;
  99100. /**
  99101. * Observable signaled when VR display mode changes
  99102. */
  99103. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99104. /**
  99105. * Observable signaled when VR request present is complete
  99106. */
  99107. onVRRequestPresentComplete: Observable<boolean>;
  99108. /**
  99109. * Observable signaled when VR request present starts
  99110. */
  99111. onVRRequestPresentStart: Observable<Engine>;
  99112. /**
  99113. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99114. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99115. */
  99116. isInVRExclusivePointerMode: boolean;
  99117. /**
  99118. * Gets a boolean indicating if a webVR device was detected
  99119. * @returns true if a webVR device was detected
  99120. */
  99121. isVRDevicePresent(): boolean;
  99122. /**
  99123. * Gets the current webVR device
  99124. * @returns the current webVR device (or null)
  99125. */
  99126. getVRDevice(): any;
  99127. /**
  99128. * Initializes a webVR display and starts listening to display change events
  99129. * The onVRDisplayChangedObservable will be notified upon these changes
  99130. * @returns A promise containing a VRDisplay and if vr is supported
  99131. */
  99132. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99133. /** @hidden */
  99134. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99135. /**
  99136. * Gets or sets the presentation attributes used to configure VR rendering
  99137. */
  99138. vrPresentationAttributes?: IVRPresentationAttributes;
  99139. /**
  99140. * Call this function to switch to webVR mode
  99141. * Will do nothing if webVR is not supported or if there is no webVR device
  99142. * @param options the webvr options provided to the camera. mainly used for multiview
  99143. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99144. */
  99145. enableVR(options: WebVROptions): void;
  99146. /** @hidden */
  99147. _onVRFullScreenTriggered(): void;
  99148. }
  99149. }
  99150. declare module BABYLON {
  99151. /**
  99152. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99153. * IMPORTANT!! The data is right-hand data.
  99154. * @export
  99155. * @interface DevicePose
  99156. */
  99157. export interface DevicePose {
  99158. /**
  99159. * The position of the device, values in array are [x,y,z].
  99160. */
  99161. readonly position: Nullable<Float32Array>;
  99162. /**
  99163. * The linearVelocity of the device, values in array are [x,y,z].
  99164. */
  99165. readonly linearVelocity: Nullable<Float32Array>;
  99166. /**
  99167. * The linearAcceleration of the device, values in array are [x,y,z].
  99168. */
  99169. readonly linearAcceleration: Nullable<Float32Array>;
  99170. /**
  99171. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99172. */
  99173. readonly orientation: Nullable<Float32Array>;
  99174. /**
  99175. * The angularVelocity of the device, values in array are [x,y,z].
  99176. */
  99177. readonly angularVelocity: Nullable<Float32Array>;
  99178. /**
  99179. * The angularAcceleration of the device, values in array are [x,y,z].
  99180. */
  99181. readonly angularAcceleration: Nullable<Float32Array>;
  99182. }
  99183. /**
  99184. * Interface representing a pose controlled object in Babylon.
  99185. * A pose controlled object has both regular pose values as well as pose values
  99186. * from an external device such as a VR head mounted display
  99187. */
  99188. export interface PoseControlled {
  99189. /**
  99190. * The position of the object in babylon space.
  99191. */
  99192. position: Vector3;
  99193. /**
  99194. * The rotation quaternion of the object in babylon space.
  99195. */
  99196. rotationQuaternion: Quaternion;
  99197. /**
  99198. * The position of the device in babylon space.
  99199. */
  99200. devicePosition?: Vector3;
  99201. /**
  99202. * The rotation quaternion of the device in babylon space.
  99203. */
  99204. deviceRotationQuaternion: Quaternion;
  99205. /**
  99206. * The raw pose coming from the device.
  99207. */
  99208. rawPose: Nullable<DevicePose>;
  99209. /**
  99210. * The scale of the device to be used when translating from device space to babylon space.
  99211. */
  99212. deviceScaleFactor: number;
  99213. /**
  99214. * Updates the poseControlled values based on the input device pose.
  99215. * @param poseData the pose data to update the object with
  99216. */
  99217. updateFromDevice(poseData: DevicePose): void;
  99218. }
  99219. /**
  99220. * Set of options to customize the webVRCamera
  99221. */
  99222. export interface WebVROptions {
  99223. /**
  99224. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99225. */
  99226. trackPosition?: boolean;
  99227. /**
  99228. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99229. */
  99230. positionScale?: number;
  99231. /**
  99232. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99233. */
  99234. displayName?: string;
  99235. /**
  99236. * Should the native controller meshes be initialized. (default: true)
  99237. */
  99238. controllerMeshes?: boolean;
  99239. /**
  99240. * Creating a default HemiLight only on controllers. (default: true)
  99241. */
  99242. defaultLightingOnControllers?: boolean;
  99243. /**
  99244. * If you don't want to use the default VR button of the helper. (default: false)
  99245. */
  99246. useCustomVRButton?: boolean;
  99247. /**
  99248. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99249. */
  99250. customVRButton?: HTMLButtonElement;
  99251. /**
  99252. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99253. */
  99254. rayLength?: number;
  99255. /**
  99256. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99257. */
  99258. defaultHeight?: number;
  99259. /**
  99260. * If multiview should be used if availible (default: false)
  99261. */
  99262. useMultiview?: boolean;
  99263. }
  99264. /**
  99265. * This represents a WebVR camera.
  99266. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99267. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99268. */
  99269. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99270. private webVROptions;
  99271. /**
  99272. * @hidden
  99273. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99274. */
  99275. _vrDevice: any;
  99276. /**
  99277. * The rawPose of the vrDevice.
  99278. */
  99279. rawPose: Nullable<DevicePose>;
  99280. private _onVREnabled;
  99281. private _specsVersion;
  99282. private _attached;
  99283. private _frameData;
  99284. protected _descendants: Array<Node>;
  99285. private _deviceRoomPosition;
  99286. /** @hidden */
  99287. _deviceRoomRotationQuaternion: Quaternion;
  99288. private _standingMatrix;
  99289. /**
  99290. * Represents device position in babylon space.
  99291. */
  99292. devicePosition: Vector3;
  99293. /**
  99294. * Represents device rotation in babylon space.
  99295. */
  99296. deviceRotationQuaternion: Quaternion;
  99297. /**
  99298. * The scale of the device to be used when translating from device space to babylon space.
  99299. */
  99300. deviceScaleFactor: number;
  99301. private _deviceToWorld;
  99302. private _worldToDevice;
  99303. /**
  99304. * References to the webVR controllers for the vrDevice.
  99305. */
  99306. controllers: Array<WebVRController>;
  99307. /**
  99308. * Emits an event when a controller is attached.
  99309. */
  99310. onControllersAttachedObservable: Observable<WebVRController[]>;
  99311. /**
  99312. * Emits an event when a controller's mesh has been loaded;
  99313. */
  99314. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99315. /**
  99316. * Emits an event when the HMD's pose has been updated.
  99317. */
  99318. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99319. private _poseSet;
  99320. /**
  99321. * If the rig cameras be used as parent instead of this camera.
  99322. */
  99323. rigParenting: boolean;
  99324. private _lightOnControllers;
  99325. private _defaultHeight?;
  99326. /**
  99327. * Instantiates a WebVRFreeCamera.
  99328. * @param name The name of the WebVRFreeCamera
  99329. * @param position The starting anchor position for the camera
  99330. * @param scene The scene the camera belongs to
  99331. * @param webVROptions a set of customizable options for the webVRCamera
  99332. */
  99333. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99334. /**
  99335. * Gets the device distance from the ground in meters.
  99336. * @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.
  99337. */
  99338. deviceDistanceToRoomGround(): number;
  99339. /**
  99340. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99341. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99342. */
  99343. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99344. /**
  99345. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99346. * @returns A promise with a boolean set to if the standing matrix is supported.
  99347. */
  99348. useStandingMatrixAsync(): Promise<boolean>;
  99349. /**
  99350. * Disposes the camera
  99351. */
  99352. dispose(): void;
  99353. /**
  99354. * Gets a vrController by name.
  99355. * @param name The name of the controller to retreive
  99356. * @returns the controller matching the name specified or null if not found
  99357. */
  99358. getControllerByName(name: string): Nullable<WebVRController>;
  99359. private _leftController;
  99360. /**
  99361. * The controller corresponding to the users left hand.
  99362. */
  99363. get leftController(): Nullable<WebVRController>;
  99364. private _rightController;
  99365. /**
  99366. * The controller corresponding to the users right hand.
  99367. */
  99368. get rightController(): Nullable<WebVRController>;
  99369. /**
  99370. * Casts a ray forward from the vrCamera's gaze.
  99371. * @param length Length of the ray (default: 100)
  99372. * @returns the ray corresponding to the gaze
  99373. */
  99374. getForwardRay(length?: number): Ray;
  99375. /**
  99376. * @hidden
  99377. * Updates the camera based on device's frame data
  99378. */
  99379. _checkInputs(): void;
  99380. /**
  99381. * Updates the poseControlled values based on the input device pose.
  99382. * @param poseData Pose coming from the device
  99383. */
  99384. updateFromDevice(poseData: DevicePose): void;
  99385. private _htmlElementAttached;
  99386. private _detachIfAttached;
  99387. /**
  99388. * WebVR's attach control will start broadcasting frames to the device.
  99389. * Note that in certain browsers (chrome for example) this function must be called
  99390. * within a user-interaction callback. Example:
  99391. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99392. *
  99393. * @param element html element to attach the vrDevice to
  99394. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99395. */
  99396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99397. /**
  99398. * Detaches the camera from the html element and disables VR
  99399. *
  99400. * @param element html element to detach from
  99401. */
  99402. detachControl(element: HTMLElement): void;
  99403. /**
  99404. * @returns the name of this class
  99405. */
  99406. getClassName(): string;
  99407. /**
  99408. * Calls resetPose on the vrDisplay
  99409. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99410. */
  99411. resetToCurrentRotation(): void;
  99412. /**
  99413. * @hidden
  99414. * Updates the rig cameras (left and right eye)
  99415. */
  99416. _updateRigCameras(): void;
  99417. private _workingVector;
  99418. private _oneVector;
  99419. private _workingMatrix;
  99420. private updateCacheCalled;
  99421. private _correctPositionIfNotTrackPosition;
  99422. /**
  99423. * @hidden
  99424. * Updates the cached values of the camera
  99425. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99426. */
  99427. _updateCache(ignoreParentClass?: boolean): void;
  99428. /**
  99429. * @hidden
  99430. * Get current device position in babylon world
  99431. */
  99432. _computeDevicePosition(): void;
  99433. /**
  99434. * Updates the current device position and rotation in the babylon world
  99435. */
  99436. update(): void;
  99437. /**
  99438. * @hidden
  99439. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99440. * @returns an identity matrix
  99441. */
  99442. _getViewMatrix(): Matrix;
  99443. private _tmpMatrix;
  99444. /**
  99445. * This function is called by the two RIG cameras.
  99446. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99447. * @hidden
  99448. */
  99449. _getWebVRViewMatrix(): Matrix;
  99450. /** @hidden */
  99451. _getWebVRProjectionMatrix(): Matrix;
  99452. private _onGamepadConnectedObserver;
  99453. private _onGamepadDisconnectedObserver;
  99454. private _updateCacheWhenTrackingDisabledObserver;
  99455. /**
  99456. * Initializes the controllers and their meshes
  99457. */
  99458. initControllers(): void;
  99459. }
  99460. }
  99461. declare module BABYLON {
  99462. /**
  99463. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99464. *
  99465. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99466. *
  99467. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99468. */
  99469. export class MaterialHelper {
  99470. /**
  99471. * Bind the current view position to an effect.
  99472. * @param effect The effect to be bound
  99473. * @param scene The scene the eyes position is used from
  99474. * @param variableName name of the shader variable that will hold the eye position
  99475. */
  99476. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99477. /**
  99478. * Helps preparing the defines values about the UVs in used in the effect.
  99479. * UVs are shared as much as we can accross channels in the shaders.
  99480. * @param texture The texture we are preparing the UVs for
  99481. * @param defines The defines to update
  99482. * @param key The channel key "diffuse", "specular"... used in the shader
  99483. */
  99484. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99485. /**
  99486. * Binds a texture matrix value to its corrsponding uniform
  99487. * @param texture The texture to bind the matrix for
  99488. * @param uniformBuffer The uniform buffer receivin the data
  99489. * @param key The channel key "diffuse", "specular"... used in the shader
  99490. */
  99491. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99492. /**
  99493. * Gets the current status of the fog (should it be enabled?)
  99494. * @param mesh defines the mesh to evaluate for fog support
  99495. * @param scene defines the hosting scene
  99496. * @returns true if fog must be enabled
  99497. */
  99498. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99499. /**
  99500. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99501. * @param mesh defines the current mesh
  99502. * @param scene defines the current scene
  99503. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  99504. * @param pointsCloud defines if point cloud rendering has to be turned on
  99505. * @param fogEnabled defines if fog has to be turned on
  99506. * @param alphaTest defines if alpha testing has to be turned on
  99507. * @param defines defines the current list of defines
  99508. */
  99509. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  99510. /**
  99511. * Helper used to prepare the list of defines associated with frame values for shader compilation
  99512. * @param scene defines the current scene
  99513. * @param engine defines the current engine
  99514. * @param defines specifies the list of active defines
  99515. * @param useInstances defines if instances have to be turned on
  99516. * @param useClipPlane defines if clip plane have to be turned on
  99517. * @param useInstances defines if instances have to be turned on
  99518. * @param useThinInstances defines if thin instances have to be turned on
  99519. */
  99520. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  99521. /**
  99522. * Prepares the defines for bones
  99523. * @param mesh The mesh containing the geometry data we will draw
  99524. * @param defines The defines to update
  99525. */
  99526. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  99527. /**
  99528. * Prepares the defines for morph targets
  99529. * @param mesh The mesh containing the geometry data we will draw
  99530. * @param defines The defines to update
  99531. */
  99532. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  99533. /**
  99534. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  99535. * @param mesh The mesh containing the geometry data we will draw
  99536. * @param defines The defines to update
  99537. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  99538. * @param useBones Precise whether bones should be used or not (override mesh info)
  99539. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  99540. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  99541. * @returns false if defines are considered not dirty and have not been checked
  99542. */
  99543. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  99544. /**
  99545. * Prepares the defines related to multiview
  99546. * @param scene The scene we are intending to draw
  99547. * @param defines The defines to update
  99548. */
  99549. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  99550. /**
  99551. * Prepares the defines related to the prepass
  99552. * @param scene The scene we are intending to draw
  99553. * @param defines The defines to update
  99554. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  99555. */
  99556. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  99557. /**
  99558. * Prepares the defines related to the light information passed in parameter
  99559. * @param scene The scene we are intending to draw
  99560. * @param mesh The mesh the effect is compiling for
  99561. * @param light The light the effect is compiling for
  99562. * @param lightIndex The index of the light
  99563. * @param defines The defines to update
  99564. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99565. * @param state Defines the current state regarding what is needed (normals, etc...)
  99566. */
  99567. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99568. needNormals: boolean;
  99569. needRebuild: boolean;
  99570. shadowEnabled: boolean;
  99571. specularEnabled: boolean;
  99572. lightmapMode: boolean;
  99573. }): void;
  99574. /**
  99575. * Prepares the defines related to the light information passed in parameter
  99576. * @param scene The scene we are intending to draw
  99577. * @param mesh The mesh the effect is compiling for
  99578. * @param defines The defines to update
  99579. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99580. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99581. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99582. * @returns true if normals will be required for the rest of the effect
  99583. */
  99584. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99585. /**
  99586. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99587. * @param lightIndex defines the light index
  99588. * @param uniformsList The uniform list
  99589. * @param samplersList The sampler list
  99590. * @param projectedLightTexture defines if projected texture must be used
  99591. * @param uniformBuffersList defines an optional list of uniform buffers
  99592. */
  99593. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99594. /**
  99595. * Prepares the uniforms and samplers list to be used in the effect
  99596. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99597. * @param samplersList The sampler list
  99598. * @param defines The defines helping in the list generation
  99599. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99600. */
  99601. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99602. /**
  99603. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99604. * @param defines The defines to update while falling back
  99605. * @param fallbacks The authorized effect fallbacks
  99606. * @param maxSimultaneousLights The maximum number of lights allowed
  99607. * @param rank the current rank of the Effect
  99608. * @returns The newly affected rank
  99609. */
  99610. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99611. private static _TmpMorphInfluencers;
  99612. /**
  99613. * Prepares the list of attributes required for morph targets according to the effect defines.
  99614. * @param attribs The current list of supported attribs
  99615. * @param mesh The mesh to prepare the morph targets attributes for
  99616. * @param influencers The number of influencers
  99617. */
  99618. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99619. /**
  99620. * Prepares the list of attributes required for morph targets according to the effect defines.
  99621. * @param attribs The current list of supported attribs
  99622. * @param mesh The mesh to prepare the morph targets attributes for
  99623. * @param defines The current Defines of the effect
  99624. */
  99625. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99626. /**
  99627. * Prepares the list of attributes required for bones according to the effect defines.
  99628. * @param attribs The current list of supported attribs
  99629. * @param mesh The mesh to prepare the bones attributes for
  99630. * @param defines The current Defines of the effect
  99631. * @param fallbacks The current efffect fallback strategy
  99632. */
  99633. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99634. /**
  99635. * Check and prepare the list of attributes required for instances according to the effect defines.
  99636. * @param attribs The current list of supported attribs
  99637. * @param defines The current MaterialDefines of the effect
  99638. */
  99639. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99640. /**
  99641. * Add the list of attributes required for instances to the attribs array.
  99642. * @param attribs The current list of supported attribs
  99643. */
  99644. static PushAttributesForInstances(attribs: string[]): void;
  99645. /**
  99646. * Binds the light information to the effect.
  99647. * @param light The light containing the generator
  99648. * @param effect The effect we are binding the data to
  99649. * @param lightIndex The light index in the effect used to render
  99650. */
  99651. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99652. /**
  99653. * Binds the lights information from the scene to the effect for the given mesh.
  99654. * @param light Light to bind
  99655. * @param lightIndex Light index
  99656. * @param scene The scene where the light belongs to
  99657. * @param effect The effect we are binding the data to
  99658. * @param useSpecular Defines if specular is supported
  99659. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99660. */
  99661. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99662. /**
  99663. * Binds the lights information from the scene to the effect for the given mesh.
  99664. * @param scene The scene the lights belongs to
  99665. * @param mesh The mesh we are binding the information to render
  99666. * @param effect The effect we are binding the data to
  99667. * @param defines The generated defines for the effect
  99668. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99669. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99670. */
  99671. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99672. private static _tempFogColor;
  99673. /**
  99674. * Binds the fog information from the scene to the effect for the given mesh.
  99675. * @param scene The scene the lights belongs to
  99676. * @param mesh The mesh we are binding the information to render
  99677. * @param effect The effect we are binding the data to
  99678. * @param linearSpace Defines if the fog effect is applied in linear space
  99679. */
  99680. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99681. /**
  99682. * Binds the bones information from the mesh to the effect.
  99683. * @param mesh The mesh we are binding the information to render
  99684. * @param effect The effect we are binding the data to
  99685. */
  99686. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99687. /**
  99688. * Binds the morph targets information from the mesh to the effect.
  99689. * @param abstractMesh The mesh we are binding the information to render
  99690. * @param effect The effect we are binding the data to
  99691. */
  99692. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99693. /**
  99694. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99695. * @param defines The generated defines used in the effect
  99696. * @param effect The effect we are binding the data to
  99697. * @param scene The scene we are willing to render with logarithmic scale for
  99698. */
  99699. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99700. /**
  99701. * Binds the clip plane information from the scene to the effect.
  99702. * @param scene The scene the clip plane information are extracted from
  99703. * @param effect The effect we are binding the data to
  99704. */
  99705. static BindClipPlane(effect: Effect, scene: Scene): void;
  99706. }
  99707. }
  99708. declare module BABYLON {
  99709. /**
  99710. * Block used to expose an input value
  99711. */
  99712. export class InputBlock extends NodeMaterialBlock {
  99713. private _mode;
  99714. private _associatedVariableName;
  99715. private _storedValue;
  99716. private _valueCallback;
  99717. private _type;
  99718. private _animationType;
  99719. /** Gets or set a value used to limit the range of float values */
  99720. min: number;
  99721. /** Gets or set a value used to limit the range of float values */
  99722. max: number;
  99723. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99724. isBoolean: boolean;
  99725. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99726. matrixMode: number;
  99727. /** @hidden */
  99728. _systemValue: Nullable<NodeMaterialSystemValues>;
  99729. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99730. visibleInInspector: boolean;
  99731. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99732. isConstant: boolean;
  99733. /** Gets or sets the group to use to display this block in the Inspector */
  99734. groupInInspector: string;
  99735. /** Gets an observable raised when the value is changed */
  99736. onValueChangedObservable: Observable<InputBlock>;
  99737. /**
  99738. * Gets or sets the connection point type (default is float)
  99739. */
  99740. get type(): NodeMaterialBlockConnectionPointTypes;
  99741. /**
  99742. * Creates a new InputBlock
  99743. * @param name defines the block name
  99744. * @param target defines the target of that block (Vertex by default)
  99745. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99746. */
  99747. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99748. /**
  99749. * Validates if a name is a reserve word.
  99750. * @param newName the new name to be given to the node.
  99751. * @returns false if the name is a reserve word, else true.
  99752. */
  99753. validateBlockName(newName: string): boolean;
  99754. /**
  99755. * Gets the output component
  99756. */
  99757. get output(): NodeMaterialConnectionPoint;
  99758. /**
  99759. * Set the source of this connection point to a vertex attribute
  99760. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99761. * @returns the current connection point
  99762. */
  99763. setAsAttribute(attributeName?: string): InputBlock;
  99764. /**
  99765. * Set the source of this connection point to a system value
  99766. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99767. * @returns the current connection point
  99768. */
  99769. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99770. /**
  99771. * Gets or sets the value of that point.
  99772. * Please note that this value will be ignored if valueCallback is defined
  99773. */
  99774. get value(): any;
  99775. set value(value: any);
  99776. /**
  99777. * Gets or sets a callback used to get the value of that point.
  99778. * Please note that setting this value will force the connection point to ignore the value property
  99779. */
  99780. get valueCallback(): () => any;
  99781. set valueCallback(value: () => any);
  99782. /**
  99783. * Gets or sets the associated variable name in the shader
  99784. */
  99785. get associatedVariableName(): string;
  99786. set associatedVariableName(value: string);
  99787. /** Gets or sets the type of animation applied to the input */
  99788. get animationType(): AnimatedInputBlockTypes;
  99789. set animationType(value: AnimatedInputBlockTypes);
  99790. /**
  99791. * Gets a boolean indicating that this connection point not defined yet
  99792. */
  99793. get isUndefined(): boolean;
  99794. /**
  99795. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99796. * In this case the connection point name must be the name of the uniform to use.
  99797. * Can only be set on inputs
  99798. */
  99799. get isUniform(): boolean;
  99800. set isUniform(value: boolean);
  99801. /**
  99802. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99803. * In this case the connection point name must be the name of the attribute to use
  99804. * Can only be set on inputs
  99805. */
  99806. get isAttribute(): boolean;
  99807. set isAttribute(value: boolean);
  99808. /**
  99809. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99810. * Can only be set on exit points
  99811. */
  99812. get isVarying(): boolean;
  99813. set isVarying(value: boolean);
  99814. /**
  99815. * Gets a boolean indicating that the current connection point is a system value
  99816. */
  99817. get isSystemValue(): boolean;
  99818. /**
  99819. * Gets or sets the current well known value or null if not defined as a system value
  99820. */
  99821. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99822. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99823. /**
  99824. * Gets the current class name
  99825. * @returns the class name
  99826. */
  99827. getClassName(): string;
  99828. /**
  99829. * Animate the input if animationType !== None
  99830. * @param scene defines the rendering scene
  99831. */
  99832. animate(scene: Scene): void;
  99833. private _emitDefine;
  99834. initialize(state: NodeMaterialBuildState): void;
  99835. /**
  99836. * Set the input block to its default value (based on its type)
  99837. */
  99838. setDefaultValue(): void;
  99839. private _emitConstant;
  99840. /** @hidden */
  99841. get _noContextSwitch(): boolean;
  99842. private _emit;
  99843. /** @hidden */
  99844. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99845. /** @hidden */
  99846. _transmit(effect: Effect, scene: Scene): void;
  99847. protected _buildBlock(state: NodeMaterialBuildState): void;
  99848. protected _dumpPropertiesCode(): string;
  99849. dispose(): void;
  99850. serialize(): any;
  99851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99852. }
  99853. }
  99854. declare module BABYLON {
  99855. /**
  99856. * Enum used to define the compatibility state between two connection points
  99857. */
  99858. export enum NodeMaterialConnectionPointCompatibilityStates {
  99859. /** Points are compatibles */
  99860. Compatible = 0,
  99861. /** Points are incompatible because of their types */
  99862. TypeIncompatible = 1,
  99863. /** Points are incompatible because of their targets (vertex vs fragment) */
  99864. TargetIncompatible = 2
  99865. }
  99866. /**
  99867. * Defines the direction of a connection point
  99868. */
  99869. export enum NodeMaterialConnectionPointDirection {
  99870. /** Input */
  99871. Input = 0,
  99872. /** Output */
  99873. Output = 1
  99874. }
  99875. /**
  99876. * Defines a connection point for a block
  99877. */
  99878. export class NodeMaterialConnectionPoint {
  99879. /** @hidden */
  99880. _ownerBlock: NodeMaterialBlock;
  99881. /** @hidden */
  99882. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99883. private _endpoints;
  99884. private _associatedVariableName;
  99885. private _direction;
  99886. /** @hidden */
  99887. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99888. /** @hidden */
  99889. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99890. private _type;
  99891. /** @hidden */
  99892. _enforceAssociatedVariableName: boolean;
  99893. /** Gets the direction of the point */
  99894. get direction(): NodeMaterialConnectionPointDirection;
  99895. /** Indicates that this connection point needs dual validation before being connected to another point */
  99896. needDualDirectionValidation: boolean;
  99897. /**
  99898. * Gets or sets the additional types supported by this connection point
  99899. */
  99900. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99901. /**
  99902. * Gets or sets the additional types excluded by this connection point
  99903. */
  99904. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99905. /**
  99906. * Observable triggered when this point is connected
  99907. */
  99908. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99909. /**
  99910. * Gets or sets the associated variable name in the shader
  99911. */
  99912. get associatedVariableName(): string;
  99913. set associatedVariableName(value: string);
  99914. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99915. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99916. /**
  99917. * Gets or sets the connection point type (default is float)
  99918. */
  99919. get type(): NodeMaterialBlockConnectionPointTypes;
  99920. set type(value: NodeMaterialBlockConnectionPointTypes);
  99921. /**
  99922. * Gets or sets the connection point name
  99923. */
  99924. name: string;
  99925. /**
  99926. * Gets or sets the connection point name
  99927. */
  99928. displayName: string;
  99929. /**
  99930. * Gets or sets a boolean indicating that this connection point can be omitted
  99931. */
  99932. isOptional: boolean;
  99933. /**
  99934. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99935. */
  99936. isExposedOnFrame: boolean;
  99937. /**
  99938. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99939. */
  99940. define: string;
  99941. /** @hidden */
  99942. _prioritizeVertex: boolean;
  99943. private _target;
  99944. /** Gets or sets the target of that connection point */
  99945. get target(): NodeMaterialBlockTargets;
  99946. set target(value: NodeMaterialBlockTargets);
  99947. /**
  99948. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99949. */
  99950. get isConnected(): boolean;
  99951. /**
  99952. * Gets a boolean indicating that the current point is connected to an input block
  99953. */
  99954. get isConnectedToInputBlock(): boolean;
  99955. /**
  99956. * Gets a the connected input block (if any)
  99957. */
  99958. get connectInputBlock(): Nullable<InputBlock>;
  99959. /** Get the other side of the connection (if any) */
  99960. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99961. /** Get the block that owns this connection point */
  99962. get ownerBlock(): NodeMaterialBlock;
  99963. /** Get the block connected on the other side of this connection (if any) */
  99964. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99965. /** Get the block connected on the endpoints of this connection (if any) */
  99966. get connectedBlocks(): Array<NodeMaterialBlock>;
  99967. /** Gets the list of connected endpoints */
  99968. get endpoints(): NodeMaterialConnectionPoint[];
  99969. /** Gets a boolean indicating if that output point is connected to at least one input */
  99970. get hasEndpoints(): boolean;
  99971. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99972. get isConnectedInVertexShader(): boolean;
  99973. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99974. get isConnectedInFragmentShader(): boolean;
  99975. /**
  99976. * Creates a block suitable to be used as an input for this input point.
  99977. * If null is returned, a block based on the point type will be created.
  99978. * @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
  99979. */
  99980. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99981. /**
  99982. * Creates a new connection point
  99983. * @param name defines the connection point name
  99984. * @param ownerBlock defines the block hosting this connection point
  99985. * @param direction defines the direction of the connection point
  99986. */
  99987. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99988. /**
  99989. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99990. * @returns the class name
  99991. */
  99992. getClassName(): string;
  99993. /**
  99994. * Gets a boolean indicating if the current point can be connected to another point
  99995. * @param connectionPoint defines the other connection point
  99996. * @returns a boolean
  99997. */
  99998. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99999. /**
  100000. * Gets a number indicating if the current point can be connected to another point
  100001. * @param connectionPoint defines the other connection point
  100002. * @returns a number defining the compatibility state
  100003. */
  100004. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100005. /**
  100006. * Connect this point to another connection point
  100007. * @param connectionPoint defines the other connection point
  100008. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100009. * @returns the current connection point
  100010. */
  100011. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100012. /**
  100013. * Disconnect this point from one of his endpoint
  100014. * @param endpoint defines the other connection point
  100015. * @returns the current connection point
  100016. */
  100017. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100018. /**
  100019. * Serializes this point in a JSON representation
  100020. * @param isInput defines if the connection point is an input (default is true)
  100021. * @returns the serialized point object
  100022. */
  100023. serialize(isInput?: boolean): any;
  100024. /**
  100025. * Release resources
  100026. */
  100027. dispose(): void;
  100028. }
  100029. }
  100030. declare module BABYLON {
  100031. /**
  100032. * Enum used to define the material modes
  100033. */
  100034. export enum NodeMaterialModes {
  100035. /** Regular material */
  100036. Material = 0,
  100037. /** For post process */
  100038. PostProcess = 1,
  100039. /** For particle system */
  100040. Particle = 2
  100041. }
  100042. }
  100043. declare module BABYLON {
  100044. /**
  100045. * Block used to read a texture from a sampler
  100046. */
  100047. export class TextureBlock extends NodeMaterialBlock {
  100048. private _defineName;
  100049. private _linearDefineName;
  100050. private _gammaDefineName;
  100051. private _tempTextureRead;
  100052. private _samplerName;
  100053. private _transformedUVName;
  100054. private _textureTransformName;
  100055. private _textureInfoName;
  100056. private _mainUVName;
  100057. private _mainUVDefineName;
  100058. private _fragmentOnly;
  100059. /**
  100060. * Gets or sets the texture associated with the node
  100061. */
  100062. texture: Nullable<Texture>;
  100063. /**
  100064. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100065. */
  100066. convertToGammaSpace: boolean;
  100067. /**
  100068. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100069. */
  100070. convertToLinearSpace: boolean;
  100071. /**
  100072. * Create a new TextureBlock
  100073. * @param name defines the block name
  100074. */
  100075. constructor(name: string, fragmentOnly?: boolean);
  100076. /**
  100077. * Gets the current class name
  100078. * @returns the class name
  100079. */
  100080. getClassName(): string;
  100081. /**
  100082. * Gets the uv input component
  100083. */
  100084. get uv(): NodeMaterialConnectionPoint;
  100085. /**
  100086. * Gets the rgba output component
  100087. */
  100088. get rgba(): NodeMaterialConnectionPoint;
  100089. /**
  100090. * Gets the rgb output component
  100091. */
  100092. get rgb(): NodeMaterialConnectionPoint;
  100093. /**
  100094. * Gets the r output component
  100095. */
  100096. get r(): NodeMaterialConnectionPoint;
  100097. /**
  100098. * Gets the g output component
  100099. */
  100100. get g(): NodeMaterialConnectionPoint;
  100101. /**
  100102. * Gets the b output component
  100103. */
  100104. get b(): NodeMaterialConnectionPoint;
  100105. /**
  100106. * Gets the a output component
  100107. */
  100108. get a(): NodeMaterialConnectionPoint;
  100109. get target(): NodeMaterialBlockTargets;
  100110. autoConfigure(material: NodeMaterial): void;
  100111. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100113. isReady(): boolean;
  100114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100115. private get _isMixed();
  100116. private _injectVertexCode;
  100117. private _writeTextureRead;
  100118. private _writeOutput;
  100119. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100120. protected _dumpPropertiesCode(): string;
  100121. serialize(): any;
  100122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100123. }
  100124. }
  100125. declare module BABYLON {
  100126. /** @hidden */
  100127. export var reflectionFunction: {
  100128. name: string;
  100129. shader: string;
  100130. };
  100131. }
  100132. declare module BABYLON {
  100133. /**
  100134. * Base block used to read a reflection texture from a sampler
  100135. */
  100136. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100137. /** @hidden */
  100138. _define3DName: string;
  100139. /** @hidden */
  100140. _defineCubicName: string;
  100141. /** @hidden */
  100142. _defineExplicitName: string;
  100143. /** @hidden */
  100144. _defineProjectionName: string;
  100145. /** @hidden */
  100146. _defineLocalCubicName: string;
  100147. /** @hidden */
  100148. _defineSphericalName: string;
  100149. /** @hidden */
  100150. _definePlanarName: string;
  100151. /** @hidden */
  100152. _defineEquirectangularName: string;
  100153. /** @hidden */
  100154. _defineMirroredEquirectangularFixedName: string;
  100155. /** @hidden */
  100156. _defineEquirectangularFixedName: string;
  100157. /** @hidden */
  100158. _defineSkyboxName: string;
  100159. /** @hidden */
  100160. _defineOppositeZ: string;
  100161. /** @hidden */
  100162. _cubeSamplerName: string;
  100163. /** @hidden */
  100164. _2DSamplerName: string;
  100165. protected _positionUVWName: string;
  100166. protected _directionWName: string;
  100167. protected _reflectionVectorName: string;
  100168. /** @hidden */
  100169. _reflectionCoordsName: string;
  100170. /** @hidden */
  100171. _reflectionMatrixName: string;
  100172. protected _reflectionColorName: string;
  100173. /**
  100174. * Gets or sets the texture associated with the node
  100175. */
  100176. texture: Nullable<BaseTexture>;
  100177. /**
  100178. * Create a new ReflectionTextureBaseBlock
  100179. * @param name defines the block name
  100180. */
  100181. constructor(name: string);
  100182. /**
  100183. * Gets the current class name
  100184. * @returns the class name
  100185. */
  100186. getClassName(): string;
  100187. /**
  100188. * Gets the world position input component
  100189. */
  100190. abstract get position(): NodeMaterialConnectionPoint;
  100191. /**
  100192. * Gets the world position input component
  100193. */
  100194. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100195. /**
  100196. * Gets the world normal input component
  100197. */
  100198. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100199. /**
  100200. * Gets the world input component
  100201. */
  100202. abstract get world(): NodeMaterialConnectionPoint;
  100203. /**
  100204. * Gets the camera (or eye) position component
  100205. */
  100206. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100207. /**
  100208. * Gets the view input component
  100209. */
  100210. abstract get view(): NodeMaterialConnectionPoint;
  100211. protected _getTexture(): Nullable<BaseTexture>;
  100212. autoConfigure(material: NodeMaterial): void;
  100213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100214. isReady(): boolean;
  100215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100216. /**
  100217. * Gets the code to inject in the vertex shader
  100218. * @param state current state of the node material building
  100219. * @returns the shader code
  100220. */
  100221. handleVertexSide(state: NodeMaterialBuildState): string;
  100222. /**
  100223. * Handles the inits for the fragment code path
  100224. * @param state node material build state
  100225. */
  100226. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100227. /**
  100228. * Generates the reflection coords code for the fragment code path
  100229. * @param worldNormalVarName name of the world normal variable
  100230. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100231. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100232. * @returns the shader code
  100233. */
  100234. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100235. /**
  100236. * Generates the reflection color code for the fragment code path
  100237. * @param lodVarName name of the lod variable
  100238. * @param swizzleLookupTexture swizzle to use for the final color variable
  100239. * @returns the shader code
  100240. */
  100241. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100242. /**
  100243. * Generates the code corresponding to the connected output points
  100244. * @param state node material build state
  100245. * @param varName name of the variable to output
  100246. * @returns the shader code
  100247. */
  100248. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100249. protected _buildBlock(state: NodeMaterialBuildState): this;
  100250. protected _dumpPropertiesCode(): string;
  100251. serialize(): any;
  100252. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100253. }
  100254. }
  100255. declare module BABYLON {
  100256. /**
  100257. * Defines a connection point to be used for points with a custom object type
  100258. */
  100259. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100260. private _blockType;
  100261. private _blockName;
  100262. private _nameForCheking?;
  100263. /**
  100264. * Creates a new connection point
  100265. * @param name defines the connection point name
  100266. * @param ownerBlock defines the block hosting this connection point
  100267. * @param direction defines the direction of the connection point
  100268. */
  100269. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100270. /**
  100271. * Gets a number indicating if the current point can be connected to another point
  100272. * @param connectionPoint defines the other connection point
  100273. * @returns a number defining the compatibility state
  100274. */
  100275. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100276. /**
  100277. * Creates a block suitable to be used as an input for this input point.
  100278. * If null is returned, a block based on the point type will be created.
  100279. * @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
  100280. */
  100281. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100282. }
  100283. }
  100284. declare module BABYLON {
  100285. /**
  100286. * Enum defining the type of properties that can be edited in the property pages in the NME
  100287. */
  100288. export enum PropertyTypeForEdition {
  100289. /** property is a boolean */
  100290. Boolean = 0,
  100291. /** property is a float */
  100292. Float = 1,
  100293. /** property is a Vector2 */
  100294. Vector2 = 2,
  100295. /** property is a list of values */
  100296. List = 3
  100297. }
  100298. /**
  100299. * Interface that defines an option in a variable of type list
  100300. */
  100301. export interface IEditablePropertyListOption {
  100302. /** label of the option */
  100303. "label": string;
  100304. /** value of the option */
  100305. "value": number;
  100306. }
  100307. /**
  100308. * Interface that defines the options available for an editable property
  100309. */
  100310. export interface IEditablePropertyOption {
  100311. /** min value */
  100312. "min"?: number;
  100313. /** max value */
  100314. "max"?: number;
  100315. /** notifiers: indicates which actions to take when the property is changed */
  100316. "notifiers"?: {
  100317. /** the material should be rebuilt */
  100318. "rebuild"?: boolean;
  100319. /** the preview should be updated */
  100320. "update"?: boolean;
  100321. };
  100322. /** list of the options for a variable of type list */
  100323. "options"?: IEditablePropertyListOption[];
  100324. }
  100325. /**
  100326. * Interface that describes an editable property
  100327. */
  100328. export interface IPropertyDescriptionForEdition {
  100329. /** name of the property */
  100330. "propertyName": string;
  100331. /** display name of the property */
  100332. "displayName": string;
  100333. /** type of the property */
  100334. "type": PropertyTypeForEdition;
  100335. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100336. "groupName": string;
  100337. /** options for the property */
  100338. "options": IEditablePropertyOption;
  100339. }
  100340. /**
  100341. * Decorator that flags a property in a node material block as being editable
  100342. */
  100343. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100344. }
  100345. declare module BABYLON {
  100346. /**
  100347. * Block used to implement the refraction part of the sub surface module of the PBR material
  100348. */
  100349. export class RefractionBlock extends NodeMaterialBlock {
  100350. /** @hidden */
  100351. _define3DName: string;
  100352. /** @hidden */
  100353. _refractionMatrixName: string;
  100354. /** @hidden */
  100355. _defineLODRefractionAlpha: string;
  100356. /** @hidden */
  100357. _defineLinearSpecularRefraction: string;
  100358. /** @hidden */
  100359. _defineOppositeZ: string;
  100360. /** @hidden */
  100361. _cubeSamplerName: string;
  100362. /** @hidden */
  100363. _2DSamplerName: string;
  100364. /** @hidden */
  100365. _vRefractionMicrosurfaceInfosName: string;
  100366. /** @hidden */
  100367. _vRefractionInfosName: string;
  100368. private _scene;
  100369. /**
  100370. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100371. * Materials half opaque for instance using refraction could benefit from this control.
  100372. */
  100373. linkRefractionWithTransparency: boolean;
  100374. /**
  100375. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100376. */
  100377. invertRefractionY: boolean;
  100378. /**
  100379. * Gets or sets the texture associated with the node
  100380. */
  100381. texture: Nullable<BaseTexture>;
  100382. /**
  100383. * Create a new RefractionBlock
  100384. * @param name defines the block name
  100385. */
  100386. constructor(name: string);
  100387. /**
  100388. * Gets the current class name
  100389. * @returns the class name
  100390. */
  100391. getClassName(): string;
  100392. /**
  100393. * Gets the intensity input component
  100394. */
  100395. get intensity(): NodeMaterialConnectionPoint;
  100396. /**
  100397. * Gets the index of refraction input component
  100398. */
  100399. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100400. /**
  100401. * Gets the tint at distance input component
  100402. */
  100403. get tintAtDistance(): NodeMaterialConnectionPoint;
  100404. /**
  100405. * Gets the view input component
  100406. */
  100407. get view(): NodeMaterialConnectionPoint;
  100408. /**
  100409. * Gets the refraction object output component
  100410. */
  100411. get refraction(): NodeMaterialConnectionPoint;
  100412. /**
  100413. * Returns true if the block has a texture
  100414. */
  100415. get hasTexture(): boolean;
  100416. protected _getTexture(): Nullable<BaseTexture>;
  100417. autoConfigure(material: NodeMaterial): void;
  100418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100419. isReady(): boolean;
  100420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100421. /**
  100422. * Gets the main code of the block (fragment side)
  100423. * @param state current state of the node material building
  100424. * @returns the shader code
  100425. */
  100426. getCode(state: NodeMaterialBuildState): string;
  100427. protected _buildBlock(state: NodeMaterialBuildState): this;
  100428. protected _dumpPropertiesCode(): string;
  100429. serialize(): any;
  100430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100431. }
  100432. }
  100433. declare module BABYLON {
  100434. /**
  100435. * Base block used as input for post process
  100436. */
  100437. export class CurrentScreenBlock extends NodeMaterialBlock {
  100438. private _samplerName;
  100439. private _linearDefineName;
  100440. private _gammaDefineName;
  100441. private _mainUVName;
  100442. private _tempTextureRead;
  100443. /**
  100444. * Gets or sets the texture associated with the node
  100445. */
  100446. texture: Nullable<BaseTexture>;
  100447. /**
  100448. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100449. */
  100450. convertToGammaSpace: boolean;
  100451. /**
  100452. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100453. */
  100454. convertToLinearSpace: boolean;
  100455. /**
  100456. * Create a new CurrentScreenBlock
  100457. * @param name defines the block name
  100458. */
  100459. constructor(name: string);
  100460. /**
  100461. * Gets the current class name
  100462. * @returns the class name
  100463. */
  100464. getClassName(): string;
  100465. /**
  100466. * Gets the uv input component
  100467. */
  100468. get uv(): NodeMaterialConnectionPoint;
  100469. /**
  100470. * Gets the rgba output component
  100471. */
  100472. get rgba(): NodeMaterialConnectionPoint;
  100473. /**
  100474. * Gets the rgb output component
  100475. */
  100476. get rgb(): NodeMaterialConnectionPoint;
  100477. /**
  100478. * Gets the r output component
  100479. */
  100480. get r(): NodeMaterialConnectionPoint;
  100481. /**
  100482. * Gets the g output component
  100483. */
  100484. get g(): NodeMaterialConnectionPoint;
  100485. /**
  100486. * Gets the b output component
  100487. */
  100488. get b(): NodeMaterialConnectionPoint;
  100489. /**
  100490. * Gets the a output component
  100491. */
  100492. get a(): NodeMaterialConnectionPoint;
  100493. /**
  100494. * Initialize the block and prepare the context for build
  100495. * @param state defines the state that will be used for the build
  100496. */
  100497. initialize(state: NodeMaterialBuildState): void;
  100498. get target(): NodeMaterialBlockTargets;
  100499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100500. isReady(): boolean;
  100501. private _injectVertexCode;
  100502. private _writeTextureRead;
  100503. private _writeOutput;
  100504. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100505. serialize(): any;
  100506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100507. }
  100508. }
  100509. declare module BABYLON {
  100510. /**
  100511. * Base block used for the particle texture
  100512. */
  100513. export class ParticleTextureBlock extends NodeMaterialBlock {
  100514. private _samplerName;
  100515. private _linearDefineName;
  100516. private _gammaDefineName;
  100517. private _tempTextureRead;
  100518. /**
  100519. * Gets or sets the texture associated with the node
  100520. */
  100521. texture: Nullable<BaseTexture>;
  100522. /**
  100523. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100524. */
  100525. convertToGammaSpace: boolean;
  100526. /**
  100527. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100528. */
  100529. convertToLinearSpace: boolean;
  100530. /**
  100531. * Create a new ParticleTextureBlock
  100532. * @param name defines the block name
  100533. */
  100534. constructor(name: string);
  100535. /**
  100536. * Gets the current class name
  100537. * @returns the class name
  100538. */
  100539. getClassName(): string;
  100540. /**
  100541. * Gets the uv input component
  100542. */
  100543. get uv(): NodeMaterialConnectionPoint;
  100544. /**
  100545. * Gets the rgba output component
  100546. */
  100547. get rgba(): NodeMaterialConnectionPoint;
  100548. /**
  100549. * Gets the rgb output component
  100550. */
  100551. get rgb(): NodeMaterialConnectionPoint;
  100552. /**
  100553. * Gets the r output component
  100554. */
  100555. get r(): NodeMaterialConnectionPoint;
  100556. /**
  100557. * Gets the g output component
  100558. */
  100559. get g(): NodeMaterialConnectionPoint;
  100560. /**
  100561. * Gets the b output component
  100562. */
  100563. get b(): NodeMaterialConnectionPoint;
  100564. /**
  100565. * Gets the a output component
  100566. */
  100567. get a(): NodeMaterialConnectionPoint;
  100568. /**
  100569. * Initialize the block and prepare the context for build
  100570. * @param state defines the state that will be used for the build
  100571. */
  100572. initialize(state: NodeMaterialBuildState): void;
  100573. autoConfigure(material: NodeMaterial): void;
  100574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100575. isReady(): boolean;
  100576. private _writeOutput;
  100577. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100578. serialize(): any;
  100579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100580. }
  100581. }
  100582. declare module BABYLON {
  100583. /**
  100584. * Class used to store shared data between 2 NodeMaterialBuildState
  100585. */
  100586. export class NodeMaterialBuildStateSharedData {
  100587. /**
  100588. * Gets the list of emitted varyings
  100589. */
  100590. temps: string[];
  100591. /**
  100592. * Gets the list of emitted varyings
  100593. */
  100594. varyings: string[];
  100595. /**
  100596. * Gets the varying declaration string
  100597. */
  100598. varyingDeclaration: string;
  100599. /**
  100600. * Input blocks
  100601. */
  100602. inputBlocks: InputBlock[];
  100603. /**
  100604. * Input blocks
  100605. */
  100606. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100607. /**
  100608. * Bindable blocks (Blocks that need to set data to the effect)
  100609. */
  100610. bindableBlocks: NodeMaterialBlock[];
  100611. /**
  100612. * List of blocks that can provide a compilation fallback
  100613. */
  100614. blocksWithFallbacks: NodeMaterialBlock[];
  100615. /**
  100616. * List of blocks that can provide a define update
  100617. */
  100618. blocksWithDefines: NodeMaterialBlock[];
  100619. /**
  100620. * List of blocks that can provide a repeatable content
  100621. */
  100622. repeatableContentBlocks: NodeMaterialBlock[];
  100623. /**
  100624. * List of blocks that can provide a dynamic list of uniforms
  100625. */
  100626. dynamicUniformBlocks: NodeMaterialBlock[];
  100627. /**
  100628. * List of blocks that can block the isReady function for the material
  100629. */
  100630. blockingBlocks: NodeMaterialBlock[];
  100631. /**
  100632. * Gets the list of animated inputs
  100633. */
  100634. animatedInputs: InputBlock[];
  100635. /**
  100636. * Build Id used to avoid multiple recompilations
  100637. */
  100638. buildId: number;
  100639. /** List of emitted variables */
  100640. variableNames: {
  100641. [key: string]: number;
  100642. };
  100643. /** List of emitted defines */
  100644. defineNames: {
  100645. [key: string]: number;
  100646. };
  100647. /** Should emit comments? */
  100648. emitComments: boolean;
  100649. /** Emit build activity */
  100650. verbose: boolean;
  100651. /** Gets or sets the hosting scene */
  100652. scene: Scene;
  100653. /**
  100654. * Gets the compilation hints emitted at compilation time
  100655. */
  100656. hints: {
  100657. needWorldViewMatrix: boolean;
  100658. needWorldViewProjectionMatrix: boolean;
  100659. needAlphaBlending: boolean;
  100660. needAlphaTesting: boolean;
  100661. };
  100662. /**
  100663. * List of compilation checks
  100664. */
  100665. checks: {
  100666. emitVertex: boolean;
  100667. emitFragment: boolean;
  100668. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100669. };
  100670. /**
  100671. * Is vertex program allowed to be empty?
  100672. */
  100673. allowEmptyVertexProgram: boolean;
  100674. /** Creates a new shared data */
  100675. constructor();
  100676. /**
  100677. * Emits console errors and exceptions if there is a failing check
  100678. */
  100679. emitErrors(): void;
  100680. }
  100681. }
  100682. declare module BABYLON {
  100683. /**
  100684. * Class used to store node based material build state
  100685. */
  100686. export class NodeMaterialBuildState {
  100687. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100688. supportUniformBuffers: boolean;
  100689. /**
  100690. * Gets the list of emitted attributes
  100691. */
  100692. attributes: string[];
  100693. /**
  100694. * Gets the list of emitted uniforms
  100695. */
  100696. uniforms: string[];
  100697. /**
  100698. * Gets the list of emitted constants
  100699. */
  100700. constants: string[];
  100701. /**
  100702. * Gets the list of emitted samplers
  100703. */
  100704. samplers: string[];
  100705. /**
  100706. * Gets the list of emitted functions
  100707. */
  100708. functions: {
  100709. [key: string]: string;
  100710. };
  100711. /**
  100712. * Gets the list of emitted extensions
  100713. */
  100714. extensions: {
  100715. [key: string]: string;
  100716. };
  100717. /**
  100718. * Gets the target of the compilation state
  100719. */
  100720. target: NodeMaterialBlockTargets;
  100721. /**
  100722. * Gets the list of emitted counters
  100723. */
  100724. counters: {
  100725. [key: string]: number;
  100726. };
  100727. /**
  100728. * Shared data between multiple NodeMaterialBuildState instances
  100729. */
  100730. sharedData: NodeMaterialBuildStateSharedData;
  100731. /** @hidden */
  100732. _vertexState: NodeMaterialBuildState;
  100733. /** @hidden */
  100734. _attributeDeclaration: string;
  100735. /** @hidden */
  100736. _uniformDeclaration: string;
  100737. /** @hidden */
  100738. _constantDeclaration: string;
  100739. /** @hidden */
  100740. _samplerDeclaration: string;
  100741. /** @hidden */
  100742. _varyingTransfer: string;
  100743. /** @hidden */
  100744. _injectAtEnd: string;
  100745. private _repeatableContentAnchorIndex;
  100746. /** @hidden */
  100747. _builtCompilationString: string;
  100748. /**
  100749. * Gets the emitted compilation strings
  100750. */
  100751. compilationString: string;
  100752. /**
  100753. * Finalize the compilation strings
  100754. * @param state defines the current compilation state
  100755. */
  100756. finalize(state: NodeMaterialBuildState): void;
  100757. /** @hidden */
  100758. get _repeatableContentAnchor(): string;
  100759. /** @hidden */
  100760. _getFreeVariableName(prefix: string): string;
  100761. /** @hidden */
  100762. _getFreeDefineName(prefix: string): string;
  100763. /** @hidden */
  100764. _excludeVariableName(name: string): void;
  100765. /** @hidden */
  100766. _emit2DSampler(name: string): void;
  100767. /** @hidden */
  100768. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100769. /** @hidden */
  100770. _emitExtension(name: string, extension: string, define?: string): void;
  100771. /** @hidden */
  100772. _emitFunction(name: string, code: string, comments: string): void;
  100773. /** @hidden */
  100774. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100775. replaceStrings?: {
  100776. search: RegExp;
  100777. replace: string;
  100778. }[];
  100779. repeatKey?: string;
  100780. }): string;
  100781. /** @hidden */
  100782. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100783. repeatKey?: string;
  100784. removeAttributes?: boolean;
  100785. removeUniforms?: boolean;
  100786. removeVaryings?: boolean;
  100787. removeIfDef?: boolean;
  100788. replaceStrings?: {
  100789. search: RegExp;
  100790. replace: string;
  100791. }[];
  100792. }, storeKey?: string): void;
  100793. /** @hidden */
  100794. _registerTempVariable(name: string): boolean;
  100795. /** @hidden */
  100796. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100797. /** @hidden */
  100798. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100799. /** @hidden */
  100800. _emitFloat(value: number): string;
  100801. }
  100802. }
  100803. declare module BABYLON {
  100804. /**
  100805. * Helper class used to generate session unique ID
  100806. */
  100807. export class UniqueIdGenerator {
  100808. private static _UniqueIdCounter;
  100809. /**
  100810. * Gets an unique (relatively to the current scene) Id
  100811. */
  100812. static get UniqueId(): number;
  100813. }
  100814. }
  100815. declare module BABYLON {
  100816. /**
  100817. * Defines a block that can be used inside a node based material
  100818. */
  100819. export class NodeMaterialBlock {
  100820. private _buildId;
  100821. private _buildTarget;
  100822. private _target;
  100823. private _isFinalMerger;
  100824. private _isInput;
  100825. private _name;
  100826. protected _isUnique: boolean;
  100827. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100828. inputsAreExclusive: boolean;
  100829. /** @hidden */
  100830. _codeVariableName: string;
  100831. /** @hidden */
  100832. _inputs: NodeMaterialConnectionPoint[];
  100833. /** @hidden */
  100834. _outputs: NodeMaterialConnectionPoint[];
  100835. /** @hidden */
  100836. _preparationId: number;
  100837. /**
  100838. * Gets the name of the block
  100839. */
  100840. get name(): string;
  100841. /**
  100842. * Sets the name of the block. Will check if the name is valid.
  100843. */
  100844. set name(newName: string);
  100845. /**
  100846. * Gets or sets the unique id of the node
  100847. */
  100848. uniqueId: number;
  100849. /**
  100850. * Gets or sets the comments associated with this block
  100851. */
  100852. comments: string;
  100853. /**
  100854. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100855. */
  100856. get isUnique(): boolean;
  100857. /**
  100858. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100859. */
  100860. get isFinalMerger(): boolean;
  100861. /**
  100862. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100863. */
  100864. get isInput(): boolean;
  100865. /**
  100866. * Gets or sets the build Id
  100867. */
  100868. get buildId(): number;
  100869. set buildId(value: number);
  100870. /**
  100871. * Gets or sets the target of the block
  100872. */
  100873. get target(): NodeMaterialBlockTargets;
  100874. set target(value: NodeMaterialBlockTargets);
  100875. /**
  100876. * Gets the list of input points
  100877. */
  100878. get inputs(): NodeMaterialConnectionPoint[];
  100879. /** Gets the list of output points */
  100880. get outputs(): NodeMaterialConnectionPoint[];
  100881. /**
  100882. * Find an input by its name
  100883. * @param name defines the name of the input to look for
  100884. * @returns the input or null if not found
  100885. */
  100886. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100887. /**
  100888. * Find an output by its name
  100889. * @param name defines the name of the outputto look for
  100890. * @returns the output or null if not found
  100891. */
  100892. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100893. /**
  100894. * Creates a new NodeMaterialBlock
  100895. * @param name defines the block name
  100896. * @param target defines the target of that block (Vertex by default)
  100897. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100898. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100899. */
  100900. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100901. /**
  100902. * Initialize the block and prepare the context for build
  100903. * @param state defines the state that will be used for the build
  100904. */
  100905. initialize(state: NodeMaterialBuildState): void;
  100906. /**
  100907. * Bind data to effect. Will only be called for blocks with isBindable === true
  100908. * @param effect defines the effect to bind data to
  100909. * @param nodeMaterial defines the hosting NodeMaterial
  100910. * @param mesh defines the mesh that will be rendered
  100911. * @param subMesh defines the submesh that will be rendered
  100912. */
  100913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100914. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100915. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100916. protected _writeFloat(value: number): string;
  100917. /**
  100918. * Gets the current class name e.g. "NodeMaterialBlock"
  100919. * @returns the class name
  100920. */
  100921. getClassName(): string;
  100922. /**
  100923. * Register a new input. Must be called inside a block constructor
  100924. * @param name defines the connection point name
  100925. * @param type defines the connection point type
  100926. * @param isOptional defines a boolean indicating that this input can be omitted
  100927. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100928. * @param point an already created connection point. If not provided, create a new one
  100929. * @returns the current block
  100930. */
  100931. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100932. /**
  100933. * Register a new output. Must be called inside a block constructor
  100934. * @param name defines the connection point name
  100935. * @param type defines the connection point type
  100936. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100937. * @param point an already created connection point. If not provided, create a new one
  100938. * @returns the current block
  100939. */
  100940. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100941. /**
  100942. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100943. * @param forOutput defines an optional connection point to check compatibility with
  100944. * @returns the first available input or null
  100945. */
  100946. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100947. /**
  100948. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100949. * @param forBlock defines an optional block to check compatibility with
  100950. * @returns the first available input or null
  100951. */
  100952. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100953. /**
  100954. * Gets the sibling of the given output
  100955. * @param current defines the current output
  100956. * @returns the next output in the list or null
  100957. */
  100958. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100959. /**
  100960. * Connect current block with another block
  100961. * @param other defines the block to connect with
  100962. * @param options define the various options to help pick the right connections
  100963. * @returns the current block
  100964. */
  100965. connectTo(other: NodeMaterialBlock, options?: {
  100966. input?: string;
  100967. output?: string;
  100968. outputSwizzle?: string;
  100969. }): this | undefined;
  100970. protected _buildBlock(state: NodeMaterialBuildState): void;
  100971. /**
  100972. * Add uniforms, samplers and uniform buffers at compilation time
  100973. * @param state defines the state to update
  100974. * @param nodeMaterial defines the node material requesting the update
  100975. * @param defines defines the material defines to update
  100976. * @param uniformBuffers defines the list of uniform buffer names
  100977. */
  100978. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100979. /**
  100980. * Add potential fallbacks if shader compilation fails
  100981. * @param mesh defines the mesh to be rendered
  100982. * @param fallbacks defines the current prioritized list of fallbacks
  100983. */
  100984. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100985. /**
  100986. * Initialize defines for shader compilation
  100987. * @param mesh defines the mesh to be rendered
  100988. * @param nodeMaterial defines the node material requesting the update
  100989. * @param defines defines the material defines to update
  100990. * @param useInstances specifies that instances should be used
  100991. */
  100992. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100993. /**
  100994. * Update defines for shader compilation
  100995. * @param mesh defines the mesh to be rendered
  100996. * @param nodeMaterial defines the node material requesting the update
  100997. * @param defines defines the material defines to update
  100998. * @param useInstances specifies that instances should be used
  100999. * @param subMesh defines which submesh to render
  101000. */
  101001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101002. /**
  101003. * Lets the block try to connect some inputs automatically
  101004. * @param material defines the hosting NodeMaterial
  101005. */
  101006. autoConfigure(material: NodeMaterial): void;
  101007. /**
  101008. * Function called when a block is declared as repeatable content generator
  101009. * @param vertexShaderState defines the current compilation state for the vertex shader
  101010. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101011. * @param mesh defines the mesh to be rendered
  101012. * @param defines defines the material defines to update
  101013. */
  101014. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101015. /**
  101016. * Checks if the block is ready
  101017. * @param mesh defines the mesh to be rendered
  101018. * @param nodeMaterial defines the node material requesting the update
  101019. * @param defines defines the material defines to update
  101020. * @param useInstances specifies that instances should be used
  101021. * @returns true if the block is ready
  101022. */
  101023. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101024. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101025. private _processBuild;
  101026. /**
  101027. * Validates the new name for the block node.
  101028. * @param newName the new name to be given to the node.
  101029. * @returns false if the name is a reserve word, else true.
  101030. */
  101031. validateBlockName(newName: string): boolean;
  101032. /**
  101033. * Compile the current node and generate the shader code
  101034. * @param state defines the current compilation state (uniforms, samplers, current string)
  101035. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101036. * @returns true if already built
  101037. */
  101038. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101039. protected _inputRename(name: string): string;
  101040. protected _outputRename(name: string): string;
  101041. protected _dumpPropertiesCode(): string;
  101042. /** @hidden */
  101043. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101044. /** @hidden */
  101045. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101046. /**
  101047. * Clone the current block to a new identical block
  101048. * @param scene defines the hosting scene
  101049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101050. * @returns a copy of the current block
  101051. */
  101052. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101053. /**
  101054. * Serializes this block in a JSON representation
  101055. * @returns the serialized block object
  101056. */
  101057. serialize(): any;
  101058. /** @hidden */
  101059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101060. private _deserializePortDisplayNamesAndExposedOnFrame;
  101061. /**
  101062. * Release resources
  101063. */
  101064. dispose(): void;
  101065. }
  101066. }
  101067. declare module BABYLON {
  101068. /**
  101069. * Base class of materials working in push mode in babylon JS
  101070. * @hidden
  101071. */
  101072. export class PushMaterial extends Material {
  101073. protected _activeEffect: Effect;
  101074. protected _normalMatrix: Matrix;
  101075. constructor(name: string, scene: Scene);
  101076. getEffect(): Effect;
  101077. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101078. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101079. /**
  101080. * Binds the given world matrix to the active effect
  101081. *
  101082. * @param world the matrix to bind
  101083. */
  101084. bindOnlyWorldMatrix(world: Matrix): void;
  101085. /**
  101086. * Binds the given normal matrix to the active effect
  101087. *
  101088. * @param normalMatrix the matrix to bind
  101089. */
  101090. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101091. bind(world: Matrix, mesh?: Mesh): void;
  101092. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101093. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101094. }
  101095. }
  101096. declare module BABYLON {
  101097. /**
  101098. * Root class for all node material optimizers
  101099. */
  101100. export class NodeMaterialOptimizer {
  101101. /**
  101102. * Function used to optimize a NodeMaterial graph
  101103. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101104. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101105. */
  101106. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101107. }
  101108. }
  101109. declare module BABYLON {
  101110. /**
  101111. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101112. */
  101113. export class TransformBlock extends NodeMaterialBlock {
  101114. /**
  101115. * Defines the value to use to complement W value to transform it to a Vector4
  101116. */
  101117. complementW: number;
  101118. /**
  101119. * Defines the value to use to complement z value to transform it to a Vector4
  101120. */
  101121. complementZ: number;
  101122. /**
  101123. * Creates a new TransformBlock
  101124. * @param name defines the block name
  101125. */
  101126. constructor(name: string);
  101127. /**
  101128. * Gets the current class name
  101129. * @returns the class name
  101130. */
  101131. getClassName(): string;
  101132. /**
  101133. * Gets the vector input
  101134. */
  101135. get vector(): NodeMaterialConnectionPoint;
  101136. /**
  101137. * Gets the output component
  101138. */
  101139. get output(): NodeMaterialConnectionPoint;
  101140. /**
  101141. * Gets the xyz output component
  101142. */
  101143. get xyz(): NodeMaterialConnectionPoint;
  101144. /**
  101145. * Gets the matrix transform input
  101146. */
  101147. get transform(): NodeMaterialConnectionPoint;
  101148. protected _buildBlock(state: NodeMaterialBuildState): this;
  101149. /**
  101150. * Update defines for shader compilation
  101151. * @param mesh defines the mesh to be rendered
  101152. * @param nodeMaterial defines the node material requesting the update
  101153. * @param defines defines the material defines to update
  101154. * @param useInstances specifies that instances should be used
  101155. * @param subMesh defines which submesh to render
  101156. */
  101157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101158. serialize(): any;
  101159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101160. protected _dumpPropertiesCode(): string;
  101161. }
  101162. }
  101163. declare module BABYLON {
  101164. /**
  101165. * Block used to output the vertex position
  101166. */
  101167. export class VertexOutputBlock extends NodeMaterialBlock {
  101168. /**
  101169. * Creates a new VertexOutputBlock
  101170. * @param name defines the block name
  101171. */
  101172. constructor(name: string);
  101173. /**
  101174. * Gets the current class name
  101175. * @returns the class name
  101176. */
  101177. getClassName(): string;
  101178. /**
  101179. * Gets the vector input component
  101180. */
  101181. get vector(): NodeMaterialConnectionPoint;
  101182. protected _buildBlock(state: NodeMaterialBuildState): this;
  101183. }
  101184. }
  101185. declare module BABYLON {
  101186. /**
  101187. * Block used to output the final color
  101188. */
  101189. export class FragmentOutputBlock extends NodeMaterialBlock {
  101190. /**
  101191. * Create a new FragmentOutputBlock
  101192. * @param name defines the block name
  101193. */
  101194. constructor(name: string);
  101195. /**
  101196. * Gets the current class name
  101197. * @returns the class name
  101198. */
  101199. getClassName(): string;
  101200. /**
  101201. * Gets the rgba input component
  101202. */
  101203. get rgba(): NodeMaterialConnectionPoint;
  101204. /**
  101205. * Gets the rgb input component
  101206. */
  101207. get rgb(): NodeMaterialConnectionPoint;
  101208. /**
  101209. * Gets the a input component
  101210. */
  101211. get a(): NodeMaterialConnectionPoint;
  101212. protected _buildBlock(state: NodeMaterialBuildState): this;
  101213. }
  101214. }
  101215. declare module BABYLON {
  101216. /**
  101217. * Block used for the particle ramp gradient section
  101218. */
  101219. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101220. /**
  101221. * Create a new ParticleRampGradientBlock
  101222. * @param name defines the block name
  101223. */
  101224. constructor(name: string);
  101225. /**
  101226. * Gets the current class name
  101227. * @returns the class name
  101228. */
  101229. getClassName(): string;
  101230. /**
  101231. * Gets the color input component
  101232. */
  101233. get color(): NodeMaterialConnectionPoint;
  101234. /**
  101235. * Gets the rampColor output component
  101236. */
  101237. get rampColor(): NodeMaterialConnectionPoint;
  101238. /**
  101239. * Initialize the block and prepare the context for build
  101240. * @param state defines the state that will be used for the build
  101241. */
  101242. initialize(state: NodeMaterialBuildState): void;
  101243. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101244. }
  101245. }
  101246. declare module BABYLON {
  101247. /**
  101248. * Block used for the particle blend multiply section
  101249. */
  101250. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101251. /**
  101252. * Create a new ParticleBlendMultiplyBlock
  101253. * @param name defines the block name
  101254. */
  101255. constructor(name: string);
  101256. /**
  101257. * Gets the current class name
  101258. * @returns the class name
  101259. */
  101260. getClassName(): string;
  101261. /**
  101262. * Gets the color input component
  101263. */
  101264. get color(): NodeMaterialConnectionPoint;
  101265. /**
  101266. * Gets the alphaTexture input component
  101267. */
  101268. get alphaTexture(): NodeMaterialConnectionPoint;
  101269. /**
  101270. * Gets the alphaColor input component
  101271. */
  101272. get alphaColor(): NodeMaterialConnectionPoint;
  101273. /**
  101274. * Gets the blendColor output component
  101275. */
  101276. get blendColor(): NodeMaterialConnectionPoint;
  101277. /**
  101278. * Initialize the block and prepare the context for build
  101279. * @param state defines the state that will be used for the build
  101280. */
  101281. initialize(state: NodeMaterialBuildState): void;
  101282. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101283. }
  101284. }
  101285. declare module BABYLON {
  101286. /**
  101287. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101288. */
  101289. export class VectorMergerBlock extends NodeMaterialBlock {
  101290. /**
  101291. * Create a new VectorMergerBlock
  101292. * @param name defines the block name
  101293. */
  101294. constructor(name: string);
  101295. /**
  101296. * Gets the current class name
  101297. * @returns the class name
  101298. */
  101299. getClassName(): string;
  101300. /**
  101301. * Gets the xyz component (input)
  101302. */
  101303. get xyzIn(): NodeMaterialConnectionPoint;
  101304. /**
  101305. * Gets the xy component (input)
  101306. */
  101307. get xyIn(): NodeMaterialConnectionPoint;
  101308. /**
  101309. * Gets the x component (input)
  101310. */
  101311. get x(): NodeMaterialConnectionPoint;
  101312. /**
  101313. * Gets the y component (input)
  101314. */
  101315. get y(): NodeMaterialConnectionPoint;
  101316. /**
  101317. * Gets the z component (input)
  101318. */
  101319. get z(): NodeMaterialConnectionPoint;
  101320. /**
  101321. * Gets the w component (input)
  101322. */
  101323. get w(): NodeMaterialConnectionPoint;
  101324. /**
  101325. * Gets the xyzw component (output)
  101326. */
  101327. get xyzw(): NodeMaterialConnectionPoint;
  101328. /**
  101329. * Gets the xyz component (output)
  101330. */
  101331. get xyzOut(): NodeMaterialConnectionPoint;
  101332. /**
  101333. * Gets the xy component (output)
  101334. */
  101335. get xyOut(): NodeMaterialConnectionPoint;
  101336. /**
  101337. * Gets the xy component (output)
  101338. * @deprecated Please use xyOut instead.
  101339. */
  101340. get xy(): NodeMaterialConnectionPoint;
  101341. /**
  101342. * Gets the xyz component (output)
  101343. * @deprecated Please use xyzOut instead.
  101344. */
  101345. get xyz(): NodeMaterialConnectionPoint;
  101346. protected _buildBlock(state: NodeMaterialBuildState): this;
  101347. }
  101348. }
  101349. declare module BABYLON {
  101350. /**
  101351. * Block used to remap a float from a range to a new one
  101352. */
  101353. export class RemapBlock extends NodeMaterialBlock {
  101354. /**
  101355. * Gets or sets the source range
  101356. */
  101357. sourceRange: Vector2;
  101358. /**
  101359. * Gets or sets the target range
  101360. */
  101361. targetRange: Vector2;
  101362. /**
  101363. * Creates a new RemapBlock
  101364. * @param name defines the block name
  101365. */
  101366. constructor(name: string);
  101367. /**
  101368. * Gets the current class name
  101369. * @returns the class name
  101370. */
  101371. getClassName(): string;
  101372. /**
  101373. * Gets the input component
  101374. */
  101375. get input(): NodeMaterialConnectionPoint;
  101376. /**
  101377. * Gets the source min input component
  101378. */
  101379. get sourceMin(): NodeMaterialConnectionPoint;
  101380. /**
  101381. * Gets the source max input component
  101382. */
  101383. get sourceMax(): NodeMaterialConnectionPoint;
  101384. /**
  101385. * Gets the target min input component
  101386. */
  101387. get targetMin(): NodeMaterialConnectionPoint;
  101388. /**
  101389. * Gets the target max input component
  101390. */
  101391. get targetMax(): NodeMaterialConnectionPoint;
  101392. /**
  101393. * Gets the output component
  101394. */
  101395. get output(): NodeMaterialConnectionPoint;
  101396. protected _buildBlock(state: NodeMaterialBuildState): this;
  101397. protected _dumpPropertiesCode(): string;
  101398. serialize(): any;
  101399. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101400. }
  101401. }
  101402. declare module BABYLON {
  101403. /**
  101404. * Block used to multiply 2 values
  101405. */
  101406. export class MultiplyBlock extends NodeMaterialBlock {
  101407. /**
  101408. * Creates a new MultiplyBlock
  101409. * @param name defines the block name
  101410. */
  101411. constructor(name: string);
  101412. /**
  101413. * Gets the current class name
  101414. * @returns the class name
  101415. */
  101416. getClassName(): string;
  101417. /**
  101418. * Gets the left operand input component
  101419. */
  101420. get left(): NodeMaterialConnectionPoint;
  101421. /**
  101422. * Gets the right operand input component
  101423. */
  101424. get right(): NodeMaterialConnectionPoint;
  101425. /**
  101426. * Gets the output component
  101427. */
  101428. get output(): NodeMaterialConnectionPoint;
  101429. protected _buildBlock(state: NodeMaterialBuildState): this;
  101430. }
  101431. }
  101432. declare module BABYLON {
  101433. /**
  101434. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101435. */
  101436. export class ColorSplitterBlock extends NodeMaterialBlock {
  101437. /**
  101438. * Create a new ColorSplitterBlock
  101439. * @param name defines the block name
  101440. */
  101441. constructor(name: string);
  101442. /**
  101443. * Gets the current class name
  101444. * @returns the class name
  101445. */
  101446. getClassName(): string;
  101447. /**
  101448. * Gets the rgba component (input)
  101449. */
  101450. get rgba(): NodeMaterialConnectionPoint;
  101451. /**
  101452. * Gets the rgb component (input)
  101453. */
  101454. get rgbIn(): NodeMaterialConnectionPoint;
  101455. /**
  101456. * Gets the rgb component (output)
  101457. */
  101458. get rgbOut(): NodeMaterialConnectionPoint;
  101459. /**
  101460. * Gets the r component (output)
  101461. */
  101462. get r(): NodeMaterialConnectionPoint;
  101463. /**
  101464. * Gets the g component (output)
  101465. */
  101466. get g(): NodeMaterialConnectionPoint;
  101467. /**
  101468. * Gets the b component (output)
  101469. */
  101470. get b(): NodeMaterialConnectionPoint;
  101471. /**
  101472. * Gets the a component (output)
  101473. */
  101474. get a(): NodeMaterialConnectionPoint;
  101475. protected _inputRename(name: string): string;
  101476. protected _outputRename(name: string): string;
  101477. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101478. }
  101479. }
  101480. declare module BABYLON {
  101481. /**
  101482. * Interface used to configure the node material editor
  101483. */
  101484. export interface INodeMaterialEditorOptions {
  101485. /** Define the URl to load node editor script */
  101486. editorURL?: string;
  101487. }
  101488. /** @hidden */
  101489. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101490. NORMAL: boolean;
  101491. TANGENT: boolean;
  101492. UV1: boolean;
  101493. /** BONES */
  101494. NUM_BONE_INFLUENCERS: number;
  101495. BonesPerMesh: number;
  101496. BONETEXTURE: boolean;
  101497. /** MORPH TARGETS */
  101498. MORPHTARGETS: boolean;
  101499. MORPHTARGETS_NORMAL: boolean;
  101500. MORPHTARGETS_TANGENT: boolean;
  101501. MORPHTARGETS_UV: boolean;
  101502. NUM_MORPH_INFLUENCERS: number;
  101503. /** IMAGE PROCESSING */
  101504. IMAGEPROCESSING: boolean;
  101505. VIGNETTE: boolean;
  101506. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101507. VIGNETTEBLENDMODEOPAQUE: boolean;
  101508. TONEMAPPING: boolean;
  101509. TONEMAPPING_ACES: boolean;
  101510. CONTRAST: boolean;
  101511. EXPOSURE: boolean;
  101512. COLORCURVES: boolean;
  101513. COLORGRADING: boolean;
  101514. COLORGRADING3D: boolean;
  101515. SAMPLER3DGREENDEPTH: boolean;
  101516. SAMPLER3DBGRMAP: boolean;
  101517. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101518. /** MISC. */
  101519. BUMPDIRECTUV: number;
  101520. constructor();
  101521. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  101522. }
  101523. /**
  101524. * Class used to configure NodeMaterial
  101525. */
  101526. export interface INodeMaterialOptions {
  101527. /**
  101528. * Defines if blocks should emit comments
  101529. */
  101530. emitComments: boolean;
  101531. }
  101532. /**
  101533. * Class used to create a node based material built by assembling shader blocks
  101534. */
  101535. export class NodeMaterial extends PushMaterial {
  101536. private static _BuildIdGenerator;
  101537. private _options;
  101538. private _vertexCompilationState;
  101539. private _fragmentCompilationState;
  101540. private _sharedData;
  101541. private _buildId;
  101542. private _buildWasSuccessful;
  101543. private _cachedWorldViewMatrix;
  101544. private _cachedWorldViewProjectionMatrix;
  101545. private _optimizers;
  101546. private _animationFrame;
  101547. /** Define the Url to load node editor script */
  101548. static EditorURL: string;
  101549. /** Define the Url to load snippets */
  101550. static SnippetUrl: string;
  101551. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  101552. static IgnoreTexturesAtLoadTime: boolean;
  101553. private BJSNODEMATERIALEDITOR;
  101554. /** Get the inspector from bundle or global */
  101555. private _getGlobalNodeMaterialEditor;
  101556. /**
  101557. * Snippet ID if the material was created from the snippet server
  101558. */
  101559. snippetId: string;
  101560. /**
  101561. * Gets or sets data used by visual editor
  101562. * @see https://nme.babylonjs.com
  101563. */
  101564. editorData: any;
  101565. /**
  101566. * 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)
  101567. */
  101568. ignoreAlpha: boolean;
  101569. /**
  101570. * Defines the maximum number of lights that can be used in the material
  101571. */
  101572. maxSimultaneousLights: number;
  101573. /**
  101574. * Observable raised when the material is built
  101575. */
  101576. onBuildObservable: Observable<NodeMaterial>;
  101577. /**
  101578. * Gets or sets the root nodes of the material vertex shader
  101579. */
  101580. _vertexOutputNodes: NodeMaterialBlock[];
  101581. /**
  101582. * Gets or sets the root nodes of the material fragment (pixel) shader
  101583. */
  101584. _fragmentOutputNodes: NodeMaterialBlock[];
  101585. /** Gets or sets options to control the node material overall behavior */
  101586. get options(): INodeMaterialOptions;
  101587. set options(options: INodeMaterialOptions);
  101588. /**
  101589. * Default configuration related to image processing available in the standard Material.
  101590. */
  101591. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101592. /**
  101593. * Gets the image processing configuration used either in this material.
  101594. */
  101595. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101596. /**
  101597. * Sets the Default image processing configuration used either in the this material.
  101598. *
  101599. * If sets to null, the scene one is in use.
  101600. */
  101601. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101602. /**
  101603. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101604. */
  101605. attachedBlocks: NodeMaterialBlock[];
  101606. /**
  101607. * Specifies the mode of the node material
  101608. * @hidden
  101609. */
  101610. _mode: NodeMaterialModes;
  101611. /**
  101612. * Gets the mode property
  101613. */
  101614. get mode(): NodeMaterialModes;
  101615. /**
  101616. * Create a new node based material
  101617. * @param name defines the material name
  101618. * @param scene defines the hosting scene
  101619. * @param options defines creation option
  101620. */
  101621. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101622. /**
  101623. * Gets the current class name of the material e.g. "NodeMaterial"
  101624. * @returns the class name
  101625. */
  101626. getClassName(): string;
  101627. /**
  101628. * Keep track of the image processing observer to allow dispose and replace.
  101629. */
  101630. private _imageProcessingObserver;
  101631. /**
  101632. * Attaches a new image processing configuration to the Standard Material.
  101633. * @param configuration
  101634. */
  101635. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101636. /**
  101637. * Get a block by its name
  101638. * @param name defines the name of the block to retrieve
  101639. * @returns the required block or null if not found
  101640. */
  101641. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101642. /**
  101643. * Get a block by its name
  101644. * @param predicate defines the predicate used to find the good candidate
  101645. * @returns the required block or null if not found
  101646. */
  101647. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101648. /**
  101649. * Get an input block by its name
  101650. * @param predicate defines the predicate used to find the good candidate
  101651. * @returns the required input block or null if not found
  101652. */
  101653. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101654. /**
  101655. * Gets the list of input blocks attached to this material
  101656. * @returns an array of InputBlocks
  101657. */
  101658. getInputBlocks(): InputBlock[];
  101659. /**
  101660. * Adds a new optimizer to the list of optimizers
  101661. * @param optimizer defines the optimizers to add
  101662. * @returns the current material
  101663. */
  101664. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101665. /**
  101666. * Remove an optimizer from the list of optimizers
  101667. * @param optimizer defines the optimizers to remove
  101668. * @returns the current material
  101669. */
  101670. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101671. /**
  101672. * Add a new block to the list of output nodes
  101673. * @param node defines the node to add
  101674. * @returns the current material
  101675. */
  101676. addOutputNode(node: NodeMaterialBlock): this;
  101677. /**
  101678. * Remove a block from the list of root nodes
  101679. * @param node defines the node to remove
  101680. * @returns the current material
  101681. */
  101682. removeOutputNode(node: NodeMaterialBlock): this;
  101683. private _addVertexOutputNode;
  101684. private _removeVertexOutputNode;
  101685. private _addFragmentOutputNode;
  101686. private _removeFragmentOutputNode;
  101687. /**
  101688. * Specifies if the material will require alpha blending
  101689. * @returns a boolean specifying if alpha blending is needed
  101690. */
  101691. needAlphaBlending(): boolean;
  101692. /**
  101693. * Specifies if this material should be rendered in alpha test mode
  101694. * @returns a boolean specifying if an alpha test is needed.
  101695. */
  101696. needAlphaTesting(): boolean;
  101697. private _initializeBlock;
  101698. private _resetDualBlocks;
  101699. /**
  101700. * Remove a block from the current node material
  101701. * @param block defines the block to remove
  101702. */
  101703. removeBlock(block: NodeMaterialBlock): void;
  101704. /**
  101705. * Build the material and generates the inner effect
  101706. * @param verbose defines if the build should log activity
  101707. */
  101708. build(verbose?: boolean): void;
  101709. /**
  101710. * Runs an otpimization phase to try to improve the shader code
  101711. */
  101712. optimize(): void;
  101713. private _prepareDefinesForAttributes;
  101714. /**
  101715. * Create a post process from the material
  101716. * @param camera The camera to apply the render pass to.
  101717. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101719. * @param engine The engine which the post process will be applied. (default: current engine)
  101720. * @param reusable If the post process can be reused on the same frame. (default: false)
  101721. * @param textureType Type of textures used when performing the post process. (default: 0)
  101722. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101723. * @returns the post process created
  101724. */
  101725. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101726. /**
  101727. * Create the post process effect from the material
  101728. * @param postProcess The post process to create the effect for
  101729. */
  101730. createEffectForPostProcess(postProcess: PostProcess): void;
  101731. private _createEffectOrPostProcess;
  101732. private _createEffectForParticles;
  101733. /**
  101734. * Create the effect to be used as the custom effect for a particle system
  101735. * @param particleSystem Particle system to create the effect for
  101736. * @param onCompiled defines a function to call when the effect creation is successful
  101737. * @param onError defines a function to call when the effect creation has failed
  101738. */
  101739. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101740. private _processDefines;
  101741. /**
  101742. * Get if the submesh is ready to be used and all its information available.
  101743. * Child classes can use it to update shaders
  101744. * @param mesh defines the mesh to check
  101745. * @param subMesh defines which submesh to check
  101746. * @param useInstances specifies that instances should be used
  101747. * @returns a boolean indicating that the submesh is ready or not
  101748. */
  101749. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101750. /**
  101751. * Get a string representing the shaders built by the current node graph
  101752. */
  101753. get compiledShaders(): string;
  101754. /**
  101755. * Binds the world matrix to the material
  101756. * @param world defines the world transformation matrix
  101757. */
  101758. bindOnlyWorldMatrix(world: Matrix): void;
  101759. /**
  101760. * Binds the submesh to this material by preparing the effect and shader to draw
  101761. * @param world defines the world transformation matrix
  101762. * @param mesh defines the mesh containing the submesh
  101763. * @param subMesh defines the submesh to bind the material to
  101764. */
  101765. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101766. /**
  101767. * Gets the active textures from the material
  101768. * @returns an array of textures
  101769. */
  101770. getActiveTextures(): BaseTexture[];
  101771. /**
  101772. * Gets the list of texture blocks
  101773. * @returns an array of texture blocks
  101774. */
  101775. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101776. /**
  101777. * Specifies if the material uses a texture
  101778. * @param texture defines the texture to check against the material
  101779. * @returns a boolean specifying if the material uses the texture
  101780. */
  101781. hasTexture(texture: BaseTexture): boolean;
  101782. /**
  101783. * Disposes the material
  101784. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101785. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101786. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101787. */
  101788. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101789. /** Creates the node editor window. */
  101790. private _createNodeEditor;
  101791. /**
  101792. * Launch the node material editor
  101793. * @param config Define the configuration of the editor
  101794. * @return a promise fulfilled when the node editor is visible
  101795. */
  101796. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101797. /**
  101798. * Clear the current material
  101799. */
  101800. clear(): void;
  101801. /**
  101802. * Clear the current material and set it to a default state
  101803. */
  101804. setToDefault(): void;
  101805. /**
  101806. * Clear the current material and set it to a default state for post process
  101807. */
  101808. setToDefaultPostProcess(): void;
  101809. /**
  101810. * Clear the current material and set it to a default state for particle
  101811. */
  101812. setToDefaultParticle(): void;
  101813. /**
  101814. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101815. * @param url defines the url to load from
  101816. * @returns a promise that will fullfil when the material is fully loaded
  101817. */
  101818. loadAsync(url: string): Promise<void>;
  101819. private _gatherBlocks;
  101820. /**
  101821. * Generate a string containing the code declaration required to create an equivalent of this material
  101822. * @returns a string
  101823. */
  101824. generateCode(): string;
  101825. /**
  101826. * Serializes this material in a JSON representation
  101827. * @returns the serialized material object
  101828. */
  101829. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101830. private _restoreConnections;
  101831. /**
  101832. * Clear the current graph and load a new one from a serialization object
  101833. * @param source defines the JSON representation of the material
  101834. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101835. * @param merge defines whether or not the source must be merged or replace the current content
  101836. */
  101837. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101838. /**
  101839. * Makes a duplicate of the current material.
  101840. * @param name - name to use for the new material.
  101841. */
  101842. clone(name: string): NodeMaterial;
  101843. /**
  101844. * Creates a node material from parsed material data
  101845. * @param source defines the JSON representation of the material
  101846. * @param scene defines the hosting scene
  101847. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101848. * @returns a new node material
  101849. */
  101850. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101851. /**
  101852. * Creates a node material from a snippet saved in a remote file
  101853. * @param name defines the name of the material to create
  101854. * @param url defines the url to load from
  101855. * @param scene defines the hosting scene
  101856. * @returns a promise that will resolve to the new node material
  101857. */
  101858. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101859. /**
  101860. * Creates a node material from a snippet saved by the node material editor
  101861. * @param snippetId defines the snippet to load
  101862. * @param scene defines the hosting scene
  101863. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101864. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101865. * @returns a promise that will resolve to the new node material
  101866. */
  101867. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101868. /**
  101869. * Creates a new node material set to default basic configuration
  101870. * @param name defines the name of the material
  101871. * @param scene defines the hosting scene
  101872. * @returns a new NodeMaterial
  101873. */
  101874. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101875. }
  101876. }
  101877. declare module BABYLON {
  101878. /**
  101879. * Size options for a post process
  101880. */
  101881. export type PostProcessOptions = {
  101882. width: number;
  101883. height: number;
  101884. };
  101885. /**
  101886. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101887. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101888. */
  101889. export class PostProcess {
  101890. /**
  101891. * Gets or sets the unique id of the post process
  101892. */
  101893. uniqueId: number;
  101894. /** Name of the PostProcess. */
  101895. name: string;
  101896. /**
  101897. * Width of the texture to apply the post process on
  101898. */
  101899. width: number;
  101900. /**
  101901. * Height of the texture to apply the post process on
  101902. */
  101903. height: number;
  101904. /**
  101905. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101906. */
  101907. nodeMaterialSource: Nullable<NodeMaterial>;
  101908. /**
  101909. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101910. * @hidden
  101911. */
  101912. _outputTexture: Nullable<InternalTexture>;
  101913. /**
  101914. * Sampling mode used by the shader
  101915. * See https://doc.babylonjs.com/classes/3.1/texture
  101916. */
  101917. renderTargetSamplingMode: number;
  101918. /**
  101919. * Clear color to use when screen clearing
  101920. */
  101921. clearColor: Color4;
  101922. /**
  101923. * If the buffer needs to be cleared before applying the post process. (default: true)
  101924. * Should be set to false if shader will overwrite all previous pixels.
  101925. */
  101926. autoClear: boolean;
  101927. /**
  101928. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101929. */
  101930. alphaMode: number;
  101931. /**
  101932. * Sets the setAlphaBlendConstants of the babylon engine
  101933. */
  101934. alphaConstants: Color4;
  101935. /**
  101936. * Animations to be used for the post processing
  101937. */
  101938. animations: Animation[];
  101939. /**
  101940. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101941. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101942. */
  101943. enablePixelPerfectMode: boolean;
  101944. /**
  101945. * Force the postprocess to be applied without taking in account viewport
  101946. */
  101947. forceFullscreenViewport: boolean;
  101948. /**
  101949. * List of inspectable custom properties (used by the Inspector)
  101950. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101951. */
  101952. inspectableCustomProperties: IInspectable[];
  101953. /**
  101954. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101955. *
  101956. * | Value | Type | Description |
  101957. * | ----- | ----------------------------------- | ----------- |
  101958. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101959. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101960. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101961. *
  101962. */
  101963. scaleMode: number;
  101964. /**
  101965. * Force textures to be a power of two (default: false)
  101966. */
  101967. alwaysForcePOT: boolean;
  101968. private _samples;
  101969. /**
  101970. * Number of sample textures (default: 1)
  101971. */
  101972. get samples(): number;
  101973. set samples(n: number);
  101974. /**
  101975. * Modify the scale of the post process to be the same as the viewport (default: false)
  101976. */
  101977. adaptScaleToCurrentViewport: boolean;
  101978. private _camera;
  101979. protected _scene: Scene;
  101980. private _engine;
  101981. private _options;
  101982. private _reusable;
  101983. private _textureType;
  101984. private _textureFormat;
  101985. /**
  101986. * Smart array of input and output textures for the post process.
  101987. * @hidden
  101988. */
  101989. _textures: SmartArray<InternalTexture>;
  101990. /**
  101991. * The index in _textures that corresponds to the output texture.
  101992. * @hidden
  101993. */
  101994. _currentRenderTextureInd: number;
  101995. private _effect;
  101996. private _samplers;
  101997. private _fragmentUrl;
  101998. private _vertexUrl;
  101999. private _parameters;
  102000. private _scaleRatio;
  102001. protected _indexParameters: any;
  102002. private _shareOutputWithPostProcess;
  102003. private _texelSize;
  102004. private _forcedOutputTexture;
  102005. /**
  102006. * Returns the fragment url or shader name used in the post process.
  102007. * @returns the fragment url or name in the shader store.
  102008. */
  102009. getEffectName(): string;
  102010. /**
  102011. * An event triggered when the postprocess is activated.
  102012. */
  102013. onActivateObservable: Observable<Camera>;
  102014. private _onActivateObserver;
  102015. /**
  102016. * A function that is added to the onActivateObservable
  102017. */
  102018. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102019. /**
  102020. * An event triggered when the postprocess changes its size.
  102021. */
  102022. onSizeChangedObservable: Observable<PostProcess>;
  102023. private _onSizeChangedObserver;
  102024. /**
  102025. * A function that is added to the onSizeChangedObservable
  102026. */
  102027. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102028. /**
  102029. * An event triggered when the postprocess applies its effect.
  102030. */
  102031. onApplyObservable: Observable<Effect>;
  102032. private _onApplyObserver;
  102033. /**
  102034. * A function that is added to the onApplyObservable
  102035. */
  102036. set onApply(callback: (effect: Effect) => void);
  102037. /**
  102038. * An event triggered before rendering the postprocess
  102039. */
  102040. onBeforeRenderObservable: Observable<Effect>;
  102041. private _onBeforeRenderObserver;
  102042. /**
  102043. * A function that is added to the onBeforeRenderObservable
  102044. */
  102045. set onBeforeRender(callback: (effect: Effect) => void);
  102046. /**
  102047. * An event triggered after rendering the postprocess
  102048. */
  102049. onAfterRenderObservable: Observable<Effect>;
  102050. private _onAfterRenderObserver;
  102051. /**
  102052. * A function that is added to the onAfterRenderObservable
  102053. */
  102054. set onAfterRender(callback: (efect: Effect) => void);
  102055. /**
  102056. * 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
  102057. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102058. */
  102059. get inputTexture(): InternalTexture;
  102060. set inputTexture(value: InternalTexture);
  102061. /**
  102062. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102063. * the only way to unset it is to use this function to restore its internal state
  102064. */
  102065. restoreDefaultInputTexture(): void;
  102066. /**
  102067. * Gets the camera which post process is applied to.
  102068. * @returns The camera the post process is applied to.
  102069. */
  102070. getCamera(): Camera;
  102071. /**
  102072. * Gets the texel size of the postprocess.
  102073. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102074. */
  102075. get texelSize(): Vector2;
  102076. /**
  102077. * Creates a new instance PostProcess
  102078. * @param name The name of the PostProcess.
  102079. * @param fragmentUrl The url of the fragment shader to be used.
  102080. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102081. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102082. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102083. * @param camera The camera to apply the render pass to.
  102084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102085. * @param engine The engine which the post process will be applied. (default: current engine)
  102086. * @param reusable If the post process can be reused on the same frame. (default: false)
  102087. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102088. * @param textureType Type of textures used when performing the post process. (default: 0)
  102089. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102090. * @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
  102091. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  102092. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102093. */
  102094. 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);
  102095. /**
  102096. * Gets a string identifying the name of the class
  102097. * @returns "PostProcess" string
  102098. */
  102099. getClassName(): string;
  102100. /**
  102101. * Gets the engine which this post process belongs to.
  102102. * @returns The engine the post process was enabled with.
  102103. */
  102104. getEngine(): Engine;
  102105. /**
  102106. * The effect that is created when initializing the post process.
  102107. * @returns The created effect corresponding the the postprocess.
  102108. */
  102109. getEffect(): Effect;
  102110. /**
  102111. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102112. * @param postProcess The post process to share the output with.
  102113. * @returns This post process.
  102114. */
  102115. shareOutputWith(postProcess: PostProcess): PostProcess;
  102116. /**
  102117. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102118. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102119. */
  102120. useOwnOutput(): void;
  102121. /**
  102122. * Updates the effect with the current post process compile time values and recompiles the shader.
  102123. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102124. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102125. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102126. * @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
  102127. * @param onCompiled Called when the shader has been compiled.
  102128. * @param onError Called if there is an error when compiling a shader.
  102129. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102130. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102131. */
  102132. 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;
  102133. /**
  102134. * The post process is reusable if it can be used multiple times within one frame.
  102135. * @returns If the post process is reusable
  102136. */
  102137. isReusable(): boolean;
  102138. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102139. markTextureDirty(): void;
  102140. /**
  102141. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102142. * 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.
  102143. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102144. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102145. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102146. * @returns The target texture that was bound to be written to.
  102147. */
  102148. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102149. /**
  102150. * If the post process is supported.
  102151. */
  102152. get isSupported(): boolean;
  102153. /**
  102154. * The aspect ratio of the output texture.
  102155. */
  102156. get aspectRatio(): number;
  102157. /**
  102158. * Get a value indicating if the post-process is ready to be used
  102159. * @returns true if the post-process is ready (shader is compiled)
  102160. */
  102161. isReady(): boolean;
  102162. /**
  102163. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102164. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102165. */
  102166. apply(): Nullable<Effect>;
  102167. private _disposeTextures;
  102168. /**
  102169. * Disposes the post process.
  102170. * @param camera The camera to dispose the post process on.
  102171. */
  102172. dispose(camera?: Camera): void;
  102173. /**
  102174. * Serializes the particle system to a JSON object
  102175. * @returns the JSON object
  102176. */
  102177. serialize(): any;
  102178. /**
  102179. * Creates a material from parsed material data
  102180. * @param parsedPostProcess defines parsed post process data
  102181. * @param scene defines the hosting scene
  102182. * @param rootUrl defines the root URL to use to load textures
  102183. * @returns a new post process
  102184. */
  102185. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102186. }
  102187. }
  102188. declare module BABYLON {
  102189. /** @hidden */
  102190. export var kernelBlurVaryingDeclaration: {
  102191. name: string;
  102192. shader: string;
  102193. };
  102194. }
  102195. declare module BABYLON {
  102196. /** @hidden */
  102197. export var kernelBlurFragment: {
  102198. name: string;
  102199. shader: string;
  102200. };
  102201. }
  102202. declare module BABYLON {
  102203. /** @hidden */
  102204. export var kernelBlurFragment2: {
  102205. name: string;
  102206. shader: string;
  102207. };
  102208. }
  102209. declare module BABYLON {
  102210. /** @hidden */
  102211. export var kernelBlurPixelShader: {
  102212. name: string;
  102213. shader: string;
  102214. };
  102215. }
  102216. declare module BABYLON {
  102217. /** @hidden */
  102218. export var kernelBlurVertex: {
  102219. name: string;
  102220. shader: string;
  102221. };
  102222. }
  102223. declare module BABYLON {
  102224. /** @hidden */
  102225. export var kernelBlurVertexShader: {
  102226. name: string;
  102227. shader: string;
  102228. };
  102229. }
  102230. declare module BABYLON {
  102231. /**
  102232. * The Blur Post Process which blurs an image based on a kernel and direction.
  102233. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102234. */
  102235. export class BlurPostProcess extends PostProcess {
  102236. private blockCompilation;
  102237. protected _kernel: number;
  102238. protected _idealKernel: number;
  102239. protected _packedFloat: boolean;
  102240. private _staticDefines;
  102241. /** The direction in which to blur the image. */
  102242. direction: Vector2;
  102243. /**
  102244. * Sets the length in pixels of the blur sample region
  102245. */
  102246. set kernel(v: number);
  102247. /**
  102248. * Gets the length in pixels of the blur sample region
  102249. */
  102250. get kernel(): number;
  102251. /**
  102252. * Sets wether or not the blur needs to unpack/repack floats
  102253. */
  102254. set packedFloat(v: boolean);
  102255. /**
  102256. * Gets wether or not the blur is unpacking/repacking floats
  102257. */
  102258. get packedFloat(): boolean;
  102259. /**
  102260. * Gets a string identifying the name of the class
  102261. * @returns "BlurPostProcess" string
  102262. */
  102263. getClassName(): string;
  102264. /**
  102265. * Creates a new instance BlurPostProcess
  102266. * @param name The name of the effect.
  102267. * @param direction The direction in which to blur the image.
  102268. * @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.
  102269. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102270. * @param camera The camera to apply the render pass to.
  102271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102272. * @param engine The engine which the post process will be applied. (default: current engine)
  102273. * @param reusable If the post process can be reused on the same frame. (default: false)
  102274. * @param textureType Type of textures used when performing the post process. (default: 0)
  102275. * @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)
  102276. */
  102277. 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);
  102278. /**
  102279. * Updates the effect with the current post process compile time values and recompiles the shader.
  102280. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102281. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102282. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102283. * @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
  102284. * @param onCompiled Called when the shader has been compiled.
  102285. * @param onError Called if there is an error when compiling a shader.
  102286. */
  102287. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102288. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102289. /**
  102290. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  102291. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  102292. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  102293. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  102294. * The gaps between physical kernels are compensated for in the weighting of the samples
  102295. * @param idealKernel Ideal blur kernel.
  102296. * @return Nearest best kernel.
  102297. */
  102298. protected _nearestBestKernel(idealKernel: number): number;
  102299. /**
  102300. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  102301. * @param x The point on the Gaussian distribution to sample.
  102302. * @return the value of the Gaussian function at x.
  102303. */
  102304. protected _gaussianWeight(x: number): number;
  102305. /**
  102306. * Generates a string that can be used as a floating point number in GLSL.
  102307. * @param x Value to print.
  102308. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  102309. * @return GLSL float string.
  102310. */
  102311. protected _glslFloat(x: number, decimalFigures?: number): string;
  102312. /** @hidden */
  102313. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  102314. }
  102315. }
  102316. declare module BABYLON {
  102317. /**
  102318. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102319. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102320. * You can then easily use it as a reflectionTexture on a flat surface.
  102321. * In case the surface is not a plane, please consider relying on reflection probes.
  102322. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102323. */
  102324. export class MirrorTexture extends RenderTargetTexture {
  102325. private scene;
  102326. /**
  102327. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102328. * 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.
  102329. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102330. */
  102331. mirrorPlane: Plane;
  102332. /**
  102333. * Define the blur ratio used to blur the reflection if needed.
  102334. */
  102335. set blurRatio(value: number);
  102336. get blurRatio(): number;
  102337. /**
  102338. * Define the adaptive blur kernel used to blur the reflection if needed.
  102339. * This will autocompute the closest best match for the `blurKernel`
  102340. */
  102341. set adaptiveBlurKernel(value: number);
  102342. /**
  102343. * Define the blur kernel used to blur the reflection if needed.
  102344. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102345. */
  102346. set blurKernel(value: number);
  102347. /**
  102348. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102349. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102350. */
  102351. set blurKernelX(value: number);
  102352. get blurKernelX(): number;
  102353. /**
  102354. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102355. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102356. */
  102357. set blurKernelY(value: number);
  102358. get blurKernelY(): number;
  102359. private _autoComputeBlurKernel;
  102360. protected _onRatioRescale(): void;
  102361. private _updateGammaSpace;
  102362. private _imageProcessingConfigChangeObserver;
  102363. private _transformMatrix;
  102364. private _mirrorMatrix;
  102365. private _savedViewMatrix;
  102366. private _blurX;
  102367. private _blurY;
  102368. private _adaptiveBlurKernel;
  102369. private _blurKernelX;
  102370. private _blurKernelY;
  102371. private _blurRatio;
  102372. /**
  102373. * Instantiates a Mirror Texture.
  102374. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102375. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102376. * You can then easily use it as a reflectionTexture on a flat surface.
  102377. * In case the surface is not a plane, please consider relying on reflection probes.
  102378. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102379. * @param name
  102380. * @param size
  102381. * @param scene
  102382. * @param generateMipMaps
  102383. * @param type
  102384. * @param samplingMode
  102385. * @param generateDepthBuffer
  102386. */
  102387. constructor(name: string, size: number | {
  102388. width: number;
  102389. height: number;
  102390. } | {
  102391. ratio: number;
  102392. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102393. private _preparePostProcesses;
  102394. /**
  102395. * Clone the mirror texture.
  102396. * @returns the cloned texture
  102397. */
  102398. clone(): MirrorTexture;
  102399. /**
  102400. * Serialize the texture to a JSON representation you could use in Parse later on
  102401. * @returns the serialized JSON representation
  102402. */
  102403. serialize(): any;
  102404. /**
  102405. * Dispose the texture and release its associated resources.
  102406. */
  102407. dispose(): void;
  102408. }
  102409. }
  102410. declare module BABYLON {
  102411. /**
  102412. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102413. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102414. */
  102415. export class Texture extends BaseTexture {
  102416. /**
  102417. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102418. */
  102419. static SerializeBuffers: boolean;
  102420. /** @hidden */
  102421. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102422. /** @hidden */
  102423. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102424. /** @hidden */
  102425. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102426. /** nearest is mag = nearest and min = nearest and mip = linear */
  102427. static readonly NEAREST_SAMPLINGMODE: number;
  102428. /** nearest is mag = nearest and min = nearest and mip = linear */
  102429. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102430. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102431. static readonly BILINEAR_SAMPLINGMODE: number;
  102432. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102433. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102434. /** Trilinear is mag = linear and min = linear and mip = linear */
  102435. static readonly TRILINEAR_SAMPLINGMODE: number;
  102436. /** Trilinear is mag = linear and min = linear and mip = linear */
  102437. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102438. /** mag = nearest and min = nearest and mip = nearest */
  102439. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102440. /** mag = nearest and min = linear and mip = nearest */
  102441. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102442. /** mag = nearest and min = linear and mip = linear */
  102443. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102444. /** mag = nearest and min = linear and mip = none */
  102445. static readonly NEAREST_LINEAR: number;
  102446. /** mag = nearest and min = nearest and mip = none */
  102447. static readonly NEAREST_NEAREST: number;
  102448. /** mag = linear and min = nearest and mip = nearest */
  102449. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102450. /** mag = linear and min = nearest and mip = linear */
  102451. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102452. /** mag = linear and min = linear and mip = none */
  102453. static readonly LINEAR_LINEAR: number;
  102454. /** mag = linear and min = nearest and mip = none */
  102455. static readonly LINEAR_NEAREST: number;
  102456. /** Explicit coordinates mode */
  102457. static readonly EXPLICIT_MODE: number;
  102458. /** Spherical coordinates mode */
  102459. static readonly SPHERICAL_MODE: number;
  102460. /** Planar coordinates mode */
  102461. static readonly PLANAR_MODE: number;
  102462. /** Cubic coordinates mode */
  102463. static readonly CUBIC_MODE: number;
  102464. /** Projection coordinates mode */
  102465. static readonly PROJECTION_MODE: number;
  102466. /** Inverse Cubic coordinates mode */
  102467. static readonly SKYBOX_MODE: number;
  102468. /** Inverse Cubic coordinates mode */
  102469. static readonly INVCUBIC_MODE: number;
  102470. /** Equirectangular coordinates mode */
  102471. static readonly EQUIRECTANGULAR_MODE: number;
  102472. /** Equirectangular Fixed coordinates mode */
  102473. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102474. /** Equirectangular Fixed Mirrored coordinates mode */
  102475. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102476. /** Texture is not repeating outside of 0..1 UVs */
  102477. static readonly CLAMP_ADDRESSMODE: number;
  102478. /** Texture is repeating outside of 0..1 UVs */
  102479. static readonly WRAP_ADDRESSMODE: number;
  102480. /** Texture is repeating and mirrored */
  102481. static readonly MIRROR_ADDRESSMODE: number;
  102482. /**
  102483. * 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
  102484. */
  102485. static UseSerializedUrlIfAny: boolean;
  102486. /**
  102487. * Define the url of the texture.
  102488. */
  102489. url: Nullable<string>;
  102490. /**
  102491. * Define an offset on the texture to offset the u coordinates of the UVs
  102492. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102493. */
  102494. uOffset: number;
  102495. /**
  102496. * Define an offset on the texture to offset the v coordinates of the UVs
  102497. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102498. */
  102499. vOffset: number;
  102500. /**
  102501. * Define an offset on the texture to scale the u coordinates of the UVs
  102502. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102503. */
  102504. uScale: number;
  102505. /**
  102506. * Define an offset on the texture to scale the v coordinates of the UVs
  102507. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102508. */
  102509. vScale: number;
  102510. /**
  102511. * Define an offset on the texture to rotate around the u coordinates of the UVs
  102512. * @see https://doc.babylonjs.com/how_to/more_materials
  102513. */
  102514. uAng: number;
  102515. /**
  102516. * Define an offset on the texture to rotate around the v coordinates of the UVs
  102517. * @see https://doc.babylonjs.com/how_to/more_materials
  102518. */
  102519. vAng: number;
  102520. /**
  102521. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  102522. * @see https://doc.babylonjs.com/how_to/more_materials
  102523. */
  102524. wAng: number;
  102525. /**
  102526. * Defines the center of rotation (U)
  102527. */
  102528. uRotationCenter: number;
  102529. /**
  102530. * Defines the center of rotation (V)
  102531. */
  102532. vRotationCenter: number;
  102533. /**
  102534. * Defines the center of rotation (W)
  102535. */
  102536. wRotationCenter: number;
  102537. /**
  102538. * Are mip maps generated for this texture or not.
  102539. */
  102540. get noMipmap(): boolean;
  102541. /**
  102542. * List of inspectable custom properties (used by the Inspector)
  102543. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102544. */
  102545. inspectableCustomProperties: Nullable<IInspectable[]>;
  102546. private _noMipmap;
  102547. /** @hidden */
  102548. _invertY: boolean;
  102549. private _rowGenerationMatrix;
  102550. private _cachedTextureMatrix;
  102551. private _projectionModeMatrix;
  102552. private _t0;
  102553. private _t1;
  102554. private _t2;
  102555. private _cachedUOffset;
  102556. private _cachedVOffset;
  102557. private _cachedUScale;
  102558. private _cachedVScale;
  102559. private _cachedUAng;
  102560. private _cachedVAng;
  102561. private _cachedWAng;
  102562. private _cachedProjectionMatrixId;
  102563. private _cachedCoordinatesMode;
  102564. /** @hidden */
  102565. protected _initialSamplingMode: number;
  102566. /** @hidden */
  102567. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102568. private _deleteBuffer;
  102569. protected _format: Nullable<number>;
  102570. private _delayedOnLoad;
  102571. private _delayedOnError;
  102572. private _mimeType?;
  102573. /**
  102574. * Observable triggered once the texture has been loaded.
  102575. */
  102576. onLoadObservable: Observable<Texture>;
  102577. protected _isBlocking: boolean;
  102578. /**
  102579. * Is the texture preventing material to render while loading.
  102580. * If false, a default texture will be used instead of the loading one during the preparation step.
  102581. */
  102582. set isBlocking(value: boolean);
  102583. get isBlocking(): boolean;
  102584. /**
  102585. * Get the current sampling mode associated with the texture.
  102586. */
  102587. get samplingMode(): number;
  102588. /**
  102589. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102590. */
  102591. get invertY(): boolean;
  102592. /**
  102593. * Instantiates a new texture.
  102594. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102595. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102596. * @param url defines the url of the picture to load as a texture
  102597. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102598. * @param noMipmap defines if the texture will require mip maps or not
  102599. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102600. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102601. * @param onLoad defines a callback triggered when the texture has been loaded
  102602. * @param onError defines a callback triggered when an error occurred during the loading session
  102603. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102604. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102605. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102606. * @param mimeType defines an optional mime type information
  102607. */
  102608. 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);
  102609. /**
  102610. * Update the url (and optional buffer) of this texture if url was null during construction.
  102611. * @param url the url of the texture
  102612. * @param buffer the buffer of the texture (defaults to null)
  102613. * @param onLoad callback called when the texture is loaded (defaults to null)
  102614. */
  102615. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102616. /**
  102617. * Finish the loading sequence of a texture flagged as delayed load.
  102618. * @hidden
  102619. */
  102620. delayLoad(): void;
  102621. private _prepareRowForTextureGeneration;
  102622. /**
  102623. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102624. * @returns the transform matrix of the texture.
  102625. */
  102626. getTextureMatrix(uBase?: number): Matrix;
  102627. /**
  102628. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102629. * @returns The reflection texture transform
  102630. */
  102631. getReflectionTextureMatrix(): Matrix;
  102632. /**
  102633. * Clones the texture.
  102634. * @returns the cloned texture
  102635. */
  102636. clone(): Texture;
  102637. /**
  102638. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102639. * @returns The JSON representation of the texture
  102640. */
  102641. serialize(): any;
  102642. /**
  102643. * Get the current class name of the texture useful for serialization or dynamic coding.
  102644. * @returns "Texture"
  102645. */
  102646. getClassName(): string;
  102647. /**
  102648. * Dispose the texture and release its associated resources.
  102649. */
  102650. dispose(): void;
  102651. /**
  102652. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102653. * @param parsedTexture Define the JSON representation of the texture
  102654. * @param scene Define the scene the parsed texture should be instantiated in
  102655. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102656. * @returns The parsed texture if successful
  102657. */
  102658. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102659. /**
  102660. * Creates a texture from its base 64 representation.
  102661. * @param data Define the base64 payload without the data: prefix
  102662. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102663. * @param scene Define the scene the texture should belong to
  102664. * @param noMipmap Forces the texture to not create mip map information if true
  102665. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102666. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102667. * @param onLoad define a callback triggered when the texture has been loaded
  102668. * @param onError define a callback triggered when an error occurred during the loading session
  102669. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102670. * @returns the created texture
  102671. */
  102672. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102673. /**
  102674. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102675. * @param data Define the base64 payload without the data: prefix
  102676. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102677. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102678. * @param scene Define the scene the texture should belong to
  102679. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102680. * @param noMipmap Forces the texture to not create mip map information if true
  102681. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102682. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102683. * @param onLoad define a callback triggered when the texture has been loaded
  102684. * @param onError define a callback triggered when an error occurred during the loading session
  102685. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102686. * @returns the created texture
  102687. */
  102688. 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;
  102689. }
  102690. }
  102691. declare module BABYLON {
  102692. /**
  102693. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102694. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102695. */
  102696. export class PostProcessManager {
  102697. private _scene;
  102698. private _indexBuffer;
  102699. private _vertexBuffers;
  102700. /**
  102701. * Creates a new instance PostProcess
  102702. * @param scene The scene that the post process is associated with.
  102703. */
  102704. constructor(scene: Scene);
  102705. private _prepareBuffers;
  102706. private _buildIndexBuffer;
  102707. /**
  102708. * Rebuilds the vertex buffers of the manager.
  102709. * @hidden
  102710. */
  102711. _rebuild(): void;
  102712. /**
  102713. * Prepares a frame to be run through a post process.
  102714. * @param sourceTexture The input texture to the post procesess. (default: null)
  102715. * @param postProcesses An array of post processes to be run. (default: null)
  102716. * @returns True if the post processes were able to be run.
  102717. * @hidden
  102718. */
  102719. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102720. /**
  102721. * Manually render a set of post processes to a texture.
  102722. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102723. * @param postProcesses An array of post processes to be run.
  102724. * @param targetTexture The target texture to render to.
  102725. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102726. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102727. * @param lodLevel defines which lod of the texture to render to
  102728. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102729. */
  102730. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102731. /**
  102732. * Finalize the result of the output of the postprocesses.
  102733. * @param doNotPresent If true the result will not be displayed to the screen.
  102734. * @param targetTexture The target texture to render to.
  102735. * @param faceIndex The index of the face to bind the target texture to.
  102736. * @param postProcesses The array of post processes to render.
  102737. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102738. * @hidden
  102739. */
  102740. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102741. /**
  102742. * Disposes of the post process manager.
  102743. */
  102744. dispose(): void;
  102745. }
  102746. }
  102747. declare module BABYLON {
  102748. /**
  102749. * This Helps creating a texture that will be created from a camera in your scene.
  102750. * It is basically a dynamic texture that could be used to create special effects for instance.
  102751. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102752. */
  102753. export class RenderTargetTexture extends Texture {
  102754. isCube: boolean;
  102755. /**
  102756. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102757. */
  102758. static readonly REFRESHRATE_RENDER_ONCE: number;
  102759. /**
  102760. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102761. */
  102762. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102763. /**
  102764. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102765. * the central point of your effect and can save a lot of performances.
  102766. */
  102767. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102768. /**
  102769. * Use this predicate to dynamically define the list of mesh you want to render.
  102770. * If set, the renderList property will be overwritten.
  102771. */
  102772. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102773. private _renderList;
  102774. /**
  102775. * Use this list to define the list of mesh you want to render.
  102776. */
  102777. get renderList(): Nullable<Array<AbstractMesh>>;
  102778. set renderList(value: Nullable<Array<AbstractMesh>>);
  102779. /**
  102780. * Use this function to overload the renderList array at rendering time.
  102781. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102782. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102783. * the cube (if the RTT is a cube, else layerOrFace=0).
  102784. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102785. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102786. * hold dummy elements!
  102787. */
  102788. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102789. private _hookArray;
  102790. /**
  102791. * Define if particles should be rendered in your texture.
  102792. */
  102793. renderParticles: boolean;
  102794. /**
  102795. * Define if sprites should be rendered in your texture.
  102796. */
  102797. renderSprites: boolean;
  102798. /**
  102799. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102800. */
  102801. coordinatesMode: number;
  102802. /**
  102803. * Define the camera used to render the texture.
  102804. */
  102805. activeCamera: Nullable<Camera>;
  102806. /**
  102807. * Override the mesh isReady function with your own one.
  102808. */
  102809. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102810. /**
  102811. * Override the render function of the texture with your own one.
  102812. */
  102813. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102814. /**
  102815. * Define if camera post processes should be use while rendering the texture.
  102816. */
  102817. useCameraPostProcesses: boolean;
  102818. /**
  102819. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102820. */
  102821. ignoreCameraViewport: boolean;
  102822. private _postProcessManager;
  102823. private _postProcesses;
  102824. private _resizeObserver;
  102825. /**
  102826. * An event triggered when the texture is unbind.
  102827. */
  102828. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102829. /**
  102830. * An event triggered when the texture is unbind.
  102831. */
  102832. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102833. private _onAfterUnbindObserver;
  102834. /**
  102835. * Set a after unbind callback in the texture.
  102836. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102837. */
  102838. set onAfterUnbind(callback: () => void);
  102839. /**
  102840. * An event triggered before rendering the texture
  102841. */
  102842. onBeforeRenderObservable: Observable<number>;
  102843. private _onBeforeRenderObserver;
  102844. /**
  102845. * Set a before render callback in the texture.
  102846. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102847. */
  102848. set onBeforeRender(callback: (faceIndex: number) => void);
  102849. /**
  102850. * An event triggered after rendering the texture
  102851. */
  102852. onAfterRenderObservable: Observable<number>;
  102853. private _onAfterRenderObserver;
  102854. /**
  102855. * Set a after render callback in the texture.
  102856. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102857. */
  102858. set onAfterRender(callback: (faceIndex: number) => void);
  102859. /**
  102860. * An event triggered after the texture clear
  102861. */
  102862. onClearObservable: Observable<Engine>;
  102863. private _onClearObserver;
  102864. /**
  102865. * Set a clear callback in the texture.
  102866. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102867. */
  102868. set onClear(callback: (Engine: Engine) => void);
  102869. /**
  102870. * An event triggered when the texture is resized.
  102871. */
  102872. onResizeObservable: Observable<RenderTargetTexture>;
  102873. /**
  102874. * Define the clear color of the Render Target if it should be different from the scene.
  102875. */
  102876. clearColor: Color4;
  102877. protected _size: number | {
  102878. width: number;
  102879. height: number;
  102880. layers?: number;
  102881. };
  102882. protected _initialSizeParameter: number | {
  102883. width: number;
  102884. height: number;
  102885. } | {
  102886. ratio: number;
  102887. };
  102888. protected _sizeRatio: Nullable<number>;
  102889. /** @hidden */
  102890. _generateMipMaps: boolean;
  102891. protected _renderingManager: RenderingManager;
  102892. /** @hidden */
  102893. _waitingRenderList: string[];
  102894. protected _doNotChangeAspectRatio: boolean;
  102895. protected _currentRefreshId: number;
  102896. protected _refreshRate: number;
  102897. protected _textureMatrix: Matrix;
  102898. protected _samples: number;
  102899. protected _renderTargetOptions: RenderTargetCreationOptions;
  102900. /**
  102901. * Gets render target creation options that were used.
  102902. */
  102903. get renderTargetOptions(): RenderTargetCreationOptions;
  102904. protected _onRatioRescale(): void;
  102905. /**
  102906. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102907. * It must define where the camera used to render the texture is set
  102908. */
  102909. boundingBoxPosition: Vector3;
  102910. private _boundingBoxSize;
  102911. /**
  102912. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102913. * When defined, the cubemap will switch to local mode
  102914. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102915. * @example https://www.babylonjs-playground.com/#RNASML
  102916. */
  102917. set boundingBoxSize(value: Vector3);
  102918. get boundingBoxSize(): Vector3;
  102919. /**
  102920. * In case the RTT has been created with a depth texture, get the associated
  102921. * depth texture.
  102922. * Otherwise, return null.
  102923. */
  102924. get depthStencilTexture(): Nullable<InternalTexture>;
  102925. /**
  102926. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102927. * or used a shadow, depth texture...
  102928. * @param name The friendly name of the texture
  102929. * @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)
  102930. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102931. * @param generateMipMaps True if mip maps need to be generated after render.
  102932. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102933. * @param type The type of the buffer in the RTT (int, half float, float...)
  102934. * @param isCube True if a cube texture needs to be created
  102935. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102936. * @param generateDepthBuffer True to generate a depth buffer
  102937. * @param generateStencilBuffer True to generate a stencil buffer
  102938. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102939. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102940. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102941. */
  102942. constructor(name: string, size: number | {
  102943. width: number;
  102944. height: number;
  102945. layers?: number;
  102946. } | {
  102947. ratio: number;
  102948. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102949. /**
  102950. * Creates a depth stencil texture.
  102951. * This is only available in WebGL 2 or with the depth texture extension available.
  102952. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102953. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102954. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102955. */
  102956. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102957. private _processSizeParameter;
  102958. /**
  102959. * Define the number of samples to use in case of MSAA.
  102960. * It defaults to one meaning no MSAA has been enabled.
  102961. */
  102962. get samples(): number;
  102963. set samples(value: number);
  102964. /**
  102965. * Resets the refresh counter of the texture and start bak from scratch.
  102966. * Could be useful to regenerate the texture if it is setup to render only once.
  102967. */
  102968. resetRefreshCounter(): void;
  102969. /**
  102970. * Define the refresh rate of the texture or the rendering frequency.
  102971. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102972. */
  102973. get refreshRate(): number;
  102974. set refreshRate(value: number);
  102975. /**
  102976. * Adds a post process to the render target rendering passes.
  102977. * @param postProcess define the post process to add
  102978. */
  102979. addPostProcess(postProcess: PostProcess): void;
  102980. /**
  102981. * Clear all the post processes attached to the render target
  102982. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102983. */
  102984. clearPostProcesses(dispose?: boolean): void;
  102985. /**
  102986. * Remove one of the post process from the list of attached post processes to the texture
  102987. * @param postProcess define the post process to remove from the list
  102988. */
  102989. removePostProcess(postProcess: PostProcess): void;
  102990. /** @hidden */
  102991. _shouldRender(): boolean;
  102992. /**
  102993. * Gets the actual render size of the texture.
  102994. * @returns the width of the render size
  102995. */
  102996. getRenderSize(): number;
  102997. /**
  102998. * Gets the actual render width of the texture.
  102999. * @returns the width of the render size
  103000. */
  103001. getRenderWidth(): number;
  103002. /**
  103003. * Gets the actual render height of the texture.
  103004. * @returns the height of the render size
  103005. */
  103006. getRenderHeight(): number;
  103007. /**
  103008. * Gets the actual number of layers of the texture.
  103009. * @returns the number of layers
  103010. */
  103011. getRenderLayers(): number;
  103012. /**
  103013. * Get if the texture can be rescaled or not.
  103014. */
  103015. get canRescale(): boolean;
  103016. /**
  103017. * Resize the texture using a ratio.
  103018. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103019. */
  103020. scale(ratio: number): void;
  103021. /**
  103022. * Get the texture reflection matrix used to rotate/transform the reflection.
  103023. * @returns the reflection matrix
  103024. */
  103025. getReflectionTextureMatrix(): Matrix;
  103026. /**
  103027. * Resize the texture to a new desired size.
  103028. * Be carrefull as it will recreate all the data in the new texture.
  103029. * @param size Define the new size. It can be:
  103030. * - a number for squared texture,
  103031. * - an object containing { width: number, height: number }
  103032. * - or an object containing a ratio { ratio: number }
  103033. */
  103034. resize(size: number | {
  103035. width: number;
  103036. height: number;
  103037. } | {
  103038. ratio: number;
  103039. }): void;
  103040. private _defaultRenderListPrepared;
  103041. /**
  103042. * Renders all the objects from the render list into the texture.
  103043. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103044. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103045. */
  103046. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103047. private _bestReflectionRenderTargetDimension;
  103048. private _prepareRenderingManager;
  103049. /**
  103050. * @hidden
  103051. * @param faceIndex face index to bind to if this is a cubetexture
  103052. * @param layer defines the index of the texture to bind in the array
  103053. */
  103054. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103055. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103056. private renderToTarget;
  103057. /**
  103058. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103059. * This allowed control for front to back rendering or reversly depending of the special needs.
  103060. *
  103061. * @param renderingGroupId The rendering group id corresponding to its index
  103062. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103063. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103064. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103065. */
  103066. 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;
  103067. /**
  103068. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103069. *
  103070. * @param renderingGroupId The rendering group id corresponding to its index
  103071. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103072. */
  103073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103074. /**
  103075. * Clones the texture.
  103076. * @returns the cloned texture
  103077. */
  103078. clone(): RenderTargetTexture;
  103079. /**
  103080. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103081. * @returns The JSON representation of the texture
  103082. */
  103083. serialize(): any;
  103084. /**
  103085. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103086. */
  103087. disposeFramebufferObjects(): void;
  103088. /**
  103089. * Dispose the texture and release its associated resources.
  103090. */
  103091. dispose(): void;
  103092. /** @hidden */
  103093. _rebuild(): void;
  103094. /**
  103095. * Clear the info related to rendering groups preventing retention point in material dispose.
  103096. */
  103097. freeRenderingGroups(): void;
  103098. /**
  103099. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103100. * @returns the view count
  103101. */
  103102. getViewCount(): number;
  103103. }
  103104. }
  103105. declare module BABYLON {
  103106. /**
  103107. * Class used to manipulate GUIDs
  103108. */
  103109. export class GUID {
  103110. /**
  103111. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103112. * Be aware Math.random() could cause collisions, but:
  103113. * "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"
  103114. * @returns a pseudo random id
  103115. */
  103116. static RandomId(): string;
  103117. }
  103118. }
  103119. declare module BABYLON {
  103120. /**
  103121. * Options to be used when creating a shadow depth material
  103122. */
  103123. export interface IIOptionShadowDepthMaterial {
  103124. /** Variables in the vertex shader code that need to have their names remapped.
  103125. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103126. * "var_name" should be either: worldPos or vNormalW
  103127. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103128. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103129. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103130. */
  103131. remappedVariables?: string[];
  103132. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103133. standalone?: boolean;
  103134. }
  103135. /**
  103136. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103137. */
  103138. export class ShadowDepthWrapper {
  103139. private _scene;
  103140. private _options?;
  103141. private _baseMaterial;
  103142. private _onEffectCreatedObserver;
  103143. private _subMeshToEffect;
  103144. private _subMeshToDepthEffect;
  103145. private _meshes;
  103146. /** @hidden */
  103147. _matriceNames: any;
  103148. /** Gets the standalone status of the wrapper */
  103149. get standalone(): boolean;
  103150. /** Gets the base material the wrapper is built upon */
  103151. get baseMaterial(): Material;
  103152. /**
  103153. * Instantiate a new shadow depth wrapper.
  103154. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103155. * generate the shadow depth map. For more information, please refer to the documentation:
  103156. * https://doc.babylonjs.com/babylon101/shadows
  103157. * @param baseMaterial Material to wrap
  103158. * @param scene Define the scene the material belongs to
  103159. * @param options Options used to create the wrapper
  103160. */
  103161. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103162. /**
  103163. * Gets the effect to use to generate the depth map
  103164. * @param subMesh subMesh to get the effect for
  103165. * @param shadowGenerator shadow generator to get the effect for
  103166. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103167. */
  103168. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103169. /**
  103170. * Specifies that the submesh is ready to be used for depth rendering
  103171. * @param subMesh submesh to check
  103172. * @param defines the list of defines to take into account when checking the effect
  103173. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103174. * @param useInstances specifies that instances should be used
  103175. * @returns a boolean indicating that the submesh is ready or not
  103176. */
  103177. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103178. /**
  103179. * Disposes the resources
  103180. */
  103181. dispose(): void;
  103182. private _makeEffect;
  103183. }
  103184. }
  103185. declare module BABYLON {
  103186. interface ThinEngine {
  103187. /**
  103188. * Unbind a list of render target textures from the webGL context
  103189. * This is used only when drawBuffer extension or webGL2 are active
  103190. * @param textures defines the render target textures to unbind
  103191. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103192. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103193. */
  103194. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103195. /**
  103196. * Create a multi render target texture
  103197. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103198. * @param size defines the size of the texture
  103199. * @param options defines the creation options
  103200. * @returns the cube texture as an InternalTexture
  103201. */
  103202. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103203. /**
  103204. * Update the sample count for a given multiple render target texture
  103205. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103206. * @param textures defines the textures to update
  103207. * @param samples defines the sample count to set
  103208. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103209. */
  103210. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103211. /**
  103212. * Select a subsets of attachments to draw to.
  103213. * @param attachments gl attachments
  103214. */
  103215. bindAttachments(attachments: number[]): void;
  103216. }
  103217. }
  103218. declare module BABYLON {
  103219. /**
  103220. * Creation options of the multi render target texture.
  103221. */
  103222. export interface IMultiRenderTargetOptions {
  103223. /**
  103224. * Define if the texture needs to create mip maps after render.
  103225. */
  103226. generateMipMaps?: boolean;
  103227. /**
  103228. * Define the types of all the draw buffers we want to create
  103229. */
  103230. types?: number[];
  103231. /**
  103232. * Define the sampling modes of all the draw buffers we want to create
  103233. */
  103234. samplingModes?: number[];
  103235. /**
  103236. * Define if a depth buffer is required
  103237. */
  103238. generateDepthBuffer?: boolean;
  103239. /**
  103240. * Define if a stencil buffer is required
  103241. */
  103242. generateStencilBuffer?: boolean;
  103243. /**
  103244. * Define if a depth texture is required instead of a depth buffer
  103245. */
  103246. generateDepthTexture?: boolean;
  103247. /**
  103248. * Define the number of desired draw buffers
  103249. */
  103250. textureCount?: number;
  103251. /**
  103252. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103253. */
  103254. doNotChangeAspectRatio?: boolean;
  103255. /**
  103256. * Define the default type of the buffers we are creating
  103257. */
  103258. defaultType?: number;
  103259. }
  103260. /**
  103261. * A multi render target, like a render target provides the ability to render to a texture.
  103262. * Unlike the render target, it can render to several draw buffers in one draw.
  103263. * This is specially interesting in deferred rendering or for any effects requiring more than
  103264. * just one color from a single pass.
  103265. */
  103266. export class MultiRenderTarget extends RenderTargetTexture {
  103267. private _internalTextures;
  103268. private _textures;
  103269. private _multiRenderTargetOptions;
  103270. private _count;
  103271. /**
  103272. * Get if draw buffers are currently supported by the used hardware and browser.
  103273. */
  103274. get isSupported(): boolean;
  103275. /**
  103276. * Get the list of textures generated by the multi render target.
  103277. */
  103278. get textures(): Texture[];
  103279. /**
  103280. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103281. */
  103282. get count(): number;
  103283. /**
  103284. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103285. */
  103286. get depthTexture(): Texture;
  103287. /**
  103288. * Set the wrapping mode on U of all the textures we are rendering to.
  103289. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103290. */
  103291. set wrapU(wrap: number);
  103292. /**
  103293. * Set the wrapping mode on V of all the textures we are rendering to.
  103294. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103295. */
  103296. set wrapV(wrap: number);
  103297. /**
  103298. * Instantiate a new multi render target texture.
  103299. * A multi render target, like a render target provides the ability to render to a texture.
  103300. * Unlike the render target, it can render to several draw buffers in one draw.
  103301. * This is specially interesting in deferred rendering or for any effects requiring more than
  103302. * just one color from a single pass.
  103303. * @param name Define the name of the texture
  103304. * @param size Define the size of the buffers to render to
  103305. * @param count Define the number of target we are rendering into
  103306. * @param scene Define the scene the texture belongs to
  103307. * @param options Define the options used to create the multi render target
  103308. */
  103309. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103310. /** @hidden */
  103311. _rebuild(): void;
  103312. private _createInternalTextures;
  103313. private _createTextures;
  103314. /**
  103315. * Define the number of samples used if MSAA is enabled.
  103316. */
  103317. get samples(): number;
  103318. set samples(value: number);
  103319. /**
  103320. * Resize all the textures in the multi render target.
  103321. * Be carrefull as it will recreate all the data in the new texture.
  103322. * @param size Define the new size
  103323. */
  103324. resize(size: any): void;
  103325. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103326. /**
  103327. * Dispose the render targets and their associated resources
  103328. */
  103329. dispose(): void;
  103330. /**
  103331. * Release all the underlying texture used as draw buffers.
  103332. */
  103333. releaseInternalTextures(): void;
  103334. }
  103335. }
  103336. declare module BABYLON {
  103337. /** @hidden */
  103338. export var imageProcessingPixelShader: {
  103339. name: string;
  103340. shader: string;
  103341. };
  103342. }
  103343. declare module BABYLON {
  103344. /**
  103345. * ImageProcessingPostProcess
  103346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103347. */
  103348. export class ImageProcessingPostProcess extends PostProcess {
  103349. /**
  103350. * Default configuration related to image processing available in the PBR Material.
  103351. */
  103352. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103353. /**
  103354. * Gets the image processing configuration used either in this material.
  103355. */
  103356. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103357. /**
  103358. * Sets the Default image processing configuration used either in the this material.
  103359. *
  103360. * If sets to null, the scene one is in use.
  103361. */
  103362. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103363. /**
  103364. * Keep track of the image processing observer to allow dispose and replace.
  103365. */
  103366. private _imageProcessingObserver;
  103367. /**
  103368. * Attaches a new image processing configuration to the PBR Material.
  103369. * @param configuration
  103370. */
  103371. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103372. /**
  103373. * If the post process is supported.
  103374. */
  103375. get isSupported(): boolean;
  103376. /**
  103377. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103378. */
  103379. get colorCurves(): Nullable<ColorCurves>;
  103380. /**
  103381. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103382. */
  103383. set colorCurves(value: Nullable<ColorCurves>);
  103384. /**
  103385. * Gets wether the color curves effect is enabled.
  103386. */
  103387. get colorCurvesEnabled(): boolean;
  103388. /**
  103389. * Sets wether the color curves effect is enabled.
  103390. */
  103391. set colorCurvesEnabled(value: boolean);
  103392. /**
  103393. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103394. */
  103395. get colorGradingTexture(): Nullable<BaseTexture>;
  103396. /**
  103397. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103398. */
  103399. set colorGradingTexture(value: Nullable<BaseTexture>);
  103400. /**
  103401. * Gets wether the color grading effect is enabled.
  103402. */
  103403. get colorGradingEnabled(): boolean;
  103404. /**
  103405. * Gets wether the color grading effect is enabled.
  103406. */
  103407. set colorGradingEnabled(value: boolean);
  103408. /**
  103409. * Gets exposure used in the effect.
  103410. */
  103411. get exposure(): number;
  103412. /**
  103413. * Sets exposure used in the effect.
  103414. */
  103415. set exposure(value: number);
  103416. /**
  103417. * Gets wether tonemapping is enabled or not.
  103418. */
  103419. get toneMappingEnabled(): boolean;
  103420. /**
  103421. * Sets wether tonemapping is enabled or not
  103422. */
  103423. set toneMappingEnabled(value: boolean);
  103424. /**
  103425. * Gets the type of tone mapping effect.
  103426. */
  103427. get toneMappingType(): number;
  103428. /**
  103429. * Sets the type of tone mapping effect.
  103430. */
  103431. set toneMappingType(value: number);
  103432. /**
  103433. * Gets contrast used in the effect.
  103434. */
  103435. get contrast(): number;
  103436. /**
  103437. * Sets contrast used in the effect.
  103438. */
  103439. set contrast(value: number);
  103440. /**
  103441. * Gets Vignette stretch size.
  103442. */
  103443. get vignetteStretch(): number;
  103444. /**
  103445. * Sets Vignette stretch size.
  103446. */
  103447. set vignetteStretch(value: number);
  103448. /**
  103449. * Gets Vignette centre X Offset.
  103450. */
  103451. get vignetteCentreX(): number;
  103452. /**
  103453. * Sets Vignette centre X Offset.
  103454. */
  103455. set vignetteCentreX(value: number);
  103456. /**
  103457. * Gets Vignette centre Y Offset.
  103458. */
  103459. get vignetteCentreY(): number;
  103460. /**
  103461. * Sets Vignette centre Y Offset.
  103462. */
  103463. set vignetteCentreY(value: number);
  103464. /**
  103465. * Gets Vignette weight or intensity of the vignette effect.
  103466. */
  103467. get vignetteWeight(): number;
  103468. /**
  103469. * Sets Vignette weight or intensity of the vignette effect.
  103470. */
  103471. set vignetteWeight(value: number);
  103472. /**
  103473. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103474. * if vignetteEnabled is set to true.
  103475. */
  103476. get vignetteColor(): Color4;
  103477. /**
  103478. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103479. * if vignetteEnabled is set to true.
  103480. */
  103481. set vignetteColor(value: Color4);
  103482. /**
  103483. * Gets Camera field of view used by the Vignette effect.
  103484. */
  103485. get vignetteCameraFov(): number;
  103486. /**
  103487. * Sets Camera field of view used by the Vignette effect.
  103488. */
  103489. set vignetteCameraFov(value: number);
  103490. /**
  103491. * Gets the vignette blend mode allowing different kind of effect.
  103492. */
  103493. get vignetteBlendMode(): number;
  103494. /**
  103495. * Sets the vignette blend mode allowing different kind of effect.
  103496. */
  103497. set vignetteBlendMode(value: number);
  103498. /**
  103499. * Gets wether the vignette effect is enabled.
  103500. */
  103501. get vignetteEnabled(): boolean;
  103502. /**
  103503. * Sets wether the vignette effect is enabled.
  103504. */
  103505. set vignetteEnabled(value: boolean);
  103506. private _fromLinearSpace;
  103507. /**
  103508. * Gets wether the input of the processing is in Gamma or Linear Space.
  103509. */
  103510. get fromLinearSpace(): boolean;
  103511. /**
  103512. * Sets wether the input of the processing is in Gamma or Linear Space.
  103513. */
  103514. set fromLinearSpace(value: boolean);
  103515. /**
  103516. * Defines cache preventing GC.
  103517. */
  103518. private _defines;
  103519. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103520. /**
  103521. * "ImageProcessingPostProcess"
  103522. * @returns "ImageProcessingPostProcess"
  103523. */
  103524. getClassName(): string;
  103525. /**
  103526. * @hidden
  103527. */
  103528. _updateParameters(): void;
  103529. dispose(camera?: Camera): void;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /** @hidden */
  103534. export var fibonacci: {
  103535. name: string;
  103536. shader: string;
  103537. };
  103538. }
  103539. declare module BABYLON {
  103540. /** @hidden */
  103541. export var subSurfaceScatteringFunctions: {
  103542. name: string;
  103543. shader: string;
  103544. };
  103545. }
  103546. declare module BABYLON {
  103547. /** @hidden */
  103548. export var diffusionProfile: {
  103549. name: string;
  103550. shader: string;
  103551. };
  103552. }
  103553. declare module BABYLON {
  103554. /** @hidden */
  103555. export var subSurfaceScatteringPixelShader: {
  103556. name: string;
  103557. shader: string;
  103558. };
  103559. }
  103560. declare module BABYLON {
  103561. /**
  103562. * Sub surface scattering post process
  103563. */
  103564. export class SubSurfaceScatteringPostProcess extends PostProcess {
  103565. /**
  103566. * Gets a string identifying the name of the class
  103567. * @returns "SubSurfaceScatteringPostProcess" string
  103568. */
  103569. getClassName(): string;
  103570. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  103571. }
  103572. }
  103573. declare module BABYLON {
  103574. /**
  103575. * Interface for defining prepass effects in the prepass post-process pipeline
  103576. */
  103577. export interface PrePassEffectConfiguration {
  103578. /**
  103579. * Post process to attach for this effect
  103580. */
  103581. postProcess: PostProcess;
  103582. /**
  103583. * Is the effect enabled
  103584. */
  103585. enabled: boolean;
  103586. /**
  103587. * Disposes the effect configuration
  103588. */
  103589. dispose(): void;
  103590. /**
  103591. * Disposes the effect configuration
  103592. */
  103593. createPostProcess: () => PostProcess;
  103594. }
  103595. }
  103596. declare module BABYLON {
  103597. /**
  103598. * Contains all parameters needed for the prepass to perform
  103599. * screen space subsurface scattering
  103600. */
  103601. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103602. private _ssDiffusionS;
  103603. private _ssFilterRadii;
  103604. private _ssDiffusionD;
  103605. /**
  103606. * Post process to attach for screen space subsurface scattering
  103607. */
  103608. postProcess: SubSurfaceScatteringPostProcess;
  103609. /**
  103610. * Diffusion profile color for subsurface scattering
  103611. */
  103612. get ssDiffusionS(): number[];
  103613. /**
  103614. * Diffusion profile max color channel value for subsurface scattering
  103615. */
  103616. get ssDiffusionD(): number[];
  103617. /**
  103618. * Diffusion profile filter radius for subsurface scattering
  103619. */
  103620. get ssFilterRadii(): number[];
  103621. /**
  103622. * Is subsurface enabled
  103623. */
  103624. enabled: boolean;
  103625. /**
  103626. * Diffusion profile colors for subsurface scattering
  103627. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103628. * See ...
  103629. * Note that you can only store up to 5 of them
  103630. */
  103631. ssDiffusionProfileColors: Color3[];
  103632. /**
  103633. * Defines the ratio real world => scene units.
  103634. * Used for subsurface scattering
  103635. */
  103636. metersPerUnit: number;
  103637. private _scene;
  103638. /**
  103639. * Builds a subsurface configuration object
  103640. * @param scene The scene
  103641. */
  103642. constructor(scene: Scene);
  103643. /**
  103644. * Adds a new diffusion profile.
  103645. * Useful for more realistic subsurface scattering on diverse materials.
  103646. * @param color The color of the diffusion profile. Should be the average color of the material.
  103647. * @return The index of the diffusion profile for the material subsurface configuration
  103648. */
  103649. addDiffusionProfile(color: Color3): number;
  103650. /**
  103651. * Creates the sss post process
  103652. * @return The created post process
  103653. */
  103654. createPostProcess(): SubSurfaceScatteringPostProcess;
  103655. /**
  103656. * Deletes all diffusion profiles.
  103657. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103658. */
  103659. clearAllDiffusionProfiles(): void;
  103660. /**
  103661. * Disposes this object
  103662. */
  103663. dispose(): void;
  103664. /**
  103665. * @hidden
  103666. * https://zero-radiance.github.io/post/sampling-diffusion/
  103667. *
  103668. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103669. * ------------------------------------------------------------------------------------
  103670. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103671. * PDF[r, phi, s] = r * R[r, phi, s]
  103672. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103673. * ------------------------------------------------------------------------------------
  103674. * We importance sample the color channel with the widest scattering distance.
  103675. */
  103676. getDiffusionProfileParameters(color: Color3): number;
  103677. /**
  103678. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103679. * 'u' is the random number (the value of the CDF): [0, 1).
  103680. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103681. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103682. */
  103683. private _sampleBurleyDiffusionProfile;
  103684. }
  103685. }
  103686. declare module BABYLON {
  103687. /**
  103688. * Renders a pre pass of the scene
  103689. * This means every mesh in the scene will be rendered to a render target texture
  103690. * And then this texture will be composited to the rendering canvas with post processes
  103691. * It is necessary for effects like subsurface scattering or deferred shading
  103692. */
  103693. export class PrePassRenderer {
  103694. /** @hidden */
  103695. static _SceneComponentInitialization: (scene: Scene) => void;
  103696. private _scene;
  103697. private _engine;
  103698. private _isDirty;
  103699. /**
  103700. * Number of textures in the multi render target texture where the scene is directly rendered
  103701. */
  103702. readonly mrtCount: number;
  103703. /**
  103704. * The render target where the scene is directly rendered
  103705. */
  103706. prePassRT: MultiRenderTarget;
  103707. private _mrtTypes;
  103708. private _multiRenderAttachments;
  103709. private _defaultAttachments;
  103710. private _clearAttachments;
  103711. private _postProcesses;
  103712. private readonly _clearColor;
  103713. /**
  103714. * Image processing post process for composition
  103715. */
  103716. imageProcessingPostProcess: ImageProcessingPostProcess;
  103717. /**
  103718. * Configuration for sub surface scattering post process
  103719. */
  103720. subSurfaceConfiguration: SubSurfaceConfiguration;
  103721. /**
  103722. * Should materials render their geometry on the MRT
  103723. */
  103724. materialsShouldRenderGeometry: boolean;
  103725. /**
  103726. * Should materials render the irradiance information on the MRT
  103727. */
  103728. materialsShouldRenderIrradiance: boolean;
  103729. private _enabled;
  103730. /**
  103731. * Indicates if the prepass is enabled
  103732. */
  103733. get enabled(): boolean;
  103734. /**
  103735. * How many samples are used for MSAA of the scene render target
  103736. */
  103737. get samples(): number;
  103738. set samples(n: number);
  103739. /**
  103740. * Instanciates a prepass renderer
  103741. * @param scene The scene
  103742. */
  103743. constructor(scene: Scene);
  103744. private _initializeAttachments;
  103745. private _createCompositionEffect;
  103746. /**
  103747. * Indicates if rendering a prepass is supported
  103748. */
  103749. get isSupported(): boolean;
  103750. /**
  103751. * Sets the proper output textures to draw in the engine.
  103752. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103753. */
  103754. bindAttachmentsForEffect(effect: Effect): void;
  103755. /**
  103756. * @hidden
  103757. */
  103758. _beforeCameraDraw(): void;
  103759. /**
  103760. * @hidden
  103761. */
  103762. _afterCameraDraw(): void;
  103763. private _checkRTSize;
  103764. private _bindFrameBuffer;
  103765. /**
  103766. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103767. */
  103768. clear(): void;
  103769. private _setState;
  103770. private _enable;
  103771. private _disable;
  103772. private _resetPostProcessChain;
  103773. private _bindPostProcessChain;
  103774. /**
  103775. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103776. */
  103777. markAsDirty(): void;
  103778. private _update;
  103779. /**
  103780. * Disposes the prepass renderer.
  103781. */
  103782. dispose(): void;
  103783. }
  103784. }
  103785. declare module BABYLON {
  103786. /**
  103787. * Options for compiling materials.
  103788. */
  103789. export interface IMaterialCompilationOptions {
  103790. /**
  103791. * Defines whether clip planes are enabled.
  103792. */
  103793. clipPlane: boolean;
  103794. /**
  103795. * Defines whether instances are enabled.
  103796. */
  103797. useInstances: boolean;
  103798. }
  103799. /**
  103800. * Options passed when calling customShaderNameResolve
  103801. */
  103802. export interface ICustomShaderNameResolveOptions {
  103803. /**
  103804. * 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
  103805. */
  103806. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103807. }
  103808. /**
  103809. * Base class for the main features of a material in Babylon.js
  103810. */
  103811. export class Material implements IAnimatable {
  103812. /**
  103813. * Returns the triangle fill mode
  103814. */
  103815. static readonly TriangleFillMode: number;
  103816. /**
  103817. * Returns the wireframe mode
  103818. */
  103819. static readonly WireFrameFillMode: number;
  103820. /**
  103821. * Returns the point fill mode
  103822. */
  103823. static readonly PointFillMode: number;
  103824. /**
  103825. * Returns the point list draw mode
  103826. */
  103827. static readonly PointListDrawMode: number;
  103828. /**
  103829. * Returns the line list draw mode
  103830. */
  103831. static readonly LineListDrawMode: number;
  103832. /**
  103833. * Returns the line loop draw mode
  103834. */
  103835. static readonly LineLoopDrawMode: number;
  103836. /**
  103837. * Returns the line strip draw mode
  103838. */
  103839. static readonly LineStripDrawMode: number;
  103840. /**
  103841. * Returns the triangle strip draw mode
  103842. */
  103843. static readonly TriangleStripDrawMode: number;
  103844. /**
  103845. * Returns the triangle fan draw mode
  103846. */
  103847. static readonly TriangleFanDrawMode: number;
  103848. /**
  103849. * Stores the clock-wise side orientation
  103850. */
  103851. static readonly ClockWiseSideOrientation: number;
  103852. /**
  103853. * Stores the counter clock-wise side orientation
  103854. */
  103855. static readonly CounterClockWiseSideOrientation: number;
  103856. /**
  103857. * The dirty texture flag value
  103858. */
  103859. static readonly TextureDirtyFlag: number;
  103860. /**
  103861. * The dirty light flag value
  103862. */
  103863. static readonly LightDirtyFlag: number;
  103864. /**
  103865. * The dirty fresnel flag value
  103866. */
  103867. static readonly FresnelDirtyFlag: number;
  103868. /**
  103869. * The dirty attribute flag value
  103870. */
  103871. static readonly AttributesDirtyFlag: number;
  103872. /**
  103873. * The dirty misc flag value
  103874. */
  103875. static readonly MiscDirtyFlag: number;
  103876. /**
  103877. * The all dirty flag value
  103878. */
  103879. static readonly AllDirtyFlag: number;
  103880. /**
  103881. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103882. */
  103883. static readonly MATERIAL_OPAQUE: number;
  103884. /**
  103885. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103886. */
  103887. static readonly MATERIAL_ALPHATEST: number;
  103888. /**
  103889. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103890. */
  103891. static readonly MATERIAL_ALPHABLEND: number;
  103892. /**
  103893. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103894. * They are also discarded below the alpha cutoff threshold to improve performances.
  103895. */
  103896. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103897. /**
  103898. * The Whiteout method is used to blend normals.
  103899. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103900. */
  103901. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103902. /**
  103903. * The Reoriented Normal Mapping method is used to blend normals.
  103904. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103905. */
  103906. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103907. /**
  103908. * Custom callback helping to override the default shader used in the material.
  103909. */
  103910. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103911. /**
  103912. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103913. */
  103914. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103915. /**
  103916. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103917. * This means that the material can keep using a previous shader while a new one is being compiled.
  103918. * This is mostly used when shader parallel compilation is supported (true by default)
  103919. */
  103920. allowShaderHotSwapping: boolean;
  103921. /**
  103922. * The ID of the material
  103923. */
  103924. id: string;
  103925. /**
  103926. * Gets or sets the unique id of the material
  103927. */
  103928. uniqueId: number;
  103929. /**
  103930. * The name of the material
  103931. */
  103932. name: string;
  103933. /**
  103934. * Gets or sets user defined metadata
  103935. */
  103936. metadata: any;
  103937. /**
  103938. * For internal use only. Please do not use.
  103939. */
  103940. reservedDataStore: any;
  103941. /**
  103942. * Specifies if the ready state should be checked on each call
  103943. */
  103944. checkReadyOnEveryCall: boolean;
  103945. /**
  103946. * Specifies if the ready state should be checked once
  103947. */
  103948. checkReadyOnlyOnce: boolean;
  103949. /**
  103950. * The state of the material
  103951. */
  103952. state: string;
  103953. /**
  103954. * If the material can be rendered to several textures with MRT extension
  103955. */
  103956. get canRenderToMRT(): boolean;
  103957. /**
  103958. * The alpha value of the material
  103959. */
  103960. protected _alpha: number;
  103961. /**
  103962. * List of inspectable custom properties (used by the Inspector)
  103963. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103964. */
  103965. inspectableCustomProperties: IInspectable[];
  103966. /**
  103967. * Sets the alpha value of the material
  103968. */
  103969. set alpha(value: number);
  103970. /**
  103971. * Gets the alpha value of the material
  103972. */
  103973. get alpha(): number;
  103974. /**
  103975. * Specifies if back face culling is enabled
  103976. */
  103977. protected _backFaceCulling: boolean;
  103978. /**
  103979. * Sets the back-face culling state
  103980. */
  103981. set backFaceCulling(value: boolean);
  103982. /**
  103983. * Gets the back-face culling state
  103984. */
  103985. get backFaceCulling(): boolean;
  103986. /**
  103987. * Stores the value for side orientation
  103988. */
  103989. sideOrientation: number;
  103990. /**
  103991. * Callback triggered when the material is compiled
  103992. */
  103993. onCompiled: Nullable<(effect: Effect) => void>;
  103994. /**
  103995. * Callback triggered when an error occurs
  103996. */
  103997. onError: Nullable<(effect: Effect, errors: string) => void>;
  103998. /**
  103999. * Callback triggered to get the render target textures
  104000. */
  104001. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104002. /**
  104003. * Gets a boolean indicating that current material needs to register RTT
  104004. */
  104005. get hasRenderTargetTextures(): boolean;
  104006. /**
  104007. * Specifies if the material should be serialized
  104008. */
  104009. doNotSerialize: boolean;
  104010. /**
  104011. * @hidden
  104012. */
  104013. _storeEffectOnSubMeshes: boolean;
  104014. /**
  104015. * Stores the animations for the material
  104016. */
  104017. animations: Nullable<Array<Animation>>;
  104018. /**
  104019. * An event triggered when the material is disposed
  104020. */
  104021. onDisposeObservable: Observable<Material>;
  104022. /**
  104023. * An observer which watches for dispose events
  104024. */
  104025. private _onDisposeObserver;
  104026. private _onUnBindObservable;
  104027. /**
  104028. * Called during a dispose event
  104029. */
  104030. set onDispose(callback: () => void);
  104031. private _onBindObservable;
  104032. /**
  104033. * An event triggered when the material is bound
  104034. */
  104035. get onBindObservable(): Observable<AbstractMesh>;
  104036. /**
  104037. * An observer which watches for bind events
  104038. */
  104039. private _onBindObserver;
  104040. /**
  104041. * Called during a bind event
  104042. */
  104043. set onBind(callback: (Mesh: AbstractMesh) => void);
  104044. /**
  104045. * An event triggered when the material is unbound
  104046. */
  104047. get onUnBindObservable(): Observable<Material>;
  104048. protected _onEffectCreatedObservable: Nullable<Observable<{
  104049. effect: Effect;
  104050. subMesh: Nullable<SubMesh>;
  104051. }>>;
  104052. /**
  104053. * An event triggered when the effect is (re)created
  104054. */
  104055. get onEffectCreatedObservable(): Observable<{
  104056. effect: Effect;
  104057. subMesh: Nullable<SubMesh>;
  104058. }>;
  104059. /**
  104060. * Stores the value of the alpha mode
  104061. */
  104062. private _alphaMode;
  104063. /**
  104064. * Sets the value of the alpha mode.
  104065. *
  104066. * | Value | Type | Description |
  104067. * | --- | --- | --- |
  104068. * | 0 | ALPHA_DISABLE | |
  104069. * | 1 | ALPHA_ADD | |
  104070. * | 2 | ALPHA_COMBINE | |
  104071. * | 3 | ALPHA_SUBTRACT | |
  104072. * | 4 | ALPHA_MULTIPLY | |
  104073. * | 5 | ALPHA_MAXIMIZED | |
  104074. * | 6 | ALPHA_ONEONE | |
  104075. * | 7 | ALPHA_PREMULTIPLIED | |
  104076. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104077. * | 9 | ALPHA_INTERPOLATE | |
  104078. * | 10 | ALPHA_SCREENMODE | |
  104079. *
  104080. */
  104081. set alphaMode(value: number);
  104082. /**
  104083. * Gets the value of the alpha mode
  104084. */
  104085. get alphaMode(): number;
  104086. /**
  104087. * Stores the state of the need depth pre-pass value
  104088. */
  104089. private _needDepthPrePass;
  104090. /**
  104091. * Sets the need depth pre-pass value
  104092. */
  104093. set needDepthPrePass(value: boolean);
  104094. /**
  104095. * Gets the depth pre-pass value
  104096. */
  104097. get needDepthPrePass(): boolean;
  104098. /**
  104099. * Specifies if depth writing should be disabled
  104100. */
  104101. disableDepthWrite: boolean;
  104102. /**
  104103. * Specifies if color writing should be disabled
  104104. */
  104105. disableColorWrite: boolean;
  104106. /**
  104107. * Specifies if depth writing should be forced
  104108. */
  104109. forceDepthWrite: boolean;
  104110. /**
  104111. * Specifies the depth function that should be used. 0 means the default engine function
  104112. */
  104113. depthFunction: number;
  104114. /**
  104115. * Specifies if there should be a separate pass for culling
  104116. */
  104117. separateCullingPass: boolean;
  104118. /**
  104119. * Stores the state specifing if fog should be enabled
  104120. */
  104121. private _fogEnabled;
  104122. /**
  104123. * Sets the state for enabling fog
  104124. */
  104125. set fogEnabled(value: boolean);
  104126. /**
  104127. * Gets the value of the fog enabled state
  104128. */
  104129. get fogEnabled(): boolean;
  104130. /**
  104131. * Stores the size of points
  104132. */
  104133. pointSize: number;
  104134. /**
  104135. * Stores the z offset value
  104136. */
  104137. zOffset: number;
  104138. get wireframe(): boolean;
  104139. /**
  104140. * Sets the state of wireframe mode
  104141. */
  104142. set wireframe(value: boolean);
  104143. /**
  104144. * Gets the value specifying if point clouds are enabled
  104145. */
  104146. get pointsCloud(): boolean;
  104147. /**
  104148. * Sets the state of point cloud mode
  104149. */
  104150. set pointsCloud(value: boolean);
  104151. /**
  104152. * Gets the material fill mode
  104153. */
  104154. get fillMode(): number;
  104155. /**
  104156. * Sets the material fill mode
  104157. */
  104158. set fillMode(value: number);
  104159. /**
  104160. * @hidden
  104161. * Stores the effects for the material
  104162. */
  104163. _effect: Nullable<Effect>;
  104164. /**
  104165. * Specifies if uniform buffers should be used
  104166. */
  104167. private _useUBO;
  104168. /**
  104169. * Stores a reference to the scene
  104170. */
  104171. private _scene;
  104172. /**
  104173. * Stores the fill mode state
  104174. */
  104175. private _fillMode;
  104176. /**
  104177. * Specifies if the depth write state should be cached
  104178. */
  104179. private _cachedDepthWriteState;
  104180. /**
  104181. * Specifies if the color write state should be cached
  104182. */
  104183. private _cachedColorWriteState;
  104184. /**
  104185. * Specifies if the depth function state should be cached
  104186. */
  104187. private _cachedDepthFunctionState;
  104188. /**
  104189. * Stores the uniform buffer
  104190. */
  104191. protected _uniformBuffer: UniformBuffer;
  104192. /** @hidden */
  104193. _indexInSceneMaterialArray: number;
  104194. /** @hidden */
  104195. meshMap: Nullable<{
  104196. [id: string]: AbstractMesh | undefined;
  104197. }>;
  104198. /**
  104199. * Creates a material instance
  104200. * @param name defines the name of the material
  104201. * @param scene defines the scene to reference
  104202. * @param doNotAdd specifies if the material should be added to the scene
  104203. */
  104204. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104205. /**
  104206. * Returns a string representation of the current material
  104207. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104208. * @returns a string with material information
  104209. */
  104210. toString(fullDetails?: boolean): string;
  104211. /**
  104212. * Gets the class name of the material
  104213. * @returns a string with the class name of the material
  104214. */
  104215. getClassName(): string;
  104216. /**
  104217. * Specifies if updates for the material been locked
  104218. */
  104219. get isFrozen(): boolean;
  104220. /**
  104221. * Locks updates for the material
  104222. */
  104223. freeze(): void;
  104224. /**
  104225. * Unlocks updates for the material
  104226. */
  104227. unfreeze(): void;
  104228. /**
  104229. * Specifies if the material is ready to be used
  104230. * @param mesh defines the mesh to check
  104231. * @param useInstances specifies if instances should be used
  104232. * @returns a boolean indicating if the material is ready to be used
  104233. */
  104234. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104235. /**
  104236. * Specifies that the submesh is ready to be used
  104237. * @param mesh defines the mesh to check
  104238. * @param subMesh defines which submesh to check
  104239. * @param useInstances specifies that instances should be used
  104240. * @returns a boolean indicating that the submesh is ready or not
  104241. */
  104242. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104243. /**
  104244. * Returns the material effect
  104245. * @returns the effect associated with the material
  104246. */
  104247. getEffect(): Nullable<Effect>;
  104248. /**
  104249. * Returns the current scene
  104250. * @returns a Scene
  104251. */
  104252. getScene(): Scene;
  104253. /**
  104254. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104255. */
  104256. protected _forceAlphaTest: boolean;
  104257. /**
  104258. * The transparency mode of the material.
  104259. */
  104260. protected _transparencyMode: Nullable<number>;
  104261. /**
  104262. * Gets the current transparency mode.
  104263. */
  104264. get transparencyMode(): Nullable<number>;
  104265. /**
  104266. * Sets the transparency mode of the material.
  104267. *
  104268. * | Value | Type | Description |
  104269. * | ----- | ----------------------------------- | ----------- |
  104270. * | 0 | OPAQUE | |
  104271. * | 1 | ALPHATEST | |
  104272. * | 2 | ALPHABLEND | |
  104273. * | 3 | ALPHATESTANDBLEND | |
  104274. *
  104275. */
  104276. set transparencyMode(value: Nullable<number>);
  104277. /**
  104278. * Returns true if alpha blending should be disabled.
  104279. */
  104280. protected get _disableAlphaBlending(): boolean;
  104281. /**
  104282. * Specifies whether or not this material should be rendered in alpha blend mode.
  104283. * @returns a boolean specifying if alpha blending is needed
  104284. */
  104285. needAlphaBlending(): boolean;
  104286. /**
  104287. * Specifies if the mesh will require alpha blending
  104288. * @param mesh defines the mesh to check
  104289. * @returns a boolean specifying if alpha blending is needed for the mesh
  104290. */
  104291. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104292. /**
  104293. * Specifies whether or not this material should be rendered in alpha test mode.
  104294. * @returns a boolean specifying if an alpha test is needed.
  104295. */
  104296. needAlphaTesting(): boolean;
  104297. /**
  104298. * Specifies if material alpha testing should be turned on for the mesh
  104299. * @param mesh defines the mesh to check
  104300. */
  104301. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  104302. /**
  104303. * Gets the texture used for the alpha test
  104304. * @returns the texture to use for alpha testing
  104305. */
  104306. getAlphaTestTexture(): Nullable<BaseTexture>;
  104307. /**
  104308. * Marks the material to indicate that it needs to be re-calculated
  104309. */
  104310. markDirty(): void;
  104311. /** @hidden */
  104312. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  104313. /**
  104314. * Binds the material to the mesh
  104315. * @param world defines the world transformation matrix
  104316. * @param mesh defines the mesh to bind the material to
  104317. */
  104318. bind(world: Matrix, mesh?: Mesh): void;
  104319. /**
  104320. * Binds the submesh to the material
  104321. * @param world defines the world transformation matrix
  104322. * @param mesh defines the mesh containing the submesh
  104323. * @param subMesh defines the submesh to bind the material to
  104324. */
  104325. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104326. /**
  104327. * Binds the world matrix to the material
  104328. * @param world defines the world transformation matrix
  104329. */
  104330. bindOnlyWorldMatrix(world: Matrix): void;
  104331. /**
  104332. * Binds the scene's uniform buffer to the effect.
  104333. * @param effect defines the effect to bind to the scene uniform buffer
  104334. * @param sceneUbo defines the uniform buffer storing scene data
  104335. */
  104336. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104337. /**
  104338. * Binds the view matrix to the effect
  104339. * @param effect defines the effect to bind the view matrix to
  104340. */
  104341. bindView(effect: Effect): void;
  104342. /**
  104343. * Binds the view projection matrix to the effect
  104344. * @param effect defines the effect to bind the view projection matrix to
  104345. */
  104346. bindViewProjection(effect: Effect): void;
  104347. /**
  104348. * Processes to execute after binding the material to a mesh
  104349. * @param mesh defines the rendered mesh
  104350. */
  104351. protected _afterBind(mesh?: Mesh): void;
  104352. /**
  104353. * Unbinds the material from the mesh
  104354. */
  104355. unbind(): void;
  104356. /**
  104357. * Gets the active textures from the material
  104358. * @returns an array of textures
  104359. */
  104360. getActiveTextures(): BaseTexture[];
  104361. /**
  104362. * Specifies if the material uses a texture
  104363. * @param texture defines the texture to check against the material
  104364. * @returns a boolean specifying if the material uses the texture
  104365. */
  104366. hasTexture(texture: BaseTexture): boolean;
  104367. /**
  104368. * Makes a duplicate of the material, and gives it a new name
  104369. * @param name defines the new name for the duplicated material
  104370. * @returns the cloned material
  104371. */
  104372. clone(name: string): Nullable<Material>;
  104373. /**
  104374. * Gets the meshes bound to the material
  104375. * @returns an array of meshes bound to the material
  104376. */
  104377. getBindedMeshes(): AbstractMesh[];
  104378. /**
  104379. * Force shader compilation
  104380. * @param mesh defines the mesh associated with this material
  104381. * @param onCompiled defines a function to execute once the material is compiled
  104382. * @param options defines the options to configure the compilation
  104383. * @param onError defines a function to execute if the material fails compiling
  104384. */
  104385. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  104386. /**
  104387. * Force shader compilation
  104388. * @param mesh defines the mesh that will use this material
  104389. * @param options defines additional options for compiling the shaders
  104390. * @returns a promise that resolves when the compilation completes
  104391. */
  104392. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104393. private static readonly _AllDirtyCallBack;
  104394. private static readonly _ImageProcessingDirtyCallBack;
  104395. private static readonly _TextureDirtyCallBack;
  104396. private static readonly _FresnelDirtyCallBack;
  104397. private static readonly _MiscDirtyCallBack;
  104398. private static readonly _LightsDirtyCallBack;
  104399. private static readonly _AttributeDirtyCallBack;
  104400. private static _FresnelAndMiscDirtyCallBack;
  104401. private static _TextureAndMiscDirtyCallBack;
  104402. private static readonly _DirtyCallbackArray;
  104403. private static readonly _RunDirtyCallBacks;
  104404. /**
  104405. * Marks a define in the material to indicate that it needs to be re-computed
  104406. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104407. */
  104408. markAsDirty(flag: number): void;
  104409. /**
  104410. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104411. * @param func defines a function which checks material defines against the submeshes
  104412. */
  104413. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104414. /**
  104415. * Indicates that the scene should check if the rendering now needs a prepass
  104416. */
  104417. protected _markScenePrePassDirty(): void;
  104418. /**
  104419. * Indicates that we need to re-calculated for all submeshes
  104420. */
  104421. protected _markAllSubMeshesAsAllDirty(): void;
  104422. /**
  104423. * Indicates that image processing needs to be re-calculated for all submeshes
  104424. */
  104425. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104426. /**
  104427. * Indicates that textures need to be re-calculated for all submeshes
  104428. */
  104429. protected _markAllSubMeshesAsTexturesDirty(): void;
  104430. /**
  104431. * Indicates that fresnel needs to be re-calculated for all submeshes
  104432. */
  104433. protected _markAllSubMeshesAsFresnelDirty(): void;
  104434. /**
  104435. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104436. */
  104437. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104438. /**
  104439. * Indicates that lights need to be re-calculated for all submeshes
  104440. */
  104441. protected _markAllSubMeshesAsLightsDirty(): void;
  104442. /**
  104443. * Indicates that attributes need to be re-calculated for all submeshes
  104444. */
  104445. protected _markAllSubMeshesAsAttributesDirty(): void;
  104446. /**
  104447. * Indicates that misc needs to be re-calculated for all submeshes
  104448. */
  104449. protected _markAllSubMeshesAsMiscDirty(): void;
  104450. /**
  104451. * Indicates that textures and misc need to be re-calculated for all submeshes
  104452. */
  104453. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104454. /**
  104455. * Sets the required values to the prepass renderer.
  104456. * @param prePassRenderer defines the prepass renderer to setup.
  104457. * @returns true if the pre pass is needed.
  104458. */
  104459. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104460. /**
  104461. * Disposes the material
  104462. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104463. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104464. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104465. */
  104466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104467. /** @hidden */
  104468. private releaseVertexArrayObject;
  104469. /**
  104470. * Serializes this material
  104471. * @returns the serialized material object
  104472. */
  104473. serialize(): any;
  104474. /**
  104475. * Creates a material from parsed material data
  104476. * @param parsedMaterial defines parsed material data
  104477. * @param scene defines the hosting scene
  104478. * @param rootUrl defines the root URL to use to load textures
  104479. * @returns a new material
  104480. */
  104481. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104482. }
  104483. }
  104484. declare module BABYLON {
  104485. /**
  104486. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104487. * separate meshes. This can be use to improve performances.
  104488. * @see https://doc.babylonjs.com/how_to/multi_materials
  104489. */
  104490. export class MultiMaterial extends Material {
  104491. private _subMaterials;
  104492. /**
  104493. * Gets or Sets the list of Materials used within the multi material.
  104494. * They need to be ordered according to the submeshes order in the associated mesh
  104495. */
  104496. get subMaterials(): Nullable<Material>[];
  104497. set subMaterials(value: Nullable<Material>[]);
  104498. /**
  104499. * Function used to align with Node.getChildren()
  104500. * @returns the list of Materials used within the multi material
  104501. */
  104502. getChildren(): Nullable<Material>[];
  104503. /**
  104504. * Instantiates a new Multi Material
  104505. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104506. * separate meshes. This can be use to improve performances.
  104507. * @see https://doc.babylonjs.com/how_to/multi_materials
  104508. * @param name Define the name in the scene
  104509. * @param scene Define the scene the material belongs to
  104510. */
  104511. constructor(name: string, scene: Scene);
  104512. private _hookArray;
  104513. /**
  104514. * Get one of the submaterial by its index in the submaterials array
  104515. * @param index The index to look the sub material at
  104516. * @returns The Material if the index has been defined
  104517. */
  104518. getSubMaterial(index: number): Nullable<Material>;
  104519. /**
  104520. * Get the list of active textures for the whole sub materials list.
  104521. * @returns All the textures that will be used during the rendering
  104522. */
  104523. getActiveTextures(): BaseTexture[];
  104524. /**
  104525. * Gets the current class name of the material e.g. "MultiMaterial"
  104526. * Mainly use in serialization.
  104527. * @returns the class name
  104528. */
  104529. getClassName(): string;
  104530. /**
  104531. * Checks if the material is ready to render the requested sub mesh
  104532. * @param mesh Define the mesh the submesh belongs to
  104533. * @param subMesh Define the sub mesh to look readyness for
  104534. * @param useInstances Define whether or not the material is used with instances
  104535. * @returns true if ready, otherwise false
  104536. */
  104537. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104538. /**
  104539. * Clones the current material and its related sub materials
  104540. * @param name Define the name of the newly cloned material
  104541. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  104542. * @returns the cloned material
  104543. */
  104544. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  104545. /**
  104546. * Serializes the materials into a JSON representation.
  104547. * @returns the JSON representation
  104548. */
  104549. serialize(): any;
  104550. /**
  104551. * Dispose the material and release its associated resources
  104552. * @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)
  104553. * @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)
  104554. * @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)
  104555. */
  104556. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  104557. /**
  104558. * Creates a MultiMaterial from parsed MultiMaterial data.
  104559. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  104560. * @param scene defines the hosting scene
  104561. * @returns a new MultiMaterial
  104562. */
  104563. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  104564. }
  104565. }
  104566. declare module BABYLON {
  104567. /**
  104568. * Defines a subdivision inside a mesh
  104569. */
  104570. export class SubMesh implements ICullable {
  104571. /** the material index to use */
  104572. materialIndex: number;
  104573. /** vertex index start */
  104574. verticesStart: number;
  104575. /** vertices count */
  104576. verticesCount: number;
  104577. /** index start */
  104578. indexStart: number;
  104579. /** indices count */
  104580. indexCount: number;
  104581. /** @hidden */
  104582. _materialDefines: Nullable<MaterialDefines>;
  104583. /** @hidden */
  104584. _materialEffect: Nullable<Effect>;
  104585. /** @hidden */
  104586. _effectOverride: Nullable<Effect>;
  104587. /**
  104588. * Gets material defines used by the effect associated to the sub mesh
  104589. */
  104590. get materialDefines(): Nullable<MaterialDefines>;
  104591. /**
  104592. * Sets material defines used by the effect associated to the sub mesh
  104593. */
  104594. set materialDefines(defines: Nullable<MaterialDefines>);
  104595. /**
  104596. * Gets associated effect
  104597. */
  104598. get effect(): Nullable<Effect>;
  104599. /**
  104600. * Sets associated effect (effect used to render this submesh)
  104601. * @param effect defines the effect to associate with
  104602. * @param defines defines the set of defines used to compile this effect
  104603. */
  104604. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104605. /** @hidden */
  104606. _linesIndexCount: number;
  104607. private _mesh;
  104608. private _renderingMesh;
  104609. private _boundingInfo;
  104610. private _linesIndexBuffer;
  104611. /** @hidden */
  104612. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104613. /** @hidden */
  104614. _trianglePlanes: Plane[];
  104615. /** @hidden */
  104616. _lastColliderTransformMatrix: Nullable<Matrix>;
  104617. /** @hidden */
  104618. _renderId: number;
  104619. /** @hidden */
  104620. _alphaIndex: number;
  104621. /** @hidden */
  104622. _distanceToCamera: number;
  104623. /** @hidden */
  104624. _id: number;
  104625. private _currentMaterial;
  104626. /**
  104627. * Add a new submesh to a mesh
  104628. * @param materialIndex defines the material index to use
  104629. * @param verticesStart defines vertex index start
  104630. * @param verticesCount defines vertices count
  104631. * @param indexStart defines index start
  104632. * @param indexCount defines indices count
  104633. * @param mesh defines the parent mesh
  104634. * @param renderingMesh defines an optional rendering mesh
  104635. * @param createBoundingBox defines if bounding box should be created for this submesh
  104636. * @returns the new submesh
  104637. */
  104638. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104639. /**
  104640. * Creates a new submesh
  104641. * @param materialIndex defines the material index to use
  104642. * @param verticesStart defines vertex index start
  104643. * @param verticesCount defines vertices count
  104644. * @param indexStart defines index start
  104645. * @param indexCount defines indices count
  104646. * @param mesh defines the parent mesh
  104647. * @param renderingMesh defines an optional rendering mesh
  104648. * @param createBoundingBox defines if bounding box should be created for this submesh
  104649. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104650. */
  104651. constructor(
  104652. /** the material index to use */
  104653. materialIndex: number,
  104654. /** vertex index start */
  104655. verticesStart: number,
  104656. /** vertices count */
  104657. verticesCount: number,
  104658. /** index start */
  104659. indexStart: number,
  104660. /** indices count */
  104661. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104662. /**
  104663. * Returns true if this submesh covers the entire parent mesh
  104664. * @ignorenaming
  104665. */
  104666. get IsGlobal(): boolean;
  104667. /**
  104668. * Returns the submesh BoudingInfo object
  104669. * @returns current bounding info (or mesh's one if the submesh is global)
  104670. */
  104671. getBoundingInfo(): BoundingInfo;
  104672. /**
  104673. * Sets the submesh BoundingInfo
  104674. * @param boundingInfo defines the new bounding info to use
  104675. * @returns the SubMesh
  104676. */
  104677. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104678. /**
  104679. * Returns the mesh of the current submesh
  104680. * @return the parent mesh
  104681. */
  104682. getMesh(): AbstractMesh;
  104683. /**
  104684. * Returns the rendering mesh of the submesh
  104685. * @returns the rendering mesh (could be different from parent mesh)
  104686. */
  104687. getRenderingMesh(): Mesh;
  104688. /**
  104689. * Returns the replacement mesh of the submesh
  104690. * @returns the replacement mesh (could be different from parent mesh)
  104691. */
  104692. getReplacementMesh(): Nullable<AbstractMesh>;
  104693. /**
  104694. * Returns the effective mesh of the submesh
  104695. * @returns the effective mesh (could be different from parent mesh)
  104696. */
  104697. getEffectiveMesh(): AbstractMesh;
  104698. /**
  104699. * Returns the submesh material
  104700. * @returns null or the current material
  104701. */
  104702. getMaterial(): Nullable<Material>;
  104703. private _IsMultiMaterial;
  104704. /**
  104705. * Sets a new updated BoundingInfo object to the submesh
  104706. * @param data defines an optional position array to use to determine the bounding info
  104707. * @returns the SubMesh
  104708. */
  104709. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104710. /** @hidden */
  104711. _checkCollision(collider: Collider): boolean;
  104712. /**
  104713. * Updates the submesh BoundingInfo
  104714. * @param world defines the world matrix to use to update the bounding info
  104715. * @returns the submesh
  104716. */
  104717. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104718. /**
  104719. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104720. * @param frustumPlanes defines the frustum planes
  104721. * @returns true if the submesh is intersecting with the frustum
  104722. */
  104723. isInFrustum(frustumPlanes: Plane[]): boolean;
  104724. /**
  104725. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104726. * @param frustumPlanes defines the frustum planes
  104727. * @returns true if the submesh is inside the frustum
  104728. */
  104729. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104730. /**
  104731. * Renders the submesh
  104732. * @param enableAlphaMode defines if alpha needs to be used
  104733. * @returns the submesh
  104734. */
  104735. render(enableAlphaMode: boolean): SubMesh;
  104736. /**
  104737. * @hidden
  104738. */
  104739. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104740. /**
  104741. * Checks if the submesh intersects with a ray
  104742. * @param ray defines the ray to test
  104743. * @returns true is the passed ray intersects the submesh bounding box
  104744. */
  104745. canIntersects(ray: Ray): boolean;
  104746. /**
  104747. * Intersects current submesh with a ray
  104748. * @param ray defines the ray to test
  104749. * @param positions defines mesh's positions array
  104750. * @param indices defines mesh's indices array
  104751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104752. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104753. * @returns intersection info or null if no intersection
  104754. */
  104755. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104756. /** @hidden */
  104757. private _intersectLines;
  104758. /** @hidden */
  104759. private _intersectUnIndexedLines;
  104760. /** @hidden */
  104761. private _intersectTriangles;
  104762. /** @hidden */
  104763. private _intersectUnIndexedTriangles;
  104764. /** @hidden */
  104765. _rebuild(): void;
  104766. /**
  104767. * Creates a new submesh from the passed mesh
  104768. * @param newMesh defines the new hosting mesh
  104769. * @param newRenderingMesh defines an optional rendering mesh
  104770. * @returns the new submesh
  104771. */
  104772. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104773. /**
  104774. * Release associated resources
  104775. */
  104776. dispose(): void;
  104777. /**
  104778. * Gets the class name
  104779. * @returns the string "SubMesh".
  104780. */
  104781. getClassName(): string;
  104782. /**
  104783. * Creates a new submesh from indices data
  104784. * @param materialIndex the index of the main mesh material
  104785. * @param startIndex the index where to start the copy in the mesh indices array
  104786. * @param indexCount the number of indices to copy then from the startIndex
  104787. * @param mesh the main mesh to create the submesh from
  104788. * @param renderingMesh the optional rendering mesh
  104789. * @returns a new submesh
  104790. */
  104791. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104792. }
  104793. }
  104794. declare module BABYLON {
  104795. /**
  104796. * Class used to represent data loading progression
  104797. */
  104798. export class SceneLoaderFlags {
  104799. private static _ForceFullSceneLoadingForIncremental;
  104800. private static _ShowLoadingScreen;
  104801. private static _CleanBoneMatrixWeights;
  104802. private static _loggingLevel;
  104803. /**
  104804. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104805. */
  104806. static get ForceFullSceneLoadingForIncremental(): boolean;
  104807. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104808. /**
  104809. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104810. */
  104811. static get ShowLoadingScreen(): boolean;
  104812. static set ShowLoadingScreen(value: boolean);
  104813. /**
  104814. * Defines the current logging level (while loading the scene)
  104815. * @ignorenaming
  104816. */
  104817. static get loggingLevel(): number;
  104818. static set loggingLevel(value: number);
  104819. /**
  104820. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104821. */
  104822. static get CleanBoneMatrixWeights(): boolean;
  104823. static set CleanBoneMatrixWeights(value: boolean);
  104824. }
  104825. }
  104826. declare module BABYLON {
  104827. /**
  104828. * Class used to store geometry data (vertex buffers + index buffer)
  104829. */
  104830. export class Geometry implements IGetSetVerticesData {
  104831. /**
  104832. * Gets or sets the ID of the geometry
  104833. */
  104834. id: string;
  104835. /**
  104836. * Gets or sets the unique ID of the geometry
  104837. */
  104838. uniqueId: number;
  104839. /**
  104840. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104841. */
  104842. delayLoadState: number;
  104843. /**
  104844. * Gets the file containing the data to load when running in delay load state
  104845. */
  104846. delayLoadingFile: Nullable<string>;
  104847. /**
  104848. * Callback called when the geometry is updated
  104849. */
  104850. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104851. private _scene;
  104852. private _engine;
  104853. private _meshes;
  104854. private _totalVertices;
  104855. /** @hidden */
  104856. _indices: IndicesArray;
  104857. /** @hidden */
  104858. _vertexBuffers: {
  104859. [key: string]: VertexBuffer;
  104860. };
  104861. private _isDisposed;
  104862. private _extend;
  104863. private _boundingBias;
  104864. /** @hidden */
  104865. _delayInfo: Array<string>;
  104866. private _indexBuffer;
  104867. private _indexBufferIsUpdatable;
  104868. /** @hidden */
  104869. _boundingInfo: Nullable<BoundingInfo>;
  104870. /** @hidden */
  104871. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104872. /** @hidden */
  104873. _softwareSkinningFrameId: number;
  104874. private _vertexArrayObjects;
  104875. private _updatable;
  104876. /** @hidden */
  104877. _positions: Nullable<Vector3[]>;
  104878. /**
  104879. * 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
  104880. */
  104881. get boundingBias(): Vector2;
  104882. /**
  104883. * 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
  104884. */
  104885. set boundingBias(value: Vector2);
  104886. /**
  104887. * Static function used to attach a new empty geometry to a mesh
  104888. * @param mesh defines the mesh to attach the geometry to
  104889. * @returns the new Geometry
  104890. */
  104891. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104892. /** Get the list of meshes using this geometry */
  104893. get meshes(): Mesh[];
  104894. /**
  104895. * 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
  104896. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104897. */
  104898. useBoundingInfoFromGeometry: boolean;
  104899. /**
  104900. * Creates a new geometry
  104901. * @param id defines the unique ID
  104902. * @param scene defines the hosting scene
  104903. * @param vertexData defines the VertexData used to get geometry data
  104904. * @param updatable defines if geometry must be updatable (false by default)
  104905. * @param mesh defines the mesh that will be associated with the geometry
  104906. */
  104907. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104908. /**
  104909. * Gets the current extend of the geometry
  104910. */
  104911. get extend(): {
  104912. minimum: Vector3;
  104913. maximum: Vector3;
  104914. };
  104915. /**
  104916. * Gets the hosting scene
  104917. * @returns the hosting Scene
  104918. */
  104919. getScene(): Scene;
  104920. /**
  104921. * Gets the hosting engine
  104922. * @returns the hosting Engine
  104923. */
  104924. getEngine(): Engine;
  104925. /**
  104926. * Defines if the geometry is ready to use
  104927. * @returns true if the geometry is ready to be used
  104928. */
  104929. isReady(): boolean;
  104930. /**
  104931. * Gets a value indicating that the geometry should not be serialized
  104932. */
  104933. get doNotSerialize(): boolean;
  104934. /** @hidden */
  104935. _rebuild(): void;
  104936. /**
  104937. * Affects all geometry data in one call
  104938. * @param vertexData defines the geometry data
  104939. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104940. */
  104941. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104942. /**
  104943. * Set specific vertex data
  104944. * @param kind defines the data kind (Position, normal, etc...)
  104945. * @param data defines the vertex data to use
  104946. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104947. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104948. */
  104949. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104950. /**
  104951. * Removes a specific vertex data
  104952. * @param kind defines the data kind (Position, normal, etc...)
  104953. */
  104954. removeVerticesData(kind: string): void;
  104955. /**
  104956. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104957. * @param buffer defines the vertex buffer to use
  104958. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104959. */
  104960. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104961. /**
  104962. * Update a specific vertex buffer
  104963. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104964. * It will do nothing if the buffer is not updatable
  104965. * @param kind defines the data kind (Position, normal, etc...)
  104966. * @param data defines the data to use
  104967. * @param offset defines the offset in the target buffer where to store the data
  104968. * @param useBytes set to true if the offset is in bytes
  104969. */
  104970. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104971. /**
  104972. * Update a specific vertex buffer
  104973. * This function will create a new buffer if the current one is not updatable
  104974. * @param kind defines the data kind (Position, normal, etc...)
  104975. * @param data defines the data to use
  104976. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104977. */
  104978. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104979. private _updateBoundingInfo;
  104980. /** @hidden */
  104981. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104982. /**
  104983. * Gets total number of vertices
  104984. * @returns the total number of vertices
  104985. */
  104986. getTotalVertices(): number;
  104987. /**
  104988. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104989. * @param kind defines the data kind (Position, normal, etc...)
  104990. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104991. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104992. * @returns a float array containing vertex data
  104993. */
  104994. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104995. /**
  104996. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104997. * @param kind defines the data kind (Position, normal, etc...)
  104998. * @returns true if the vertex buffer with the specified kind is updatable
  104999. */
  105000. isVertexBufferUpdatable(kind: string): boolean;
  105001. /**
  105002. * Gets a specific vertex buffer
  105003. * @param kind defines the data kind (Position, normal, etc...)
  105004. * @returns a VertexBuffer
  105005. */
  105006. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105007. /**
  105008. * Returns all vertex buffers
  105009. * @return an object holding all vertex buffers indexed by kind
  105010. */
  105011. getVertexBuffers(): Nullable<{
  105012. [key: string]: VertexBuffer;
  105013. }>;
  105014. /**
  105015. * Gets a boolean indicating if specific vertex buffer is present
  105016. * @param kind defines the data kind (Position, normal, etc...)
  105017. * @returns true if data is present
  105018. */
  105019. isVerticesDataPresent(kind: string): boolean;
  105020. /**
  105021. * Gets a list of all attached data kinds (Position, normal, etc...)
  105022. * @returns a list of string containing all kinds
  105023. */
  105024. getVerticesDataKinds(): string[];
  105025. /**
  105026. * Update index buffer
  105027. * @param indices defines the indices to store in the index buffer
  105028. * @param offset defines the offset in the target buffer where to store the data
  105029. * @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)
  105030. */
  105031. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105032. /**
  105033. * Creates a new index buffer
  105034. * @param indices defines the indices to store in the index buffer
  105035. * @param totalVertices defines the total number of vertices (could be null)
  105036. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105037. */
  105038. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105039. /**
  105040. * Return the total number of indices
  105041. * @returns the total number of indices
  105042. */
  105043. getTotalIndices(): number;
  105044. /**
  105045. * Gets the index buffer array
  105046. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105047. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105048. * @returns the index buffer array
  105049. */
  105050. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105051. /**
  105052. * Gets the index buffer
  105053. * @return the index buffer
  105054. */
  105055. getIndexBuffer(): Nullable<DataBuffer>;
  105056. /** @hidden */
  105057. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105058. /**
  105059. * Release the associated resources for a specific mesh
  105060. * @param mesh defines the source mesh
  105061. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105062. */
  105063. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105064. /**
  105065. * Apply current geometry to a given mesh
  105066. * @param mesh defines the mesh to apply geometry to
  105067. */
  105068. applyToMesh(mesh: Mesh): void;
  105069. private _updateExtend;
  105070. private _applyToMesh;
  105071. private notifyUpdate;
  105072. /**
  105073. * Load the geometry if it was flagged as delay loaded
  105074. * @param scene defines the hosting scene
  105075. * @param onLoaded defines a callback called when the geometry is loaded
  105076. */
  105077. load(scene: Scene, onLoaded?: () => void): void;
  105078. private _queueLoad;
  105079. /**
  105080. * Invert the geometry to move from a right handed system to a left handed one.
  105081. */
  105082. toLeftHanded(): void;
  105083. /** @hidden */
  105084. _resetPointsArrayCache(): void;
  105085. /** @hidden */
  105086. _generatePointsArray(): boolean;
  105087. /**
  105088. * Gets a value indicating if the geometry is disposed
  105089. * @returns true if the geometry was disposed
  105090. */
  105091. isDisposed(): boolean;
  105092. private _disposeVertexArrayObjects;
  105093. /**
  105094. * Free all associated resources
  105095. */
  105096. dispose(): void;
  105097. /**
  105098. * Clone the current geometry into a new geometry
  105099. * @param id defines the unique ID of the new geometry
  105100. * @returns a new geometry object
  105101. */
  105102. copy(id: string): Geometry;
  105103. /**
  105104. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105105. * @return a JSON representation of the current geometry data (without the vertices data)
  105106. */
  105107. serialize(): any;
  105108. private toNumberArray;
  105109. /**
  105110. * Serialize all vertices data into a JSON oject
  105111. * @returns a JSON representation of the current geometry data
  105112. */
  105113. serializeVerticeData(): any;
  105114. /**
  105115. * Extracts a clone of a mesh geometry
  105116. * @param mesh defines the source mesh
  105117. * @param id defines the unique ID of the new geometry object
  105118. * @returns the new geometry object
  105119. */
  105120. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105121. /**
  105122. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105123. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105124. * Be aware Math.random() could cause collisions, but:
  105125. * "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"
  105126. * @returns a string containing a new GUID
  105127. */
  105128. static RandomId(): string;
  105129. /** @hidden */
  105130. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105131. private static _CleanMatricesWeights;
  105132. /**
  105133. * Create a new geometry from persisted data (Using .babylon file format)
  105134. * @param parsedVertexData defines the persisted data
  105135. * @param scene defines the hosting scene
  105136. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105137. * @returns the new geometry object
  105138. */
  105139. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105140. }
  105141. }
  105142. declare module BABYLON {
  105143. /**
  105144. * Define an interface for all classes that will get and set the data on vertices
  105145. */
  105146. export interface IGetSetVerticesData {
  105147. /**
  105148. * Gets a boolean indicating if specific vertex data is present
  105149. * @param kind defines the vertex data kind to use
  105150. * @returns true is data kind is present
  105151. */
  105152. isVerticesDataPresent(kind: string): boolean;
  105153. /**
  105154. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105155. * @param kind defines the data kind (Position, normal, etc...)
  105156. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105157. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105158. * @returns a float array containing vertex data
  105159. */
  105160. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105161. /**
  105162. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105163. * @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.
  105164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105165. * @returns the indices array or an empty array if the mesh has no geometry
  105166. */
  105167. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105168. /**
  105169. * Set specific vertex data
  105170. * @param kind defines the data kind (Position, normal, etc...)
  105171. * @param data defines the vertex data to use
  105172. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105173. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105174. */
  105175. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105176. /**
  105177. * Update a specific associated vertex buffer
  105178. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105179. * - VertexBuffer.PositionKind
  105180. * - VertexBuffer.UVKind
  105181. * - VertexBuffer.UV2Kind
  105182. * - VertexBuffer.UV3Kind
  105183. * - VertexBuffer.UV4Kind
  105184. * - VertexBuffer.UV5Kind
  105185. * - VertexBuffer.UV6Kind
  105186. * - VertexBuffer.ColorKind
  105187. * - VertexBuffer.MatricesIndicesKind
  105188. * - VertexBuffer.MatricesIndicesExtraKind
  105189. * - VertexBuffer.MatricesWeightsKind
  105190. * - VertexBuffer.MatricesWeightsExtraKind
  105191. * @param data defines the data source
  105192. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105193. * @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)
  105194. */
  105195. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105196. /**
  105197. * Creates a new index buffer
  105198. * @param indices defines the indices to store in the index buffer
  105199. * @param totalVertices defines the total number of vertices (could be null)
  105200. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105201. */
  105202. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105203. }
  105204. /**
  105205. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105206. */
  105207. export class VertexData {
  105208. /**
  105209. * Mesh side orientation : usually the external or front surface
  105210. */
  105211. static readonly FRONTSIDE: number;
  105212. /**
  105213. * Mesh side orientation : usually the internal or back surface
  105214. */
  105215. static readonly BACKSIDE: number;
  105216. /**
  105217. * Mesh side orientation : both internal and external or front and back surfaces
  105218. */
  105219. static readonly DOUBLESIDE: number;
  105220. /**
  105221. * Mesh side orientation : by default, `FRONTSIDE`
  105222. */
  105223. static readonly DEFAULTSIDE: number;
  105224. /**
  105225. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105226. */
  105227. positions: Nullable<FloatArray>;
  105228. /**
  105229. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105230. */
  105231. normals: Nullable<FloatArray>;
  105232. /**
  105233. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105234. */
  105235. tangents: Nullable<FloatArray>;
  105236. /**
  105237. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105238. */
  105239. uvs: Nullable<FloatArray>;
  105240. /**
  105241. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105242. */
  105243. uvs2: Nullable<FloatArray>;
  105244. /**
  105245. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105246. */
  105247. uvs3: Nullable<FloatArray>;
  105248. /**
  105249. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105250. */
  105251. uvs4: Nullable<FloatArray>;
  105252. /**
  105253. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105254. */
  105255. uvs5: Nullable<FloatArray>;
  105256. /**
  105257. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105258. */
  105259. uvs6: Nullable<FloatArray>;
  105260. /**
  105261. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  105262. */
  105263. colors: Nullable<FloatArray>;
  105264. /**
  105265. * 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).
  105266. */
  105267. matricesIndices: Nullable<FloatArray>;
  105268. /**
  105269. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  105270. */
  105271. matricesWeights: Nullable<FloatArray>;
  105272. /**
  105273. * An array extending the number of possible indices
  105274. */
  105275. matricesIndicesExtra: Nullable<FloatArray>;
  105276. /**
  105277. * An array extending the number of possible weights when the number of indices is extended
  105278. */
  105279. matricesWeightsExtra: Nullable<FloatArray>;
  105280. /**
  105281. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  105282. */
  105283. indices: Nullable<IndicesArray>;
  105284. /**
  105285. * Uses the passed data array to set the set the values for the specified kind of data
  105286. * @param data a linear array of floating numbers
  105287. * @param kind the type of data that is being set, eg positions, colors etc
  105288. */
  105289. set(data: FloatArray, kind: string): void;
  105290. /**
  105291. * Associates the vertexData to the passed Mesh.
  105292. * Sets it as updatable or not (default `false`)
  105293. * @param mesh the mesh the vertexData is applied to
  105294. * @param updatable when used and having the value true allows new data to update the vertexData
  105295. * @returns the VertexData
  105296. */
  105297. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  105298. /**
  105299. * Associates the vertexData to the passed Geometry.
  105300. * Sets it as updatable or not (default `false`)
  105301. * @param geometry the geometry the vertexData is applied to
  105302. * @param updatable when used and having the value true allows new data to update the vertexData
  105303. * @returns VertexData
  105304. */
  105305. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  105306. /**
  105307. * Updates the associated mesh
  105308. * @param mesh the mesh to be updated
  105309. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105310. * @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
  105311. * @returns VertexData
  105312. */
  105313. updateMesh(mesh: Mesh): VertexData;
  105314. /**
  105315. * Updates the associated geometry
  105316. * @param geometry the geometry to be updated
  105317. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105318. * @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
  105319. * @returns VertexData.
  105320. */
  105321. updateGeometry(geometry: Geometry): VertexData;
  105322. private _applyTo;
  105323. private _update;
  105324. /**
  105325. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105326. * @param matrix the transforming matrix
  105327. * @returns the VertexData
  105328. */
  105329. transform(matrix: Matrix): VertexData;
  105330. /**
  105331. * Merges the passed VertexData into the current one
  105332. * @param other the VertexData to be merged into the current one
  105333. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105334. * @returns the modified VertexData
  105335. */
  105336. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105337. private _mergeElement;
  105338. private _validate;
  105339. /**
  105340. * Serializes the VertexData
  105341. * @returns a serialized object
  105342. */
  105343. serialize(): any;
  105344. /**
  105345. * Extracts the vertexData from a mesh
  105346. * @param mesh the mesh from which to extract the VertexData
  105347. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105348. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105349. * @returns the object VertexData associated to the passed mesh
  105350. */
  105351. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105352. /**
  105353. * Extracts the vertexData from the geometry
  105354. * @param geometry the geometry from which to extract the VertexData
  105355. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105356. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105357. * @returns the object VertexData associated to the passed mesh
  105358. */
  105359. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105360. private static _ExtractFrom;
  105361. /**
  105362. * Creates the VertexData for a Ribbon
  105363. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105364. * * pathArray array of paths, each of which an array of successive Vector3
  105365. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105366. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105367. * * 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
  105368. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105369. * * 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)
  105370. * * 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)
  105371. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105372. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105373. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105374. * @returns the VertexData of the ribbon
  105375. */
  105376. static CreateRibbon(options: {
  105377. pathArray: Vector3[][];
  105378. closeArray?: boolean;
  105379. closePath?: boolean;
  105380. offset?: number;
  105381. sideOrientation?: number;
  105382. frontUVs?: Vector4;
  105383. backUVs?: Vector4;
  105384. invertUV?: boolean;
  105385. uvs?: Vector2[];
  105386. colors?: Color4[];
  105387. }): VertexData;
  105388. /**
  105389. * Creates the VertexData for a box
  105390. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105391. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105392. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105393. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105394. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105395. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105396. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105398. * * 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)
  105399. * * 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)
  105400. * @returns the VertexData of the box
  105401. */
  105402. static CreateBox(options: {
  105403. size?: number;
  105404. width?: number;
  105405. height?: number;
  105406. depth?: number;
  105407. faceUV?: Vector4[];
  105408. faceColors?: Color4[];
  105409. sideOrientation?: number;
  105410. frontUVs?: Vector4;
  105411. backUVs?: Vector4;
  105412. }): VertexData;
  105413. /**
  105414. * Creates the VertexData for a tiled box
  105415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105416. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105417. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105418. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105419. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105420. * @returns the VertexData of the box
  105421. */
  105422. static CreateTiledBox(options: {
  105423. pattern?: number;
  105424. width?: number;
  105425. height?: number;
  105426. depth?: number;
  105427. tileSize?: number;
  105428. tileWidth?: number;
  105429. tileHeight?: number;
  105430. alignHorizontal?: number;
  105431. alignVertical?: number;
  105432. faceUV?: Vector4[];
  105433. faceColors?: Color4[];
  105434. sideOrientation?: number;
  105435. }): VertexData;
  105436. /**
  105437. * Creates the VertexData for a tiled plane
  105438. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105439. * * pattern a limited pattern arrangement depending on the number
  105440. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105441. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105442. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105444. * * 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)
  105445. * * 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)
  105446. * @returns the VertexData of the tiled plane
  105447. */
  105448. static CreateTiledPlane(options: {
  105449. pattern?: number;
  105450. tileSize?: number;
  105451. tileWidth?: number;
  105452. tileHeight?: number;
  105453. size?: number;
  105454. width?: number;
  105455. height?: number;
  105456. alignHorizontal?: number;
  105457. alignVertical?: number;
  105458. sideOrientation?: number;
  105459. frontUVs?: Vector4;
  105460. backUVs?: Vector4;
  105461. }): VertexData;
  105462. /**
  105463. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105464. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105465. * * segments sets the number of horizontal strips optional, default 32
  105466. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105467. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105468. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105469. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105470. * * 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
  105471. * * 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
  105472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105473. * * 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)
  105474. * * 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)
  105475. * @returns the VertexData of the ellipsoid
  105476. */
  105477. static CreateSphere(options: {
  105478. segments?: number;
  105479. diameter?: number;
  105480. diameterX?: number;
  105481. diameterY?: number;
  105482. diameterZ?: number;
  105483. arc?: number;
  105484. slice?: number;
  105485. sideOrientation?: number;
  105486. frontUVs?: Vector4;
  105487. backUVs?: Vector4;
  105488. }): VertexData;
  105489. /**
  105490. * Creates the VertexData for a cylinder, cone or prism
  105491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105492. * * height sets the height (y direction) of the cylinder, optional, default 2
  105493. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  105494. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  105495. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  105496. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105497. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  105498. * * 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
  105499. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105500. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105501. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105502. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105504. * * 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)
  105505. * * 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)
  105506. * @returns the VertexData of the cylinder, cone or prism
  105507. */
  105508. static CreateCylinder(options: {
  105509. height?: number;
  105510. diameterTop?: number;
  105511. diameterBottom?: number;
  105512. diameter?: number;
  105513. tessellation?: number;
  105514. subdivisions?: number;
  105515. arc?: number;
  105516. faceColors?: Color4[];
  105517. faceUV?: Vector4[];
  105518. hasRings?: boolean;
  105519. enclose?: boolean;
  105520. sideOrientation?: number;
  105521. frontUVs?: Vector4;
  105522. backUVs?: Vector4;
  105523. }): VertexData;
  105524. /**
  105525. * Creates the VertexData for a torus
  105526. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105527. * * diameter the diameter of the torus, optional default 1
  105528. * * thickness the diameter of the tube forming the torus, optional default 0.5
  105529. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105531. * * 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)
  105532. * * 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)
  105533. * @returns the VertexData of the torus
  105534. */
  105535. static CreateTorus(options: {
  105536. diameter?: number;
  105537. thickness?: number;
  105538. tessellation?: number;
  105539. sideOrientation?: number;
  105540. frontUVs?: Vector4;
  105541. backUVs?: Vector4;
  105542. }): VertexData;
  105543. /**
  105544. * Creates the VertexData of the LineSystem
  105545. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  105546. * - lines an array of lines, each line being an array of successive Vector3
  105547. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  105548. * @returns the VertexData of the LineSystem
  105549. */
  105550. static CreateLineSystem(options: {
  105551. lines: Vector3[][];
  105552. colors?: Nullable<Color4[][]>;
  105553. }): VertexData;
  105554. /**
  105555. * Create the VertexData for a DashedLines
  105556. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  105557. * - points an array successive Vector3
  105558. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  105559. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  105560. * - dashNb the intended total number of dashes, optional, default 200
  105561. * @returns the VertexData for the DashedLines
  105562. */
  105563. static CreateDashedLines(options: {
  105564. points: Vector3[];
  105565. dashSize?: number;
  105566. gapSize?: number;
  105567. dashNb?: number;
  105568. }): VertexData;
  105569. /**
  105570. * Creates the VertexData for a Ground
  105571. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105572. * - width the width (x direction) of the ground, optional, default 1
  105573. * - height the height (z direction) of the ground, optional, default 1
  105574. * - subdivisions the number of subdivisions per side, optional, default 1
  105575. * @returns the VertexData of the Ground
  105576. */
  105577. static CreateGround(options: {
  105578. width?: number;
  105579. height?: number;
  105580. subdivisions?: number;
  105581. subdivisionsX?: number;
  105582. subdivisionsY?: number;
  105583. }): VertexData;
  105584. /**
  105585. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105586. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105587. * * xmin the ground minimum X coordinate, optional, default -1
  105588. * * zmin the ground minimum Z coordinate, optional, default -1
  105589. * * xmax the ground maximum X coordinate, optional, default 1
  105590. * * zmax the ground maximum Z coordinate, optional, default 1
  105591. * * 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}
  105592. * * 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}
  105593. * @returns the VertexData of the TiledGround
  105594. */
  105595. static CreateTiledGround(options: {
  105596. xmin: number;
  105597. zmin: number;
  105598. xmax: number;
  105599. zmax: number;
  105600. subdivisions?: {
  105601. w: number;
  105602. h: number;
  105603. };
  105604. precision?: {
  105605. w: number;
  105606. h: number;
  105607. };
  105608. }): VertexData;
  105609. /**
  105610. * Creates the VertexData of the Ground designed from a heightmap
  105611. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105612. * * width the width (x direction) of the ground
  105613. * * height the height (z direction) of the ground
  105614. * * subdivisions the number of subdivisions per side
  105615. * * minHeight the minimum altitude on the ground, optional, default 0
  105616. * * maxHeight the maximum altitude on the ground, optional default 1
  105617. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105618. * * buffer the array holding the image color data
  105619. * * bufferWidth the width of image
  105620. * * bufferHeight the height of image
  105621. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105622. * @returns the VertexData of the Ground designed from a heightmap
  105623. */
  105624. static CreateGroundFromHeightMap(options: {
  105625. width: number;
  105626. height: number;
  105627. subdivisions: number;
  105628. minHeight: number;
  105629. maxHeight: number;
  105630. colorFilter: Color3;
  105631. buffer: Uint8Array;
  105632. bufferWidth: number;
  105633. bufferHeight: number;
  105634. alphaFilter: number;
  105635. }): VertexData;
  105636. /**
  105637. * Creates the VertexData for a Plane
  105638. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105639. * * size sets the width and height of the plane to the value of size, optional default 1
  105640. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105641. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105643. * * 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)
  105644. * * 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)
  105645. * @returns the VertexData of the box
  105646. */
  105647. static CreatePlane(options: {
  105648. size?: number;
  105649. width?: number;
  105650. height?: number;
  105651. sideOrientation?: number;
  105652. frontUVs?: Vector4;
  105653. backUVs?: Vector4;
  105654. }): VertexData;
  105655. /**
  105656. * Creates the VertexData of the Disc or regular Polygon
  105657. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105658. * * radius the radius of the disc, optional default 0.5
  105659. * * tessellation the number of polygon sides, optional, default 64
  105660. * * 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
  105661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105662. * * 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)
  105663. * * 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)
  105664. * @returns the VertexData of the box
  105665. */
  105666. static CreateDisc(options: {
  105667. radius?: number;
  105668. tessellation?: number;
  105669. arc?: number;
  105670. sideOrientation?: number;
  105671. frontUVs?: Vector4;
  105672. backUVs?: Vector4;
  105673. }): VertexData;
  105674. /**
  105675. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105676. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105677. * @param polygon a mesh built from polygonTriangulation.build()
  105678. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105679. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105680. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105681. * @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)
  105682. * @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)
  105683. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105684. * @returns the VertexData of the Polygon
  105685. */
  105686. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105687. /**
  105688. * Creates the VertexData of the IcoSphere
  105689. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105690. * * radius the radius of the IcoSphere, optional default 1
  105691. * * radiusX allows stretching in the x direction, optional, default radius
  105692. * * radiusY allows stretching in the y direction, optional, default radius
  105693. * * radiusZ allows stretching in the z direction, optional, default radius
  105694. * * flat when true creates a flat shaded mesh, optional, default true
  105695. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105696. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105697. * * 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)
  105698. * * 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)
  105699. * @returns the VertexData of the IcoSphere
  105700. */
  105701. static CreateIcoSphere(options: {
  105702. radius?: number;
  105703. radiusX?: number;
  105704. radiusY?: number;
  105705. radiusZ?: number;
  105706. flat?: boolean;
  105707. subdivisions?: number;
  105708. sideOrientation?: number;
  105709. frontUVs?: Vector4;
  105710. backUVs?: Vector4;
  105711. }): VertexData;
  105712. /**
  105713. * Creates the VertexData for a Polyhedron
  105714. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105715. * * type provided types are:
  105716. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105717. * * 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)
  105718. * * size the size of the IcoSphere, optional default 1
  105719. * * sizeX allows stretching in the x direction, optional, default size
  105720. * * sizeY allows stretching in the y direction, optional, default size
  105721. * * sizeZ allows stretching in the z direction, optional, default size
  105722. * * 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
  105723. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105724. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105725. * * flat when true creates a flat shaded mesh, optional, default true
  105726. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105727. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105728. * * 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)
  105729. * * 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)
  105730. * @returns the VertexData of the Polyhedron
  105731. */
  105732. static CreatePolyhedron(options: {
  105733. type?: number;
  105734. size?: number;
  105735. sizeX?: number;
  105736. sizeY?: number;
  105737. sizeZ?: number;
  105738. custom?: any;
  105739. faceUV?: Vector4[];
  105740. faceColors?: Color4[];
  105741. flat?: boolean;
  105742. sideOrientation?: number;
  105743. frontUVs?: Vector4;
  105744. backUVs?: Vector4;
  105745. }): VertexData;
  105746. /**
  105747. * Creates the VertexData for a TorusKnot
  105748. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105749. * * radius the radius of the torus knot, optional, default 2
  105750. * * tube the thickness of the tube, optional, default 0.5
  105751. * * radialSegments the number of sides on each tube segments, optional, default 32
  105752. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105753. * * p the number of windings around the z axis, optional, default 2
  105754. * * q the number of windings around the x axis, optional, default 3
  105755. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105756. * * 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)
  105757. * * 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)
  105758. * @returns the VertexData of the Torus Knot
  105759. */
  105760. static CreateTorusKnot(options: {
  105761. radius?: number;
  105762. tube?: number;
  105763. radialSegments?: number;
  105764. tubularSegments?: number;
  105765. p?: number;
  105766. q?: number;
  105767. sideOrientation?: number;
  105768. frontUVs?: Vector4;
  105769. backUVs?: Vector4;
  105770. }): VertexData;
  105771. /**
  105772. * Compute normals for given positions and indices
  105773. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105774. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105775. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105776. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105777. * * facetNormals : optional array of facet normals (vector3)
  105778. * * facetPositions : optional array of facet positions (vector3)
  105779. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105780. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105781. * * bInfo : optional bounding info, required for facetPartitioning computation
  105782. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105783. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105784. * * useRightHandedSystem: optional boolean to for right handed system computation
  105785. * * depthSort : optional boolean to enable the facet depth sort computation
  105786. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105787. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105788. */
  105789. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105790. facetNormals?: any;
  105791. facetPositions?: any;
  105792. facetPartitioning?: any;
  105793. ratio?: number;
  105794. bInfo?: any;
  105795. bbSize?: Vector3;
  105796. subDiv?: any;
  105797. useRightHandedSystem?: boolean;
  105798. depthSort?: boolean;
  105799. distanceTo?: Vector3;
  105800. depthSortedFacets?: any;
  105801. }): void;
  105802. /** @hidden */
  105803. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105804. /**
  105805. * Applies VertexData created from the imported parameters to the geometry
  105806. * @param parsedVertexData the parsed data from an imported file
  105807. * @param geometry the geometry to apply the VertexData to
  105808. */
  105809. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105810. }
  105811. }
  105812. declare module BABYLON {
  105813. /**
  105814. * Defines a target to use with MorphTargetManager
  105815. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105816. */
  105817. export class MorphTarget implements IAnimatable {
  105818. /** defines the name of the target */
  105819. name: string;
  105820. /**
  105821. * Gets or sets the list of animations
  105822. */
  105823. animations: Animation[];
  105824. private _scene;
  105825. private _positions;
  105826. private _normals;
  105827. private _tangents;
  105828. private _uvs;
  105829. private _influence;
  105830. private _uniqueId;
  105831. /**
  105832. * Observable raised when the influence changes
  105833. */
  105834. onInfluenceChanged: Observable<boolean>;
  105835. /** @hidden */
  105836. _onDataLayoutChanged: Observable<void>;
  105837. /**
  105838. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105839. */
  105840. get influence(): number;
  105841. set influence(influence: number);
  105842. /**
  105843. * Gets or sets the id of the morph Target
  105844. */
  105845. id: string;
  105846. private _animationPropertiesOverride;
  105847. /**
  105848. * Gets or sets the animation properties override
  105849. */
  105850. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105851. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105852. /**
  105853. * Creates a new MorphTarget
  105854. * @param name defines the name of the target
  105855. * @param influence defines the influence to use
  105856. * @param scene defines the scene the morphtarget belongs to
  105857. */
  105858. constructor(
  105859. /** defines the name of the target */
  105860. name: string, influence?: number, scene?: Nullable<Scene>);
  105861. /**
  105862. * Gets the unique ID of this manager
  105863. */
  105864. get uniqueId(): number;
  105865. /**
  105866. * Gets a boolean defining if the target contains position data
  105867. */
  105868. get hasPositions(): boolean;
  105869. /**
  105870. * Gets a boolean defining if the target contains normal data
  105871. */
  105872. get hasNormals(): boolean;
  105873. /**
  105874. * Gets a boolean defining if the target contains tangent data
  105875. */
  105876. get hasTangents(): boolean;
  105877. /**
  105878. * Gets a boolean defining if the target contains texture coordinates data
  105879. */
  105880. get hasUVs(): boolean;
  105881. /**
  105882. * Affects position data to this target
  105883. * @param data defines the position data to use
  105884. */
  105885. setPositions(data: Nullable<FloatArray>): void;
  105886. /**
  105887. * Gets the position data stored in this target
  105888. * @returns a FloatArray containing the position data (or null if not present)
  105889. */
  105890. getPositions(): Nullable<FloatArray>;
  105891. /**
  105892. * Affects normal data to this target
  105893. * @param data defines the normal data to use
  105894. */
  105895. setNormals(data: Nullable<FloatArray>): void;
  105896. /**
  105897. * Gets the normal data stored in this target
  105898. * @returns a FloatArray containing the normal data (or null if not present)
  105899. */
  105900. getNormals(): Nullable<FloatArray>;
  105901. /**
  105902. * Affects tangent data to this target
  105903. * @param data defines the tangent data to use
  105904. */
  105905. setTangents(data: Nullable<FloatArray>): void;
  105906. /**
  105907. * Gets the tangent data stored in this target
  105908. * @returns a FloatArray containing the tangent data (or null if not present)
  105909. */
  105910. getTangents(): Nullable<FloatArray>;
  105911. /**
  105912. * Affects texture coordinates data to this target
  105913. * @param data defines the texture coordinates data to use
  105914. */
  105915. setUVs(data: Nullable<FloatArray>): void;
  105916. /**
  105917. * Gets the texture coordinates data stored in this target
  105918. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105919. */
  105920. getUVs(): Nullable<FloatArray>;
  105921. /**
  105922. * Clone the current target
  105923. * @returns a new MorphTarget
  105924. */
  105925. clone(): MorphTarget;
  105926. /**
  105927. * Serializes the current target into a Serialization object
  105928. * @returns the serialized object
  105929. */
  105930. serialize(): any;
  105931. /**
  105932. * Returns the string "MorphTarget"
  105933. * @returns "MorphTarget"
  105934. */
  105935. getClassName(): string;
  105936. /**
  105937. * Creates a new target from serialized data
  105938. * @param serializationObject defines the serialized data to use
  105939. * @returns a new MorphTarget
  105940. */
  105941. static Parse(serializationObject: any): MorphTarget;
  105942. /**
  105943. * Creates a MorphTarget from mesh data
  105944. * @param mesh defines the source mesh
  105945. * @param name defines the name to use for the new target
  105946. * @param influence defines the influence to attach to the target
  105947. * @returns a new MorphTarget
  105948. */
  105949. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105950. }
  105951. }
  105952. declare module BABYLON {
  105953. /**
  105954. * This class is used to deform meshes using morphing between different targets
  105955. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105956. */
  105957. export class MorphTargetManager {
  105958. private _targets;
  105959. private _targetInfluenceChangedObservers;
  105960. private _targetDataLayoutChangedObservers;
  105961. private _activeTargets;
  105962. private _scene;
  105963. private _influences;
  105964. private _supportsNormals;
  105965. private _supportsTangents;
  105966. private _supportsUVs;
  105967. private _vertexCount;
  105968. private _uniqueId;
  105969. private _tempInfluences;
  105970. /**
  105971. * Gets or sets a boolean indicating if normals must be morphed
  105972. */
  105973. enableNormalMorphing: boolean;
  105974. /**
  105975. * Gets or sets a boolean indicating if tangents must be morphed
  105976. */
  105977. enableTangentMorphing: boolean;
  105978. /**
  105979. * Gets or sets a boolean indicating if UV must be morphed
  105980. */
  105981. enableUVMorphing: boolean;
  105982. /**
  105983. * Creates a new MorphTargetManager
  105984. * @param scene defines the current scene
  105985. */
  105986. constructor(scene?: Nullable<Scene>);
  105987. /**
  105988. * Gets the unique ID of this manager
  105989. */
  105990. get uniqueId(): number;
  105991. /**
  105992. * Gets the number of vertices handled by this manager
  105993. */
  105994. get vertexCount(): number;
  105995. /**
  105996. * Gets a boolean indicating if this manager supports morphing of normals
  105997. */
  105998. get supportsNormals(): boolean;
  105999. /**
  106000. * Gets a boolean indicating if this manager supports morphing of tangents
  106001. */
  106002. get supportsTangents(): boolean;
  106003. /**
  106004. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106005. */
  106006. get supportsUVs(): boolean;
  106007. /**
  106008. * Gets the number of targets stored in this manager
  106009. */
  106010. get numTargets(): number;
  106011. /**
  106012. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106013. */
  106014. get numInfluencers(): number;
  106015. /**
  106016. * Gets the list of influences (one per target)
  106017. */
  106018. get influences(): Float32Array;
  106019. /**
  106020. * Gets the active target at specified index. An active target is a target with an influence > 0
  106021. * @param index defines the index to check
  106022. * @returns the requested target
  106023. */
  106024. getActiveTarget(index: number): MorphTarget;
  106025. /**
  106026. * Gets the target at specified index
  106027. * @param index defines the index to check
  106028. * @returns the requested target
  106029. */
  106030. getTarget(index: number): MorphTarget;
  106031. /**
  106032. * Add a new target to this manager
  106033. * @param target defines the target to add
  106034. */
  106035. addTarget(target: MorphTarget): void;
  106036. /**
  106037. * Removes a target from the manager
  106038. * @param target defines the target to remove
  106039. */
  106040. removeTarget(target: MorphTarget): void;
  106041. /**
  106042. * Clone the current manager
  106043. * @returns a new MorphTargetManager
  106044. */
  106045. clone(): MorphTargetManager;
  106046. /**
  106047. * Serializes the current manager into a Serialization object
  106048. * @returns the serialized object
  106049. */
  106050. serialize(): any;
  106051. private _syncActiveTargets;
  106052. /**
  106053. * Syncrhonize the targets with all the meshes using this morph target manager
  106054. */
  106055. synchronize(): void;
  106056. /**
  106057. * Creates a new MorphTargetManager from serialized data
  106058. * @param serializationObject defines the serialized data
  106059. * @param scene defines the hosting scene
  106060. * @returns the new MorphTargetManager
  106061. */
  106062. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106063. }
  106064. }
  106065. declare module BABYLON {
  106066. /**
  106067. * Class used to represent a specific level of detail of a mesh
  106068. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106069. */
  106070. export class MeshLODLevel {
  106071. /** Defines the distance where this level should start being displayed */
  106072. distance: number;
  106073. /** Defines the mesh to use to render this level */
  106074. mesh: Nullable<Mesh>;
  106075. /**
  106076. * Creates a new LOD level
  106077. * @param distance defines the distance where this level should star being displayed
  106078. * @param mesh defines the mesh to use to render this level
  106079. */
  106080. constructor(
  106081. /** Defines the distance where this level should start being displayed */
  106082. distance: number,
  106083. /** Defines the mesh to use to render this level */
  106084. mesh: Nullable<Mesh>);
  106085. }
  106086. }
  106087. declare module BABYLON {
  106088. /**
  106089. * Helper class used to generate a canvas to manipulate images
  106090. */
  106091. export class CanvasGenerator {
  106092. /**
  106093. * Create a new canvas (or offscreen canvas depending on the context)
  106094. * @param width defines the expected width
  106095. * @param height defines the expected height
  106096. * @return a new canvas or offscreen canvas
  106097. */
  106098. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106099. }
  106100. }
  106101. declare module BABYLON {
  106102. /**
  106103. * Mesh representing the gorund
  106104. */
  106105. export class GroundMesh extends Mesh {
  106106. /** If octree should be generated */
  106107. generateOctree: boolean;
  106108. private _heightQuads;
  106109. /** @hidden */
  106110. _subdivisionsX: number;
  106111. /** @hidden */
  106112. _subdivisionsY: number;
  106113. /** @hidden */
  106114. _width: number;
  106115. /** @hidden */
  106116. _height: number;
  106117. /** @hidden */
  106118. _minX: number;
  106119. /** @hidden */
  106120. _maxX: number;
  106121. /** @hidden */
  106122. _minZ: number;
  106123. /** @hidden */
  106124. _maxZ: number;
  106125. constructor(name: string, scene: Scene);
  106126. /**
  106127. * "GroundMesh"
  106128. * @returns "GroundMesh"
  106129. */
  106130. getClassName(): string;
  106131. /**
  106132. * The minimum of x and y subdivisions
  106133. */
  106134. get subdivisions(): number;
  106135. /**
  106136. * X subdivisions
  106137. */
  106138. get subdivisionsX(): number;
  106139. /**
  106140. * Y subdivisions
  106141. */
  106142. get subdivisionsY(): number;
  106143. /**
  106144. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106145. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106146. * @param chunksCount the number of subdivisions for x and y
  106147. * @param octreeBlocksSize (Default: 32)
  106148. */
  106149. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106150. /**
  106151. * Returns a height (y) value in the Worl system :
  106152. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106153. * @param x x coordinate
  106154. * @param z z coordinate
  106155. * @returns the ground y position if (x, z) are outside the ground surface.
  106156. */
  106157. getHeightAtCoordinates(x: number, z: number): number;
  106158. /**
  106159. * Returns a normalized vector (Vector3) orthogonal to the ground
  106160. * at the ground coordinates (x, z) expressed in the World system.
  106161. * @param x x coordinate
  106162. * @param z z coordinate
  106163. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106164. */
  106165. getNormalAtCoordinates(x: number, z: number): Vector3;
  106166. /**
  106167. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106168. * at the ground coordinates (x, z) expressed in the World system.
  106169. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106170. * @param x x coordinate
  106171. * @param z z coordinate
  106172. * @param ref vector to store the result
  106173. * @returns the GroundMesh.
  106174. */
  106175. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106176. /**
  106177. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106178. * if the ground has been updated.
  106179. * This can be used in the render loop.
  106180. * @returns the GroundMesh.
  106181. */
  106182. updateCoordinateHeights(): GroundMesh;
  106183. private _getFacetAt;
  106184. private _initHeightQuads;
  106185. private _computeHeightQuads;
  106186. /**
  106187. * Serializes this ground mesh
  106188. * @param serializationObject object to write serialization to
  106189. */
  106190. serialize(serializationObject: any): void;
  106191. /**
  106192. * Parses a serialized ground mesh
  106193. * @param parsedMesh the serialized mesh
  106194. * @param scene the scene to create the ground mesh in
  106195. * @returns the created ground mesh
  106196. */
  106197. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106198. }
  106199. }
  106200. declare module BABYLON {
  106201. /**
  106202. * Interface for Physics-Joint data
  106203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106204. */
  106205. export interface PhysicsJointData {
  106206. /**
  106207. * The main pivot of the joint
  106208. */
  106209. mainPivot?: Vector3;
  106210. /**
  106211. * The connected pivot of the joint
  106212. */
  106213. connectedPivot?: Vector3;
  106214. /**
  106215. * The main axis of the joint
  106216. */
  106217. mainAxis?: Vector3;
  106218. /**
  106219. * The connected axis of the joint
  106220. */
  106221. connectedAxis?: Vector3;
  106222. /**
  106223. * The collision of the joint
  106224. */
  106225. collision?: boolean;
  106226. /**
  106227. * Native Oimo/Cannon/Energy data
  106228. */
  106229. nativeParams?: any;
  106230. }
  106231. /**
  106232. * This is a holder class for the physics joint created by the physics plugin
  106233. * It holds a set of functions to control the underlying joint
  106234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106235. */
  106236. export class PhysicsJoint {
  106237. /**
  106238. * The type of the physics joint
  106239. */
  106240. type: number;
  106241. /**
  106242. * The data for the physics joint
  106243. */
  106244. jointData: PhysicsJointData;
  106245. private _physicsJoint;
  106246. protected _physicsPlugin: IPhysicsEnginePlugin;
  106247. /**
  106248. * Initializes the physics joint
  106249. * @param type The type of the physics joint
  106250. * @param jointData The data for the physics joint
  106251. */
  106252. constructor(
  106253. /**
  106254. * The type of the physics joint
  106255. */
  106256. type: number,
  106257. /**
  106258. * The data for the physics joint
  106259. */
  106260. jointData: PhysicsJointData);
  106261. /**
  106262. * Gets the physics joint
  106263. */
  106264. get physicsJoint(): any;
  106265. /**
  106266. * Sets the physics joint
  106267. */
  106268. set physicsJoint(newJoint: any);
  106269. /**
  106270. * Sets the physics plugin
  106271. */
  106272. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  106273. /**
  106274. * Execute a function that is physics-plugin specific.
  106275. * @param {Function} func the function that will be executed.
  106276. * It accepts two parameters: the physics world and the physics joint
  106277. */
  106278. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  106279. /**
  106280. * Distance-Joint type
  106281. */
  106282. static DistanceJoint: number;
  106283. /**
  106284. * Hinge-Joint type
  106285. */
  106286. static HingeJoint: number;
  106287. /**
  106288. * Ball-and-Socket joint type
  106289. */
  106290. static BallAndSocketJoint: number;
  106291. /**
  106292. * Wheel-Joint type
  106293. */
  106294. static WheelJoint: number;
  106295. /**
  106296. * Slider-Joint type
  106297. */
  106298. static SliderJoint: number;
  106299. /**
  106300. * Prismatic-Joint type
  106301. */
  106302. static PrismaticJoint: number;
  106303. /**
  106304. * Universal-Joint type
  106305. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  106306. */
  106307. static UniversalJoint: number;
  106308. /**
  106309. * Hinge-Joint 2 type
  106310. */
  106311. static Hinge2Joint: number;
  106312. /**
  106313. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  106314. */
  106315. static PointToPointJoint: number;
  106316. /**
  106317. * Spring-Joint type
  106318. */
  106319. static SpringJoint: number;
  106320. /**
  106321. * Lock-Joint type
  106322. */
  106323. static LockJoint: number;
  106324. }
  106325. /**
  106326. * A class representing a physics distance joint
  106327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106328. */
  106329. export class DistanceJoint extends PhysicsJoint {
  106330. /**
  106331. *
  106332. * @param jointData The data for the Distance-Joint
  106333. */
  106334. constructor(jointData: DistanceJointData);
  106335. /**
  106336. * Update the predefined distance.
  106337. * @param maxDistance The maximum preferred distance
  106338. * @param minDistance The minimum preferred distance
  106339. */
  106340. updateDistance(maxDistance: number, minDistance?: number): void;
  106341. }
  106342. /**
  106343. * Represents a Motor-Enabled Joint
  106344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106345. */
  106346. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106347. /**
  106348. * Initializes the Motor-Enabled Joint
  106349. * @param type The type of the joint
  106350. * @param jointData The physica joint data for the joint
  106351. */
  106352. constructor(type: number, jointData: PhysicsJointData);
  106353. /**
  106354. * Set the motor values.
  106355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106356. * @param force the force to apply
  106357. * @param maxForce max force for this motor.
  106358. */
  106359. setMotor(force?: number, maxForce?: number): void;
  106360. /**
  106361. * Set the motor's limits.
  106362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106363. * @param upperLimit The upper limit of the motor
  106364. * @param lowerLimit The lower limit of the motor
  106365. */
  106366. setLimit(upperLimit: number, lowerLimit?: number): void;
  106367. }
  106368. /**
  106369. * This class represents a single physics Hinge-Joint
  106370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106371. */
  106372. export class HingeJoint extends MotorEnabledJoint {
  106373. /**
  106374. * Initializes the Hinge-Joint
  106375. * @param jointData The joint data for the Hinge-Joint
  106376. */
  106377. constructor(jointData: PhysicsJointData);
  106378. /**
  106379. * Set the motor values.
  106380. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106381. * @param {number} force the force to apply
  106382. * @param {number} maxForce max force for this motor.
  106383. */
  106384. setMotor(force?: number, maxForce?: number): void;
  106385. /**
  106386. * Set the motor's limits.
  106387. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106388. * @param upperLimit The upper limit of the motor
  106389. * @param lowerLimit The lower limit of the motor
  106390. */
  106391. setLimit(upperLimit: number, lowerLimit?: number): void;
  106392. }
  106393. /**
  106394. * This class represents a dual hinge physics joint (same as wheel joint)
  106395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106396. */
  106397. export class Hinge2Joint extends MotorEnabledJoint {
  106398. /**
  106399. * Initializes the Hinge2-Joint
  106400. * @param jointData The joint data for the Hinge2-Joint
  106401. */
  106402. constructor(jointData: PhysicsJointData);
  106403. /**
  106404. * Set the motor values.
  106405. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106406. * @param {number} targetSpeed the speed the motor is to reach
  106407. * @param {number} maxForce max force for this motor.
  106408. * @param {motorIndex} the motor's index, 0 or 1.
  106409. */
  106410. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106411. /**
  106412. * Set the motor limits.
  106413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106414. * @param {number} upperLimit the upper limit
  106415. * @param {number} lowerLimit lower limit
  106416. * @param {motorIndex} the motor's index, 0 or 1.
  106417. */
  106418. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106419. }
  106420. /**
  106421. * Interface for a motor enabled joint
  106422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106423. */
  106424. export interface IMotorEnabledJoint {
  106425. /**
  106426. * Physics joint
  106427. */
  106428. physicsJoint: any;
  106429. /**
  106430. * Sets the motor of the motor-enabled joint
  106431. * @param force The force of the motor
  106432. * @param maxForce The maximum force of the motor
  106433. * @param motorIndex The index of the motor
  106434. */
  106435. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106436. /**
  106437. * Sets the limit of the motor
  106438. * @param upperLimit The upper limit of the motor
  106439. * @param lowerLimit The lower limit of the motor
  106440. * @param motorIndex The index of the motor
  106441. */
  106442. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106443. }
  106444. /**
  106445. * Joint data for a Distance-Joint
  106446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106447. */
  106448. export interface DistanceJointData extends PhysicsJointData {
  106449. /**
  106450. * Max distance the 2 joint objects can be apart
  106451. */
  106452. maxDistance: number;
  106453. }
  106454. /**
  106455. * Joint data from a spring joint
  106456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106457. */
  106458. export interface SpringJointData extends PhysicsJointData {
  106459. /**
  106460. * Length of the spring
  106461. */
  106462. length: number;
  106463. /**
  106464. * Stiffness of the spring
  106465. */
  106466. stiffness: number;
  106467. /**
  106468. * Damping of the spring
  106469. */
  106470. damping: number;
  106471. /** this callback will be called when applying the force to the impostors. */
  106472. forceApplicationCallback: () => void;
  106473. }
  106474. }
  106475. declare module BABYLON {
  106476. /**
  106477. * Holds the data for the raycast result
  106478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106479. */
  106480. export class PhysicsRaycastResult {
  106481. private _hasHit;
  106482. private _hitDistance;
  106483. private _hitNormalWorld;
  106484. private _hitPointWorld;
  106485. private _rayFromWorld;
  106486. private _rayToWorld;
  106487. /**
  106488. * Gets if there was a hit
  106489. */
  106490. get hasHit(): boolean;
  106491. /**
  106492. * Gets the distance from the hit
  106493. */
  106494. get hitDistance(): number;
  106495. /**
  106496. * Gets the hit normal/direction in the world
  106497. */
  106498. get hitNormalWorld(): Vector3;
  106499. /**
  106500. * Gets the hit point in the world
  106501. */
  106502. get hitPointWorld(): Vector3;
  106503. /**
  106504. * Gets the ray "start point" of the ray in the world
  106505. */
  106506. get rayFromWorld(): Vector3;
  106507. /**
  106508. * Gets the ray "end point" of the ray in the world
  106509. */
  106510. get rayToWorld(): Vector3;
  106511. /**
  106512. * Sets the hit data (normal & point in world space)
  106513. * @param hitNormalWorld defines the normal in world space
  106514. * @param hitPointWorld defines the point in world space
  106515. */
  106516. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  106517. /**
  106518. * Sets the distance from the start point to the hit point
  106519. * @param distance
  106520. */
  106521. setHitDistance(distance: number): void;
  106522. /**
  106523. * Calculates the distance manually
  106524. */
  106525. calculateHitDistance(): void;
  106526. /**
  106527. * Resets all the values to default
  106528. * @param from The from point on world space
  106529. * @param to The to point on world space
  106530. */
  106531. reset(from?: Vector3, to?: Vector3): void;
  106532. }
  106533. /**
  106534. * Interface for the size containing width and height
  106535. */
  106536. interface IXYZ {
  106537. /**
  106538. * X
  106539. */
  106540. x: number;
  106541. /**
  106542. * Y
  106543. */
  106544. y: number;
  106545. /**
  106546. * Z
  106547. */
  106548. z: number;
  106549. }
  106550. }
  106551. declare module BABYLON {
  106552. /**
  106553. * Interface used to describe a physics joint
  106554. */
  106555. export interface PhysicsImpostorJoint {
  106556. /** Defines the main impostor to which the joint is linked */
  106557. mainImpostor: PhysicsImpostor;
  106558. /** Defines the impostor that is connected to the main impostor using this joint */
  106559. connectedImpostor: PhysicsImpostor;
  106560. /** Defines the joint itself */
  106561. joint: PhysicsJoint;
  106562. }
  106563. /** @hidden */
  106564. export interface IPhysicsEnginePlugin {
  106565. world: any;
  106566. name: string;
  106567. setGravity(gravity: Vector3): void;
  106568. setTimeStep(timeStep: number): void;
  106569. getTimeStep(): number;
  106570. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106571. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106572. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106573. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106574. removePhysicsBody(impostor: PhysicsImpostor): void;
  106575. generateJoint(joint: PhysicsImpostorJoint): void;
  106576. removeJoint(joint: PhysicsImpostorJoint): void;
  106577. isSupported(): boolean;
  106578. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106579. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106580. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106581. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106582. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106583. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106584. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106585. getBodyMass(impostor: PhysicsImpostor): number;
  106586. getBodyFriction(impostor: PhysicsImpostor): number;
  106587. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106588. getBodyRestitution(impostor: PhysicsImpostor): number;
  106589. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106590. getBodyPressure?(impostor: PhysicsImpostor): number;
  106591. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106592. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106593. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106594. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106595. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106596. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106597. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106598. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106599. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106600. sleepBody(impostor: PhysicsImpostor): void;
  106601. wakeUpBody(impostor: PhysicsImpostor): void;
  106602. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106604. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106605. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106606. getRadius(impostor: PhysicsImpostor): number;
  106607. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106608. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106609. dispose(): void;
  106610. }
  106611. /**
  106612. * Interface used to define a physics engine
  106613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106614. */
  106615. export interface IPhysicsEngine {
  106616. /**
  106617. * Gets the gravity vector used by the simulation
  106618. */
  106619. gravity: Vector3;
  106620. /**
  106621. * Sets the gravity vector used by the simulation
  106622. * @param gravity defines the gravity vector to use
  106623. */
  106624. setGravity(gravity: Vector3): void;
  106625. /**
  106626. * Set the time step of the physics engine.
  106627. * Default is 1/60.
  106628. * To slow it down, enter 1/600 for example.
  106629. * To speed it up, 1/30
  106630. * @param newTimeStep the new timestep to apply to this world.
  106631. */
  106632. setTimeStep(newTimeStep: number): void;
  106633. /**
  106634. * Get the time step of the physics engine.
  106635. * @returns the current time step
  106636. */
  106637. getTimeStep(): number;
  106638. /**
  106639. * Set the sub time step of the physics engine.
  106640. * Default is 0 meaning there is no sub steps
  106641. * To increase physics resolution precision, set a small value (like 1 ms)
  106642. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106643. */
  106644. setSubTimeStep(subTimeStep: number): void;
  106645. /**
  106646. * Get the sub time step of the physics engine.
  106647. * @returns the current sub time step
  106648. */
  106649. getSubTimeStep(): number;
  106650. /**
  106651. * Release all resources
  106652. */
  106653. dispose(): void;
  106654. /**
  106655. * Gets the name of the current physics plugin
  106656. * @returns the name of the plugin
  106657. */
  106658. getPhysicsPluginName(): string;
  106659. /**
  106660. * Adding a new impostor for the impostor tracking.
  106661. * This will be done by the impostor itself.
  106662. * @param impostor the impostor to add
  106663. */
  106664. addImpostor(impostor: PhysicsImpostor): void;
  106665. /**
  106666. * Remove an impostor from the engine.
  106667. * This impostor and its mesh will not longer be updated by the physics engine.
  106668. * @param impostor the impostor to remove
  106669. */
  106670. removeImpostor(impostor: PhysicsImpostor): void;
  106671. /**
  106672. * Add a joint to the physics engine
  106673. * @param mainImpostor defines the main impostor to which the joint is added.
  106674. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106675. * @param joint defines the joint that will connect both impostors.
  106676. */
  106677. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106678. /**
  106679. * Removes a joint from the simulation
  106680. * @param mainImpostor defines the impostor used with the joint
  106681. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106682. * @param joint defines the joint to remove
  106683. */
  106684. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106685. /**
  106686. * Gets the current plugin used to run the simulation
  106687. * @returns current plugin
  106688. */
  106689. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106690. /**
  106691. * Gets the list of physic impostors
  106692. * @returns an array of PhysicsImpostor
  106693. */
  106694. getImpostors(): Array<PhysicsImpostor>;
  106695. /**
  106696. * Gets the impostor for a physics enabled object
  106697. * @param object defines the object impersonated by the impostor
  106698. * @returns the PhysicsImpostor or null if not found
  106699. */
  106700. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106701. /**
  106702. * Gets the impostor for a physics body object
  106703. * @param body defines physics body used by the impostor
  106704. * @returns the PhysicsImpostor or null if not found
  106705. */
  106706. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106707. /**
  106708. * Does a raycast in the physics world
  106709. * @param from when should the ray start?
  106710. * @param to when should the ray end?
  106711. * @returns PhysicsRaycastResult
  106712. */
  106713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106714. /**
  106715. * Called by the scene. No need to call it.
  106716. * @param delta defines the timespam between frames
  106717. */
  106718. _step(delta: number): void;
  106719. }
  106720. }
  106721. declare module BABYLON {
  106722. /**
  106723. * The interface for the physics imposter parameters
  106724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106725. */
  106726. export interface PhysicsImpostorParameters {
  106727. /**
  106728. * The mass of the physics imposter
  106729. */
  106730. mass: number;
  106731. /**
  106732. * The friction of the physics imposter
  106733. */
  106734. friction?: number;
  106735. /**
  106736. * The coefficient of restitution of the physics imposter
  106737. */
  106738. restitution?: number;
  106739. /**
  106740. * The native options of the physics imposter
  106741. */
  106742. nativeOptions?: any;
  106743. /**
  106744. * Specifies if the parent should be ignored
  106745. */
  106746. ignoreParent?: boolean;
  106747. /**
  106748. * Specifies if bi-directional transformations should be disabled
  106749. */
  106750. disableBidirectionalTransformation?: boolean;
  106751. /**
  106752. * The pressure inside the physics imposter, soft object only
  106753. */
  106754. pressure?: number;
  106755. /**
  106756. * The stiffness the physics imposter, soft object only
  106757. */
  106758. stiffness?: number;
  106759. /**
  106760. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106761. */
  106762. velocityIterations?: number;
  106763. /**
  106764. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106765. */
  106766. positionIterations?: number;
  106767. /**
  106768. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106769. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106770. * Add to fix multiple points
  106771. */
  106772. fixedPoints?: number;
  106773. /**
  106774. * The collision margin around a soft object
  106775. */
  106776. margin?: number;
  106777. /**
  106778. * The collision margin around a soft object
  106779. */
  106780. damping?: number;
  106781. /**
  106782. * The path for a rope based on an extrusion
  106783. */
  106784. path?: any;
  106785. /**
  106786. * The shape of an extrusion used for a rope based on an extrusion
  106787. */
  106788. shape?: any;
  106789. }
  106790. /**
  106791. * Interface for a physics-enabled object
  106792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106793. */
  106794. export interface IPhysicsEnabledObject {
  106795. /**
  106796. * The position of the physics-enabled object
  106797. */
  106798. position: Vector3;
  106799. /**
  106800. * The rotation of the physics-enabled object
  106801. */
  106802. rotationQuaternion: Nullable<Quaternion>;
  106803. /**
  106804. * The scale of the physics-enabled object
  106805. */
  106806. scaling: Vector3;
  106807. /**
  106808. * The rotation of the physics-enabled object
  106809. */
  106810. rotation?: Vector3;
  106811. /**
  106812. * The parent of the physics-enabled object
  106813. */
  106814. parent?: any;
  106815. /**
  106816. * The bounding info of the physics-enabled object
  106817. * @returns The bounding info of the physics-enabled object
  106818. */
  106819. getBoundingInfo(): BoundingInfo;
  106820. /**
  106821. * Computes the world matrix
  106822. * @param force Specifies if the world matrix should be computed by force
  106823. * @returns A world matrix
  106824. */
  106825. computeWorldMatrix(force: boolean): Matrix;
  106826. /**
  106827. * Gets the world matrix
  106828. * @returns A world matrix
  106829. */
  106830. getWorldMatrix?(): Matrix;
  106831. /**
  106832. * Gets the child meshes
  106833. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106834. * @returns An array of abstract meshes
  106835. */
  106836. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106837. /**
  106838. * Gets the vertex data
  106839. * @param kind The type of vertex data
  106840. * @returns A nullable array of numbers, or a float32 array
  106841. */
  106842. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106843. /**
  106844. * Gets the indices from the mesh
  106845. * @returns A nullable array of index arrays
  106846. */
  106847. getIndices?(): Nullable<IndicesArray>;
  106848. /**
  106849. * Gets the scene from the mesh
  106850. * @returns the indices array or null
  106851. */
  106852. getScene?(): Scene;
  106853. /**
  106854. * Gets the absolute position from the mesh
  106855. * @returns the absolute position
  106856. */
  106857. getAbsolutePosition(): Vector3;
  106858. /**
  106859. * Gets the absolute pivot point from the mesh
  106860. * @returns the absolute pivot point
  106861. */
  106862. getAbsolutePivotPoint(): Vector3;
  106863. /**
  106864. * Rotates the mesh
  106865. * @param axis The axis of rotation
  106866. * @param amount The amount of rotation
  106867. * @param space The space of the rotation
  106868. * @returns The rotation transform node
  106869. */
  106870. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106871. /**
  106872. * Translates the mesh
  106873. * @param axis The axis of translation
  106874. * @param distance The distance of translation
  106875. * @param space The space of the translation
  106876. * @returns The transform node
  106877. */
  106878. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106879. /**
  106880. * Sets the absolute position of the mesh
  106881. * @param absolutePosition The absolute position of the mesh
  106882. * @returns The transform node
  106883. */
  106884. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106885. /**
  106886. * Gets the class name of the mesh
  106887. * @returns The class name
  106888. */
  106889. getClassName(): string;
  106890. }
  106891. /**
  106892. * Represents a physics imposter
  106893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106894. */
  106895. export class PhysicsImpostor {
  106896. /**
  106897. * The physics-enabled object used as the physics imposter
  106898. */
  106899. object: IPhysicsEnabledObject;
  106900. /**
  106901. * The type of the physics imposter
  106902. */
  106903. type: number;
  106904. private _options;
  106905. private _scene?;
  106906. /**
  106907. * The default object size of the imposter
  106908. */
  106909. static DEFAULT_OBJECT_SIZE: Vector3;
  106910. /**
  106911. * The identity quaternion of the imposter
  106912. */
  106913. static IDENTITY_QUATERNION: Quaternion;
  106914. /** @hidden */
  106915. _pluginData: any;
  106916. private _physicsEngine;
  106917. private _physicsBody;
  106918. private _bodyUpdateRequired;
  106919. private _onBeforePhysicsStepCallbacks;
  106920. private _onAfterPhysicsStepCallbacks;
  106921. /** @hidden */
  106922. _onPhysicsCollideCallbacks: Array<{
  106923. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106924. otherImpostors: Array<PhysicsImpostor>;
  106925. }>;
  106926. private _deltaPosition;
  106927. private _deltaRotation;
  106928. private _deltaRotationConjugated;
  106929. /** @hidden */
  106930. _isFromLine: boolean;
  106931. private _parent;
  106932. private _isDisposed;
  106933. private static _tmpVecs;
  106934. private static _tmpQuat;
  106935. /**
  106936. * Specifies if the physics imposter is disposed
  106937. */
  106938. get isDisposed(): boolean;
  106939. /**
  106940. * Gets the mass of the physics imposter
  106941. */
  106942. get mass(): number;
  106943. set mass(value: number);
  106944. /**
  106945. * Gets the coefficient of friction
  106946. */
  106947. get friction(): number;
  106948. /**
  106949. * Sets the coefficient of friction
  106950. */
  106951. set friction(value: number);
  106952. /**
  106953. * Gets the coefficient of restitution
  106954. */
  106955. get restitution(): number;
  106956. /**
  106957. * Sets the coefficient of restitution
  106958. */
  106959. set restitution(value: number);
  106960. /**
  106961. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106962. */
  106963. get pressure(): number;
  106964. /**
  106965. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106966. */
  106967. set pressure(value: number);
  106968. /**
  106969. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106970. */
  106971. get stiffness(): number;
  106972. /**
  106973. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106974. */
  106975. set stiffness(value: number);
  106976. /**
  106977. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106978. */
  106979. get velocityIterations(): number;
  106980. /**
  106981. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106982. */
  106983. set velocityIterations(value: number);
  106984. /**
  106985. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106986. */
  106987. get positionIterations(): number;
  106988. /**
  106989. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106990. */
  106991. set positionIterations(value: number);
  106992. /**
  106993. * The unique id of the physics imposter
  106994. * set by the physics engine when adding this impostor to the array
  106995. */
  106996. uniqueId: number;
  106997. /**
  106998. * @hidden
  106999. */
  107000. soft: boolean;
  107001. /**
  107002. * @hidden
  107003. */
  107004. segments: number;
  107005. private _joints;
  107006. /**
  107007. * Initializes the physics imposter
  107008. * @param object The physics-enabled object used as the physics imposter
  107009. * @param type The type of the physics imposter
  107010. * @param _options The options for the physics imposter
  107011. * @param _scene The Babylon scene
  107012. */
  107013. constructor(
  107014. /**
  107015. * The physics-enabled object used as the physics imposter
  107016. */
  107017. object: IPhysicsEnabledObject,
  107018. /**
  107019. * The type of the physics imposter
  107020. */
  107021. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107022. /**
  107023. * This function will completly initialize this impostor.
  107024. * It will create a new body - but only if this mesh has no parent.
  107025. * If it has, this impostor will not be used other than to define the impostor
  107026. * of the child mesh.
  107027. * @hidden
  107028. */
  107029. _init(): void;
  107030. private _getPhysicsParent;
  107031. /**
  107032. * Should a new body be generated.
  107033. * @returns boolean specifying if body initialization is required
  107034. */
  107035. isBodyInitRequired(): boolean;
  107036. /**
  107037. * Sets the updated scaling
  107038. * @param updated Specifies if the scaling is updated
  107039. */
  107040. setScalingUpdated(): void;
  107041. /**
  107042. * Force a regeneration of this or the parent's impostor's body.
  107043. * Use under cautious - This will remove all joints already implemented.
  107044. */
  107045. forceUpdate(): void;
  107046. /**
  107047. * Gets the body that holds this impostor. Either its own, or its parent.
  107048. */
  107049. get physicsBody(): any;
  107050. /**
  107051. * Get the parent of the physics imposter
  107052. * @returns Physics imposter or null
  107053. */
  107054. get parent(): Nullable<PhysicsImpostor>;
  107055. /**
  107056. * Sets the parent of the physics imposter
  107057. */
  107058. set parent(value: Nullable<PhysicsImpostor>);
  107059. /**
  107060. * Set the physics body. Used mainly by the physics engine/plugin
  107061. */
  107062. set physicsBody(physicsBody: any);
  107063. /**
  107064. * Resets the update flags
  107065. */
  107066. resetUpdateFlags(): void;
  107067. /**
  107068. * Gets the object extend size
  107069. * @returns the object extend size
  107070. */
  107071. getObjectExtendSize(): Vector3;
  107072. /**
  107073. * Gets the object center
  107074. * @returns The object center
  107075. */
  107076. getObjectCenter(): Vector3;
  107077. /**
  107078. * Get a specific parameter from the options parameters
  107079. * @param paramName The object parameter name
  107080. * @returns The object parameter
  107081. */
  107082. getParam(paramName: string): any;
  107083. /**
  107084. * Sets a specific parameter in the options given to the physics plugin
  107085. * @param paramName The parameter name
  107086. * @param value The value of the parameter
  107087. */
  107088. setParam(paramName: string, value: number): void;
  107089. /**
  107090. * Specifically change the body's mass option. Won't recreate the physics body object
  107091. * @param mass The mass of the physics imposter
  107092. */
  107093. setMass(mass: number): void;
  107094. /**
  107095. * Gets the linear velocity
  107096. * @returns linear velocity or null
  107097. */
  107098. getLinearVelocity(): Nullable<Vector3>;
  107099. /**
  107100. * Sets the linear velocity
  107101. * @param velocity linear velocity or null
  107102. */
  107103. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107104. /**
  107105. * Gets the angular velocity
  107106. * @returns angular velocity or null
  107107. */
  107108. getAngularVelocity(): Nullable<Vector3>;
  107109. /**
  107110. * Sets the angular velocity
  107111. * @param velocity The velocity or null
  107112. */
  107113. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107114. /**
  107115. * Execute a function with the physics plugin native code
  107116. * Provide a function the will have two variables - the world object and the physics body object
  107117. * @param func The function to execute with the physics plugin native code
  107118. */
  107119. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107120. /**
  107121. * Register a function that will be executed before the physics world is stepping forward
  107122. * @param func The function to execute before the physics world is stepped forward
  107123. */
  107124. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107125. /**
  107126. * Unregister a function that will be executed before the physics world is stepping forward
  107127. * @param func The function to execute before the physics world is stepped forward
  107128. */
  107129. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107130. /**
  107131. * Register a function that will be executed after the physics step
  107132. * @param func The function to execute after physics step
  107133. */
  107134. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107135. /**
  107136. * Unregisters a function that will be executed after the physics step
  107137. * @param func The function to execute after physics step
  107138. */
  107139. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107140. /**
  107141. * register a function that will be executed when this impostor collides against a different body
  107142. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107143. * @param func Callback that is executed on collision
  107144. */
  107145. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107146. /**
  107147. * Unregisters the physics imposter on contact
  107148. * @param collideAgainst The physics object to collide against
  107149. * @param func Callback to execute on collision
  107150. */
  107151. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107152. private _tmpQuat;
  107153. private _tmpQuat2;
  107154. /**
  107155. * Get the parent rotation
  107156. * @returns The parent rotation
  107157. */
  107158. getParentsRotation(): Quaternion;
  107159. /**
  107160. * this function is executed by the physics engine.
  107161. */
  107162. beforeStep: () => void;
  107163. /**
  107164. * this function is executed by the physics engine
  107165. */
  107166. afterStep: () => void;
  107167. /**
  107168. * Legacy collision detection event support
  107169. */
  107170. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107171. /**
  107172. * event and body object due to cannon's event-based architecture.
  107173. */
  107174. onCollide: (e: {
  107175. body: any;
  107176. }) => void;
  107177. /**
  107178. * Apply a force
  107179. * @param force The force to apply
  107180. * @param contactPoint The contact point for the force
  107181. * @returns The physics imposter
  107182. */
  107183. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107184. /**
  107185. * Apply an impulse
  107186. * @param force The impulse force
  107187. * @param contactPoint The contact point for the impulse force
  107188. * @returns The physics imposter
  107189. */
  107190. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107191. /**
  107192. * A help function to create a joint
  107193. * @param otherImpostor A physics imposter used to create a joint
  107194. * @param jointType The type of joint
  107195. * @param jointData The data for the joint
  107196. * @returns The physics imposter
  107197. */
  107198. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107199. /**
  107200. * Add a joint to this impostor with a different impostor
  107201. * @param otherImpostor A physics imposter used to add a joint
  107202. * @param joint The joint to add
  107203. * @returns The physics imposter
  107204. */
  107205. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107206. /**
  107207. * Add an anchor to a cloth impostor
  107208. * @param otherImpostor rigid impostor to anchor to
  107209. * @param width ratio across width from 0 to 1
  107210. * @param height ratio up height from 0 to 1
  107211. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107212. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107213. * @returns impostor the soft imposter
  107214. */
  107215. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107216. /**
  107217. * Add a hook to a rope impostor
  107218. * @param otherImpostor rigid impostor to anchor to
  107219. * @param length ratio across rope from 0 to 1
  107220. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107221. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107222. * @returns impostor the rope imposter
  107223. */
  107224. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107225. /**
  107226. * Will keep this body still, in a sleep mode.
  107227. * @returns the physics imposter
  107228. */
  107229. sleep(): PhysicsImpostor;
  107230. /**
  107231. * Wake the body up.
  107232. * @returns The physics imposter
  107233. */
  107234. wakeUp(): PhysicsImpostor;
  107235. /**
  107236. * Clones the physics imposter
  107237. * @param newObject The physics imposter clones to this physics-enabled object
  107238. * @returns A nullable physics imposter
  107239. */
  107240. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107241. /**
  107242. * Disposes the physics imposter
  107243. */
  107244. dispose(): void;
  107245. /**
  107246. * Sets the delta position
  107247. * @param position The delta position amount
  107248. */
  107249. setDeltaPosition(position: Vector3): void;
  107250. /**
  107251. * Sets the delta rotation
  107252. * @param rotation The delta rotation amount
  107253. */
  107254. setDeltaRotation(rotation: Quaternion): void;
  107255. /**
  107256. * Gets the box size of the physics imposter and stores the result in the input parameter
  107257. * @param result Stores the box size
  107258. * @returns The physics imposter
  107259. */
  107260. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  107261. /**
  107262. * Gets the radius of the physics imposter
  107263. * @returns Radius of the physics imposter
  107264. */
  107265. getRadius(): number;
  107266. /**
  107267. * Sync a bone with this impostor
  107268. * @param bone The bone to sync to the impostor.
  107269. * @param boneMesh The mesh that the bone is influencing.
  107270. * @param jointPivot The pivot of the joint / bone in local space.
  107271. * @param distToJoint Optional distance from the impostor to the joint.
  107272. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107273. */
  107274. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  107275. /**
  107276. * Sync impostor to a bone
  107277. * @param bone The bone that the impostor will be synced to.
  107278. * @param boneMesh The mesh that the bone is influencing.
  107279. * @param jointPivot The pivot of the joint / bone in local space.
  107280. * @param distToJoint Optional distance from the impostor to the joint.
  107281. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107282. * @param boneAxis Optional vector3 axis the bone is aligned with
  107283. */
  107284. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  107285. /**
  107286. * No-Imposter type
  107287. */
  107288. static NoImpostor: number;
  107289. /**
  107290. * Sphere-Imposter type
  107291. */
  107292. static SphereImpostor: number;
  107293. /**
  107294. * Box-Imposter type
  107295. */
  107296. static BoxImpostor: number;
  107297. /**
  107298. * Plane-Imposter type
  107299. */
  107300. static PlaneImpostor: number;
  107301. /**
  107302. * Mesh-imposter type
  107303. */
  107304. static MeshImpostor: number;
  107305. /**
  107306. * Capsule-Impostor type (Ammo.js plugin only)
  107307. */
  107308. static CapsuleImpostor: number;
  107309. /**
  107310. * Cylinder-Imposter type
  107311. */
  107312. static CylinderImpostor: number;
  107313. /**
  107314. * Particle-Imposter type
  107315. */
  107316. static ParticleImpostor: number;
  107317. /**
  107318. * Heightmap-Imposter type
  107319. */
  107320. static HeightmapImpostor: number;
  107321. /**
  107322. * ConvexHull-Impostor type (Ammo.js plugin only)
  107323. */
  107324. static ConvexHullImpostor: number;
  107325. /**
  107326. * Custom-Imposter type (Ammo.js plugin only)
  107327. */
  107328. static CustomImpostor: number;
  107329. /**
  107330. * Rope-Imposter type
  107331. */
  107332. static RopeImpostor: number;
  107333. /**
  107334. * Cloth-Imposter type
  107335. */
  107336. static ClothImpostor: number;
  107337. /**
  107338. * Softbody-Imposter type
  107339. */
  107340. static SoftbodyImpostor: number;
  107341. }
  107342. }
  107343. declare module BABYLON {
  107344. /**
  107345. * @hidden
  107346. **/
  107347. export class _CreationDataStorage {
  107348. closePath?: boolean;
  107349. closeArray?: boolean;
  107350. idx: number[];
  107351. dashSize: number;
  107352. gapSize: number;
  107353. path3D: Path3D;
  107354. pathArray: Vector3[][];
  107355. arc: number;
  107356. radius: number;
  107357. cap: number;
  107358. tessellation: number;
  107359. }
  107360. /**
  107361. * @hidden
  107362. **/
  107363. class _InstanceDataStorage {
  107364. visibleInstances: any;
  107365. batchCache: _InstancesBatch;
  107366. instancesBufferSize: number;
  107367. instancesBuffer: Nullable<Buffer>;
  107368. instancesData: Float32Array;
  107369. overridenInstanceCount: number;
  107370. isFrozen: boolean;
  107371. previousBatch: Nullable<_InstancesBatch>;
  107372. hardwareInstancedRendering: boolean;
  107373. sideOrientation: number;
  107374. manualUpdate: boolean;
  107375. }
  107376. /**
  107377. * @hidden
  107378. **/
  107379. export class _InstancesBatch {
  107380. mustReturn: boolean;
  107381. visibleInstances: Nullable<InstancedMesh[]>[];
  107382. renderSelf: boolean[];
  107383. hardwareInstancedRendering: boolean[];
  107384. }
  107385. /**
  107386. * @hidden
  107387. **/
  107388. class _ThinInstanceDataStorage {
  107389. instancesCount: number;
  107390. matrixBuffer: Nullable<Buffer>;
  107391. matrixBufferSize: number;
  107392. matrixData: Nullable<Float32Array>;
  107393. boundingVectors: Array<Vector3>;
  107394. worldMatrices: Nullable<Matrix[]>;
  107395. }
  107396. /**
  107397. * Class used to represent renderable models
  107398. */
  107399. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107400. /**
  107401. * Mesh side orientation : usually the external or front surface
  107402. */
  107403. static readonly FRONTSIDE: number;
  107404. /**
  107405. * Mesh side orientation : usually the internal or back surface
  107406. */
  107407. static readonly BACKSIDE: number;
  107408. /**
  107409. * Mesh side orientation : both internal and external or front and back surfaces
  107410. */
  107411. static readonly DOUBLESIDE: number;
  107412. /**
  107413. * Mesh side orientation : by default, `FRONTSIDE`
  107414. */
  107415. static readonly DEFAULTSIDE: number;
  107416. /**
  107417. * Mesh cap setting : no cap
  107418. */
  107419. static readonly NO_CAP: number;
  107420. /**
  107421. * Mesh cap setting : one cap at the beginning of the mesh
  107422. */
  107423. static readonly CAP_START: number;
  107424. /**
  107425. * Mesh cap setting : one cap at the end of the mesh
  107426. */
  107427. static readonly CAP_END: number;
  107428. /**
  107429. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107430. */
  107431. static readonly CAP_ALL: number;
  107432. /**
  107433. * Mesh pattern setting : no flip or rotate
  107434. */
  107435. static readonly NO_FLIP: number;
  107436. /**
  107437. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107438. */
  107439. static readonly FLIP_TILE: number;
  107440. /**
  107441. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107442. */
  107443. static readonly ROTATE_TILE: number;
  107444. /**
  107445. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107446. */
  107447. static readonly FLIP_ROW: number;
  107448. /**
  107449. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107450. */
  107451. static readonly ROTATE_ROW: number;
  107452. /**
  107453. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107454. */
  107455. static readonly FLIP_N_ROTATE_TILE: number;
  107456. /**
  107457. * Mesh pattern setting : rotate pattern and rotate
  107458. */
  107459. static readonly FLIP_N_ROTATE_ROW: number;
  107460. /**
  107461. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107462. */
  107463. static readonly CENTER: number;
  107464. /**
  107465. * Mesh tile positioning : part tiles on left
  107466. */
  107467. static readonly LEFT: number;
  107468. /**
  107469. * Mesh tile positioning : part tiles on right
  107470. */
  107471. static readonly RIGHT: number;
  107472. /**
  107473. * Mesh tile positioning : part tiles on top
  107474. */
  107475. static readonly TOP: number;
  107476. /**
  107477. * Mesh tile positioning : part tiles on bottom
  107478. */
  107479. static readonly BOTTOM: number;
  107480. /**
  107481. * Gets the default side orientation.
  107482. * @param orientation the orientation to value to attempt to get
  107483. * @returns the default orientation
  107484. * @hidden
  107485. */
  107486. static _GetDefaultSideOrientation(orientation?: number): number;
  107487. private _internalMeshDataInfo;
  107488. get computeBonesUsingShaders(): boolean;
  107489. set computeBonesUsingShaders(value: boolean);
  107490. /**
  107491. * An event triggered before rendering the mesh
  107492. */
  107493. get onBeforeRenderObservable(): Observable<Mesh>;
  107494. /**
  107495. * An event triggered before binding the mesh
  107496. */
  107497. get onBeforeBindObservable(): Observable<Mesh>;
  107498. /**
  107499. * An event triggered after rendering the mesh
  107500. */
  107501. get onAfterRenderObservable(): Observable<Mesh>;
  107502. /**
  107503. * An event triggered before drawing the mesh
  107504. */
  107505. get onBeforeDrawObservable(): Observable<Mesh>;
  107506. private _onBeforeDrawObserver;
  107507. /**
  107508. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  107509. */
  107510. set onBeforeDraw(callback: () => void);
  107511. get hasInstances(): boolean;
  107512. get hasThinInstances(): boolean;
  107513. /**
  107514. * Gets the delay loading state of the mesh (when delay loading is turned on)
  107515. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  107516. */
  107517. delayLoadState: number;
  107518. /**
  107519. * Gets the list of instances created from this mesh
  107520. * it is not supposed to be modified manually.
  107521. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  107522. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107523. */
  107524. instances: InstancedMesh[];
  107525. /**
  107526. * Gets the file containing delay loading data for this mesh
  107527. */
  107528. delayLoadingFile: string;
  107529. /** @hidden */
  107530. _binaryInfo: any;
  107531. /**
  107532. * User defined function used to change how LOD level selection is done
  107533. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107534. */
  107535. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  107536. /**
  107537. * Gets or sets the morph target manager
  107538. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107539. */
  107540. get morphTargetManager(): Nullable<MorphTargetManager>;
  107541. set morphTargetManager(value: Nullable<MorphTargetManager>);
  107542. /** @hidden */
  107543. _creationDataStorage: Nullable<_CreationDataStorage>;
  107544. /** @hidden */
  107545. _geometry: Nullable<Geometry>;
  107546. /** @hidden */
  107547. _delayInfo: Array<string>;
  107548. /** @hidden */
  107549. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  107550. /** @hidden */
  107551. _instanceDataStorage: _InstanceDataStorage;
  107552. /** @hidden */
  107553. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  107554. private _effectiveMaterial;
  107555. /** @hidden */
  107556. _shouldGenerateFlatShading: boolean;
  107557. /** @hidden */
  107558. _originalBuilderSideOrientation: number;
  107559. /**
  107560. * Use this property to change the original side orientation defined at construction time
  107561. */
  107562. overrideMaterialSideOrientation: Nullable<number>;
  107563. /**
  107564. * Gets the source mesh (the one used to clone this one from)
  107565. */
  107566. get source(): Nullable<Mesh>;
  107567. /**
  107568. * Gets or sets a boolean indicating that this mesh does not use index buffer
  107569. */
  107570. get isUnIndexed(): boolean;
  107571. set isUnIndexed(value: boolean);
  107572. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  107573. get worldMatrixInstancedBuffer(): Float32Array;
  107574. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  107575. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  107576. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  107577. /**
  107578. * @constructor
  107579. * @param name The value used by scene.getMeshByName() to do a lookup.
  107580. * @param scene The scene to add this mesh to.
  107581. * @param parent The parent of this mesh, if it has one
  107582. * @param source An optional Mesh from which geometry is shared, cloned.
  107583. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  107584. * When false, achieved by calling a clone(), also passing False.
  107585. * This will make creation of children, recursive.
  107586. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107587. */
  107588. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107589. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107590. doNotInstantiate: boolean;
  107591. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107592. /**
  107593. * Gets the class name
  107594. * @returns the string "Mesh".
  107595. */
  107596. getClassName(): string;
  107597. /** @hidden */
  107598. get _isMesh(): boolean;
  107599. /**
  107600. * Returns a description of this mesh
  107601. * @param fullDetails define if full details about this mesh must be used
  107602. * @returns a descriptive string representing this mesh
  107603. */
  107604. toString(fullDetails?: boolean): string;
  107605. /** @hidden */
  107606. _unBindEffect(): void;
  107607. /**
  107608. * Gets a boolean indicating if this mesh has LOD
  107609. */
  107610. get hasLODLevels(): boolean;
  107611. /**
  107612. * Gets the list of MeshLODLevel associated with the current mesh
  107613. * @returns an array of MeshLODLevel
  107614. */
  107615. getLODLevels(): MeshLODLevel[];
  107616. private _sortLODLevels;
  107617. /**
  107618. * Add a mesh as LOD level triggered at the given distance.
  107619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107620. * @param distance The distance from the center of the object to show this level
  107621. * @param mesh The mesh to be added as LOD level (can be null)
  107622. * @return This mesh (for chaining)
  107623. */
  107624. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107625. /**
  107626. * Returns the LOD level mesh at the passed distance or null if not found.
  107627. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107628. * @param distance The distance from the center of the object to show this level
  107629. * @returns a Mesh or `null`
  107630. */
  107631. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107632. /**
  107633. * Remove a mesh from the LOD array
  107634. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107635. * @param mesh defines the mesh to be removed
  107636. * @return This mesh (for chaining)
  107637. */
  107638. removeLODLevel(mesh: Mesh): Mesh;
  107639. /**
  107640. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107642. * @param camera defines the camera to use to compute distance
  107643. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107644. * @return This mesh (for chaining)
  107645. */
  107646. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107647. /**
  107648. * Gets the mesh internal Geometry object
  107649. */
  107650. get geometry(): Nullable<Geometry>;
  107651. /**
  107652. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107653. * @returns the total number of vertices
  107654. */
  107655. getTotalVertices(): number;
  107656. /**
  107657. * Returns the content of an associated vertex buffer
  107658. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107659. * - VertexBuffer.PositionKind
  107660. * - VertexBuffer.UVKind
  107661. * - VertexBuffer.UV2Kind
  107662. * - VertexBuffer.UV3Kind
  107663. * - VertexBuffer.UV4Kind
  107664. * - VertexBuffer.UV5Kind
  107665. * - VertexBuffer.UV6Kind
  107666. * - VertexBuffer.ColorKind
  107667. * - VertexBuffer.MatricesIndicesKind
  107668. * - VertexBuffer.MatricesIndicesExtraKind
  107669. * - VertexBuffer.MatricesWeightsKind
  107670. * - VertexBuffer.MatricesWeightsExtraKind
  107671. * @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
  107672. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107673. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107674. */
  107675. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107676. /**
  107677. * Returns the mesh VertexBuffer object from the requested `kind`
  107678. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107679. * - VertexBuffer.PositionKind
  107680. * - VertexBuffer.NormalKind
  107681. * - VertexBuffer.UVKind
  107682. * - VertexBuffer.UV2Kind
  107683. * - VertexBuffer.UV3Kind
  107684. * - VertexBuffer.UV4Kind
  107685. * - VertexBuffer.UV5Kind
  107686. * - VertexBuffer.UV6Kind
  107687. * - VertexBuffer.ColorKind
  107688. * - VertexBuffer.MatricesIndicesKind
  107689. * - VertexBuffer.MatricesIndicesExtraKind
  107690. * - VertexBuffer.MatricesWeightsKind
  107691. * - VertexBuffer.MatricesWeightsExtraKind
  107692. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107693. */
  107694. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107695. /**
  107696. * Tests if a specific vertex buffer is associated with this mesh
  107697. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107698. * - VertexBuffer.PositionKind
  107699. * - VertexBuffer.NormalKind
  107700. * - VertexBuffer.UVKind
  107701. * - VertexBuffer.UV2Kind
  107702. * - VertexBuffer.UV3Kind
  107703. * - VertexBuffer.UV4Kind
  107704. * - VertexBuffer.UV5Kind
  107705. * - VertexBuffer.UV6Kind
  107706. * - VertexBuffer.ColorKind
  107707. * - VertexBuffer.MatricesIndicesKind
  107708. * - VertexBuffer.MatricesIndicesExtraKind
  107709. * - VertexBuffer.MatricesWeightsKind
  107710. * - VertexBuffer.MatricesWeightsExtraKind
  107711. * @returns a boolean
  107712. */
  107713. isVerticesDataPresent(kind: string): boolean;
  107714. /**
  107715. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107716. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107717. * - VertexBuffer.PositionKind
  107718. * - VertexBuffer.UVKind
  107719. * - VertexBuffer.UV2Kind
  107720. * - VertexBuffer.UV3Kind
  107721. * - VertexBuffer.UV4Kind
  107722. * - VertexBuffer.UV5Kind
  107723. * - VertexBuffer.UV6Kind
  107724. * - VertexBuffer.ColorKind
  107725. * - VertexBuffer.MatricesIndicesKind
  107726. * - VertexBuffer.MatricesIndicesExtraKind
  107727. * - VertexBuffer.MatricesWeightsKind
  107728. * - VertexBuffer.MatricesWeightsExtraKind
  107729. * @returns a boolean
  107730. */
  107731. isVertexBufferUpdatable(kind: string): boolean;
  107732. /**
  107733. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107734. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107735. * - VertexBuffer.PositionKind
  107736. * - VertexBuffer.NormalKind
  107737. * - VertexBuffer.UVKind
  107738. * - VertexBuffer.UV2Kind
  107739. * - VertexBuffer.UV3Kind
  107740. * - VertexBuffer.UV4Kind
  107741. * - VertexBuffer.UV5Kind
  107742. * - VertexBuffer.UV6Kind
  107743. * - VertexBuffer.ColorKind
  107744. * - VertexBuffer.MatricesIndicesKind
  107745. * - VertexBuffer.MatricesIndicesExtraKind
  107746. * - VertexBuffer.MatricesWeightsKind
  107747. * - VertexBuffer.MatricesWeightsExtraKind
  107748. * @returns an array of strings
  107749. */
  107750. getVerticesDataKinds(): string[];
  107751. /**
  107752. * Returns a positive integer : the total number of indices in this mesh geometry.
  107753. * @returns the numner of indices or zero if the mesh has no geometry.
  107754. */
  107755. getTotalIndices(): number;
  107756. /**
  107757. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107758. * @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.
  107759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107760. * @returns the indices array or an empty array if the mesh has no geometry
  107761. */
  107762. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107763. get isBlocked(): boolean;
  107764. /**
  107765. * Determine if the current mesh is ready to be rendered
  107766. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107767. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107768. * @returns true if all associated assets are ready (material, textures, shaders)
  107769. */
  107770. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107771. /**
  107772. * 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.
  107773. */
  107774. get areNormalsFrozen(): boolean;
  107775. /**
  107776. * 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.
  107777. * @returns the current mesh
  107778. */
  107779. freezeNormals(): Mesh;
  107780. /**
  107781. * 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
  107782. * @returns the current mesh
  107783. */
  107784. unfreezeNormals(): Mesh;
  107785. /**
  107786. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107787. */
  107788. set overridenInstanceCount(count: number);
  107789. /** @hidden */
  107790. _preActivate(): Mesh;
  107791. /** @hidden */
  107792. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107793. /** @hidden */
  107794. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107795. protected _afterComputeWorldMatrix(): void;
  107796. /** @hidden */
  107797. _postActivate(): void;
  107798. /**
  107799. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107800. * This means the mesh underlying bounding box and sphere are recomputed.
  107801. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107802. * @returns the current mesh
  107803. */
  107804. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107805. /** @hidden */
  107806. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107807. /**
  107808. * This function will subdivide the mesh into multiple submeshes
  107809. * @param count defines the expected number of submeshes
  107810. */
  107811. subdivide(count: number): void;
  107812. /**
  107813. * Copy a FloatArray into a specific associated vertex buffer
  107814. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107815. * - VertexBuffer.PositionKind
  107816. * - VertexBuffer.UVKind
  107817. * - VertexBuffer.UV2Kind
  107818. * - VertexBuffer.UV3Kind
  107819. * - VertexBuffer.UV4Kind
  107820. * - VertexBuffer.UV5Kind
  107821. * - VertexBuffer.UV6Kind
  107822. * - VertexBuffer.ColorKind
  107823. * - VertexBuffer.MatricesIndicesKind
  107824. * - VertexBuffer.MatricesIndicesExtraKind
  107825. * - VertexBuffer.MatricesWeightsKind
  107826. * - VertexBuffer.MatricesWeightsExtraKind
  107827. * @param data defines the data source
  107828. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107829. * @param stride defines the data stride size (can be null)
  107830. * @returns the current mesh
  107831. */
  107832. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107833. /**
  107834. * Delete a vertex buffer associated with this mesh
  107835. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107836. * - VertexBuffer.PositionKind
  107837. * - VertexBuffer.UVKind
  107838. * - VertexBuffer.UV2Kind
  107839. * - VertexBuffer.UV3Kind
  107840. * - VertexBuffer.UV4Kind
  107841. * - VertexBuffer.UV5Kind
  107842. * - VertexBuffer.UV6Kind
  107843. * - VertexBuffer.ColorKind
  107844. * - VertexBuffer.MatricesIndicesKind
  107845. * - VertexBuffer.MatricesIndicesExtraKind
  107846. * - VertexBuffer.MatricesWeightsKind
  107847. * - VertexBuffer.MatricesWeightsExtraKind
  107848. */
  107849. removeVerticesData(kind: string): void;
  107850. /**
  107851. * Flags an associated vertex buffer as updatable
  107852. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107853. * - VertexBuffer.PositionKind
  107854. * - VertexBuffer.UVKind
  107855. * - VertexBuffer.UV2Kind
  107856. * - VertexBuffer.UV3Kind
  107857. * - VertexBuffer.UV4Kind
  107858. * - VertexBuffer.UV5Kind
  107859. * - VertexBuffer.UV6Kind
  107860. * - VertexBuffer.ColorKind
  107861. * - VertexBuffer.MatricesIndicesKind
  107862. * - VertexBuffer.MatricesIndicesExtraKind
  107863. * - VertexBuffer.MatricesWeightsKind
  107864. * - VertexBuffer.MatricesWeightsExtraKind
  107865. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107866. */
  107867. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107868. /**
  107869. * Sets the mesh global Vertex Buffer
  107870. * @param buffer defines the buffer to use
  107871. * @returns the current mesh
  107872. */
  107873. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107874. /**
  107875. * Update a specific associated vertex buffer
  107876. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107877. * - VertexBuffer.PositionKind
  107878. * - VertexBuffer.UVKind
  107879. * - VertexBuffer.UV2Kind
  107880. * - VertexBuffer.UV3Kind
  107881. * - VertexBuffer.UV4Kind
  107882. * - VertexBuffer.UV5Kind
  107883. * - VertexBuffer.UV6Kind
  107884. * - VertexBuffer.ColorKind
  107885. * - VertexBuffer.MatricesIndicesKind
  107886. * - VertexBuffer.MatricesIndicesExtraKind
  107887. * - VertexBuffer.MatricesWeightsKind
  107888. * - VertexBuffer.MatricesWeightsExtraKind
  107889. * @param data defines the data source
  107890. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107891. * @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)
  107892. * @returns the current mesh
  107893. */
  107894. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107895. /**
  107896. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107897. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107898. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107899. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107900. * @returns the current mesh
  107901. */
  107902. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107903. /**
  107904. * Creates a un-shared specific occurence of the geometry for the mesh.
  107905. * @returns the current mesh
  107906. */
  107907. makeGeometryUnique(): Mesh;
  107908. /**
  107909. * Set the index buffer of this mesh
  107910. * @param indices defines the source data
  107911. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107912. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107913. * @returns the current mesh
  107914. */
  107915. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107916. /**
  107917. * Update the current index buffer
  107918. * @param indices defines the source data
  107919. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107920. * @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)
  107921. * @returns the current mesh
  107922. */
  107923. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107924. /**
  107925. * Invert the geometry to move from a right handed system to a left handed one.
  107926. * @returns the current mesh
  107927. */
  107928. toLeftHanded(): Mesh;
  107929. /** @hidden */
  107930. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107931. /** @hidden */
  107932. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107933. /**
  107934. * Registers for this mesh a javascript function called just before the rendering process
  107935. * @param func defines the function to call before rendering this mesh
  107936. * @returns the current mesh
  107937. */
  107938. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107939. /**
  107940. * Disposes a previously registered javascript function called before the rendering
  107941. * @param func defines the function to remove
  107942. * @returns the current mesh
  107943. */
  107944. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107945. /**
  107946. * Registers for this mesh a javascript function called just after the rendering is complete
  107947. * @param func defines the function to call after rendering this mesh
  107948. * @returns the current mesh
  107949. */
  107950. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107951. /**
  107952. * Disposes a previously registered javascript function called after the rendering.
  107953. * @param func defines the function to remove
  107954. * @returns the current mesh
  107955. */
  107956. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107957. /** @hidden */
  107958. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107959. /** @hidden */
  107960. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107961. /** @hidden */
  107962. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107963. /** @hidden */
  107964. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107965. /** @hidden */
  107966. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107967. /** @hidden */
  107968. _rebuild(): void;
  107969. /** @hidden */
  107970. _freeze(): void;
  107971. /** @hidden */
  107972. _unFreeze(): void;
  107973. /**
  107974. * 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
  107975. * @param subMesh defines the subMesh to render
  107976. * @param enableAlphaMode defines if alpha mode can be changed
  107977. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107978. * @returns the current mesh
  107979. */
  107980. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107981. private _onBeforeDraw;
  107982. /**
  107983. * Renormalize the mesh and patch it up if there are no weights
  107984. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107985. * However in the case of zero weights then we set just a single influence to 1.
  107986. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107987. */
  107988. cleanMatrixWeights(): void;
  107989. private normalizeSkinFourWeights;
  107990. private normalizeSkinWeightsAndExtra;
  107991. /**
  107992. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107993. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107994. * the user know there was an issue with importing the mesh
  107995. * @returns a validation object with skinned, valid and report string
  107996. */
  107997. validateSkinning(): {
  107998. skinned: boolean;
  107999. valid: boolean;
  108000. report: string;
  108001. };
  108002. /** @hidden */
  108003. _checkDelayState(): Mesh;
  108004. private _queueLoad;
  108005. /**
  108006. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108007. * A mesh is in the frustum if its bounding box intersects the frustum
  108008. * @param frustumPlanes defines the frustum to test
  108009. * @returns true if the mesh is in the frustum planes
  108010. */
  108011. isInFrustum(frustumPlanes: Plane[]): boolean;
  108012. /**
  108013. * Sets the mesh material by the material or multiMaterial `id` property
  108014. * @param id is a string identifying the material or the multiMaterial
  108015. * @returns the current mesh
  108016. */
  108017. setMaterialByID(id: string): Mesh;
  108018. /**
  108019. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108020. * @returns an array of IAnimatable
  108021. */
  108022. getAnimatables(): IAnimatable[];
  108023. /**
  108024. * Modifies the mesh geometry according to the passed transformation matrix.
  108025. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108026. * The mesh normals are modified using the same transformation.
  108027. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108028. * @param transform defines the transform matrix to use
  108029. * @see https://doc.babylonjs.com/resources/baking_transformations
  108030. * @returns the current mesh
  108031. */
  108032. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108033. /**
  108034. * Modifies the mesh geometry according to its own current World Matrix.
  108035. * The mesh World Matrix is then reset.
  108036. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108037. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108038. * @see https://doc.babylonjs.com/resources/baking_transformations
  108039. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108040. * @returns the current mesh
  108041. */
  108042. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108043. /** @hidden */
  108044. get _positions(): Nullable<Vector3[]>;
  108045. /** @hidden */
  108046. _resetPointsArrayCache(): Mesh;
  108047. /** @hidden */
  108048. _generatePointsArray(): boolean;
  108049. /**
  108050. * Returns a new Mesh object generated from the current mesh properties.
  108051. * This method must not get confused with createInstance()
  108052. * @param name is a string, the name given to the new mesh
  108053. * @param newParent can be any Node object (default `null`)
  108054. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108055. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108056. * @returns a new mesh
  108057. */
  108058. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108059. /**
  108060. * Releases resources associated with this mesh.
  108061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108063. */
  108064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108065. /** @hidden */
  108066. _disposeInstanceSpecificData(): void;
  108067. /** @hidden */
  108068. _disposeThinInstanceSpecificData(): void;
  108069. /**
  108070. * Modifies the mesh geometry according to a displacement map.
  108071. * 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.
  108072. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108073. * @param url is a string, the URL from the image file is to be downloaded.
  108074. * @param minHeight is the lower limit of the displacement.
  108075. * @param maxHeight is the upper limit of the displacement.
  108076. * @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.
  108077. * @param uvOffset is an optional vector2 used to offset UV.
  108078. * @param uvScale is an optional vector2 used to scale UV.
  108079. * @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.
  108080. * @returns the Mesh.
  108081. */
  108082. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108083. /**
  108084. * Modifies the mesh geometry according to a displacementMap buffer.
  108085. * 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.
  108086. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108087. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108088. * @param heightMapWidth is the width of the buffer image.
  108089. * @param heightMapHeight is the height of the buffer image.
  108090. * @param minHeight is the lower limit of the displacement.
  108091. * @param maxHeight is the upper limit of the displacement.
  108092. * @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.
  108093. * @param uvOffset is an optional vector2 used to offset UV.
  108094. * @param uvScale is an optional vector2 used to scale UV.
  108095. * @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.
  108096. * @returns the Mesh.
  108097. */
  108098. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108099. /**
  108100. * Modify the mesh to get a flat shading rendering.
  108101. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108102. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108103. * @returns current mesh
  108104. */
  108105. convertToFlatShadedMesh(): Mesh;
  108106. /**
  108107. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108108. * In other words, more vertices, no more indices and a single bigger VBO.
  108109. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108110. * @returns current mesh
  108111. */
  108112. convertToUnIndexedMesh(): Mesh;
  108113. /**
  108114. * Inverses facet orientations.
  108115. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108116. * @param flipNormals will also inverts the normals
  108117. * @returns current mesh
  108118. */
  108119. flipFaces(flipNormals?: boolean): Mesh;
  108120. /**
  108121. * Increase the number of facets and hence vertices in a mesh
  108122. * Vertex normals are interpolated from existing vertex normals
  108123. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108124. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108125. */
  108126. increaseVertices(numberPerEdge: number): void;
  108127. /**
  108128. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108129. * This will undo any application of covertToFlatShadedMesh
  108130. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108131. */
  108132. forceSharedVertices(): void;
  108133. /** @hidden */
  108134. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108135. /** @hidden */
  108136. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108137. /**
  108138. * Creates a new InstancedMesh object from the mesh model.
  108139. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108140. * @param name defines the name of the new instance
  108141. * @returns a new InstancedMesh
  108142. */
  108143. createInstance(name: string): InstancedMesh;
  108144. /**
  108145. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108146. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108147. * @returns the current mesh
  108148. */
  108149. synchronizeInstances(): Mesh;
  108150. /**
  108151. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108152. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108153. * This should be used together with the simplification to avoid disappearing triangles.
  108154. * @param successCallback an optional success callback to be called after the optimization finished.
  108155. * @returns the current mesh
  108156. */
  108157. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108158. /**
  108159. * Serialize current mesh
  108160. * @param serializationObject defines the object which will receive the serialization data
  108161. */
  108162. serialize(serializationObject: any): void;
  108163. /** @hidden */
  108164. _syncGeometryWithMorphTargetManager(): void;
  108165. /** @hidden */
  108166. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108167. /**
  108168. * Returns a new Mesh object parsed from the source provided.
  108169. * @param parsedMesh is the source
  108170. * @param scene defines the hosting scene
  108171. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108172. * @returns a new Mesh
  108173. */
  108174. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108175. /**
  108176. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108178. * @param name defines the name of the mesh to create
  108179. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108180. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108181. * @param closePath creates a seam between the first and the last points of each path of the path array
  108182. * @param offset is taken in account only if the `pathArray` is containing a single path
  108183. * @param scene defines the hosting scene
  108184. * @param updatable defines if the mesh must be flagged as updatable
  108185. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108186. * @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)
  108187. * @returns a new Mesh
  108188. */
  108189. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108190. /**
  108191. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108192. * @param name defines the name of the mesh to create
  108193. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108194. * @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
  108195. * @param scene defines the hosting scene
  108196. * @param updatable defines if the mesh must be flagged as updatable
  108197. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108198. * @returns a new Mesh
  108199. */
  108200. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108201. /**
  108202. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108203. * @param name defines the name of the mesh to create
  108204. * @param size sets the size (float) of each box side (default 1)
  108205. * @param scene defines the hosting scene
  108206. * @param updatable defines if the mesh must be flagged as updatable
  108207. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108208. * @returns a new Mesh
  108209. */
  108210. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108211. /**
  108212. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108213. * @param name defines the name of the mesh to create
  108214. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108215. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108216. * @param scene defines the hosting scene
  108217. * @param updatable defines if the mesh must be flagged as updatable
  108218. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108219. * @returns a new Mesh
  108220. */
  108221. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108222. /**
  108223. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108224. * @param name defines the name of the mesh to create
  108225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108227. * @param scene defines the hosting scene
  108228. * @returns a new Mesh
  108229. */
  108230. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108231. /**
  108232. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108233. * @param name defines the name of the mesh to create
  108234. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108235. * @param diameterTop set the top cap diameter (floats, default 1)
  108236. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108237. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108238. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108239. * @param scene defines the hosting scene
  108240. * @param updatable defines if the mesh must be flagged as updatable
  108241. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108242. * @returns a new Mesh
  108243. */
  108244. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108245. /**
  108246. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  108247. * @param name defines the name of the mesh to create
  108248. * @param diameter sets the diameter size (float) of the torus (default 1)
  108249. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  108250. * @param tessellation sets the number of torus sides (postive integer, default 16)
  108251. * @param scene defines the hosting scene
  108252. * @param updatable defines if the mesh must be flagged as updatable
  108253. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108254. * @returns a new Mesh
  108255. */
  108256. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108257. /**
  108258. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  108259. * @param name defines the name of the mesh to create
  108260. * @param radius sets the global radius size (float) of the torus knot (default 2)
  108261. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  108262. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  108263. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  108264. * @param p the number of windings on X axis (positive integers, default 2)
  108265. * @param q the number of windings on Y axis (positive integers, default 3)
  108266. * @param scene defines the hosting scene
  108267. * @param updatable defines if the mesh must be flagged as updatable
  108268. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108269. * @returns a new Mesh
  108270. */
  108271. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108272. /**
  108273. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  108274. * @param name defines the name of the mesh to create
  108275. * @param points is an array successive Vector3
  108276. * @param scene defines the hosting scene
  108277. * @param updatable defines if the mesh must be flagged as updatable
  108278. * @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).
  108279. * @returns a new Mesh
  108280. */
  108281. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  108282. /**
  108283. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  108284. * @param name defines the name of the mesh to create
  108285. * @param points is an array successive Vector3
  108286. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  108287. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108288. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  108289. * @param scene defines the hosting scene
  108290. * @param updatable defines if the mesh must be flagged as updatable
  108291. * @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)
  108292. * @returns a new Mesh
  108293. */
  108294. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  108295. /**
  108296. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  108297. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  108298. * 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.
  108299. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108300. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108301. * Remember you can only change the shape positions, not their number when updating a polygon.
  108302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108303. * @param name defines the name of the mesh to create
  108304. * @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
  108305. * @param scene defines the hosting scene
  108306. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108307. * @param updatable defines if the mesh must be flagged as updatable
  108308. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108309. * @param earcutInjection can be used to inject your own earcut reference
  108310. * @returns a new Mesh
  108311. */
  108312. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108313. /**
  108314. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  108315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  108316. * @param name defines the name of the mesh to create
  108317. * @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
  108318. * @param depth defines the height of extrusion
  108319. * @param scene defines the hosting scene
  108320. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108321. * @param updatable defines if the mesh must be flagged as updatable
  108322. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108323. * @param earcutInjection can be used to inject your own earcut reference
  108324. * @returns a new Mesh
  108325. */
  108326. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108327. /**
  108328. * Creates an extruded shape mesh.
  108329. * 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
  108330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108332. * @param name defines the name of the mesh to create
  108333. * @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
  108334. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108335. * @param scale is the value to scale the shape
  108336. * @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
  108337. * @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
  108338. * @param scene defines the hosting scene
  108339. * @param updatable defines if the mesh must be flagged as updatable
  108340. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108341. * @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)
  108342. * @returns a new Mesh
  108343. */
  108344. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108345. /**
  108346. * Creates an custom extruded shape mesh.
  108347. * The custom extrusion is a parametric shape.
  108348. * It has no predefined shape. Its final shape will depend on the input parameters.
  108349. * Please consider using the same method from the MeshBuilder class instead
  108350. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108351. * @param name defines the name of the mesh to create
  108352. * @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
  108353. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108354. * @param scaleFunction is a custom Javascript function called on each path point
  108355. * @param rotationFunction is a custom Javascript function called on each path point
  108356. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108357. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108358. * @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
  108359. * @param scene defines the hosting scene
  108360. * @param updatable defines if the mesh must be flagged as updatable
  108361. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108362. * @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)
  108363. * @returns a new Mesh
  108364. */
  108365. 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;
  108366. /**
  108367. * Creates lathe mesh.
  108368. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  108369. * Please consider using the same method from the MeshBuilder class instead
  108370. * @param name defines the name of the mesh to create
  108371. * @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
  108372. * @param radius is the radius value of the lathe
  108373. * @param tessellation is the side number of the lathe.
  108374. * @param scene defines the hosting scene
  108375. * @param updatable defines if the mesh must be flagged as updatable
  108376. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108377. * @returns a new Mesh
  108378. */
  108379. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108380. /**
  108381. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  108382. * @param name defines the name of the mesh to create
  108383. * @param size sets the size (float) of both sides of the plane at once (default 1)
  108384. * @param scene defines the hosting scene
  108385. * @param updatable defines if the mesh must be flagged as updatable
  108386. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108387. * @returns a new Mesh
  108388. */
  108389. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108390. /**
  108391. * Creates a ground mesh.
  108392. * Please consider using the same method from the MeshBuilder class instead
  108393. * @param name defines the name of the mesh to create
  108394. * @param width set the width of the ground
  108395. * @param height set the height of the ground
  108396. * @param subdivisions sets the number of subdivisions per side
  108397. * @param scene defines the hosting scene
  108398. * @param updatable defines if the mesh must be flagged as updatable
  108399. * @returns a new Mesh
  108400. */
  108401. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108402. /**
  108403. * Creates a tiled ground mesh.
  108404. * Please consider using the same method from the MeshBuilder class instead
  108405. * @param name defines the name of the mesh to create
  108406. * @param xmin set the ground minimum X coordinate
  108407. * @param zmin set the ground minimum Y coordinate
  108408. * @param xmax set the ground maximum X coordinate
  108409. * @param zmax set the ground maximum Z coordinate
  108410. * @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
  108411. * @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
  108412. * @param scene defines the hosting scene
  108413. * @param updatable defines if the mesh must be flagged as updatable
  108414. * @returns a new Mesh
  108415. */
  108416. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108417. w: number;
  108418. h: number;
  108419. }, precision: {
  108420. w: number;
  108421. h: number;
  108422. }, scene: Scene, updatable?: boolean): Mesh;
  108423. /**
  108424. * Creates a ground mesh from a height map.
  108425. * Please consider using the same method from the MeshBuilder class instead
  108426. * @see https://doc.babylonjs.com/babylon101/height_map
  108427. * @param name defines the name of the mesh to create
  108428. * @param url sets the URL of the height map image resource
  108429. * @param width set the ground width size
  108430. * @param height set the ground height size
  108431. * @param subdivisions sets the number of subdivision per side
  108432. * @param minHeight is the minimum altitude on the ground
  108433. * @param maxHeight is the maximum altitude on the ground
  108434. * @param scene defines the hosting scene
  108435. * @param updatable defines if the mesh must be flagged as updatable
  108436. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108437. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108438. * @returns a new Mesh
  108439. */
  108440. 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;
  108441. /**
  108442. * Creates a tube mesh.
  108443. * The tube is a parametric shape.
  108444. * It has no predefined shape. Its final shape will depend on the input parameters.
  108445. * Please consider using the same method from the MeshBuilder class instead
  108446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108447. * @param name defines the name of the mesh to create
  108448. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108449. * @param radius sets the tube radius size
  108450. * @param tessellation is the number of sides on the tubular surface
  108451. * @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
  108452. * @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
  108453. * @param scene defines the hosting scene
  108454. * @param updatable defines if the mesh must be flagged as updatable
  108455. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108456. * @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)
  108457. * @returns a new Mesh
  108458. */
  108459. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108460. (i: number, distance: number): number;
  108461. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108462. /**
  108463. * Creates a polyhedron mesh.
  108464. * Please consider using the same method from the MeshBuilder class instead.
  108465. * * 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
  108466. * * The parameter `size` (positive float, default 1) sets the polygon size
  108467. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108468. * * 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`
  108469. * * 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
  108470. * * 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)`)
  108471. * * 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
  108472. * * 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
  108473. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108476. * @param name defines the name of the mesh to create
  108477. * @param options defines the options used to create the mesh
  108478. * @param scene defines the hosting scene
  108479. * @returns a new Mesh
  108480. */
  108481. static CreatePolyhedron(name: string, options: {
  108482. type?: number;
  108483. size?: number;
  108484. sizeX?: number;
  108485. sizeY?: number;
  108486. sizeZ?: number;
  108487. custom?: any;
  108488. faceUV?: Vector4[];
  108489. faceColors?: Color4[];
  108490. updatable?: boolean;
  108491. sideOrientation?: number;
  108492. }, scene: Scene): Mesh;
  108493. /**
  108494. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108495. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108496. * * 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`)
  108497. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108498. * * 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
  108499. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108502. * @param name defines the name of the mesh
  108503. * @param options defines the options used to create the mesh
  108504. * @param scene defines the hosting scene
  108505. * @returns a new Mesh
  108506. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108507. */
  108508. static CreateIcoSphere(name: string, options: {
  108509. radius?: number;
  108510. flat?: boolean;
  108511. subdivisions?: number;
  108512. sideOrientation?: number;
  108513. updatable?: boolean;
  108514. }, scene: Scene): Mesh;
  108515. /**
  108516. * Creates a decal mesh.
  108517. * Please consider using the same method from the MeshBuilder class instead.
  108518. * A decal is a mesh usually applied as a model onto the surface of another mesh
  108519. * @param name defines the name of the mesh
  108520. * @param sourceMesh defines the mesh receiving the decal
  108521. * @param position sets the position of the decal in world coordinates
  108522. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  108523. * @param size sets the decal scaling
  108524. * @param angle sets the angle to rotate the decal
  108525. * @returns a new Mesh
  108526. */
  108527. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  108528. /**
  108529. * Prepare internal position array for software CPU skinning
  108530. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  108531. */
  108532. setPositionsForCPUSkinning(): Float32Array;
  108533. /**
  108534. * Prepare internal normal array for software CPU skinning
  108535. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  108536. */
  108537. setNormalsForCPUSkinning(): Float32Array;
  108538. /**
  108539. * Updates the vertex buffer by applying transformation from the bones
  108540. * @param skeleton defines the skeleton to apply to current mesh
  108541. * @returns the current mesh
  108542. */
  108543. applySkeleton(skeleton: Skeleton): Mesh;
  108544. /**
  108545. * 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
  108546. * @param meshes defines the list of meshes to scan
  108547. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  108548. */
  108549. static MinMax(meshes: AbstractMesh[]): {
  108550. min: Vector3;
  108551. max: Vector3;
  108552. };
  108553. /**
  108554. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  108555. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  108556. * @returns a vector3
  108557. */
  108558. static Center(meshesOrMinMaxVector: {
  108559. min: Vector3;
  108560. max: Vector3;
  108561. } | AbstractMesh[]): Vector3;
  108562. /**
  108563. * Merge the array of meshes into a single mesh for performance reasons.
  108564. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  108565. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  108566. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  108567. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  108568. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  108569. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  108570. * @returns a new mesh
  108571. */
  108572. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  108573. /** @hidden */
  108574. addInstance(instance: InstancedMesh): void;
  108575. /** @hidden */
  108576. removeInstance(instance: InstancedMesh): void;
  108577. }
  108578. }
  108579. declare module BABYLON {
  108580. /**
  108581. * This is the base class of all the camera used in the application.
  108582. * @see https://doc.babylonjs.com/features/cameras
  108583. */
  108584. export class Camera extends Node {
  108585. /** @hidden */
  108586. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108587. /**
  108588. * This is the default projection mode used by the cameras.
  108589. * It helps recreating a feeling of perspective and better appreciate depth.
  108590. * This is the best way to simulate real life cameras.
  108591. */
  108592. static readonly PERSPECTIVE_CAMERA: number;
  108593. /**
  108594. * This helps creating camera with an orthographic mode.
  108595. * 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.
  108596. */
  108597. static readonly ORTHOGRAPHIC_CAMERA: number;
  108598. /**
  108599. * This is the default FOV mode for perspective cameras.
  108600. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108601. */
  108602. static readonly FOVMODE_VERTICAL_FIXED: number;
  108603. /**
  108604. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108605. */
  108606. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108607. /**
  108608. * This specifies ther is no need for a camera rig.
  108609. * Basically only one eye is rendered corresponding to the camera.
  108610. */
  108611. static readonly RIG_MODE_NONE: number;
  108612. /**
  108613. * Simulates a camera Rig with one blue eye and one red eye.
  108614. * This can be use with 3d blue and red glasses.
  108615. */
  108616. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108617. /**
  108618. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108619. */
  108620. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108621. /**
  108622. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108623. */
  108624. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108625. /**
  108626. * Defines that both eyes of the camera will be rendered over under each other.
  108627. */
  108628. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108629. /**
  108630. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108631. */
  108632. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108633. /**
  108634. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108635. */
  108636. static readonly RIG_MODE_VR: number;
  108637. /**
  108638. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108639. */
  108640. static readonly RIG_MODE_WEBVR: number;
  108641. /**
  108642. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108643. */
  108644. static readonly RIG_MODE_CUSTOM: number;
  108645. /**
  108646. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108647. */
  108648. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108649. /**
  108650. * Define the input manager associated with the camera.
  108651. */
  108652. inputs: CameraInputsManager<Camera>;
  108653. /** @hidden */
  108654. _position: Vector3;
  108655. /**
  108656. * Define the current local position of the camera in the scene
  108657. */
  108658. get position(): Vector3;
  108659. set position(newPosition: Vector3);
  108660. /**
  108661. * The vector the camera should consider as up.
  108662. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108663. */
  108664. upVector: Vector3;
  108665. /**
  108666. * Define the current limit on the left side for an orthographic camera
  108667. * In scene unit
  108668. */
  108669. orthoLeft: Nullable<number>;
  108670. /**
  108671. * Define the current limit on the right side for an orthographic camera
  108672. * In scene unit
  108673. */
  108674. orthoRight: Nullable<number>;
  108675. /**
  108676. * Define the current limit on the bottom side for an orthographic camera
  108677. * In scene unit
  108678. */
  108679. orthoBottom: Nullable<number>;
  108680. /**
  108681. * Define the current limit on the top side for an orthographic camera
  108682. * In scene unit
  108683. */
  108684. orthoTop: Nullable<number>;
  108685. /**
  108686. * Field Of View is set in Radians. (default is 0.8)
  108687. */
  108688. fov: number;
  108689. /**
  108690. * Define the minimum distance the camera can see from.
  108691. * This is important to note that the depth buffer are not infinite and the closer it starts
  108692. * the more your scene might encounter depth fighting issue.
  108693. */
  108694. minZ: number;
  108695. /**
  108696. * Define the maximum distance the camera can see to.
  108697. * This is important to note that the depth buffer are not infinite and the further it end
  108698. * the more your scene might encounter depth fighting issue.
  108699. */
  108700. maxZ: number;
  108701. /**
  108702. * Define the default inertia of the camera.
  108703. * This helps giving a smooth feeling to the camera movement.
  108704. */
  108705. inertia: number;
  108706. /**
  108707. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108708. */
  108709. mode: number;
  108710. /**
  108711. * Define whether the camera is intermediate.
  108712. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108713. */
  108714. isIntermediate: boolean;
  108715. /**
  108716. * Define the viewport of the camera.
  108717. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108718. */
  108719. viewport: Viewport;
  108720. /**
  108721. * Restricts the camera to viewing objects with the same layerMask.
  108722. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108723. */
  108724. layerMask: number;
  108725. /**
  108726. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108727. */
  108728. fovMode: number;
  108729. /**
  108730. * Rig mode of the camera.
  108731. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108732. * This is normally controlled byt the camera themselves as internal use.
  108733. */
  108734. cameraRigMode: number;
  108735. /**
  108736. * Defines the distance between both "eyes" in case of a RIG
  108737. */
  108738. interaxialDistance: number;
  108739. /**
  108740. * Defines if stereoscopic rendering is done side by side or over under.
  108741. */
  108742. isStereoscopicSideBySide: boolean;
  108743. /**
  108744. * 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
  108745. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108746. * else in the scene. (Eg. security camera)
  108747. *
  108748. * 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)
  108749. */
  108750. customRenderTargets: RenderTargetTexture[];
  108751. /**
  108752. * When set, the camera will render to this render target instead of the default canvas
  108753. *
  108754. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108755. */
  108756. outputRenderTarget: Nullable<RenderTargetTexture>;
  108757. /**
  108758. * Observable triggered when the camera view matrix has changed.
  108759. */
  108760. onViewMatrixChangedObservable: Observable<Camera>;
  108761. /**
  108762. * Observable triggered when the camera Projection matrix has changed.
  108763. */
  108764. onProjectionMatrixChangedObservable: Observable<Camera>;
  108765. /**
  108766. * Observable triggered when the inputs have been processed.
  108767. */
  108768. onAfterCheckInputsObservable: Observable<Camera>;
  108769. /**
  108770. * Observable triggered when reset has been called and applied to the camera.
  108771. */
  108772. onRestoreStateObservable: Observable<Camera>;
  108773. /**
  108774. * Is this camera a part of a rig system?
  108775. */
  108776. isRigCamera: boolean;
  108777. /**
  108778. * If isRigCamera set to true this will be set with the parent camera.
  108779. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108780. */
  108781. rigParent?: Camera;
  108782. /** @hidden */
  108783. _cameraRigParams: any;
  108784. /** @hidden */
  108785. _rigCameras: Camera[];
  108786. /** @hidden */
  108787. _rigPostProcess: Nullable<PostProcess>;
  108788. protected _webvrViewMatrix: Matrix;
  108789. /** @hidden */
  108790. _skipRendering: boolean;
  108791. /** @hidden */
  108792. _projectionMatrix: Matrix;
  108793. /** @hidden */
  108794. _postProcesses: Nullable<PostProcess>[];
  108795. /** @hidden */
  108796. _activeMeshes: SmartArray<AbstractMesh>;
  108797. protected _globalPosition: Vector3;
  108798. /** @hidden */
  108799. _computedViewMatrix: Matrix;
  108800. private _doNotComputeProjectionMatrix;
  108801. private _transformMatrix;
  108802. private _frustumPlanes;
  108803. private _refreshFrustumPlanes;
  108804. private _storedFov;
  108805. private _stateStored;
  108806. /**
  108807. * Instantiates a new camera object.
  108808. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108809. * @see https://doc.babylonjs.com/features/cameras
  108810. * @param name Defines the name of the camera in the scene
  108811. * @param position Defines the position of the camera
  108812. * @param scene Defines the scene the camera belongs too
  108813. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108814. */
  108815. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108816. /**
  108817. * Store current camera state (fov, position, etc..)
  108818. * @returns the camera
  108819. */
  108820. storeState(): Camera;
  108821. /**
  108822. * Restores the camera state values if it has been stored. You must call storeState() first
  108823. */
  108824. protected _restoreStateValues(): boolean;
  108825. /**
  108826. * Restored camera state. You must call storeState() first.
  108827. * @returns true if restored and false otherwise
  108828. */
  108829. restoreState(): boolean;
  108830. /**
  108831. * Gets the class name of the camera.
  108832. * @returns the class name
  108833. */
  108834. getClassName(): string;
  108835. /** @hidden */
  108836. readonly _isCamera: boolean;
  108837. /**
  108838. * Gets a string representation of the camera useful for debug purpose.
  108839. * @param fullDetails Defines that a more verboe level of logging is required
  108840. * @returns the string representation
  108841. */
  108842. toString(fullDetails?: boolean): string;
  108843. /**
  108844. * Gets the current world space position of the camera.
  108845. */
  108846. get globalPosition(): Vector3;
  108847. /**
  108848. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108849. * @returns the active meshe list
  108850. */
  108851. getActiveMeshes(): SmartArray<AbstractMesh>;
  108852. /**
  108853. * Check whether a mesh is part of the current active mesh list of the camera
  108854. * @param mesh Defines the mesh to check
  108855. * @returns true if active, false otherwise
  108856. */
  108857. isActiveMesh(mesh: Mesh): boolean;
  108858. /**
  108859. * Is this camera ready to be used/rendered
  108860. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108861. * @return true if the camera is ready
  108862. */
  108863. isReady(completeCheck?: boolean): boolean;
  108864. /** @hidden */
  108865. _initCache(): void;
  108866. /** @hidden */
  108867. _updateCache(ignoreParentClass?: boolean): void;
  108868. /** @hidden */
  108869. _isSynchronized(): boolean;
  108870. /** @hidden */
  108871. _isSynchronizedViewMatrix(): boolean;
  108872. /** @hidden */
  108873. _isSynchronizedProjectionMatrix(): boolean;
  108874. /**
  108875. * Attach the input controls to a specific dom element to get the input from.
  108876. * @param element Defines the element the controls should be listened from
  108877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108878. */
  108879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108880. /**
  108881. * Detach the current controls from the specified dom element.
  108882. * @param element Defines the element to stop listening the inputs from
  108883. */
  108884. detachControl(element: HTMLElement): void;
  108885. /**
  108886. * Update the camera state according to the different inputs gathered during the frame.
  108887. */
  108888. update(): void;
  108889. /** @hidden */
  108890. _checkInputs(): void;
  108891. /** @hidden */
  108892. get rigCameras(): Camera[];
  108893. /**
  108894. * Gets the post process used by the rig cameras
  108895. */
  108896. get rigPostProcess(): Nullable<PostProcess>;
  108897. /**
  108898. * Internal, gets the first post proces.
  108899. * @returns the first post process to be run on this camera.
  108900. */
  108901. _getFirstPostProcess(): Nullable<PostProcess>;
  108902. private _cascadePostProcessesToRigCams;
  108903. /**
  108904. * Attach a post process to the camera.
  108905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108906. * @param postProcess The post process to attach to the camera
  108907. * @param insertAt The position of the post process in case several of them are in use in the scene
  108908. * @returns the position the post process has been inserted at
  108909. */
  108910. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108911. /**
  108912. * Detach a post process to the camera.
  108913. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108914. * @param postProcess The post process to detach from the camera
  108915. */
  108916. detachPostProcess(postProcess: PostProcess): void;
  108917. /**
  108918. * Gets the current world matrix of the camera
  108919. */
  108920. getWorldMatrix(): Matrix;
  108921. /** @hidden */
  108922. _getViewMatrix(): Matrix;
  108923. /**
  108924. * Gets the current view matrix of the camera.
  108925. * @param force forces the camera to recompute the matrix without looking at the cached state
  108926. * @returns the view matrix
  108927. */
  108928. getViewMatrix(force?: boolean): Matrix;
  108929. /**
  108930. * Freeze the projection matrix.
  108931. * It will prevent the cache check of the camera projection compute and can speed up perf
  108932. * if no parameter of the camera are meant to change
  108933. * @param projection Defines manually a projection if necessary
  108934. */
  108935. freezeProjectionMatrix(projection?: Matrix): void;
  108936. /**
  108937. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108938. */
  108939. unfreezeProjectionMatrix(): void;
  108940. /**
  108941. * Gets the current projection matrix of the camera.
  108942. * @param force forces the camera to recompute the matrix without looking at the cached state
  108943. * @returns the projection matrix
  108944. */
  108945. getProjectionMatrix(force?: boolean): Matrix;
  108946. /**
  108947. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108948. * @returns a Matrix
  108949. */
  108950. getTransformationMatrix(): Matrix;
  108951. private _updateFrustumPlanes;
  108952. /**
  108953. * Checks if a cullable object (mesh...) is in the camera frustum
  108954. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108955. * @param target The object to check
  108956. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108957. * @returns true if the object is in frustum otherwise false
  108958. */
  108959. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108960. /**
  108961. * Checks if a cullable object (mesh...) is in the camera frustum
  108962. * Unlike isInFrustum this cheks the full bounding box
  108963. * @param target The object to check
  108964. * @returns true if the object is in frustum otherwise false
  108965. */
  108966. isCompletelyInFrustum(target: ICullable): boolean;
  108967. /**
  108968. * Gets a ray in the forward direction from the camera.
  108969. * @param length Defines the length of the ray to create
  108970. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108971. * @param origin Defines the start point of the ray which defaults to the camera position
  108972. * @returns the forward ray
  108973. */
  108974. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108975. /**
  108976. * Gets a ray in the forward direction from the camera.
  108977. * @param refRay the ray to (re)use when setting the values
  108978. * @param length Defines the length of the ray to create
  108979. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108980. * @param origin Defines the start point of the ray which defaults to the camera position
  108981. * @returns the forward ray
  108982. */
  108983. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108984. /**
  108985. * Releases resources associated with this node.
  108986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108988. */
  108989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108990. /** @hidden */
  108991. _isLeftCamera: boolean;
  108992. /**
  108993. * Gets the left camera of a rig setup in case of Rigged Camera
  108994. */
  108995. get isLeftCamera(): boolean;
  108996. /** @hidden */
  108997. _isRightCamera: boolean;
  108998. /**
  108999. * Gets the right camera of a rig setup in case of Rigged Camera
  109000. */
  109001. get isRightCamera(): boolean;
  109002. /**
  109003. * Gets the left camera of a rig setup in case of Rigged Camera
  109004. */
  109005. get leftCamera(): Nullable<FreeCamera>;
  109006. /**
  109007. * Gets the right camera of a rig setup in case of Rigged Camera
  109008. */
  109009. get rightCamera(): Nullable<FreeCamera>;
  109010. /**
  109011. * Gets the left camera target of a rig setup in case of Rigged Camera
  109012. * @returns the target position
  109013. */
  109014. getLeftTarget(): Nullable<Vector3>;
  109015. /**
  109016. * Gets the right camera target of a rig setup in case of Rigged Camera
  109017. * @returns the target position
  109018. */
  109019. getRightTarget(): Nullable<Vector3>;
  109020. /**
  109021. * @hidden
  109022. */
  109023. setCameraRigMode(mode: number, rigParams: any): void;
  109024. /** @hidden */
  109025. static _setStereoscopicRigMode(camera: Camera): void;
  109026. /** @hidden */
  109027. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109028. /** @hidden */
  109029. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109030. /** @hidden */
  109031. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109032. /** @hidden */
  109033. _getVRProjectionMatrix(): Matrix;
  109034. protected _updateCameraRotationMatrix(): void;
  109035. protected _updateWebVRCameraRotationMatrix(): void;
  109036. /**
  109037. * This function MUST be overwritten by the different WebVR cameras available.
  109038. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109039. * @hidden
  109040. */
  109041. _getWebVRProjectionMatrix(): Matrix;
  109042. /**
  109043. * This function MUST be overwritten by the different WebVR cameras available.
  109044. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109045. * @hidden
  109046. */
  109047. _getWebVRViewMatrix(): Matrix;
  109048. /** @hidden */
  109049. setCameraRigParameter(name: string, value: any): void;
  109050. /**
  109051. * needs to be overridden by children so sub has required properties to be copied
  109052. * @hidden
  109053. */
  109054. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109055. /**
  109056. * May need to be overridden by children
  109057. * @hidden
  109058. */
  109059. _updateRigCameras(): void;
  109060. /** @hidden */
  109061. _setupInputs(): void;
  109062. /**
  109063. * Serialiaze the camera setup to a json represention
  109064. * @returns the JSON representation
  109065. */
  109066. serialize(): any;
  109067. /**
  109068. * Clones the current camera.
  109069. * @param name The cloned camera name
  109070. * @returns the cloned camera
  109071. */
  109072. clone(name: string): Camera;
  109073. /**
  109074. * Gets the direction of the camera relative to a given local axis.
  109075. * @param localAxis Defines the reference axis to provide a relative direction.
  109076. * @return the direction
  109077. */
  109078. getDirection(localAxis: Vector3): Vector3;
  109079. /**
  109080. * Returns the current camera absolute rotation
  109081. */
  109082. get absoluteRotation(): Quaternion;
  109083. /**
  109084. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109085. * @param localAxis Defines the reference axis to provide a relative direction.
  109086. * @param result Defines the vector to store the result in
  109087. */
  109088. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109089. /**
  109090. * Gets a camera constructor for a given camera type
  109091. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109092. * @param name The name of the camera the result will be able to instantiate
  109093. * @param scene The scene the result will construct the camera in
  109094. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109095. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109096. * @returns a factory method to construc the camera
  109097. */
  109098. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109099. /**
  109100. * Compute the world matrix of the camera.
  109101. * @returns the camera world matrix
  109102. */
  109103. computeWorldMatrix(): Matrix;
  109104. /**
  109105. * Parse a JSON and creates the camera from the parsed information
  109106. * @param parsedCamera The JSON to parse
  109107. * @param scene The scene to instantiate the camera in
  109108. * @returns the newly constructed camera
  109109. */
  109110. static Parse(parsedCamera: any, scene: Scene): Camera;
  109111. }
  109112. }
  109113. declare module BABYLON {
  109114. /**
  109115. * Class containing static functions to help procedurally build meshes
  109116. */
  109117. export class DiscBuilder {
  109118. /**
  109119. * Creates a plane polygonal mesh. By default, this is a disc
  109120. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109121. * * 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
  109122. * * 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
  109123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109126. * @param name defines the name of the mesh
  109127. * @param options defines the options used to create the mesh
  109128. * @param scene defines the hosting scene
  109129. * @returns the plane polygonal mesh
  109130. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109131. */
  109132. static CreateDisc(name: string, options: {
  109133. radius?: number;
  109134. tessellation?: number;
  109135. arc?: number;
  109136. updatable?: boolean;
  109137. sideOrientation?: number;
  109138. frontUVs?: Vector4;
  109139. backUVs?: Vector4;
  109140. }, scene?: Nullable<Scene>): Mesh;
  109141. }
  109142. }
  109143. declare module BABYLON {
  109144. /**
  109145. * Options to be used when creating a FresnelParameters.
  109146. */
  109147. export type IFresnelParametersCreationOptions = {
  109148. /**
  109149. * Define the color used on edges (grazing angle)
  109150. */
  109151. leftColor?: Color3;
  109152. /**
  109153. * Define the color used on center
  109154. */
  109155. rightColor?: Color3;
  109156. /**
  109157. * Define bias applied to computed fresnel term
  109158. */
  109159. bias?: number;
  109160. /**
  109161. * Defined the power exponent applied to fresnel term
  109162. */
  109163. power?: number;
  109164. /**
  109165. * Define if the fresnel effect is enable or not.
  109166. */
  109167. isEnabled?: boolean;
  109168. };
  109169. /**
  109170. * Serialized format for FresnelParameters.
  109171. */
  109172. export type IFresnelParametersSerialized = {
  109173. /**
  109174. * Define the color used on edges (grazing angle) [as an array]
  109175. */
  109176. leftColor: number[];
  109177. /**
  109178. * Define the color used on center [as an array]
  109179. */
  109180. rightColor: number[];
  109181. /**
  109182. * Define bias applied to computed fresnel term
  109183. */
  109184. bias: number;
  109185. /**
  109186. * Defined the power exponent applied to fresnel term
  109187. */
  109188. power?: number;
  109189. /**
  109190. * Define if the fresnel effect is enable or not.
  109191. */
  109192. isEnabled: boolean;
  109193. };
  109194. /**
  109195. * This represents all the required information to add a fresnel effect on a material:
  109196. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109197. */
  109198. export class FresnelParameters {
  109199. private _isEnabled;
  109200. /**
  109201. * Define if the fresnel effect is enable or not.
  109202. */
  109203. get isEnabled(): boolean;
  109204. set isEnabled(value: boolean);
  109205. /**
  109206. * Define the color used on edges (grazing angle)
  109207. */
  109208. leftColor: Color3;
  109209. /**
  109210. * Define the color used on center
  109211. */
  109212. rightColor: Color3;
  109213. /**
  109214. * Define bias applied to computed fresnel term
  109215. */
  109216. bias: number;
  109217. /**
  109218. * Defined the power exponent applied to fresnel term
  109219. */
  109220. power: number;
  109221. /**
  109222. * Creates a new FresnelParameters object.
  109223. *
  109224. * @param options provide your own settings to optionally to override defaults
  109225. */
  109226. constructor(options?: IFresnelParametersCreationOptions);
  109227. /**
  109228. * Clones the current fresnel and its valuues
  109229. * @returns a clone fresnel configuration
  109230. */
  109231. clone(): FresnelParameters;
  109232. /**
  109233. * Determines equality between FresnelParameters objects
  109234. * @param otherFresnelParameters defines the second operand
  109235. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  109236. */
  109237. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  109238. /**
  109239. * Serializes the current fresnel parameters to a JSON representation.
  109240. * @return the JSON serialization
  109241. */
  109242. serialize(): IFresnelParametersSerialized;
  109243. /**
  109244. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  109245. * @param parsedFresnelParameters Define the JSON representation
  109246. * @returns the parsed parameters
  109247. */
  109248. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  109249. }
  109250. }
  109251. declare module BABYLON {
  109252. /**
  109253. * This groups all the flags used to control the materials channel.
  109254. */
  109255. export class MaterialFlags {
  109256. private static _DiffuseTextureEnabled;
  109257. /**
  109258. * Are diffuse textures enabled in the application.
  109259. */
  109260. static get DiffuseTextureEnabled(): boolean;
  109261. static set DiffuseTextureEnabled(value: boolean);
  109262. private static _DetailTextureEnabled;
  109263. /**
  109264. * Are detail textures enabled in the application.
  109265. */
  109266. static get DetailTextureEnabled(): boolean;
  109267. static set DetailTextureEnabled(value: boolean);
  109268. private static _AmbientTextureEnabled;
  109269. /**
  109270. * Are ambient textures enabled in the application.
  109271. */
  109272. static get AmbientTextureEnabled(): boolean;
  109273. static set AmbientTextureEnabled(value: boolean);
  109274. private static _OpacityTextureEnabled;
  109275. /**
  109276. * Are opacity textures enabled in the application.
  109277. */
  109278. static get OpacityTextureEnabled(): boolean;
  109279. static set OpacityTextureEnabled(value: boolean);
  109280. private static _ReflectionTextureEnabled;
  109281. /**
  109282. * Are reflection textures enabled in the application.
  109283. */
  109284. static get ReflectionTextureEnabled(): boolean;
  109285. static set ReflectionTextureEnabled(value: boolean);
  109286. private static _EmissiveTextureEnabled;
  109287. /**
  109288. * Are emissive textures enabled in the application.
  109289. */
  109290. static get EmissiveTextureEnabled(): boolean;
  109291. static set EmissiveTextureEnabled(value: boolean);
  109292. private static _SpecularTextureEnabled;
  109293. /**
  109294. * Are specular textures enabled in the application.
  109295. */
  109296. static get SpecularTextureEnabled(): boolean;
  109297. static set SpecularTextureEnabled(value: boolean);
  109298. private static _BumpTextureEnabled;
  109299. /**
  109300. * Are bump textures enabled in the application.
  109301. */
  109302. static get BumpTextureEnabled(): boolean;
  109303. static set BumpTextureEnabled(value: boolean);
  109304. private static _LightmapTextureEnabled;
  109305. /**
  109306. * Are lightmap textures enabled in the application.
  109307. */
  109308. static get LightmapTextureEnabled(): boolean;
  109309. static set LightmapTextureEnabled(value: boolean);
  109310. private static _RefractionTextureEnabled;
  109311. /**
  109312. * Are refraction textures enabled in the application.
  109313. */
  109314. static get RefractionTextureEnabled(): boolean;
  109315. static set RefractionTextureEnabled(value: boolean);
  109316. private static _ColorGradingTextureEnabled;
  109317. /**
  109318. * Are color grading textures enabled in the application.
  109319. */
  109320. static get ColorGradingTextureEnabled(): boolean;
  109321. static set ColorGradingTextureEnabled(value: boolean);
  109322. private static _FresnelEnabled;
  109323. /**
  109324. * Are fresnels enabled in the application.
  109325. */
  109326. static get FresnelEnabled(): boolean;
  109327. static set FresnelEnabled(value: boolean);
  109328. private static _ClearCoatTextureEnabled;
  109329. /**
  109330. * Are clear coat textures enabled in the application.
  109331. */
  109332. static get ClearCoatTextureEnabled(): boolean;
  109333. static set ClearCoatTextureEnabled(value: boolean);
  109334. private static _ClearCoatBumpTextureEnabled;
  109335. /**
  109336. * Are clear coat bump textures enabled in the application.
  109337. */
  109338. static get ClearCoatBumpTextureEnabled(): boolean;
  109339. static set ClearCoatBumpTextureEnabled(value: boolean);
  109340. private static _ClearCoatTintTextureEnabled;
  109341. /**
  109342. * Are clear coat tint textures enabled in the application.
  109343. */
  109344. static get ClearCoatTintTextureEnabled(): boolean;
  109345. static set ClearCoatTintTextureEnabled(value: boolean);
  109346. private static _SheenTextureEnabled;
  109347. /**
  109348. * Are sheen textures enabled in the application.
  109349. */
  109350. static get SheenTextureEnabled(): boolean;
  109351. static set SheenTextureEnabled(value: boolean);
  109352. private static _AnisotropicTextureEnabled;
  109353. /**
  109354. * Are anisotropic textures enabled in the application.
  109355. */
  109356. static get AnisotropicTextureEnabled(): boolean;
  109357. static set AnisotropicTextureEnabled(value: boolean);
  109358. private static _ThicknessTextureEnabled;
  109359. /**
  109360. * Are thickness textures enabled in the application.
  109361. */
  109362. static get ThicknessTextureEnabled(): boolean;
  109363. static set ThicknessTextureEnabled(value: boolean);
  109364. }
  109365. }
  109366. declare module BABYLON {
  109367. /** @hidden */
  109368. export var defaultFragmentDeclaration: {
  109369. name: string;
  109370. shader: string;
  109371. };
  109372. }
  109373. declare module BABYLON {
  109374. /** @hidden */
  109375. export var defaultUboDeclaration: {
  109376. name: string;
  109377. shader: string;
  109378. };
  109379. }
  109380. declare module BABYLON {
  109381. /** @hidden */
  109382. export var prePassDeclaration: {
  109383. name: string;
  109384. shader: string;
  109385. };
  109386. }
  109387. declare module BABYLON {
  109388. /** @hidden */
  109389. export var lightFragmentDeclaration: {
  109390. name: string;
  109391. shader: string;
  109392. };
  109393. }
  109394. declare module BABYLON {
  109395. /** @hidden */
  109396. export var lightUboDeclaration: {
  109397. name: string;
  109398. shader: string;
  109399. };
  109400. }
  109401. declare module BABYLON {
  109402. /** @hidden */
  109403. export var lightsFragmentFunctions: {
  109404. name: string;
  109405. shader: string;
  109406. };
  109407. }
  109408. declare module BABYLON {
  109409. /** @hidden */
  109410. export var shadowsFragmentFunctions: {
  109411. name: string;
  109412. shader: string;
  109413. };
  109414. }
  109415. declare module BABYLON {
  109416. /** @hidden */
  109417. export var fresnelFunction: {
  109418. name: string;
  109419. shader: string;
  109420. };
  109421. }
  109422. declare module BABYLON {
  109423. /** @hidden */
  109424. export var bumpFragmentMainFunctions: {
  109425. name: string;
  109426. shader: string;
  109427. };
  109428. }
  109429. declare module BABYLON {
  109430. /** @hidden */
  109431. export var bumpFragmentFunctions: {
  109432. name: string;
  109433. shader: string;
  109434. };
  109435. }
  109436. declare module BABYLON {
  109437. /** @hidden */
  109438. export var logDepthDeclaration: {
  109439. name: string;
  109440. shader: string;
  109441. };
  109442. }
  109443. declare module BABYLON {
  109444. /** @hidden */
  109445. export var bumpFragment: {
  109446. name: string;
  109447. shader: string;
  109448. };
  109449. }
  109450. declare module BABYLON {
  109451. /** @hidden */
  109452. export var depthPrePass: {
  109453. name: string;
  109454. shader: string;
  109455. };
  109456. }
  109457. declare module BABYLON {
  109458. /** @hidden */
  109459. export var lightFragment: {
  109460. name: string;
  109461. shader: string;
  109462. };
  109463. }
  109464. declare module BABYLON {
  109465. /** @hidden */
  109466. export var logDepthFragment: {
  109467. name: string;
  109468. shader: string;
  109469. };
  109470. }
  109471. declare module BABYLON {
  109472. /** @hidden */
  109473. export var defaultPixelShader: {
  109474. name: string;
  109475. shader: string;
  109476. };
  109477. }
  109478. declare module BABYLON {
  109479. /** @hidden */
  109480. export var defaultVertexDeclaration: {
  109481. name: string;
  109482. shader: string;
  109483. };
  109484. }
  109485. declare module BABYLON {
  109486. /** @hidden */
  109487. export var bumpVertexDeclaration: {
  109488. name: string;
  109489. shader: string;
  109490. };
  109491. }
  109492. declare module BABYLON {
  109493. /** @hidden */
  109494. export var bumpVertex: {
  109495. name: string;
  109496. shader: string;
  109497. };
  109498. }
  109499. declare module BABYLON {
  109500. /** @hidden */
  109501. export var fogVertex: {
  109502. name: string;
  109503. shader: string;
  109504. };
  109505. }
  109506. declare module BABYLON {
  109507. /** @hidden */
  109508. export var shadowsVertex: {
  109509. name: string;
  109510. shader: string;
  109511. };
  109512. }
  109513. declare module BABYLON {
  109514. /** @hidden */
  109515. export var pointCloudVertex: {
  109516. name: string;
  109517. shader: string;
  109518. };
  109519. }
  109520. declare module BABYLON {
  109521. /** @hidden */
  109522. export var logDepthVertex: {
  109523. name: string;
  109524. shader: string;
  109525. };
  109526. }
  109527. declare module BABYLON {
  109528. /** @hidden */
  109529. export var defaultVertexShader: {
  109530. name: string;
  109531. shader: string;
  109532. };
  109533. }
  109534. declare module BABYLON {
  109535. /**
  109536. * @hidden
  109537. */
  109538. export interface IMaterialDetailMapDefines {
  109539. DETAIL: boolean;
  109540. DETAILDIRECTUV: number;
  109541. DETAIL_NORMALBLENDMETHOD: number;
  109542. /** @hidden */
  109543. _areTexturesDirty: boolean;
  109544. }
  109545. /**
  109546. * Define the code related to the detail map parameters of a material
  109547. *
  109548. * Inspired from:
  109549. * 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
  109550. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  109551. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  109552. */
  109553. export class DetailMapConfiguration {
  109554. private _texture;
  109555. /**
  109556. * The detail texture of the material.
  109557. */
  109558. texture: Nullable<BaseTexture>;
  109559. /**
  109560. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  109561. * Bigger values mean stronger blending
  109562. */
  109563. diffuseBlendLevel: number;
  109564. /**
  109565. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  109566. * Bigger values mean stronger blending. Only used with PBR materials
  109567. */
  109568. roughnessBlendLevel: number;
  109569. /**
  109570. * Defines how strong the bump effect from the detail map is
  109571. * Bigger values mean stronger effect
  109572. */
  109573. bumpLevel: number;
  109574. private _normalBlendMethod;
  109575. /**
  109576. * The method used to blend the bump and detail normals together
  109577. */
  109578. normalBlendMethod: number;
  109579. private _isEnabled;
  109580. /**
  109581. * Enable or disable the detail map on this material
  109582. */
  109583. isEnabled: boolean;
  109584. /** @hidden */
  109585. private _internalMarkAllSubMeshesAsTexturesDirty;
  109586. /** @hidden */
  109587. _markAllSubMeshesAsTexturesDirty(): void;
  109588. /**
  109589. * Instantiate a new detail map
  109590. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109591. */
  109592. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109593. /**
  109594. * Gets whether the submesh is ready to be used or not.
  109595. * @param defines the list of "defines" to update.
  109596. * @param scene defines the scene the material belongs to.
  109597. * @returns - boolean indicating that the submesh is ready or not.
  109598. */
  109599. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109600. /**
  109601. * Update the defines for detail map usage
  109602. * @param defines the list of "defines" to update.
  109603. * @param scene defines the scene the material belongs to.
  109604. */
  109605. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109606. /**
  109607. * Binds the material data.
  109608. * @param uniformBuffer defines the Uniform buffer to fill in.
  109609. * @param scene defines the scene the material belongs to.
  109610. * @param isFrozen defines whether the material is frozen or not.
  109611. */
  109612. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109613. /**
  109614. * Checks to see if a texture is used in the material.
  109615. * @param texture - Base texture to use.
  109616. * @returns - Boolean specifying if a texture is used in the material.
  109617. */
  109618. hasTexture(texture: BaseTexture): boolean;
  109619. /**
  109620. * Returns an array of the actively used textures.
  109621. * @param activeTextures Array of BaseTextures
  109622. */
  109623. getActiveTextures(activeTextures: BaseTexture[]): void;
  109624. /**
  109625. * Returns the animatable textures.
  109626. * @param animatables Array of animatable textures.
  109627. */
  109628. getAnimatables(animatables: IAnimatable[]): void;
  109629. /**
  109630. * Disposes the resources of the material.
  109631. * @param forceDisposeTextures - Forces the disposal of all textures.
  109632. */
  109633. dispose(forceDisposeTextures?: boolean): void;
  109634. /**
  109635. * Get the current class name useful for serialization or dynamic coding.
  109636. * @returns "DetailMap"
  109637. */
  109638. getClassName(): string;
  109639. /**
  109640. * Add the required uniforms to the current list.
  109641. * @param uniforms defines the current uniform list.
  109642. */
  109643. static AddUniforms(uniforms: string[]): void;
  109644. /**
  109645. * Add the required samplers to the current list.
  109646. * @param samplers defines the current sampler list.
  109647. */
  109648. static AddSamplers(samplers: string[]): void;
  109649. /**
  109650. * Add the required uniforms to the current buffer.
  109651. * @param uniformBuffer defines the current uniform buffer.
  109652. */
  109653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109654. /**
  109655. * Makes a duplicate of the current instance into another one.
  109656. * @param detailMap define the instance where to copy the info
  109657. */
  109658. copyTo(detailMap: DetailMapConfiguration): void;
  109659. /**
  109660. * Serializes this detail map instance
  109661. * @returns - An object with the serialized instance.
  109662. */
  109663. serialize(): any;
  109664. /**
  109665. * Parses a detail map setting from a serialized object.
  109666. * @param source - Serialized object.
  109667. * @param scene Defines the scene we are parsing for
  109668. * @param rootUrl Defines the rootUrl to load from
  109669. */
  109670. parse(source: any, scene: Scene, rootUrl: string): void;
  109671. }
  109672. }
  109673. declare module BABYLON {
  109674. /** @hidden */
  109675. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109676. MAINUV1: boolean;
  109677. MAINUV2: boolean;
  109678. DIFFUSE: boolean;
  109679. DIFFUSEDIRECTUV: number;
  109680. DETAIL: boolean;
  109681. DETAILDIRECTUV: number;
  109682. DETAIL_NORMALBLENDMETHOD: number;
  109683. AMBIENT: boolean;
  109684. AMBIENTDIRECTUV: number;
  109685. OPACITY: boolean;
  109686. OPACITYDIRECTUV: number;
  109687. OPACITYRGB: boolean;
  109688. REFLECTION: boolean;
  109689. EMISSIVE: boolean;
  109690. EMISSIVEDIRECTUV: number;
  109691. SPECULAR: boolean;
  109692. SPECULARDIRECTUV: number;
  109693. BUMP: boolean;
  109694. BUMPDIRECTUV: number;
  109695. PARALLAX: boolean;
  109696. PARALLAXOCCLUSION: boolean;
  109697. SPECULAROVERALPHA: boolean;
  109698. CLIPPLANE: boolean;
  109699. CLIPPLANE2: boolean;
  109700. CLIPPLANE3: boolean;
  109701. CLIPPLANE4: boolean;
  109702. CLIPPLANE5: boolean;
  109703. CLIPPLANE6: boolean;
  109704. ALPHATEST: boolean;
  109705. DEPTHPREPASS: boolean;
  109706. ALPHAFROMDIFFUSE: boolean;
  109707. POINTSIZE: boolean;
  109708. FOG: boolean;
  109709. SPECULARTERM: boolean;
  109710. DIFFUSEFRESNEL: boolean;
  109711. OPACITYFRESNEL: boolean;
  109712. REFLECTIONFRESNEL: boolean;
  109713. REFRACTIONFRESNEL: boolean;
  109714. EMISSIVEFRESNEL: boolean;
  109715. FRESNEL: boolean;
  109716. NORMAL: boolean;
  109717. UV1: boolean;
  109718. UV2: boolean;
  109719. VERTEXCOLOR: boolean;
  109720. VERTEXALPHA: boolean;
  109721. NUM_BONE_INFLUENCERS: number;
  109722. BonesPerMesh: number;
  109723. BONETEXTURE: boolean;
  109724. INSTANCES: boolean;
  109725. THIN_INSTANCES: boolean;
  109726. GLOSSINESS: boolean;
  109727. ROUGHNESS: boolean;
  109728. EMISSIVEASILLUMINATION: boolean;
  109729. LINKEMISSIVEWITHDIFFUSE: boolean;
  109730. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109731. LIGHTMAP: boolean;
  109732. LIGHTMAPDIRECTUV: number;
  109733. OBJECTSPACE_NORMALMAP: boolean;
  109734. USELIGHTMAPASSHADOWMAP: boolean;
  109735. REFLECTIONMAP_3D: boolean;
  109736. REFLECTIONMAP_SPHERICAL: boolean;
  109737. REFLECTIONMAP_PLANAR: boolean;
  109738. REFLECTIONMAP_CUBIC: boolean;
  109739. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109740. REFLECTIONMAP_PROJECTION: boolean;
  109741. REFLECTIONMAP_SKYBOX: boolean;
  109742. REFLECTIONMAP_EXPLICIT: boolean;
  109743. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109744. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109745. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109746. INVERTCUBICMAP: boolean;
  109747. LOGARITHMICDEPTH: boolean;
  109748. REFRACTION: boolean;
  109749. REFRACTIONMAP_3D: boolean;
  109750. REFLECTIONOVERALPHA: boolean;
  109751. TWOSIDEDLIGHTING: boolean;
  109752. SHADOWFLOAT: boolean;
  109753. MORPHTARGETS: boolean;
  109754. MORPHTARGETS_NORMAL: boolean;
  109755. MORPHTARGETS_TANGENT: boolean;
  109756. MORPHTARGETS_UV: boolean;
  109757. NUM_MORPH_INFLUENCERS: number;
  109758. NONUNIFORMSCALING: boolean;
  109759. PREMULTIPLYALPHA: boolean;
  109760. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109761. ALPHABLEND: boolean;
  109762. PREPASS: boolean;
  109763. SCENE_MRT_COUNT: number;
  109764. RGBDLIGHTMAP: boolean;
  109765. RGBDREFLECTION: boolean;
  109766. RGBDREFRACTION: boolean;
  109767. IMAGEPROCESSING: boolean;
  109768. VIGNETTE: boolean;
  109769. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109770. VIGNETTEBLENDMODEOPAQUE: boolean;
  109771. TONEMAPPING: boolean;
  109772. TONEMAPPING_ACES: boolean;
  109773. CONTRAST: boolean;
  109774. COLORCURVES: boolean;
  109775. COLORGRADING: boolean;
  109776. COLORGRADING3D: boolean;
  109777. SAMPLER3DGREENDEPTH: boolean;
  109778. SAMPLER3DBGRMAP: boolean;
  109779. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109780. MULTIVIEW: boolean;
  109781. /**
  109782. * If the reflection texture on this material is in linear color space
  109783. * @hidden
  109784. */
  109785. IS_REFLECTION_LINEAR: boolean;
  109786. /**
  109787. * If the refraction texture on this material is in linear color space
  109788. * @hidden
  109789. */
  109790. IS_REFRACTION_LINEAR: boolean;
  109791. EXPOSURE: boolean;
  109792. constructor();
  109793. setReflectionMode(modeToEnable: string): void;
  109794. }
  109795. /**
  109796. * This is the default material used in Babylon. It is the best trade off between quality
  109797. * and performances.
  109798. * @see https://doc.babylonjs.com/babylon101/materials
  109799. */
  109800. export class StandardMaterial extends PushMaterial {
  109801. private _diffuseTexture;
  109802. /**
  109803. * The basic texture of the material as viewed under a light.
  109804. */
  109805. diffuseTexture: Nullable<BaseTexture>;
  109806. private _ambientTexture;
  109807. /**
  109808. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109809. */
  109810. ambientTexture: Nullable<BaseTexture>;
  109811. private _opacityTexture;
  109812. /**
  109813. * Define the transparency of the material from a texture.
  109814. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109815. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109816. */
  109817. opacityTexture: Nullable<BaseTexture>;
  109818. private _reflectionTexture;
  109819. /**
  109820. * Define the texture used to display the reflection.
  109821. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109822. */
  109823. reflectionTexture: Nullable<BaseTexture>;
  109824. private _emissiveTexture;
  109825. /**
  109826. * Define texture of the material as if self lit.
  109827. * This will be mixed in the final result even in the absence of light.
  109828. */
  109829. emissiveTexture: Nullable<BaseTexture>;
  109830. private _specularTexture;
  109831. /**
  109832. * Define how the color and intensity of the highlight given by the light in the material.
  109833. */
  109834. specularTexture: Nullable<BaseTexture>;
  109835. private _bumpTexture;
  109836. /**
  109837. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109838. * 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.
  109839. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109840. */
  109841. bumpTexture: Nullable<BaseTexture>;
  109842. private _lightmapTexture;
  109843. /**
  109844. * Complex lighting can be computationally expensive to compute at runtime.
  109845. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109846. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109847. */
  109848. lightmapTexture: Nullable<BaseTexture>;
  109849. private _refractionTexture;
  109850. /**
  109851. * Define the texture used to display the refraction.
  109852. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109853. */
  109854. refractionTexture: Nullable<BaseTexture>;
  109855. /**
  109856. * The color of the material lit by the environmental background lighting.
  109857. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109858. */
  109859. ambientColor: Color3;
  109860. /**
  109861. * The basic color of the material as viewed under a light.
  109862. */
  109863. diffuseColor: Color3;
  109864. /**
  109865. * Define how the color and intensity of the highlight given by the light in the material.
  109866. */
  109867. specularColor: Color3;
  109868. /**
  109869. * Define the color of the material as if self lit.
  109870. * This will be mixed in the final result even in the absence of light.
  109871. */
  109872. emissiveColor: Color3;
  109873. /**
  109874. * Defines how sharp are the highlights in the material.
  109875. * The bigger the value the sharper giving a more glossy feeling to the result.
  109876. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109877. */
  109878. specularPower: number;
  109879. private _useAlphaFromDiffuseTexture;
  109880. /**
  109881. * Does the transparency come from the diffuse texture alpha channel.
  109882. */
  109883. useAlphaFromDiffuseTexture: boolean;
  109884. private _useEmissiveAsIllumination;
  109885. /**
  109886. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109887. */
  109888. useEmissiveAsIllumination: boolean;
  109889. private _linkEmissiveWithDiffuse;
  109890. /**
  109891. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109892. * the emissive level when the final color is close to one.
  109893. */
  109894. linkEmissiveWithDiffuse: boolean;
  109895. private _useSpecularOverAlpha;
  109896. /**
  109897. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109898. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109899. */
  109900. useSpecularOverAlpha: boolean;
  109901. private _useReflectionOverAlpha;
  109902. /**
  109903. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109904. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109905. */
  109906. useReflectionOverAlpha: boolean;
  109907. private _disableLighting;
  109908. /**
  109909. * Does lights from the scene impacts this material.
  109910. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109911. */
  109912. disableLighting: boolean;
  109913. private _useObjectSpaceNormalMap;
  109914. /**
  109915. * Allows using an object space normal map (instead of tangent space).
  109916. */
  109917. useObjectSpaceNormalMap: boolean;
  109918. private _useParallax;
  109919. /**
  109920. * Is parallax enabled or not.
  109921. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109922. */
  109923. useParallax: boolean;
  109924. private _useParallaxOcclusion;
  109925. /**
  109926. * Is parallax occlusion enabled or not.
  109927. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109928. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109929. */
  109930. useParallaxOcclusion: boolean;
  109931. /**
  109932. * 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.
  109933. */
  109934. parallaxScaleBias: number;
  109935. private _roughness;
  109936. /**
  109937. * Helps to define how blurry the reflections should appears in the material.
  109938. */
  109939. roughness: number;
  109940. /**
  109941. * In case of refraction, define the value of the index of refraction.
  109942. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109943. */
  109944. indexOfRefraction: number;
  109945. /**
  109946. * Invert the refraction texture alongside the y axis.
  109947. * It can be useful with procedural textures or probe for instance.
  109948. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109949. */
  109950. invertRefractionY: boolean;
  109951. /**
  109952. * Defines the alpha limits in alpha test mode.
  109953. */
  109954. alphaCutOff: number;
  109955. private _useLightmapAsShadowmap;
  109956. /**
  109957. * In case of light mapping, define whether the map contains light or shadow informations.
  109958. */
  109959. useLightmapAsShadowmap: boolean;
  109960. private _diffuseFresnelParameters;
  109961. /**
  109962. * Define the diffuse fresnel parameters of the material.
  109963. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109964. */
  109965. diffuseFresnelParameters: FresnelParameters;
  109966. private _opacityFresnelParameters;
  109967. /**
  109968. * Define the opacity fresnel parameters of the material.
  109969. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109970. */
  109971. opacityFresnelParameters: FresnelParameters;
  109972. private _reflectionFresnelParameters;
  109973. /**
  109974. * Define the reflection fresnel parameters of the material.
  109975. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109976. */
  109977. reflectionFresnelParameters: FresnelParameters;
  109978. private _refractionFresnelParameters;
  109979. /**
  109980. * Define the refraction fresnel parameters of the material.
  109981. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109982. */
  109983. refractionFresnelParameters: FresnelParameters;
  109984. private _emissiveFresnelParameters;
  109985. /**
  109986. * Define the emissive fresnel parameters of the material.
  109987. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109988. */
  109989. emissiveFresnelParameters: FresnelParameters;
  109990. private _useReflectionFresnelFromSpecular;
  109991. /**
  109992. * If true automatically deducts the fresnels values from the material specularity.
  109993. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109994. */
  109995. useReflectionFresnelFromSpecular: boolean;
  109996. private _useGlossinessFromSpecularMapAlpha;
  109997. /**
  109998. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109999. */
  110000. useGlossinessFromSpecularMapAlpha: boolean;
  110001. private _maxSimultaneousLights;
  110002. /**
  110003. * Defines the maximum number of lights that can be used in the material
  110004. */
  110005. maxSimultaneousLights: number;
  110006. private _invertNormalMapX;
  110007. /**
  110008. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110009. */
  110010. invertNormalMapX: boolean;
  110011. private _invertNormalMapY;
  110012. /**
  110013. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110014. */
  110015. invertNormalMapY: boolean;
  110016. private _twoSidedLighting;
  110017. /**
  110018. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110019. */
  110020. twoSidedLighting: boolean;
  110021. /**
  110022. * Default configuration related to image processing available in the standard Material.
  110023. */
  110024. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110025. /**
  110026. * Gets the image processing configuration used either in this material.
  110027. */
  110028. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110029. /**
  110030. * Sets the Default image processing configuration used either in the this material.
  110031. *
  110032. * If sets to null, the scene one is in use.
  110033. */
  110034. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110035. /**
  110036. * Keep track of the image processing observer to allow dispose and replace.
  110037. */
  110038. private _imageProcessingObserver;
  110039. /**
  110040. * Attaches a new image processing configuration to the Standard Material.
  110041. * @param configuration
  110042. */
  110043. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110044. /**
  110045. * Gets wether the color curves effect is enabled.
  110046. */
  110047. get cameraColorCurvesEnabled(): boolean;
  110048. /**
  110049. * Sets wether the color curves effect is enabled.
  110050. */
  110051. set cameraColorCurvesEnabled(value: boolean);
  110052. /**
  110053. * Gets wether the color grading effect is enabled.
  110054. */
  110055. get cameraColorGradingEnabled(): boolean;
  110056. /**
  110057. * Gets wether the color grading effect is enabled.
  110058. */
  110059. set cameraColorGradingEnabled(value: boolean);
  110060. /**
  110061. * Gets wether tonemapping is enabled or not.
  110062. */
  110063. get cameraToneMappingEnabled(): boolean;
  110064. /**
  110065. * Sets wether tonemapping is enabled or not
  110066. */
  110067. set cameraToneMappingEnabled(value: boolean);
  110068. /**
  110069. * The camera exposure used on this material.
  110070. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110071. * This corresponds to a photographic exposure.
  110072. */
  110073. get cameraExposure(): number;
  110074. /**
  110075. * The camera exposure used on this material.
  110076. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110077. * This corresponds to a photographic exposure.
  110078. */
  110079. set cameraExposure(value: number);
  110080. /**
  110081. * Gets The camera contrast used on this material.
  110082. */
  110083. get cameraContrast(): number;
  110084. /**
  110085. * Sets The camera contrast used on this material.
  110086. */
  110087. set cameraContrast(value: number);
  110088. /**
  110089. * Gets the Color Grading 2D Lookup Texture.
  110090. */
  110091. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110092. /**
  110093. * Sets the Color Grading 2D Lookup Texture.
  110094. */
  110095. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110096. /**
  110097. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110098. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110099. * 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;
  110100. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110101. */
  110102. get cameraColorCurves(): Nullable<ColorCurves>;
  110103. /**
  110104. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110105. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110106. * 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;
  110107. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110108. */
  110109. set cameraColorCurves(value: Nullable<ColorCurves>);
  110110. /**
  110111. * Can this material render to several textures at once
  110112. */
  110113. get canRenderToMRT(): boolean;
  110114. /**
  110115. * Defines the detail map parameters for the material.
  110116. */
  110117. readonly detailMap: DetailMapConfiguration;
  110118. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110119. protected _worldViewProjectionMatrix: Matrix;
  110120. protected _globalAmbientColor: Color3;
  110121. protected _useLogarithmicDepth: boolean;
  110122. protected _rebuildInParallel: boolean;
  110123. /**
  110124. * Instantiates a new standard material.
  110125. * This is the default material used in Babylon. It is the best trade off between quality
  110126. * and performances.
  110127. * @see https://doc.babylonjs.com/babylon101/materials
  110128. * @param name Define the name of the material in the scene
  110129. * @param scene Define the scene the material belong to
  110130. */
  110131. constructor(name: string, scene: Scene);
  110132. /**
  110133. * Gets a boolean indicating that current material needs to register RTT
  110134. */
  110135. get hasRenderTargetTextures(): boolean;
  110136. /**
  110137. * Gets the current class name of the material e.g. "StandardMaterial"
  110138. * Mainly use in serialization.
  110139. * @returns the class name
  110140. */
  110141. getClassName(): string;
  110142. /**
  110143. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110144. * You can try switching to logarithmic depth.
  110145. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110146. */
  110147. get useLogarithmicDepth(): boolean;
  110148. set useLogarithmicDepth(value: boolean);
  110149. /**
  110150. * Specifies if the material will require alpha blending
  110151. * @returns a boolean specifying if alpha blending is needed
  110152. */
  110153. needAlphaBlending(): boolean;
  110154. /**
  110155. * Specifies if this material should be rendered in alpha test mode
  110156. * @returns a boolean specifying if an alpha test is needed.
  110157. */
  110158. needAlphaTesting(): boolean;
  110159. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110160. /**
  110161. * Get the texture used for alpha test purpose.
  110162. * @returns the diffuse texture in case of the standard material.
  110163. */
  110164. getAlphaTestTexture(): Nullable<BaseTexture>;
  110165. /**
  110166. * Get if the submesh is ready to be used and all its information available.
  110167. * Child classes can use it to update shaders
  110168. * @param mesh defines the mesh to check
  110169. * @param subMesh defines which submesh to check
  110170. * @param useInstances specifies that instances should be used
  110171. * @returns a boolean indicating that the submesh is ready or not
  110172. */
  110173. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110174. /**
  110175. * Builds the material UBO layouts.
  110176. * Used internally during the effect preparation.
  110177. */
  110178. buildUniformLayout(): void;
  110179. /**
  110180. * Unbinds the material from the mesh
  110181. */
  110182. unbind(): void;
  110183. /**
  110184. * Binds the submesh to this material by preparing the effect and shader to draw
  110185. * @param world defines the world transformation matrix
  110186. * @param mesh defines the mesh containing the submesh
  110187. * @param subMesh defines the submesh to bind the material to
  110188. */
  110189. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110190. /**
  110191. * Get the list of animatables in the material.
  110192. * @returns the list of animatables object used in the material
  110193. */
  110194. getAnimatables(): IAnimatable[];
  110195. /**
  110196. * Gets the active textures from the material
  110197. * @returns an array of textures
  110198. */
  110199. getActiveTextures(): BaseTexture[];
  110200. /**
  110201. * Specifies if the material uses a texture
  110202. * @param texture defines the texture to check against the material
  110203. * @returns a boolean specifying if the material uses the texture
  110204. */
  110205. hasTexture(texture: BaseTexture): boolean;
  110206. /**
  110207. * Disposes the material
  110208. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110209. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110210. */
  110211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110212. /**
  110213. * Makes a duplicate of the material, and gives it a new name
  110214. * @param name defines the new name for the duplicated material
  110215. * @returns the cloned material
  110216. */
  110217. clone(name: string): StandardMaterial;
  110218. /**
  110219. * Serializes this material in a JSON representation
  110220. * @returns the serialized material object
  110221. */
  110222. serialize(): any;
  110223. /**
  110224. * Creates a standard material from parsed material data
  110225. * @param source defines the JSON representation of the material
  110226. * @param scene defines the hosting scene
  110227. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110228. * @returns a new standard material
  110229. */
  110230. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110231. /**
  110232. * Are diffuse textures enabled in the application.
  110233. */
  110234. static get DiffuseTextureEnabled(): boolean;
  110235. static set DiffuseTextureEnabled(value: boolean);
  110236. /**
  110237. * Are detail textures enabled in the application.
  110238. */
  110239. static get DetailTextureEnabled(): boolean;
  110240. static set DetailTextureEnabled(value: boolean);
  110241. /**
  110242. * Are ambient textures enabled in the application.
  110243. */
  110244. static get AmbientTextureEnabled(): boolean;
  110245. static set AmbientTextureEnabled(value: boolean);
  110246. /**
  110247. * Are opacity textures enabled in the application.
  110248. */
  110249. static get OpacityTextureEnabled(): boolean;
  110250. static set OpacityTextureEnabled(value: boolean);
  110251. /**
  110252. * Are reflection textures enabled in the application.
  110253. */
  110254. static get ReflectionTextureEnabled(): boolean;
  110255. static set ReflectionTextureEnabled(value: boolean);
  110256. /**
  110257. * Are emissive textures enabled in the application.
  110258. */
  110259. static get EmissiveTextureEnabled(): boolean;
  110260. static set EmissiveTextureEnabled(value: boolean);
  110261. /**
  110262. * Are specular textures enabled in the application.
  110263. */
  110264. static get SpecularTextureEnabled(): boolean;
  110265. static set SpecularTextureEnabled(value: boolean);
  110266. /**
  110267. * Are bump textures enabled in the application.
  110268. */
  110269. static get BumpTextureEnabled(): boolean;
  110270. static set BumpTextureEnabled(value: boolean);
  110271. /**
  110272. * Are lightmap textures enabled in the application.
  110273. */
  110274. static get LightmapTextureEnabled(): boolean;
  110275. static set LightmapTextureEnabled(value: boolean);
  110276. /**
  110277. * Are refraction textures enabled in the application.
  110278. */
  110279. static get RefractionTextureEnabled(): boolean;
  110280. static set RefractionTextureEnabled(value: boolean);
  110281. /**
  110282. * Are color grading textures enabled in the application.
  110283. */
  110284. static get ColorGradingTextureEnabled(): boolean;
  110285. static set ColorGradingTextureEnabled(value: boolean);
  110286. /**
  110287. * Are fresnels enabled in the application.
  110288. */
  110289. static get FresnelEnabled(): boolean;
  110290. static set FresnelEnabled(value: boolean);
  110291. }
  110292. }
  110293. declare module BABYLON {
  110294. /**
  110295. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110296. *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.
  110297. * The SPS is also a particle system. It provides some methods to manage the particles.
  110298. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110299. *
  110300. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  110301. */
  110302. export class SolidParticleSystem implements IDisposable {
  110303. /**
  110304. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110305. * Example : var p = SPS.particles[i];
  110306. */
  110307. particles: SolidParticle[];
  110308. /**
  110309. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110310. */
  110311. nbParticles: number;
  110312. /**
  110313. * If the particles must ever face the camera (default false). Useful for planar particles.
  110314. */
  110315. billboard: boolean;
  110316. /**
  110317. * Recompute normals when adding a shape
  110318. */
  110319. recomputeNormals: boolean;
  110320. /**
  110321. * This a counter ofr your own usage. It's not set by any SPS functions.
  110322. */
  110323. counter: number;
  110324. /**
  110325. * The SPS name. This name is also given to the underlying mesh.
  110326. */
  110327. name: string;
  110328. /**
  110329. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110330. */
  110331. mesh: Mesh;
  110332. /**
  110333. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110334. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110335. */
  110336. vars: any;
  110337. /**
  110338. * This array is populated when the SPS is set as 'pickable'.
  110339. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110340. * Each element of this array is an object `{idx: int, faceId: int}`.
  110341. * `idx` is the picked particle index in the `SPS.particles` array
  110342. * `faceId` is the picked face index counted within this particle.
  110343. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110344. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110345. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110346. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110347. */
  110348. pickedParticles: {
  110349. idx: number;
  110350. faceId: number;
  110351. }[];
  110352. /**
  110353. * This array is populated when the SPS is set as 'pickable'
  110354. * Each key of this array is a submesh index.
  110355. * Each element of this array is a second array defined like this :
  110356. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110357. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110358. * `idx` is the picked particle index in the `SPS.particles` array
  110359. * `faceId` is the picked face index counted within this particle.
  110360. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  110361. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110362. */
  110363. pickedBySubMesh: {
  110364. idx: number;
  110365. faceId: number;
  110366. }[][];
  110367. /**
  110368. * This array is populated when `enableDepthSort` is set to true.
  110369. * Each element of this array is an instance of the class DepthSortedParticle.
  110370. */
  110371. depthSortedParticles: DepthSortedParticle[];
  110372. /**
  110373. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110374. * @hidden
  110375. */
  110376. _bSphereOnly: boolean;
  110377. /**
  110378. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110379. * @hidden
  110380. */
  110381. _bSphereRadiusFactor: number;
  110382. private _scene;
  110383. private _positions;
  110384. private _indices;
  110385. private _normals;
  110386. private _colors;
  110387. private _uvs;
  110388. private _indices32;
  110389. private _positions32;
  110390. private _normals32;
  110391. private _fixedNormal32;
  110392. private _colors32;
  110393. private _uvs32;
  110394. private _index;
  110395. private _updatable;
  110396. private _pickable;
  110397. private _isVisibilityBoxLocked;
  110398. private _alwaysVisible;
  110399. private _depthSort;
  110400. private _expandable;
  110401. private _shapeCounter;
  110402. private _copy;
  110403. private _color;
  110404. private _computeParticleColor;
  110405. private _computeParticleTexture;
  110406. private _computeParticleRotation;
  110407. private _computeParticleVertex;
  110408. private _computeBoundingBox;
  110409. private _depthSortParticles;
  110410. private _camera;
  110411. private _mustUnrotateFixedNormals;
  110412. private _particlesIntersect;
  110413. private _needs32Bits;
  110414. private _isNotBuilt;
  110415. private _lastParticleId;
  110416. private _idxOfId;
  110417. private _multimaterialEnabled;
  110418. private _useModelMaterial;
  110419. private _indicesByMaterial;
  110420. private _materialIndexes;
  110421. private _depthSortFunction;
  110422. private _materialSortFunction;
  110423. private _materials;
  110424. private _multimaterial;
  110425. private _materialIndexesById;
  110426. private _defaultMaterial;
  110427. private _autoUpdateSubMeshes;
  110428. private _tmpVertex;
  110429. /**
  110430. * Creates a SPS (Solid Particle System) object.
  110431. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110432. * @param scene (Scene) is the scene in which the SPS is added.
  110433. * @param options defines the options of the sps e.g.
  110434. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110435. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110436. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110437. * * 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.
  110438. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110439. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110440. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110441. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110442. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110443. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110444. */
  110445. constructor(name: string, scene: Scene, options?: {
  110446. updatable?: boolean;
  110447. isPickable?: boolean;
  110448. enableDepthSort?: boolean;
  110449. particleIntersection?: boolean;
  110450. boundingSphereOnly?: boolean;
  110451. bSphereRadiusFactor?: number;
  110452. expandable?: boolean;
  110453. useModelMaterial?: boolean;
  110454. enableMultiMaterial?: boolean;
  110455. });
  110456. /**
  110457. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110458. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110459. * @returns the created mesh
  110460. */
  110461. buildMesh(): Mesh;
  110462. /**
  110463. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110464. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110465. * Thus the particles generated from `digest()` have their property `position` set yet.
  110466. * @param mesh ( Mesh ) is the mesh to be digested
  110467. * @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
  110468. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110469. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110470. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110471. * @returns the current SPS
  110472. */
  110473. digest(mesh: Mesh, options?: {
  110474. facetNb?: number;
  110475. number?: number;
  110476. delta?: number;
  110477. storage?: [];
  110478. }): SolidParticleSystem;
  110479. /**
  110480. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110481. * @hidden
  110482. */
  110483. private _unrotateFixedNormals;
  110484. /**
  110485. * Resets the temporary working copy particle
  110486. * @hidden
  110487. */
  110488. private _resetCopy;
  110489. /**
  110490. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  110491. * @param p the current index in the positions array to be updated
  110492. * @param ind the current index in the indices array
  110493. * @param shape a Vector3 array, the shape geometry
  110494. * @param positions the positions array to be updated
  110495. * @param meshInd the shape indices array
  110496. * @param indices the indices array to be updated
  110497. * @param meshUV the shape uv array
  110498. * @param uvs the uv array to be updated
  110499. * @param meshCol the shape color array
  110500. * @param colors the color array to be updated
  110501. * @param meshNor the shape normals array
  110502. * @param normals the normals array to be updated
  110503. * @param idx the particle index
  110504. * @param idxInShape the particle index in its shape
  110505. * @param options the addShape() method passed options
  110506. * @model the particle model
  110507. * @hidden
  110508. */
  110509. private _meshBuilder;
  110510. /**
  110511. * Returns a shape Vector3 array from positions float array
  110512. * @param positions float array
  110513. * @returns a vector3 array
  110514. * @hidden
  110515. */
  110516. private _posToShape;
  110517. /**
  110518. * Returns a shapeUV array from a float uvs (array deep copy)
  110519. * @param uvs as a float array
  110520. * @returns a shapeUV array
  110521. * @hidden
  110522. */
  110523. private _uvsToShapeUV;
  110524. /**
  110525. * Adds a new particle object in the particles array
  110526. * @param idx particle index in particles array
  110527. * @param id particle id
  110528. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  110529. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  110530. * @param model particle ModelShape object
  110531. * @param shapeId model shape identifier
  110532. * @param idxInShape index of the particle in the current model
  110533. * @param bInfo model bounding info object
  110534. * @param storage target storage array, if any
  110535. * @hidden
  110536. */
  110537. private _addParticle;
  110538. /**
  110539. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110540. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  110541. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110542. * @param nb (positive integer) the number of particles to be created from this model
  110543. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110544. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110545. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110546. * @returns the number of shapes in the system
  110547. */
  110548. addShape(mesh: Mesh, nb: number, options?: {
  110549. positionFunction?: any;
  110550. vertexFunction?: any;
  110551. storage?: [];
  110552. }): number;
  110553. /**
  110554. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110555. * @hidden
  110556. */
  110557. private _rebuildParticle;
  110558. /**
  110559. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110560. * @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.
  110561. * @returns the SPS.
  110562. */
  110563. rebuildMesh(reset?: boolean): SolidParticleSystem;
  110564. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  110565. * Returns an array with the removed particles.
  110566. * 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.
  110567. * The SPS can't be empty so at least one particle needs to remain in place.
  110568. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  110569. * @param start index of the first particle to remove
  110570. * @param end index of the last particle to remove (included)
  110571. * @returns an array populated with the removed particles
  110572. */
  110573. removeParticles(start: number, end: number): SolidParticle[];
  110574. /**
  110575. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  110576. * @param solidParticleArray an array populated with Solid Particles objects
  110577. * @returns the SPS
  110578. */
  110579. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  110580. /**
  110581. * Creates a new particle and modifies the SPS mesh geometry :
  110582. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  110583. * - calls _addParticle() to populate the particle array
  110584. * factorized code from addShape() and insertParticlesFromArray()
  110585. * @param idx particle index in the particles array
  110586. * @param i particle index in its shape
  110587. * @param modelShape particle ModelShape object
  110588. * @param shape shape vertex array
  110589. * @param meshInd shape indices array
  110590. * @param meshUV shape uv array
  110591. * @param meshCol shape color array
  110592. * @param meshNor shape normals array
  110593. * @param bbInfo shape bounding info
  110594. * @param storage target particle storage
  110595. * @options addShape() passed options
  110596. * @hidden
  110597. */
  110598. private _insertNewParticle;
  110599. /**
  110600. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110601. * This method calls `updateParticle()` for each particle of the SPS.
  110602. * For an animated SPS, it is usually called within the render loop.
  110603. * 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.
  110604. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110605. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110606. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110607. * @returns the SPS.
  110608. */
  110609. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110610. /**
  110611. * Disposes the SPS.
  110612. */
  110613. dispose(): void;
  110614. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110615. * idx is the particle index in the SPS
  110616. * faceId is the picked face index counted within this particle.
  110617. * Returns null if the pickInfo can't identify a picked particle.
  110618. * @param pickingInfo (PickingInfo object)
  110619. * @returns {idx: number, faceId: number} or null
  110620. */
  110621. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110622. idx: number;
  110623. faceId: number;
  110624. }>;
  110625. /**
  110626. * Returns a SolidParticle object from its identifier : particle.id
  110627. * @param id (integer) the particle Id
  110628. * @returns the searched particle or null if not found in the SPS.
  110629. */
  110630. getParticleById(id: number): Nullable<SolidParticle>;
  110631. /**
  110632. * Returns a new array populated with the particles having the passed shapeId.
  110633. * @param shapeId (integer) the shape identifier
  110634. * @returns a new solid particle array
  110635. */
  110636. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110637. /**
  110638. * Populates the passed array "ref" with the particles having the passed shapeId.
  110639. * @param shapeId the shape identifier
  110640. * @returns the SPS
  110641. * @param ref
  110642. */
  110643. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110644. /**
  110645. * Computes the required SubMeshes according the materials assigned to the particles.
  110646. * @returns the solid particle system.
  110647. * Does nothing if called before the SPS mesh is built.
  110648. */
  110649. computeSubMeshes(): SolidParticleSystem;
  110650. /**
  110651. * Sorts the solid particles by material when MultiMaterial is enabled.
  110652. * Updates the indices32 array.
  110653. * Updates the indicesByMaterial array.
  110654. * Updates the mesh indices array.
  110655. * @returns the SPS
  110656. * @hidden
  110657. */
  110658. private _sortParticlesByMaterial;
  110659. /**
  110660. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110661. * @hidden
  110662. */
  110663. private _setMaterialIndexesById;
  110664. /**
  110665. * Returns an array with unique values of Materials from the passed array
  110666. * @param array the material array to be checked and filtered
  110667. * @hidden
  110668. */
  110669. private _filterUniqueMaterialId;
  110670. /**
  110671. * Sets a new Standard Material as _defaultMaterial if not already set.
  110672. * @hidden
  110673. */
  110674. private _setDefaultMaterial;
  110675. /**
  110676. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110677. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110678. * @returns the SPS.
  110679. */
  110680. refreshVisibleSize(): SolidParticleSystem;
  110681. /**
  110682. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110683. * @param size the size (float) of the visibility box
  110684. * note : this doesn't lock the SPS mesh bounding box.
  110685. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110686. */
  110687. setVisibilityBox(size: number): void;
  110688. /**
  110689. * Gets whether the SPS as always visible or not
  110690. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110691. */
  110692. get isAlwaysVisible(): boolean;
  110693. /**
  110694. * Sets the SPS as always visible or not
  110695. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110696. */
  110697. set isAlwaysVisible(val: boolean);
  110698. /**
  110699. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110700. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110701. */
  110702. set isVisibilityBoxLocked(val: boolean);
  110703. /**
  110704. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110705. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110706. */
  110707. get isVisibilityBoxLocked(): boolean;
  110708. /**
  110709. * Tells to `setParticles()` to compute the particle rotations or not.
  110710. * Default value : true. The SPS is faster when it's set to false.
  110711. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110712. */
  110713. set computeParticleRotation(val: boolean);
  110714. /**
  110715. * Tells to `setParticles()` to compute the particle colors or not.
  110716. * Default value : true. The SPS is faster when it's set to false.
  110717. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110718. */
  110719. set computeParticleColor(val: boolean);
  110720. set computeParticleTexture(val: boolean);
  110721. /**
  110722. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110723. * Default value : false. The SPS is faster when it's set to false.
  110724. * Note : the particle custom vertex positions aren't stored values.
  110725. */
  110726. set computeParticleVertex(val: boolean);
  110727. /**
  110728. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110729. */
  110730. set computeBoundingBox(val: boolean);
  110731. /**
  110732. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110733. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110734. * Default : `true`
  110735. */
  110736. set depthSortParticles(val: boolean);
  110737. /**
  110738. * Gets if `setParticles()` computes the particle rotations or not.
  110739. * Default value : true. The SPS is faster when it's set to false.
  110740. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110741. */
  110742. get computeParticleRotation(): boolean;
  110743. /**
  110744. * Gets if `setParticles()` computes the particle colors or not.
  110745. * Default value : true. The SPS is faster when it's set to false.
  110746. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110747. */
  110748. get computeParticleColor(): boolean;
  110749. /**
  110750. * Gets if `setParticles()` computes the particle textures or not.
  110751. * Default value : true. The SPS is faster when it's set to false.
  110752. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110753. */
  110754. get computeParticleTexture(): boolean;
  110755. /**
  110756. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110757. * Default value : false. The SPS is faster when it's set to false.
  110758. * Note : the particle custom vertex positions aren't stored values.
  110759. */
  110760. get computeParticleVertex(): boolean;
  110761. /**
  110762. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110763. */
  110764. get computeBoundingBox(): boolean;
  110765. /**
  110766. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110767. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110768. * Default : `true`
  110769. */
  110770. get depthSortParticles(): boolean;
  110771. /**
  110772. * Gets if the SPS is created as expandable at construction time.
  110773. * Default : `false`
  110774. */
  110775. get expandable(): boolean;
  110776. /**
  110777. * Gets if the SPS supports the Multi Materials
  110778. */
  110779. get multimaterialEnabled(): boolean;
  110780. /**
  110781. * Gets if the SPS uses the model materials for its own multimaterial.
  110782. */
  110783. get useModelMaterial(): boolean;
  110784. /**
  110785. * The SPS used material array.
  110786. */
  110787. get materials(): Material[];
  110788. /**
  110789. * Sets the SPS MultiMaterial from the passed materials.
  110790. * Note : the passed array is internally copied and not used then by reference.
  110791. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110792. */
  110793. setMultiMaterial(materials: Material[]): void;
  110794. /**
  110795. * The SPS computed multimaterial object
  110796. */
  110797. get multimaterial(): MultiMaterial;
  110798. set multimaterial(mm: MultiMaterial);
  110799. /**
  110800. * If the subMeshes must be updated on the next call to setParticles()
  110801. */
  110802. get autoUpdateSubMeshes(): boolean;
  110803. set autoUpdateSubMeshes(val: boolean);
  110804. /**
  110805. * This function does nothing. It may be overwritten to set all the particle first values.
  110806. * The SPS doesn't call this function, you may have to call it by your own.
  110807. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110808. */
  110809. initParticles(): void;
  110810. /**
  110811. * This function does nothing. It may be overwritten to recycle a particle.
  110812. * The SPS doesn't call this function, you may have to call it by your own.
  110813. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110814. * @param particle The particle to recycle
  110815. * @returns the recycled particle
  110816. */
  110817. recycleParticle(particle: SolidParticle): SolidParticle;
  110818. /**
  110819. * Updates a particle : this function should be overwritten by the user.
  110820. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110821. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110822. * @example : just set a particle position or velocity and recycle conditions
  110823. * @param particle The particle to update
  110824. * @returns the updated particle
  110825. */
  110826. updateParticle(particle: SolidParticle): SolidParticle;
  110827. /**
  110828. * Updates a vertex of a particle : it can be overwritten by the user.
  110829. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110830. * @param particle the current particle
  110831. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110832. * @param pt the index of the current vertex in the particle shape
  110833. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110834. * @example : just set a vertex particle position or color
  110835. * @returns the sps
  110836. */
  110837. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110838. /**
  110839. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110840. * This does nothing and may be overwritten by the user.
  110841. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110842. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110843. * @param update the boolean update value actually passed to setParticles()
  110844. */
  110845. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110846. /**
  110847. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110848. * This will be passed three parameters.
  110849. * This does nothing and may be overwritten by the user.
  110850. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110851. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110852. * @param update the boolean update value actually passed to setParticles()
  110853. */
  110854. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110855. }
  110856. }
  110857. declare module BABYLON {
  110858. /**
  110859. * Represents one particle of a solid particle system.
  110860. */
  110861. export class SolidParticle {
  110862. /**
  110863. * particle global index
  110864. */
  110865. idx: number;
  110866. /**
  110867. * particle identifier
  110868. */
  110869. id: number;
  110870. /**
  110871. * The color of the particle
  110872. */
  110873. color: Nullable<Color4>;
  110874. /**
  110875. * The world space position of the particle.
  110876. */
  110877. position: Vector3;
  110878. /**
  110879. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110880. */
  110881. rotation: Vector3;
  110882. /**
  110883. * The world space rotation quaternion of the particle.
  110884. */
  110885. rotationQuaternion: Nullable<Quaternion>;
  110886. /**
  110887. * The scaling of the particle.
  110888. */
  110889. scaling: Vector3;
  110890. /**
  110891. * The uvs of the particle.
  110892. */
  110893. uvs: Vector4;
  110894. /**
  110895. * The current speed of the particle.
  110896. */
  110897. velocity: Vector3;
  110898. /**
  110899. * The pivot point in the particle local space.
  110900. */
  110901. pivot: Vector3;
  110902. /**
  110903. * Must the particle be translated from its pivot point in its local space ?
  110904. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110905. * Default : false
  110906. */
  110907. translateFromPivot: boolean;
  110908. /**
  110909. * Is the particle active or not ?
  110910. */
  110911. alive: boolean;
  110912. /**
  110913. * Is the particle visible or not ?
  110914. */
  110915. isVisible: boolean;
  110916. /**
  110917. * Index of this particle in the global "positions" array (Internal use)
  110918. * @hidden
  110919. */
  110920. _pos: number;
  110921. /**
  110922. * @hidden Index of this particle in the global "indices" array (Internal use)
  110923. */
  110924. _ind: number;
  110925. /**
  110926. * @hidden ModelShape of this particle (Internal use)
  110927. */
  110928. _model: ModelShape;
  110929. /**
  110930. * ModelShape id of this particle
  110931. */
  110932. shapeId: number;
  110933. /**
  110934. * Index of the particle in its shape id
  110935. */
  110936. idxInShape: number;
  110937. /**
  110938. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110939. */
  110940. _modelBoundingInfo: BoundingInfo;
  110941. /**
  110942. * @hidden Particle BoundingInfo object (Internal use)
  110943. */
  110944. _boundingInfo: BoundingInfo;
  110945. /**
  110946. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110947. */
  110948. _sps: SolidParticleSystem;
  110949. /**
  110950. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110951. */
  110952. _stillInvisible: boolean;
  110953. /**
  110954. * @hidden Last computed particle rotation matrix
  110955. */
  110956. _rotationMatrix: number[];
  110957. /**
  110958. * Parent particle Id, if any.
  110959. * Default null.
  110960. */
  110961. parentId: Nullable<number>;
  110962. /**
  110963. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110964. */
  110965. materialIndex: Nullable<number>;
  110966. /**
  110967. * Custom object or properties.
  110968. */
  110969. props: Nullable<any>;
  110970. /**
  110971. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110972. * The possible values are :
  110973. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110974. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110975. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110976. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110977. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110978. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110979. * */
  110980. cullingStrategy: number;
  110981. /**
  110982. * @hidden Internal global position in the SPS.
  110983. */
  110984. _globalPosition: Vector3;
  110985. /**
  110986. * Creates a Solid Particle object.
  110987. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110988. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110989. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110990. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110991. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110992. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110993. * @param shapeId (integer) is the model shape identifier in the SPS.
  110994. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110995. * @param sps defines the sps it is associated to
  110996. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110997. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110998. */
  110999. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111000. /**
  111001. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111002. * @param target the particle target
  111003. * @returns the current particle
  111004. */
  111005. copyToRef(target: SolidParticle): SolidParticle;
  111006. /**
  111007. * Legacy support, changed scale to scaling
  111008. */
  111009. get scale(): Vector3;
  111010. /**
  111011. * Legacy support, changed scale to scaling
  111012. */
  111013. set scale(scale: Vector3);
  111014. /**
  111015. * Legacy support, changed quaternion to rotationQuaternion
  111016. */
  111017. get quaternion(): Nullable<Quaternion>;
  111018. /**
  111019. * Legacy support, changed quaternion to rotationQuaternion
  111020. */
  111021. set quaternion(q: Nullable<Quaternion>);
  111022. /**
  111023. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111024. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111025. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111026. * @returns true if it intersects
  111027. */
  111028. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111029. /**
  111030. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111031. * A particle is in the frustum if its bounding box intersects the frustum
  111032. * @param frustumPlanes defines the frustum to test
  111033. * @returns true if the particle is in the frustum planes
  111034. */
  111035. isInFrustum(frustumPlanes: Plane[]): boolean;
  111036. /**
  111037. * get the rotation matrix of the particle
  111038. * @hidden
  111039. */
  111040. getRotationMatrix(m: Matrix): void;
  111041. }
  111042. /**
  111043. * Represents the shape of the model used by one particle of a solid particle system.
  111044. * SPS internal tool, don't use it manually.
  111045. */
  111046. export class ModelShape {
  111047. /**
  111048. * The shape id
  111049. * @hidden
  111050. */
  111051. shapeID: number;
  111052. /**
  111053. * flat array of model positions (internal use)
  111054. * @hidden
  111055. */
  111056. _shape: Vector3[];
  111057. /**
  111058. * flat array of model UVs (internal use)
  111059. * @hidden
  111060. */
  111061. _shapeUV: number[];
  111062. /**
  111063. * color array of the model
  111064. * @hidden
  111065. */
  111066. _shapeColors: number[];
  111067. /**
  111068. * indices array of the model
  111069. * @hidden
  111070. */
  111071. _indices: number[];
  111072. /**
  111073. * normals array of the model
  111074. * @hidden
  111075. */
  111076. _normals: number[];
  111077. /**
  111078. * length of the shape in the model indices array (internal use)
  111079. * @hidden
  111080. */
  111081. _indicesLength: number;
  111082. /**
  111083. * Custom position function (internal use)
  111084. * @hidden
  111085. */
  111086. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111087. /**
  111088. * Custom vertex function (internal use)
  111089. * @hidden
  111090. */
  111091. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111092. /**
  111093. * Model material (internal use)
  111094. * @hidden
  111095. */
  111096. _material: Nullable<Material>;
  111097. /**
  111098. * 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.
  111099. * SPS internal tool, don't use it manually.
  111100. * @hidden
  111101. */
  111102. 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>);
  111103. }
  111104. /**
  111105. * Represents a Depth Sorted Particle in the solid particle system.
  111106. * @hidden
  111107. */
  111108. export class DepthSortedParticle {
  111109. /**
  111110. * Particle index
  111111. */
  111112. idx: number;
  111113. /**
  111114. * Index of the particle in the "indices" array
  111115. */
  111116. ind: number;
  111117. /**
  111118. * Length of the particle shape in the "indices" array
  111119. */
  111120. indicesLength: number;
  111121. /**
  111122. * Squared distance from the particle to the camera
  111123. */
  111124. sqDistance: number;
  111125. /**
  111126. * Material index when used with MultiMaterials
  111127. */
  111128. materialIndex: number;
  111129. /**
  111130. * Creates a new sorted particle
  111131. * @param materialIndex
  111132. */
  111133. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111134. }
  111135. /**
  111136. * Represents a solid particle vertex
  111137. */
  111138. export class SolidParticleVertex {
  111139. /**
  111140. * Vertex position
  111141. */
  111142. position: Vector3;
  111143. /**
  111144. * Vertex color
  111145. */
  111146. color: Color4;
  111147. /**
  111148. * Vertex UV
  111149. */
  111150. uv: Vector2;
  111151. /**
  111152. * Creates a new solid particle vertex
  111153. */
  111154. constructor();
  111155. /** Vertex x coordinate */
  111156. get x(): number;
  111157. set x(val: number);
  111158. /** Vertex y coordinate */
  111159. get y(): number;
  111160. set y(val: number);
  111161. /** Vertex z coordinate */
  111162. get z(): number;
  111163. set z(val: number);
  111164. }
  111165. }
  111166. declare module BABYLON {
  111167. /**
  111168. * @hidden
  111169. */
  111170. export class _MeshCollisionData {
  111171. _checkCollisions: boolean;
  111172. _collisionMask: number;
  111173. _collisionGroup: number;
  111174. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111175. _collider: Nullable<Collider>;
  111176. _oldPositionForCollisions: Vector3;
  111177. _diffPositionForCollisions: Vector3;
  111178. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111179. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111180. }
  111181. }
  111182. declare module BABYLON {
  111183. /** @hidden */
  111184. class _FacetDataStorage {
  111185. facetPositions: Vector3[];
  111186. facetNormals: Vector3[];
  111187. facetPartitioning: number[][];
  111188. facetNb: number;
  111189. partitioningSubdivisions: number;
  111190. partitioningBBoxRatio: number;
  111191. facetDataEnabled: boolean;
  111192. facetParameters: any;
  111193. bbSize: Vector3;
  111194. subDiv: {
  111195. max: number;
  111196. X: number;
  111197. Y: number;
  111198. Z: number;
  111199. };
  111200. facetDepthSort: boolean;
  111201. facetDepthSortEnabled: boolean;
  111202. depthSortedIndices: IndicesArray;
  111203. depthSortedFacets: {
  111204. ind: number;
  111205. sqDistance: number;
  111206. }[];
  111207. facetDepthSortFunction: (f1: {
  111208. ind: number;
  111209. sqDistance: number;
  111210. }, f2: {
  111211. ind: number;
  111212. sqDistance: number;
  111213. }) => number;
  111214. facetDepthSortFrom: Vector3;
  111215. facetDepthSortOrigin: Vector3;
  111216. invertedMatrix: Matrix;
  111217. }
  111218. /**
  111219. * @hidden
  111220. **/
  111221. class _InternalAbstractMeshDataInfo {
  111222. _hasVertexAlpha: boolean;
  111223. _useVertexColors: boolean;
  111224. _numBoneInfluencers: number;
  111225. _applyFog: boolean;
  111226. _receiveShadows: boolean;
  111227. _facetData: _FacetDataStorage;
  111228. _visibility: number;
  111229. _skeleton: Nullable<Skeleton>;
  111230. _layerMask: number;
  111231. _computeBonesUsingShaders: boolean;
  111232. _isActive: boolean;
  111233. _onlyForInstances: boolean;
  111234. _isActiveIntermediate: boolean;
  111235. _onlyForInstancesIntermediate: boolean;
  111236. _actAsRegularMesh: boolean;
  111237. }
  111238. /**
  111239. * Class used to store all common mesh properties
  111240. */
  111241. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  111242. /** No occlusion */
  111243. static OCCLUSION_TYPE_NONE: number;
  111244. /** Occlusion set to optimisitic */
  111245. static OCCLUSION_TYPE_OPTIMISTIC: number;
  111246. /** Occlusion set to strict */
  111247. static OCCLUSION_TYPE_STRICT: number;
  111248. /** Use an accurante occlusion algorithm */
  111249. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  111250. /** Use a conservative occlusion algorithm */
  111251. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  111252. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  111253. * Test order :
  111254. * Is the bounding sphere outside the frustum ?
  111255. * If not, are the bounding box vertices outside the frustum ?
  111256. * It not, then the cullable object is in the frustum.
  111257. */
  111258. static readonly CULLINGSTRATEGY_STANDARD: number;
  111259. /** Culling strategy : Bounding Sphere Only.
  111260. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  111261. * It's also less accurate than the standard because some not visible objects can still be selected.
  111262. * Test : is the bounding sphere outside the frustum ?
  111263. * If not, then the cullable object is in the frustum.
  111264. */
  111265. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  111266. /** Culling strategy : Optimistic Inclusion.
  111267. * This in an inclusion test first, then the standard exclusion test.
  111268. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  111269. * 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.
  111270. * Anyway, it's as accurate as the standard strategy.
  111271. * Test :
  111272. * Is the cullable object bounding sphere center in the frustum ?
  111273. * If not, apply the default culling strategy.
  111274. */
  111275. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  111276. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  111277. * This in an inclusion test first, then the bounding sphere only exclusion test.
  111278. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  111279. * 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.
  111280. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  111281. * Test :
  111282. * Is the cullable object bounding sphere center in the frustum ?
  111283. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  111284. */
  111285. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  111286. /**
  111287. * No billboard
  111288. */
  111289. static get BILLBOARDMODE_NONE(): number;
  111290. /** Billboard on X axis */
  111291. static get BILLBOARDMODE_X(): number;
  111292. /** Billboard on Y axis */
  111293. static get BILLBOARDMODE_Y(): number;
  111294. /** Billboard on Z axis */
  111295. static get BILLBOARDMODE_Z(): number;
  111296. /** Billboard on all axes */
  111297. static get BILLBOARDMODE_ALL(): number;
  111298. /** Billboard on using position instead of orientation */
  111299. static get BILLBOARDMODE_USE_POSITION(): number;
  111300. /** @hidden */
  111301. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  111302. /**
  111303. * The culling strategy to use to check whether the mesh must be rendered or not.
  111304. * This value can be changed at any time and will be used on the next render mesh selection.
  111305. * The possible values are :
  111306. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111307. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111310. * Please read each static variable documentation to get details about the culling process.
  111311. * */
  111312. cullingStrategy: number;
  111313. /**
  111314. * Gets the number of facets in the mesh
  111315. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111316. */
  111317. get facetNb(): number;
  111318. /**
  111319. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  111320. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111321. */
  111322. get partitioningSubdivisions(): number;
  111323. set partitioningSubdivisions(nb: number);
  111324. /**
  111325. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111326. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111327. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111328. */
  111329. get partitioningBBoxRatio(): number;
  111330. set partitioningBBoxRatio(ratio: number);
  111331. /**
  111332. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111333. * Works only for updatable meshes.
  111334. * Doesn't work with multi-materials
  111335. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111336. */
  111337. get mustDepthSortFacets(): boolean;
  111338. set mustDepthSortFacets(sort: boolean);
  111339. /**
  111340. * The location (Vector3) where the facet depth sort must be computed from.
  111341. * By default, the active camera position.
  111342. * Used only when facet depth sort is enabled
  111343. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111344. */
  111345. get facetDepthSortFrom(): Vector3;
  111346. set facetDepthSortFrom(location: Vector3);
  111347. /**
  111348. * gets a boolean indicating if facetData is enabled
  111349. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111350. */
  111351. get isFacetDataEnabled(): boolean;
  111352. /** @hidden */
  111353. _updateNonUniformScalingState(value: boolean): boolean;
  111354. /**
  111355. * An event triggered when this mesh collides with another one
  111356. */
  111357. onCollideObservable: Observable<AbstractMesh>;
  111358. /** Set a function to call when this mesh collides with another one */
  111359. set onCollide(callback: () => void);
  111360. /**
  111361. * An event triggered when the collision's position changes
  111362. */
  111363. onCollisionPositionChangeObservable: Observable<Vector3>;
  111364. /** Set a function to call when the collision's position changes */
  111365. set onCollisionPositionChange(callback: () => void);
  111366. /**
  111367. * An event triggered when material is changed
  111368. */
  111369. onMaterialChangedObservable: Observable<AbstractMesh>;
  111370. /**
  111371. * Gets or sets the orientation for POV movement & rotation
  111372. */
  111373. definedFacingForward: boolean;
  111374. /** @hidden */
  111375. _occlusionQuery: Nullable<WebGLQuery>;
  111376. /** @hidden */
  111377. _renderingGroup: Nullable<RenderingGroup>;
  111378. /**
  111379. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111380. */
  111381. get visibility(): number;
  111382. /**
  111383. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111384. */
  111385. set visibility(value: number);
  111386. /** Gets or sets the alpha index used to sort transparent meshes
  111387. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  111388. */
  111389. alphaIndex: number;
  111390. /**
  111391. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111392. */
  111393. isVisible: boolean;
  111394. /**
  111395. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111396. */
  111397. isPickable: boolean;
  111398. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111399. showSubMeshesBoundingBox: boolean;
  111400. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111401. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111402. */
  111403. isBlocker: boolean;
  111404. /**
  111405. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111406. */
  111407. enablePointerMoveEvents: boolean;
  111408. /**
  111409. * Specifies the rendering group id for this mesh (0 by default)
  111410. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111411. */
  111412. renderingGroupId: number;
  111413. private _material;
  111414. /** Gets or sets current material */
  111415. get material(): Nullable<Material>;
  111416. set material(value: Nullable<Material>);
  111417. /**
  111418. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111419. * @see https://doc.babylonjs.com/babylon101/shadows
  111420. */
  111421. get receiveShadows(): boolean;
  111422. set receiveShadows(value: boolean);
  111423. /** Defines color to use when rendering outline */
  111424. outlineColor: Color3;
  111425. /** Define width to use when rendering outline */
  111426. outlineWidth: number;
  111427. /** Defines color to use when rendering overlay */
  111428. overlayColor: Color3;
  111429. /** Defines alpha to use when rendering overlay */
  111430. overlayAlpha: number;
  111431. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111432. get hasVertexAlpha(): boolean;
  111433. set hasVertexAlpha(value: boolean);
  111434. /** 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) */
  111435. get useVertexColors(): boolean;
  111436. set useVertexColors(value: boolean);
  111437. /**
  111438. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111439. */
  111440. get computeBonesUsingShaders(): boolean;
  111441. set computeBonesUsingShaders(value: boolean);
  111442. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111443. get numBoneInfluencers(): number;
  111444. set numBoneInfluencers(value: number);
  111445. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111446. get applyFog(): boolean;
  111447. set applyFog(value: boolean);
  111448. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111449. useOctreeForRenderingSelection: boolean;
  111450. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111451. useOctreeForPicking: boolean;
  111452. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111453. useOctreeForCollisions: boolean;
  111454. /**
  111455. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111456. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111457. */
  111458. get layerMask(): number;
  111459. set layerMask(value: number);
  111460. /**
  111461. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111462. */
  111463. alwaysSelectAsActiveMesh: boolean;
  111464. /**
  111465. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111466. */
  111467. doNotSyncBoundingInfo: boolean;
  111468. /**
  111469. * Gets or sets the current action manager
  111470. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111471. */
  111472. actionManager: Nullable<AbstractActionManager>;
  111473. private _meshCollisionData;
  111474. /**
  111475. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111476. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111477. */
  111478. ellipsoid: Vector3;
  111479. /**
  111480. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  111481. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111482. */
  111483. ellipsoidOffset: Vector3;
  111484. /**
  111485. * Gets or sets a collision mask used to mask collisions (default is -1).
  111486. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111487. */
  111488. get collisionMask(): number;
  111489. set collisionMask(mask: number);
  111490. /**
  111491. * Gets or sets the current collision group mask (-1 by default).
  111492. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111493. */
  111494. get collisionGroup(): number;
  111495. set collisionGroup(mask: number);
  111496. /**
  111497. * Gets or sets current surrounding meshes (null by default).
  111498. *
  111499. * By default collision detection is tested against every mesh in the scene.
  111500. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  111501. * meshes will be tested for the collision.
  111502. *
  111503. * Note: if set to an empty array no collision will happen when this mesh is moved.
  111504. */
  111505. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  111506. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  111507. /**
  111508. * Defines edge width used when edgesRenderer is enabled
  111509. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111510. */
  111511. edgesWidth: number;
  111512. /**
  111513. * Defines edge color used when edgesRenderer is enabled
  111514. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111515. */
  111516. edgesColor: Color4;
  111517. /** @hidden */
  111518. _edgesRenderer: Nullable<IEdgesRenderer>;
  111519. /** @hidden */
  111520. _masterMesh: Nullable<AbstractMesh>;
  111521. /** @hidden */
  111522. _boundingInfo: Nullable<BoundingInfo>;
  111523. /** @hidden */
  111524. _renderId: number;
  111525. /**
  111526. * Gets or sets the list of subMeshes
  111527. * @see https://doc.babylonjs.com/how_to/multi_materials
  111528. */
  111529. subMeshes: SubMesh[];
  111530. /** @hidden */
  111531. _intersectionsInProgress: AbstractMesh[];
  111532. /** @hidden */
  111533. _unIndexed: boolean;
  111534. /** @hidden */
  111535. _lightSources: Light[];
  111536. /** Gets the list of lights affecting that mesh */
  111537. get lightSources(): Light[];
  111538. /** @hidden */
  111539. get _positions(): Nullable<Vector3[]>;
  111540. /** @hidden */
  111541. _waitingData: {
  111542. lods: Nullable<any>;
  111543. actions: Nullable<any>;
  111544. freezeWorldMatrix: Nullable<boolean>;
  111545. };
  111546. /** @hidden */
  111547. _bonesTransformMatrices: Nullable<Float32Array>;
  111548. /** @hidden */
  111549. _transformMatrixTexture: Nullable<RawTexture>;
  111550. /**
  111551. * Gets or sets a skeleton to apply skining transformations
  111552. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111553. */
  111554. set skeleton(value: Nullable<Skeleton>);
  111555. get skeleton(): Nullable<Skeleton>;
  111556. /**
  111557. * An event triggered when the mesh is rebuilt.
  111558. */
  111559. onRebuildObservable: Observable<AbstractMesh>;
  111560. /**
  111561. * Creates a new AbstractMesh
  111562. * @param name defines the name of the mesh
  111563. * @param scene defines the hosting scene
  111564. */
  111565. constructor(name: string, scene?: Nullable<Scene>);
  111566. /**
  111567. * Returns the string "AbstractMesh"
  111568. * @returns "AbstractMesh"
  111569. */
  111570. getClassName(): string;
  111571. /**
  111572. * Gets a string representation of the current mesh
  111573. * @param fullDetails defines a boolean indicating if full details must be included
  111574. * @returns a string representation of the current mesh
  111575. */
  111576. toString(fullDetails?: boolean): string;
  111577. /**
  111578. * @hidden
  111579. */
  111580. protected _getEffectiveParent(): Nullable<Node>;
  111581. /** @hidden */
  111582. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111583. /** @hidden */
  111584. _rebuild(): void;
  111585. /** @hidden */
  111586. _resyncLightSources(): void;
  111587. /** @hidden */
  111588. _resyncLightSource(light: Light): void;
  111589. /** @hidden */
  111590. _unBindEffect(): void;
  111591. /** @hidden */
  111592. _removeLightSource(light: Light, dispose: boolean): void;
  111593. private _markSubMeshesAsDirty;
  111594. /** @hidden */
  111595. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111596. /** @hidden */
  111597. _markSubMeshesAsAttributesDirty(): void;
  111598. /** @hidden */
  111599. _markSubMeshesAsMiscDirty(): void;
  111600. /**
  111601. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111602. */
  111603. get scaling(): Vector3;
  111604. set scaling(newScaling: Vector3);
  111605. /**
  111606. * Returns true if the mesh is blocked. Implemented by child classes
  111607. */
  111608. get isBlocked(): boolean;
  111609. /**
  111610. * Returns the mesh itself by default. Implemented by child classes
  111611. * @param camera defines the camera to use to pick the right LOD level
  111612. * @returns the currentAbstractMesh
  111613. */
  111614. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111615. /**
  111616. * Returns 0 by default. Implemented by child classes
  111617. * @returns an integer
  111618. */
  111619. getTotalVertices(): number;
  111620. /**
  111621. * Returns a positive integer : the total number of indices in this mesh geometry.
  111622. * @returns the numner of indices or zero if the mesh has no geometry.
  111623. */
  111624. getTotalIndices(): number;
  111625. /**
  111626. * Returns null by default. Implemented by child classes
  111627. * @returns null
  111628. */
  111629. getIndices(): Nullable<IndicesArray>;
  111630. /**
  111631. * Returns the array of the requested vertex data kind. Implemented by child classes
  111632. * @param kind defines the vertex data kind to use
  111633. * @returns null
  111634. */
  111635. getVerticesData(kind: string): Nullable<FloatArray>;
  111636. /**
  111637. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111638. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111639. * Note that a new underlying VertexBuffer object is created each call.
  111640. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111641. * @param kind defines vertex data kind:
  111642. * * VertexBuffer.PositionKind
  111643. * * VertexBuffer.UVKind
  111644. * * VertexBuffer.UV2Kind
  111645. * * VertexBuffer.UV3Kind
  111646. * * VertexBuffer.UV4Kind
  111647. * * VertexBuffer.UV5Kind
  111648. * * VertexBuffer.UV6Kind
  111649. * * VertexBuffer.ColorKind
  111650. * * VertexBuffer.MatricesIndicesKind
  111651. * * VertexBuffer.MatricesIndicesExtraKind
  111652. * * VertexBuffer.MatricesWeightsKind
  111653. * * VertexBuffer.MatricesWeightsExtraKind
  111654. * @param data defines the data source
  111655. * @param updatable defines if the data must be flagged as updatable (or static)
  111656. * @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
  111657. * @returns the current mesh
  111658. */
  111659. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111660. /**
  111661. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111662. * If the mesh has no geometry, it is simply returned as it is.
  111663. * @param kind defines vertex data kind:
  111664. * * VertexBuffer.PositionKind
  111665. * * VertexBuffer.UVKind
  111666. * * VertexBuffer.UV2Kind
  111667. * * VertexBuffer.UV3Kind
  111668. * * VertexBuffer.UV4Kind
  111669. * * VertexBuffer.UV5Kind
  111670. * * VertexBuffer.UV6Kind
  111671. * * VertexBuffer.ColorKind
  111672. * * VertexBuffer.MatricesIndicesKind
  111673. * * VertexBuffer.MatricesIndicesExtraKind
  111674. * * VertexBuffer.MatricesWeightsKind
  111675. * * VertexBuffer.MatricesWeightsExtraKind
  111676. * @param data defines the data source
  111677. * @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
  111678. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111679. * @returns the current mesh
  111680. */
  111681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111682. /**
  111683. * Sets the mesh indices,
  111684. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111685. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111686. * @param totalVertices Defines the total number of vertices
  111687. * @returns the current mesh
  111688. */
  111689. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111690. /**
  111691. * Gets a boolean indicating if specific vertex data is present
  111692. * @param kind defines the vertex data kind to use
  111693. * @returns true is data kind is present
  111694. */
  111695. isVerticesDataPresent(kind: string): boolean;
  111696. /**
  111697. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111698. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111699. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111700. * @returns a BoundingInfo
  111701. */
  111702. getBoundingInfo(): BoundingInfo;
  111703. /**
  111704. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111705. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111706. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111707. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111708. * @returns the current mesh
  111709. */
  111710. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111711. /**
  111712. * Overwrite the current bounding info
  111713. * @param boundingInfo defines the new bounding info
  111714. * @returns the current mesh
  111715. */
  111716. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111717. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111718. get useBones(): boolean;
  111719. /** @hidden */
  111720. _preActivate(): void;
  111721. /** @hidden */
  111722. _preActivateForIntermediateRendering(renderId: number): void;
  111723. /** @hidden */
  111724. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111725. /** @hidden */
  111726. _postActivate(): void;
  111727. /** @hidden */
  111728. _freeze(): void;
  111729. /** @hidden */
  111730. _unFreeze(): void;
  111731. /**
  111732. * Gets the current world matrix
  111733. * @returns a Matrix
  111734. */
  111735. getWorldMatrix(): Matrix;
  111736. /** @hidden */
  111737. _getWorldMatrixDeterminant(): number;
  111738. /**
  111739. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111740. */
  111741. get isAnInstance(): boolean;
  111742. /**
  111743. * Gets a boolean indicating if this mesh has instances
  111744. */
  111745. get hasInstances(): boolean;
  111746. /**
  111747. * Gets a boolean indicating if this mesh has thin instances
  111748. */
  111749. get hasThinInstances(): boolean;
  111750. /**
  111751. * Perform relative position change from the point of view of behind the front of the mesh.
  111752. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111753. * Supports definition of mesh facing forward or backward
  111754. * @param amountRight defines the distance on the right axis
  111755. * @param amountUp defines the distance on the up axis
  111756. * @param amountForward defines the distance on the forward axis
  111757. * @returns the current mesh
  111758. */
  111759. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111760. /**
  111761. * Calculate relative position change from the point of view of behind the front of the mesh.
  111762. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111763. * Supports definition of mesh facing forward or backward
  111764. * @param amountRight defines the distance on the right axis
  111765. * @param amountUp defines the distance on the up axis
  111766. * @param amountForward defines the distance on the forward axis
  111767. * @returns the new displacement vector
  111768. */
  111769. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111770. /**
  111771. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111772. * Supports definition of mesh facing forward or backward
  111773. * @param flipBack defines the flip
  111774. * @param twirlClockwise defines the twirl
  111775. * @param tiltRight defines the tilt
  111776. * @returns the current mesh
  111777. */
  111778. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111779. /**
  111780. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111781. * Supports definition of mesh facing forward or backward.
  111782. * @param flipBack defines the flip
  111783. * @param twirlClockwise defines the twirl
  111784. * @param tiltRight defines the tilt
  111785. * @returns the new rotation vector
  111786. */
  111787. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111788. /**
  111789. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111790. * This means the mesh underlying bounding box and sphere are recomputed.
  111791. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111792. * @returns the current mesh
  111793. */
  111794. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111795. /** @hidden */
  111796. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111797. /** @hidden */
  111798. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111799. /** @hidden */
  111800. _updateBoundingInfo(): AbstractMesh;
  111801. /** @hidden */
  111802. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111803. /** @hidden */
  111804. protected _afterComputeWorldMatrix(): void;
  111805. /** @hidden */
  111806. get _effectiveMesh(): AbstractMesh;
  111807. /**
  111808. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111809. * A mesh is in the frustum if its bounding box intersects the frustum
  111810. * @param frustumPlanes defines the frustum to test
  111811. * @returns true if the mesh is in the frustum planes
  111812. */
  111813. isInFrustum(frustumPlanes: Plane[]): boolean;
  111814. /**
  111815. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111816. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111817. * @param frustumPlanes defines the frustum to test
  111818. * @returns true if the mesh is completely in the frustum planes
  111819. */
  111820. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111821. /**
  111822. * True if the mesh intersects another mesh or a SolidParticle object
  111823. * @param mesh defines a target mesh or SolidParticle to test
  111824. * @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)
  111825. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111826. * @returns true if there is an intersection
  111827. */
  111828. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111829. /**
  111830. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111831. * @param point defines the point to test
  111832. * @returns true if there is an intersection
  111833. */
  111834. intersectsPoint(point: Vector3): boolean;
  111835. /**
  111836. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111838. */
  111839. get checkCollisions(): boolean;
  111840. set checkCollisions(collisionEnabled: boolean);
  111841. /**
  111842. * Gets Collider object used to compute collisions (not physics)
  111843. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111844. */
  111845. get collider(): Nullable<Collider>;
  111846. /**
  111847. * Move the mesh using collision engine
  111848. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111849. * @param displacement defines the requested displacement vector
  111850. * @returns the current mesh
  111851. */
  111852. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111853. private _onCollisionPositionChange;
  111854. /** @hidden */
  111855. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111856. /** @hidden */
  111857. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111858. /** @hidden */
  111859. _checkCollision(collider: Collider): AbstractMesh;
  111860. /** @hidden */
  111861. _generatePointsArray(): boolean;
  111862. /**
  111863. * Checks if the passed Ray intersects with the mesh
  111864. * @param ray defines the ray to use
  111865. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111866. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111867. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111868. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  111869. * @returns the picking info
  111870. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111871. */
  111872. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  111873. /**
  111874. * Clones the current mesh
  111875. * @param name defines the mesh name
  111876. * @param newParent defines the new mesh parent
  111877. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111878. * @returns the new mesh
  111879. */
  111880. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111881. /**
  111882. * Disposes all the submeshes of the current meshnp
  111883. * @returns the current mesh
  111884. */
  111885. releaseSubMeshes(): AbstractMesh;
  111886. /**
  111887. * Releases resources associated with this abstract mesh.
  111888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111890. */
  111891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111892. /**
  111893. * Adds the passed mesh as a child to the current mesh
  111894. * @param mesh defines the child mesh
  111895. * @returns the current mesh
  111896. */
  111897. addChild(mesh: AbstractMesh): AbstractMesh;
  111898. /**
  111899. * Removes the passed mesh from the current mesh children list
  111900. * @param mesh defines the child mesh
  111901. * @returns the current mesh
  111902. */
  111903. removeChild(mesh: AbstractMesh): AbstractMesh;
  111904. /** @hidden */
  111905. private _initFacetData;
  111906. /**
  111907. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111908. * This method can be called within the render loop.
  111909. * 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
  111910. * @returns the current mesh
  111911. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111912. */
  111913. updateFacetData(): AbstractMesh;
  111914. /**
  111915. * Returns the facetLocalNormals array.
  111916. * The normals are expressed in the mesh local spac
  111917. * @returns an array of Vector3
  111918. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111919. */
  111920. getFacetLocalNormals(): Vector3[];
  111921. /**
  111922. * Returns the facetLocalPositions array.
  111923. * The facet positions are expressed in the mesh local space
  111924. * @returns an array of Vector3
  111925. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111926. */
  111927. getFacetLocalPositions(): Vector3[];
  111928. /**
  111929. * Returns the facetLocalPartioning array
  111930. * @returns an array of array of numbers
  111931. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111932. */
  111933. getFacetLocalPartitioning(): number[][];
  111934. /**
  111935. * Returns the i-th facet position in the world system.
  111936. * This method allocates a new Vector3 per call
  111937. * @param i defines the facet index
  111938. * @returns a new Vector3
  111939. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111940. */
  111941. getFacetPosition(i: number): Vector3;
  111942. /**
  111943. * Sets the reference Vector3 with the i-th facet position in the world system
  111944. * @param i defines the facet index
  111945. * @param ref defines the target vector
  111946. * @returns the current mesh
  111947. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111948. */
  111949. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111950. /**
  111951. * Returns the i-th facet normal in the world system.
  111952. * This method allocates a new Vector3 per call
  111953. * @param i defines the facet index
  111954. * @returns a new Vector3
  111955. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111956. */
  111957. getFacetNormal(i: number): Vector3;
  111958. /**
  111959. * Sets the reference Vector3 with the i-th facet normal in the world system
  111960. * @param i defines the facet index
  111961. * @param ref defines the target vector
  111962. * @returns the current mesh
  111963. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111964. */
  111965. getFacetNormalToRef(i: number, ref: Vector3): this;
  111966. /**
  111967. * 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)
  111968. * @param x defines x coordinate
  111969. * @param y defines y coordinate
  111970. * @param z defines z coordinate
  111971. * @returns the array of facet indexes
  111972. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111973. */
  111974. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111975. /**
  111976. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111977. * @param projected sets as the (x,y,z) world projection on the facet
  111978. * @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
  111979. * @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
  111980. * @param x defines x coordinate
  111981. * @param y defines y coordinate
  111982. * @param z defines z coordinate
  111983. * @returns the face index if found (or null instead)
  111984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111985. */
  111986. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111987. /**
  111988. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111989. * @param projected sets as the (x,y,z) local projection on the facet
  111990. * @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
  111991. * @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
  111992. * @param x defines x coordinate
  111993. * @param y defines y coordinate
  111994. * @param z defines z coordinate
  111995. * @returns the face index if found (or null instead)
  111996. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111997. */
  111998. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111999. /**
  112000. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112001. * @returns the parameters
  112002. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112003. */
  112004. getFacetDataParameters(): any;
  112005. /**
  112006. * Disables the feature FacetData and frees the related memory
  112007. * @returns the current mesh
  112008. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112009. */
  112010. disableFacetData(): AbstractMesh;
  112011. /**
  112012. * Updates the AbstractMesh indices array
  112013. * @param indices defines the data source
  112014. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112015. * @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)
  112016. * @returns the current mesh
  112017. */
  112018. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112019. /**
  112020. * Creates new normals data for the mesh
  112021. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112022. * @returns the current mesh
  112023. */
  112024. createNormals(updatable: boolean): AbstractMesh;
  112025. /**
  112026. * Align the mesh with a normal
  112027. * @param normal defines the normal to use
  112028. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112029. * @returns the current mesh
  112030. */
  112031. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112032. /** @hidden */
  112033. _checkOcclusionQuery(): boolean;
  112034. /**
  112035. * Disables the mesh edge rendering mode
  112036. * @returns the currentAbstractMesh
  112037. */
  112038. disableEdgesRendering(): AbstractMesh;
  112039. /**
  112040. * Enables the edge rendering mode on the mesh.
  112041. * This mode makes the mesh edges visible
  112042. * @param epsilon defines the maximal distance between two angles to detect a face
  112043. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112044. * @returns the currentAbstractMesh
  112045. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112046. */
  112047. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112048. /**
  112049. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112050. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112051. */
  112052. getConnectedParticleSystems(): IParticleSystem[];
  112053. }
  112054. }
  112055. declare module BABYLON {
  112056. /**
  112057. * Interface used to define ActionEvent
  112058. */
  112059. export interface IActionEvent {
  112060. /** The mesh or sprite that triggered the action */
  112061. source: any;
  112062. /** The X mouse cursor position at the time of the event */
  112063. pointerX: number;
  112064. /** The Y mouse cursor position at the time of the event */
  112065. pointerY: number;
  112066. /** The mesh that is currently pointed at (can be null) */
  112067. meshUnderPointer: Nullable<AbstractMesh>;
  112068. /** the original (browser) event that triggered the ActionEvent */
  112069. sourceEvent?: any;
  112070. /** additional data for the event */
  112071. additionalData?: any;
  112072. }
  112073. /**
  112074. * ActionEvent is the event being sent when an action is triggered.
  112075. */
  112076. export class ActionEvent implements IActionEvent {
  112077. /** The mesh or sprite that triggered the action */
  112078. source: any;
  112079. /** The X mouse cursor position at the time of the event */
  112080. pointerX: number;
  112081. /** The Y mouse cursor position at the time of the event */
  112082. pointerY: number;
  112083. /** The mesh that is currently pointed at (can be null) */
  112084. meshUnderPointer: Nullable<AbstractMesh>;
  112085. /** the original (browser) event that triggered the ActionEvent */
  112086. sourceEvent?: any;
  112087. /** additional data for the event */
  112088. additionalData?: any;
  112089. /**
  112090. * Creates a new ActionEvent
  112091. * @param source The mesh or sprite that triggered the action
  112092. * @param pointerX The X mouse cursor position at the time of the event
  112093. * @param pointerY The Y mouse cursor position at the time of the event
  112094. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112095. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112096. * @param additionalData additional data for the event
  112097. */
  112098. constructor(
  112099. /** The mesh or sprite that triggered the action */
  112100. source: any,
  112101. /** The X mouse cursor position at the time of the event */
  112102. pointerX: number,
  112103. /** The Y mouse cursor position at the time of the event */
  112104. pointerY: number,
  112105. /** The mesh that is currently pointed at (can be null) */
  112106. meshUnderPointer: Nullable<AbstractMesh>,
  112107. /** the original (browser) event that triggered the ActionEvent */
  112108. sourceEvent?: any,
  112109. /** additional data for the event */
  112110. additionalData?: any);
  112111. /**
  112112. * Helper function to auto-create an ActionEvent from a source mesh.
  112113. * @param source The source mesh that triggered the event
  112114. * @param evt The original (browser) event
  112115. * @param additionalData additional data for the event
  112116. * @returns the new ActionEvent
  112117. */
  112118. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112119. /**
  112120. * Helper function to auto-create an ActionEvent from a source sprite
  112121. * @param source The source sprite that triggered the event
  112122. * @param scene Scene associated with the sprite
  112123. * @param evt The original (browser) event
  112124. * @param additionalData additional data for the event
  112125. * @returns the new ActionEvent
  112126. */
  112127. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112128. /**
  112129. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112130. * @param scene the scene where the event occurred
  112131. * @param evt The original (browser) event
  112132. * @returns the new ActionEvent
  112133. */
  112134. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112135. /**
  112136. * Helper function to auto-create an ActionEvent from a primitive
  112137. * @param prim defines the target primitive
  112138. * @param pointerPos defines the pointer position
  112139. * @param evt The original (browser) event
  112140. * @param additionalData additional data for the event
  112141. * @returns the new ActionEvent
  112142. */
  112143. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112144. }
  112145. }
  112146. declare module BABYLON {
  112147. /**
  112148. * Abstract class used to decouple action Manager from scene and meshes.
  112149. * Do not instantiate.
  112150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112151. */
  112152. export abstract class AbstractActionManager implements IDisposable {
  112153. /** Gets the list of active triggers */
  112154. static Triggers: {
  112155. [key: string]: number;
  112156. };
  112157. /** Gets the cursor to use when hovering items */
  112158. hoverCursor: string;
  112159. /** Gets the list of actions */
  112160. actions: IAction[];
  112161. /**
  112162. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112163. */
  112164. isRecursive: boolean;
  112165. /**
  112166. * Releases all associated resources
  112167. */
  112168. abstract dispose(): void;
  112169. /**
  112170. * Does this action manager has pointer triggers
  112171. */
  112172. abstract get hasPointerTriggers(): boolean;
  112173. /**
  112174. * Does this action manager has pick triggers
  112175. */
  112176. abstract get hasPickTriggers(): boolean;
  112177. /**
  112178. * Process a specific trigger
  112179. * @param trigger defines the trigger to process
  112180. * @param evt defines the event details to be processed
  112181. */
  112182. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112183. /**
  112184. * Does this action manager handles actions of any of the given triggers
  112185. * @param triggers defines the triggers to be tested
  112186. * @return a boolean indicating whether one (or more) of the triggers is handled
  112187. */
  112188. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112189. /**
  112190. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112191. * speed.
  112192. * @param triggerA defines the trigger to be tested
  112193. * @param triggerB defines the trigger to be tested
  112194. * @return a boolean indicating whether one (or more) of the triggers is handled
  112195. */
  112196. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112197. /**
  112198. * Does this action manager handles actions of a given trigger
  112199. * @param trigger defines the trigger to be tested
  112200. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112201. * @return whether the trigger is handled
  112202. */
  112203. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112204. /**
  112205. * Serialize this manager to a JSON object
  112206. * @param name defines the property name to store this manager
  112207. * @returns a JSON representation of this manager
  112208. */
  112209. abstract serialize(name: string): any;
  112210. /**
  112211. * Registers an action to this action manager
  112212. * @param action defines the action to be registered
  112213. * @return the action amended (prepared) after registration
  112214. */
  112215. abstract registerAction(action: IAction): Nullable<IAction>;
  112216. /**
  112217. * Unregisters an action to this action manager
  112218. * @param action defines the action to be unregistered
  112219. * @return a boolean indicating whether the action has been unregistered
  112220. */
  112221. abstract unregisterAction(action: IAction): Boolean;
  112222. /**
  112223. * Does exist one action manager with at least one trigger
  112224. **/
  112225. static get HasTriggers(): boolean;
  112226. /**
  112227. * Does exist one action manager with at least one pick trigger
  112228. **/
  112229. static get HasPickTriggers(): boolean;
  112230. /**
  112231. * Does exist one action manager that handles actions of a given trigger
  112232. * @param trigger defines the trigger to be tested
  112233. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  112234. **/
  112235. static HasSpecificTrigger(trigger: number): boolean;
  112236. }
  112237. }
  112238. declare module BABYLON {
  112239. /**
  112240. * Defines how a node can be built from a string name.
  112241. */
  112242. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  112243. /**
  112244. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  112245. */
  112246. export class Node implements IBehaviorAware<Node> {
  112247. /** @hidden */
  112248. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  112249. private static _NodeConstructors;
  112250. /**
  112251. * Add a new node constructor
  112252. * @param type defines the type name of the node to construct
  112253. * @param constructorFunc defines the constructor function
  112254. */
  112255. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  112256. /**
  112257. * Returns a node constructor based on type name
  112258. * @param type defines the type name
  112259. * @param name defines the new node name
  112260. * @param scene defines the hosting scene
  112261. * @param options defines optional options to transmit to constructors
  112262. * @returns the new constructor or null
  112263. */
  112264. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  112265. /**
  112266. * Gets or sets the name of the node
  112267. */
  112268. name: string;
  112269. /**
  112270. * Gets or sets the id of the node
  112271. */
  112272. id: string;
  112273. /**
  112274. * Gets or sets the unique id of the node
  112275. */
  112276. uniqueId: number;
  112277. /**
  112278. * Gets or sets a string used to store user defined state for the node
  112279. */
  112280. state: string;
  112281. /**
  112282. * Gets or sets an object used to store user defined information for the node
  112283. */
  112284. metadata: any;
  112285. /**
  112286. * For internal use only. Please do not use.
  112287. */
  112288. reservedDataStore: any;
  112289. /**
  112290. * List of inspectable custom properties (used by the Inspector)
  112291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112292. */
  112293. inspectableCustomProperties: IInspectable[];
  112294. private _doNotSerialize;
  112295. /**
  112296. * Gets or sets a boolean used to define if the node must be serialized
  112297. */
  112298. get doNotSerialize(): boolean;
  112299. set doNotSerialize(value: boolean);
  112300. /** @hidden */
  112301. _isDisposed: boolean;
  112302. /**
  112303. * Gets a list of Animations associated with the node
  112304. */
  112305. animations: Animation[];
  112306. protected _ranges: {
  112307. [name: string]: Nullable<AnimationRange>;
  112308. };
  112309. /**
  112310. * Callback raised when the node is ready to be used
  112311. */
  112312. onReady: Nullable<(node: Node) => void>;
  112313. private _isEnabled;
  112314. private _isParentEnabled;
  112315. private _isReady;
  112316. /** @hidden */
  112317. _currentRenderId: number;
  112318. private _parentUpdateId;
  112319. /** @hidden */
  112320. _childUpdateId: number;
  112321. /** @hidden */
  112322. _waitingParentId: Nullable<string>;
  112323. /** @hidden */
  112324. _scene: Scene;
  112325. /** @hidden */
  112326. _cache: any;
  112327. private _parentNode;
  112328. private _children;
  112329. /** @hidden */
  112330. _worldMatrix: Matrix;
  112331. /** @hidden */
  112332. _worldMatrixDeterminant: number;
  112333. /** @hidden */
  112334. _worldMatrixDeterminantIsDirty: boolean;
  112335. /** @hidden */
  112336. private _sceneRootNodesIndex;
  112337. /**
  112338. * Gets a boolean indicating if the node has been disposed
  112339. * @returns true if the node was disposed
  112340. */
  112341. isDisposed(): boolean;
  112342. /**
  112343. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112344. * @see https://doc.babylonjs.com/how_to/parenting
  112345. */
  112346. set parent(parent: Nullable<Node>);
  112347. get parent(): Nullable<Node>;
  112348. /** @hidden */
  112349. _addToSceneRootNodes(): void;
  112350. /** @hidden */
  112351. _removeFromSceneRootNodes(): void;
  112352. private _animationPropertiesOverride;
  112353. /**
  112354. * Gets or sets the animation properties override
  112355. */
  112356. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112357. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112358. /**
  112359. * Gets a string identifying the name of the class
  112360. * @returns "Node" string
  112361. */
  112362. getClassName(): string;
  112363. /** @hidden */
  112364. readonly _isNode: boolean;
  112365. /**
  112366. * An event triggered when the mesh is disposed
  112367. */
  112368. onDisposeObservable: Observable<Node>;
  112369. private _onDisposeObserver;
  112370. /**
  112371. * Sets a callback that will be raised when the node will be disposed
  112372. */
  112373. set onDispose(callback: () => void);
  112374. /**
  112375. * Creates a new Node
  112376. * @param name the name and id to be given to this node
  112377. * @param scene the scene this node will be added to
  112378. */
  112379. constructor(name: string, scene?: Nullable<Scene>);
  112380. /**
  112381. * Gets the scene of the node
  112382. * @returns a scene
  112383. */
  112384. getScene(): Scene;
  112385. /**
  112386. * Gets the engine of the node
  112387. * @returns a Engine
  112388. */
  112389. getEngine(): Engine;
  112390. private _behaviors;
  112391. /**
  112392. * Attach a behavior to the node
  112393. * @see https://doc.babylonjs.com/features/behaviour
  112394. * @param behavior defines the behavior to attach
  112395. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112396. * @returns the current Node
  112397. */
  112398. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112399. /**
  112400. * Remove an attached behavior
  112401. * @see https://doc.babylonjs.com/features/behaviour
  112402. * @param behavior defines the behavior to attach
  112403. * @returns the current Node
  112404. */
  112405. removeBehavior(behavior: Behavior<Node>): Node;
  112406. /**
  112407. * Gets the list of attached behaviors
  112408. * @see https://doc.babylonjs.com/features/behaviour
  112409. */
  112410. get behaviors(): Behavior<Node>[];
  112411. /**
  112412. * Gets an attached behavior by name
  112413. * @param name defines the name of the behavior to look for
  112414. * @see https://doc.babylonjs.com/features/behaviour
  112415. * @returns null if behavior was not found else the requested behavior
  112416. */
  112417. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112418. /**
  112419. * Returns the latest update of the World matrix
  112420. * @returns a Matrix
  112421. */
  112422. getWorldMatrix(): Matrix;
  112423. /** @hidden */
  112424. _getWorldMatrixDeterminant(): number;
  112425. /**
  112426. * Returns directly the latest state of the mesh World matrix.
  112427. * A Matrix is returned.
  112428. */
  112429. get worldMatrixFromCache(): Matrix;
  112430. /** @hidden */
  112431. _initCache(): void;
  112432. /** @hidden */
  112433. updateCache(force?: boolean): void;
  112434. /** @hidden */
  112435. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112436. /** @hidden */
  112437. _updateCache(ignoreParentClass?: boolean): void;
  112438. /** @hidden */
  112439. _isSynchronized(): boolean;
  112440. /** @hidden */
  112441. _markSyncedWithParent(): void;
  112442. /** @hidden */
  112443. isSynchronizedWithParent(): boolean;
  112444. /** @hidden */
  112445. isSynchronized(): boolean;
  112446. /**
  112447. * Is this node ready to be used/rendered
  112448. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112449. * @return true if the node is ready
  112450. */
  112451. isReady(completeCheck?: boolean): boolean;
  112452. /**
  112453. * Is this node enabled?
  112454. * 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
  112455. * @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
  112456. * @return whether this node (and its parent) is enabled
  112457. */
  112458. isEnabled(checkAncestors?: boolean): boolean;
  112459. /** @hidden */
  112460. protected _syncParentEnabledState(): void;
  112461. /**
  112462. * Set the enabled state of this node
  112463. * @param value defines the new enabled state
  112464. */
  112465. setEnabled(value: boolean): void;
  112466. /**
  112467. * Is this node a descendant of the given node?
  112468. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112469. * @param ancestor defines the parent node to inspect
  112470. * @returns a boolean indicating if this node is a descendant of the given node
  112471. */
  112472. isDescendantOf(ancestor: Node): boolean;
  112473. /** @hidden */
  112474. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  112475. /**
  112476. * Will return all nodes that have this node as ascendant
  112477. * @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
  112478. * @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
  112479. * @return all children nodes of all types
  112480. */
  112481. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  112482. /**
  112483. * Get all child-meshes of this node
  112484. * @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)
  112485. * @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
  112486. * @returns an array of AbstractMesh
  112487. */
  112488. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  112489. /**
  112490. * Get all direct children of this node
  112491. * @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
  112492. * @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)
  112493. * @returns an array of Node
  112494. */
  112495. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  112496. /** @hidden */
  112497. _setReady(state: boolean): void;
  112498. /**
  112499. * Get an animation by name
  112500. * @param name defines the name of the animation to look for
  112501. * @returns null if not found else the requested animation
  112502. */
  112503. getAnimationByName(name: string): Nullable<Animation>;
  112504. /**
  112505. * Creates an animation range for this node
  112506. * @param name defines the name of the range
  112507. * @param from defines the starting key
  112508. * @param to defines the end key
  112509. */
  112510. createAnimationRange(name: string, from: number, to: number): void;
  112511. /**
  112512. * Delete a specific animation range
  112513. * @param name defines the name of the range to delete
  112514. * @param deleteFrames defines if animation frames from the range must be deleted as well
  112515. */
  112516. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  112517. /**
  112518. * Get an animation range by name
  112519. * @param name defines the name of the animation range to look for
  112520. * @returns null if not found else the requested animation range
  112521. */
  112522. getAnimationRange(name: string): Nullable<AnimationRange>;
  112523. /**
  112524. * Gets the list of all animation ranges defined on this node
  112525. * @returns an array
  112526. */
  112527. getAnimationRanges(): Nullable<AnimationRange>[];
  112528. /**
  112529. * Will start the animation sequence
  112530. * @param name defines the range frames for animation sequence
  112531. * @param loop defines if the animation should loop (false by default)
  112532. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  112533. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  112534. * @returns the object created for this animation. If range does not exist, it will return null
  112535. */
  112536. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  112537. /**
  112538. * Serialize animation ranges into a JSON compatible object
  112539. * @returns serialization object
  112540. */
  112541. serializeAnimationRanges(): any;
  112542. /**
  112543. * Computes the world matrix of the node
  112544. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112545. * @returns the world matrix
  112546. */
  112547. computeWorldMatrix(force?: boolean): Matrix;
  112548. /**
  112549. * Releases resources associated with this node.
  112550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112552. */
  112553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112554. /**
  112555. * Parse animation range data from a serialization object and store them into a given node
  112556. * @param node defines where to store the animation ranges
  112557. * @param parsedNode defines the serialization object to read data from
  112558. * @param scene defines the hosting scene
  112559. */
  112560. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  112561. /**
  112562. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  112563. * @param includeDescendants Include bounding info from descendants as well (true by default)
  112564. * @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
  112565. * @returns the new bounding vectors
  112566. */
  112567. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  112568. min: Vector3;
  112569. max: Vector3;
  112570. };
  112571. }
  112572. }
  112573. declare module BABYLON {
  112574. /**
  112575. * @hidden
  112576. */
  112577. export class _IAnimationState {
  112578. key: number;
  112579. repeatCount: number;
  112580. workValue?: any;
  112581. loopMode?: number;
  112582. offsetValue?: any;
  112583. highLimitValue?: any;
  112584. }
  112585. /**
  112586. * Class used to store any kind of animation
  112587. */
  112588. export class Animation {
  112589. /**Name of the animation */
  112590. name: string;
  112591. /**Property to animate */
  112592. targetProperty: string;
  112593. /**The frames per second of the animation */
  112594. framePerSecond: number;
  112595. /**The data type of the animation */
  112596. dataType: number;
  112597. /**The loop mode of the animation */
  112598. loopMode?: number | undefined;
  112599. /**Specifies if blending should be enabled */
  112600. enableBlending?: boolean | undefined;
  112601. /**
  112602. * Use matrix interpolation instead of using direct key value when animating matrices
  112603. */
  112604. static AllowMatricesInterpolation: boolean;
  112605. /**
  112606. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112607. */
  112608. static AllowMatrixDecomposeForInterpolation: boolean;
  112609. /** Define the Url to load snippets */
  112610. static SnippetUrl: string;
  112611. /** Snippet ID if the animation was created from the snippet server */
  112612. snippetId: string;
  112613. /**
  112614. * Stores the key frames of the animation
  112615. */
  112616. private _keys;
  112617. /**
  112618. * Stores the easing function of the animation
  112619. */
  112620. private _easingFunction;
  112621. /**
  112622. * @hidden Internal use only
  112623. */
  112624. _runtimeAnimations: RuntimeAnimation[];
  112625. /**
  112626. * The set of event that will be linked to this animation
  112627. */
  112628. private _events;
  112629. /**
  112630. * Stores an array of target property paths
  112631. */
  112632. targetPropertyPath: string[];
  112633. /**
  112634. * Stores the blending speed of the animation
  112635. */
  112636. blendingSpeed: number;
  112637. /**
  112638. * Stores the animation ranges for the animation
  112639. */
  112640. private _ranges;
  112641. /**
  112642. * @hidden Internal use
  112643. */
  112644. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112645. /**
  112646. * Sets up an animation
  112647. * @param property The property to animate
  112648. * @param animationType The animation type to apply
  112649. * @param framePerSecond The frames per second of the animation
  112650. * @param easingFunction The easing function used in the animation
  112651. * @returns The created animation
  112652. */
  112653. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112654. /**
  112655. * Create and start an animation on a node
  112656. * @param name defines the name of the global animation that will be run on all nodes
  112657. * @param node defines the root node where the animation will take place
  112658. * @param targetProperty defines property to animate
  112659. * @param framePerSecond defines the number of frame per second yo use
  112660. * @param totalFrame defines the number of frames in total
  112661. * @param from defines the initial value
  112662. * @param to defines the final value
  112663. * @param loopMode defines which loop mode you want to use (off by default)
  112664. * @param easingFunction defines the easing function to use (linear by default)
  112665. * @param onAnimationEnd defines the callback to call when animation end
  112666. * @returns the animatable created for this animation
  112667. */
  112668. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112669. /**
  112670. * Create and start an animation on a node and its descendants
  112671. * @param name defines the name of the global animation that will be run on all nodes
  112672. * @param node defines the root node where the animation will take place
  112673. * @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
  112674. * @param targetProperty defines property to animate
  112675. * @param framePerSecond defines the number of frame per second to use
  112676. * @param totalFrame defines the number of frames in total
  112677. * @param from defines the initial value
  112678. * @param to defines the final value
  112679. * @param loopMode defines which loop mode you want to use (off by default)
  112680. * @param easingFunction defines the easing function to use (linear by default)
  112681. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112682. * @returns the list of animatables created for all nodes
  112683. * @example https://www.babylonjs-playground.com/#MH0VLI
  112684. */
  112685. 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[]>;
  112686. /**
  112687. * Creates a new animation, merges it with the existing animations and starts it
  112688. * @param name Name of the animation
  112689. * @param node Node which contains the scene that begins the animations
  112690. * @param targetProperty Specifies which property to animate
  112691. * @param framePerSecond The frames per second of the animation
  112692. * @param totalFrame The total number of frames
  112693. * @param from The frame at the beginning of the animation
  112694. * @param to The frame at the end of the animation
  112695. * @param loopMode Specifies the loop mode of the animation
  112696. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112697. * @param onAnimationEnd Callback to run once the animation is complete
  112698. * @returns Nullable animation
  112699. */
  112700. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112701. /**
  112702. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112703. * @param sourceAnimation defines the Animation containing keyframes to convert
  112704. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112705. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112706. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112707. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112708. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112709. */
  112710. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112711. /**
  112712. * Transition property of an host to the target Value
  112713. * @param property The property to transition
  112714. * @param targetValue The target Value of the property
  112715. * @param host The object where the property to animate belongs
  112716. * @param scene Scene used to run the animation
  112717. * @param frameRate Framerate (in frame/s) to use
  112718. * @param transition The transition type we want to use
  112719. * @param duration The duration of the animation, in milliseconds
  112720. * @param onAnimationEnd Callback trigger at the end of the animation
  112721. * @returns Nullable animation
  112722. */
  112723. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112724. /**
  112725. * Return the array of runtime animations currently using this animation
  112726. */
  112727. get runtimeAnimations(): RuntimeAnimation[];
  112728. /**
  112729. * Specifies if any of the runtime animations are currently running
  112730. */
  112731. get hasRunningRuntimeAnimations(): boolean;
  112732. /**
  112733. * Initializes the animation
  112734. * @param name Name of the animation
  112735. * @param targetProperty Property to animate
  112736. * @param framePerSecond The frames per second of the animation
  112737. * @param dataType The data type of the animation
  112738. * @param loopMode The loop mode of the animation
  112739. * @param enableBlending Specifies if blending should be enabled
  112740. */
  112741. constructor(
  112742. /**Name of the animation */
  112743. name: string,
  112744. /**Property to animate */
  112745. targetProperty: string,
  112746. /**The frames per second of the animation */
  112747. framePerSecond: number,
  112748. /**The data type of the animation */
  112749. dataType: number,
  112750. /**The loop mode of the animation */
  112751. loopMode?: number | undefined,
  112752. /**Specifies if blending should be enabled */
  112753. enableBlending?: boolean | undefined);
  112754. /**
  112755. * Converts the animation to a string
  112756. * @param fullDetails support for multiple levels of logging within scene loading
  112757. * @returns String form of the animation
  112758. */
  112759. toString(fullDetails?: boolean): string;
  112760. /**
  112761. * Add an event to this animation
  112762. * @param event Event to add
  112763. */
  112764. addEvent(event: AnimationEvent): void;
  112765. /**
  112766. * Remove all events found at the given frame
  112767. * @param frame The frame to remove events from
  112768. */
  112769. removeEvents(frame: number): void;
  112770. /**
  112771. * Retrieves all the events from the animation
  112772. * @returns Events from the animation
  112773. */
  112774. getEvents(): AnimationEvent[];
  112775. /**
  112776. * Creates an animation range
  112777. * @param name Name of the animation range
  112778. * @param from Starting frame of the animation range
  112779. * @param to Ending frame of the animation
  112780. */
  112781. createRange(name: string, from: number, to: number): void;
  112782. /**
  112783. * Deletes an animation range by name
  112784. * @param name Name of the animation range to delete
  112785. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112786. */
  112787. deleteRange(name: string, deleteFrames?: boolean): void;
  112788. /**
  112789. * Gets the animation range by name, or null if not defined
  112790. * @param name Name of the animation range
  112791. * @returns Nullable animation range
  112792. */
  112793. getRange(name: string): Nullable<AnimationRange>;
  112794. /**
  112795. * Gets the key frames from the animation
  112796. * @returns The key frames of the animation
  112797. */
  112798. getKeys(): Array<IAnimationKey>;
  112799. /**
  112800. * Gets the highest frame rate of the animation
  112801. * @returns Highest frame rate of the animation
  112802. */
  112803. getHighestFrame(): number;
  112804. /**
  112805. * Gets the easing function of the animation
  112806. * @returns Easing function of the animation
  112807. */
  112808. getEasingFunction(): IEasingFunction;
  112809. /**
  112810. * Sets the easing function of the animation
  112811. * @param easingFunction A custom mathematical formula for animation
  112812. */
  112813. setEasingFunction(easingFunction: EasingFunction): void;
  112814. /**
  112815. * Interpolates a scalar linearly
  112816. * @param startValue Start value of the animation curve
  112817. * @param endValue End value of the animation curve
  112818. * @param gradient Scalar amount to interpolate
  112819. * @returns Interpolated scalar value
  112820. */
  112821. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112822. /**
  112823. * Interpolates a scalar cubically
  112824. * @param startValue Start value of the animation curve
  112825. * @param outTangent End tangent of the animation
  112826. * @param endValue End value of the animation curve
  112827. * @param inTangent Start tangent of the animation curve
  112828. * @param gradient Scalar amount to interpolate
  112829. * @returns Interpolated scalar value
  112830. */
  112831. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112832. /**
  112833. * Interpolates a quaternion using a spherical linear interpolation
  112834. * @param startValue Start value of the animation curve
  112835. * @param endValue End value of the animation curve
  112836. * @param gradient Scalar amount to interpolate
  112837. * @returns Interpolated quaternion value
  112838. */
  112839. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112840. /**
  112841. * Interpolates a quaternion cubically
  112842. * @param startValue Start value of the animation curve
  112843. * @param outTangent End tangent of the animation curve
  112844. * @param endValue End value of the animation curve
  112845. * @param inTangent Start tangent of the animation curve
  112846. * @param gradient Scalar amount to interpolate
  112847. * @returns Interpolated quaternion value
  112848. */
  112849. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112850. /**
  112851. * Interpolates a Vector3 linearl
  112852. * @param startValue Start value of the animation curve
  112853. * @param endValue End value of the animation curve
  112854. * @param gradient Scalar amount to interpolate
  112855. * @returns Interpolated scalar value
  112856. */
  112857. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112858. /**
  112859. * Interpolates a Vector3 cubically
  112860. * @param startValue Start value of the animation curve
  112861. * @param outTangent End tangent of the animation
  112862. * @param endValue End value of the animation curve
  112863. * @param inTangent Start tangent of the animation curve
  112864. * @param gradient Scalar amount to interpolate
  112865. * @returns InterpolatedVector3 value
  112866. */
  112867. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112868. /**
  112869. * Interpolates a Vector2 linearly
  112870. * @param startValue Start value of the animation curve
  112871. * @param endValue End value of the animation curve
  112872. * @param gradient Scalar amount to interpolate
  112873. * @returns Interpolated Vector2 value
  112874. */
  112875. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112876. /**
  112877. * Interpolates a Vector2 cubically
  112878. * @param startValue Start value of the animation curve
  112879. * @param outTangent End tangent of the animation
  112880. * @param endValue End value of the animation curve
  112881. * @param inTangent Start tangent of the animation curve
  112882. * @param gradient Scalar amount to interpolate
  112883. * @returns Interpolated Vector2 value
  112884. */
  112885. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112886. /**
  112887. * Interpolates a size linearly
  112888. * @param startValue Start value of the animation curve
  112889. * @param endValue End value of the animation curve
  112890. * @param gradient Scalar amount to interpolate
  112891. * @returns Interpolated Size value
  112892. */
  112893. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112894. /**
  112895. * Interpolates a Color3 linearly
  112896. * @param startValue Start value of the animation curve
  112897. * @param endValue End value of the animation curve
  112898. * @param gradient Scalar amount to interpolate
  112899. * @returns Interpolated Color3 value
  112900. */
  112901. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112902. /**
  112903. * Interpolates a Color4 linearly
  112904. * @param startValue Start value of the animation curve
  112905. * @param endValue End value of the animation curve
  112906. * @param gradient Scalar amount to interpolate
  112907. * @returns Interpolated Color3 value
  112908. */
  112909. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112910. /**
  112911. * @hidden Internal use only
  112912. */
  112913. _getKeyValue(value: any): any;
  112914. /**
  112915. * @hidden Internal use only
  112916. */
  112917. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112918. /**
  112919. * Defines the function to use to interpolate matrices
  112920. * @param startValue defines the start matrix
  112921. * @param endValue defines the end matrix
  112922. * @param gradient defines the gradient between both matrices
  112923. * @param result defines an optional target matrix where to store the interpolation
  112924. * @returns the interpolated matrix
  112925. */
  112926. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112927. /**
  112928. * Makes a copy of the animation
  112929. * @returns Cloned animation
  112930. */
  112931. clone(): Animation;
  112932. /**
  112933. * Sets the key frames of the animation
  112934. * @param values The animation key frames to set
  112935. */
  112936. setKeys(values: Array<IAnimationKey>): void;
  112937. /**
  112938. * Serializes the animation to an object
  112939. * @returns Serialized object
  112940. */
  112941. serialize(): any;
  112942. /**
  112943. * Float animation type
  112944. */
  112945. static readonly ANIMATIONTYPE_FLOAT: number;
  112946. /**
  112947. * Vector3 animation type
  112948. */
  112949. static readonly ANIMATIONTYPE_VECTOR3: number;
  112950. /**
  112951. * Quaternion animation type
  112952. */
  112953. static readonly ANIMATIONTYPE_QUATERNION: number;
  112954. /**
  112955. * Matrix animation type
  112956. */
  112957. static readonly ANIMATIONTYPE_MATRIX: number;
  112958. /**
  112959. * Color3 animation type
  112960. */
  112961. static readonly ANIMATIONTYPE_COLOR3: number;
  112962. /**
  112963. * Color3 animation type
  112964. */
  112965. static readonly ANIMATIONTYPE_COLOR4: number;
  112966. /**
  112967. * Vector2 animation type
  112968. */
  112969. static readonly ANIMATIONTYPE_VECTOR2: number;
  112970. /**
  112971. * Size animation type
  112972. */
  112973. static readonly ANIMATIONTYPE_SIZE: number;
  112974. /**
  112975. * Relative Loop Mode
  112976. */
  112977. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112978. /**
  112979. * Cycle Loop Mode
  112980. */
  112981. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112982. /**
  112983. * Constant Loop Mode
  112984. */
  112985. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112986. /** @hidden */
  112987. static _UniversalLerp(left: any, right: any, amount: number): any;
  112988. /**
  112989. * Parses an animation object and creates an animation
  112990. * @param parsedAnimation Parsed animation object
  112991. * @returns Animation object
  112992. */
  112993. static Parse(parsedAnimation: any): Animation;
  112994. /**
  112995. * Appends the serialized animations from the source animations
  112996. * @param source Source containing the animations
  112997. * @param destination Target to store the animations
  112998. */
  112999. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113000. /**
  113001. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113002. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113003. * @param url defines the url to load from
  113004. * @returns a promise that will resolve to the new animation or an array of animations
  113005. */
  113006. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113007. /**
  113008. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113009. * @param snippetId defines the snippet to load
  113010. * @returns a promise that will resolve to the new animation or a new array of animations
  113011. */
  113012. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113013. }
  113014. }
  113015. declare module BABYLON {
  113016. /**
  113017. * Interface containing an array of animations
  113018. */
  113019. export interface IAnimatable {
  113020. /**
  113021. * Array of animations
  113022. */
  113023. animations: Nullable<Array<Animation>>;
  113024. }
  113025. }
  113026. declare module BABYLON {
  113027. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113028. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113029. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113030. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113031. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113032. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113033. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113034. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113035. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113036. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113037. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113038. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113039. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113040. /**
  113041. * Decorator used to define property that can be serialized as reference to a camera
  113042. * @param sourceName defines the name of the property to decorate
  113043. */
  113044. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113045. /**
  113046. * Class used to help serialization objects
  113047. */
  113048. export class SerializationHelper {
  113049. /** @hidden */
  113050. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113051. /** @hidden */
  113052. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113053. /** @hidden */
  113054. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113055. /** @hidden */
  113056. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113057. /**
  113058. * Appends the serialized animations from the source animations
  113059. * @param source Source containing the animations
  113060. * @param destination Target to store the animations
  113061. */
  113062. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113063. /**
  113064. * Static function used to serialized a specific entity
  113065. * @param entity defines the entity to serialize
  113066. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113067. * @returns a JSON compatible object representing the serialization of the entity
  113068. */
  113069. static Serialize<T>(entity: T, serializationObject?: any): any;
  113070. /**
  113071. * Creates a new entity from a serialization data object
  113072. * @param creationFunction defines a function used to instanciated the new entity
  113073. * @param source defines the source serialization data
  113074. * @param scene defines the hosting scene
  113075. * @param rootUrl defines the root url for resources
  113076. * @returns a new entity
  113077. */
  113078. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113079. /**
  113080. * Clones an object
  113081. * @param creationFunction defines the function used to instanciate the new object
  113082. * @param source defines the source object
  113083. * @returns the cloned object
  113084. */
  113085. static Clone<T>(creationFunction: () => T, source: T): T;
  113086. /**
  113087. * Instanciates a new object based on a source one (some data will be shared between both object)
  113088. * @param creationFunction defines the function used to instanciate the new object
  113089. * @param source defines the source object
  113090. * @returns the new object
  113091. */
  113092. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113093. }
  113094. }
  113095. declare module BABYLON {
  113096. /**
  113097. * Base class of all the textures in babylon.
  113098. * It groups all the common properties the materials, post process, lights... might need
  113099. * in order to make a correct use of the texture.
  113100. */
  113101. export class BaseTexture implements IAnimatable {
  113102. /**
  113103. * Default anisotropic filtering level for the application.
  113104. * It is set to 4 as a good tradeoff between perf and quality.
  113105. */
  113106. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113107. /**
  113108. * Gets or sets the unique id of the texture
  113109. */
  113110. uniqueId: number;
  113111. /**
  113112. * Define the name of the texture.
  113113. */
  113114. name: string;
  113115. /**
  113116. * Gets or sets an object used to store user defined information.
  113117. */
  113118. metadata: any;
  113119. /**
  113120. * For internal use only. Please do not use.
  113121. */
  113122. reservedDataStore: any;
  113123. private _hasAlpha;
  113124. /**
  113125. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113126. */
  113127. set hasAlpha(value: boolean);
  113128. get hasAlpha(): boolean;
  113129. /**
  113130. * Defines if the alpha value should be determined via the rgb values.
  113131. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113132. */
  113133. getAlphaFromRGB: boolean;
  113134. /**
  113135. * Intensity or strength of the texture.
  113136. * It is commonly used by materials to fine tune the intensity of the texture
  113137. */
  113138. level: number;
  113139. /**
  113140. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113141. * This is part of the texture as textures usually maps to one uv set.
  113142. */
  113143. coordinatesIndex: number;
  113144. private _coordinatesMode;
  113145. /**
  113146. * How a texture is mapped.
  113147. *
  113148. * | Value | Type | Description |
  113149. * | ----- | ----------------------------------- | ----------- |
  113150. * | 0 | EXPLICIT_MODE | |
  113151. * | 1 | SPHERICAL_MODE | |
  113152. * | 2 | PLANAR_MODE | |
  113153. * | 3 | CUBIC_MODE | |
  113154. * | 4 | PROJECTION_MODE | |
  113155. * | 5 | SKYBOX_MODE | |
  113156. * | 6 | INVCUBIC_MODE | |
  113157. * | 7 | EQUIRECTANGULAR_MODE | |
  113158. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113159. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113160. */
  113161. set coordinatesMode(value: number);
  113162. get coordinatesMode(): number;
  113163. /**
  113164. * | Value | Type | Description |
  113165. * | ----- | ------------------ | ----------- |
  113166. * | 0 | CLAMP_ADDRESSMODE | |
  113167. * | 1 | WRAP_ADDRESSMODE | |
  113168. * | 2 | MIRROR_ADDRESSMODE | |
  113169. */
  113170. wrapU: number;
  113171. /**
  113172. * | Value | Type | Description |
  113173. * | ----- | ------------------ | ----------- |
  113174. * | 0 | CLAMP_ADDRESSMODE | |
  113175. * | 1 | WRAP_ADDRESSMODE | |
  113176. * | 2 | MIRROR_ADDRESSMODE | |
  113177. */
  113178. wrapV: number;
  113179. /**
  113180. * | Value | Type | Description |
  113181. * | ----- | ------------------ | ----------- |
  113182. * | 0 | CLAMP_ADDRESSMODE | |
  113183. * | 1 | WRAP_ADDRESSMODE | |
  113184. * | 2 | MIRROR_ADDRESSMODE | |
  113185. */
  113186. wrapR: number;
  113187. /**
  113188. * With compliant hardware and browser (supporting anisotropic filtering)
  113189. * this defines the level of anisotropic filtering in the texture.
  113190. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113191. */
  113192. anisotropicFilteringLevel: number;
  113193. /**
  113194. * Define if the texture is a cube texture or if false a 2d texture.
  113195. */
  113196. get isCube(): boolean;
  113197. set isCube(value: boolean);
  113198. /**
  113199. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113200. */
  113201. get is3D(): boolean;
  113202. set is3D(value: boolean);
  113203. /**
  113204. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113205. */
  113206. get is2DArray(): boolean;
  113207. set is2DArray(value: boolean);
  113208. /**
  113209. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113210. * HDR texture are usually stored in linear space.
  113211. * This only impacts the PBR and Background materials
  113212. */
  113213. gammaSpace: boolean;
  113214. /**
  113215. * Gets or sets whether or not the texture contains RGBD data.
  113216. */
  113217. get isRGBD(): boolean;
  113218. set isRGBD(value: boolean);
  113219. /**
  113220. * Is Z inverted in the texture (useful in a cube texture).
  113221. */
  113222. invertZ: boolean;
  113223. /**
  113224. * Are mip maps generated for this texture or not.
  113225. */
  113226. get noMipmap(): boolean;
  113227. /**
  113228. * @hidden
  113229. */
  113230. lodLevelInAlpha: boolean;
  113231. /**
  113232. * With prefiltered texture, defined the offset used during the prefiltering steps.
  113233. */
  113234. get lodGenerationOffset(): number;
  113235. set lodGenerationOffset(value: number);
  113236. /**
  113237. * With prefiltered texture, defined the scale used during the prefiltering steps.
  113238. */
  113239. get lodGenerationScale(): number;
  113240. set lodGenerationScale(value: number);
  113241. /**
  113242. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  113243. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  113244. * average roughness values.
  113245. */
  113246. get linearSpecularLOD(): boolean;
  113247. set linearSpecularLOD(value: boolean);
  113248. /**
  113249. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  113250. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  113251. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  113252. */
  113253. get irradianceTexture(): Nullable<BaseTexture>;
  113254. set irradianceTexture(value: Nullable<BaseTexture>);
  113255. /**
  113256. * Define if the texture is a render target.
  113257. */
  113258. isRenderTarget: boolean;
  113259. /**
  113260. * Define the unique id of the texture in the scene.
  113261. */
  113262. get uid(): string;
  113263. /** @hidden */
  113264. _prefiltered: boolean;
  113265. /**
  113266. * Return a string representation of the texture.
  113267. * @returns the texture as a string
  113268. */
  113269. toString(): string;
  113270. /**
  113271. * Get the class name of the texture.
  113272. * @returns "BaseTexture"
  113273. */
  113274. getClassName(): string;
  113275. /**
  113276. * Define the list of animation attached to the texture.
  113277. */
  113278. animations: Animation[];
  113279. /**
  113280. * An event triggered when the texture is disposed.
  113281. */
  113282. onDisposeObservable: Observable<BaseTexture>;
  113283. private _onDisposeObserver;
  113284. /**
  113285. * Callback triggered when the texture has been disposed.
  113286. * Kept for back compatibility, you can use the onDisposeObservable instead.
  113287. */
  113288. set onDispose(callback: () => void);
  113289. /**
  113290. * Define the current state of the loading sequence when in delayed load mode.
  113291. */
  113292. delayLoadState: number;
  113293. protected _scene: Nullable<Scene>;
  113294. protected _engine: Nullable<ThinEngine>;
  113295. /** @hidden */
  113296. _texture: Nullable<InternalTexture>;
  113297. private _uid;
  113298. /**
  113299. * Define if the texture is preventinga material to render or not.
  113300. * If not and the texture is not ready, the engine will use a default black texture instead.
  113301. */
  113302. get isBlocking(): boolean;
  113303. /**
  113304. * Instantiates a new BaseTexture.
  113305. * Base class of all the textures in babylon.
  113306. * It groups all the common properties the materials, post process, lights... might need
  113307. * in order to make a correct use of the texture.
  113308. * @param sceneOrEngine Define the scene or engine the texture blongs to
  113309. */
  113310. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  113311. /**
  113312. * Get the scene the texture belongs to.
  113313. * @returns the scene or null if undefined
  113314. */
  113315. getScene(): Nullable<Scene>;
  113316. /** @hidden */
  113317. protected _getEngine(): Nullable<ThinEngine>;
  113318. /**
  113319. * Get the texture transform matrix used to offset tile the texture for istance.
  113320. * @returns the transformation matrix
  113321. */
  113322. getTextureMatrix(): Matrix;
  113323. /**
  113324. * Get the texture reflection matrix used to rotate/transform the reflection.
  113325. * @returns the reflection matrix
  113326. */
  113327. getReflectionTextureMatrix(): Matrix;
  113328. /**
  113329. * Get the underlying lower level texture from Babylon.
  113330. * @returns the insternal texture
  113331. */
  113332. getInternalTexture(): Nullable<InternalTexture>;
  113333. /**
  113334. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113335. * @returns true if ready or not blocking
  113336. */
  113337. isReadyOrNotBlocking(): boolean;
  113338. /**
  113339. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113340. * @returns true if fully ready
  113341. */
  113342. isReady(): boolean;
  113343. private _cachedSize;
  113344. /**
  113345. * Get the size of the texture.
  113346. * @returns the texture size.
  113347. */
  113348. getSize(): ISize;
  113349. /**
  113350. * Get the base size of the texture.
  113351. * It can be different from the size if the texture has been resized for POT for instance
  113352. * @returns the base size
  113353. */
  113354. getBaseSize(): ISize;
  113355. /**
  113356. * Update the sampling mode of the texture.
  113357. * Default is Trilinear mode.
  113358. *
  113359. * | Value | Type | Description |
  113360. * | ----- | ------------------ | ----------- |
  113361. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  113362. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  113363. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  113364. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  113365. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  113366. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  113367. * | 7 | NEAREST_LINEAR | |
  113368. * | 8 | NEAREST_NEAREST | |
  113369. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  113370. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  113371. * | 11 | LINEAR_LINEAR | |
  113372. * | 12 | LINEAR_NEAREST | |
  113373. *
  113374. * > _mag_: magnification filter (close to the viewer)
  113375. * > _min_: minification filter (far from the viewer)
  113376. * > _mip_: filter used between mip map levels
  113377. *@param samplingMode Define the new sampling mode of the texture
  113378. */
  113379. updateSamplingMode(samplingMode: number): void;
  113380. /**
  113381. * Scales the texture if is `canRescale()`
  113382. * @param ratio the resize factor we want to use to rescale
  113383. */
  113384. scale(ratio: number): void;
  113385. /**
  113386. * Get if the texture can rescale.
  113387. */
  113388. get canRescale(): boolean;
  113389. /** @hidden */
  113390. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113391. /** @hidden */
  113392. _rebuild(): void;
  113393. /**
  113394. * Triggers the load sequence in delayed load mode.
  113395. */
  113396. delayLoad(): void;
  113397. /**
  113398. * Clones the texture.
  113399. * @returns the cloned texture
  113400. */
  113401. clone(): Nullable<BaseTexture>;
  113402. /**
  113403. * Get the texture underlying type (INT, FLOAT...)
  113404. */
  113405. get textureType(): number;
  113406. /**
  113407. * Get the texture underlying format (RGB, RGBA...)
  113408. */
  113409. get textureFormat(): number;
  113410. /**
  113411. * Indicates that textures need to be re-calculated for all materials
  113412. */
  113413. protected _markAllSubMeshesAsTexturesDirty(): void;
  113414. /**
  113415. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113416. * This will returns an RGBA array buffer containing either in values (0-255) or
  113417. * float values (0-1) depending of the underlying buffer type.
  113418. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113419. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113420. * @param buffer defines a user defined buffer to fill with data (can be null)
  113421. * @returns The Array buffer containing the pixels data.
  113422. */
  113423. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113424. /**
  113425. * Release and destroy the underlying lower level texture aka internalTexture.
  113426. */
  113427. releaseInternalTexture(): void;
  113428. /** @hidden */
  113429. get _lodTextureHigh(): Nullable<BaseTexture>;
  113430. /** @hidden */
  113431. get _lodTextureMid(): Nullable<BaseTexture>;
  113432. /** @hidden */
  113433. get _lodTextureLow(): Nullable<BaseTexture>;
  113434. /**
  113435. * Dispose the texture and release its associated resources.
  113436. */
  113437. dispose(): void;
  113438. /**
  113439. * Serialize the texture into a JSON representation that can be parsed later on.
  113440. * @returns the JSON representation of the texture
  113441. */
  113442. serialize(): any;
  113443. /**
  113444. * Helper function to be called back once a list of texture contains only ready textures.
  113445. * @param textures Define the list of textures to wait for
  113446. * @param callback Define the callback triggered once the entire list will be ready
  113447. */
  113448. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113449. private static _isScene;
  113450. }
  113451. }
  113452. declare module BABYLON {
  113453. /**
  113454. * Options to be used when creating an effect.
  113455. */
  113456. export interface IEffectCreationOptions {
  113457. /**
  113458. * Atrributes that will be used in the shader.
  113459. */
  113460. attributes: string[];
  113461. /**
  113462. * Uniform varible names that will be set in the shader.
  113463. */
  113464. uniformsNames: string[];
  113465. /**
  113466. * Uniform buffer variable names that will be set in the shader.
  113467. */
  113468. uniformBuffersNames: string[];
  113469. /**
  113470. * Sampler texture variable names that will be set in the shader.
  113471. */
  113472. samplers: string[];
  113473. /**
  113474. * Define statements that will be set in the shader.
  113475. */
  113476. defines: any;
  113477. /**
  113478. * Possible fallbacks for this effect to improve performance when needed.
  113479. */
  113480. fallbacks: Nullable<IEffectFallbacks>;
  113481. /**
  113482. * Callback that will be called when the shader is compiled.
  113483. */
  113484. onCompiled: Nullable<(effect: Effect) => void>;
  113485. /**
  113486. * Callback that will be called if an error occurs during shader compilation.
  113487. */
  113488. onError: Nullable<(effect: Effect, errors: string) => void>;
  113489. /**
  113490. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113491. */
  113492. indexParameters?: any;
  113493. /**
  113494. * Max number of lights that can be used in the shader.
  113495. */
  113496. maxSimultaneousLights?: number;
  113497. /**
  113498. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  113499. */
  113500. transformFeedbackVaryings?: Nullable<string[]>;
  113501. /**
  113502. * 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
  113503. */
  113504. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  113505. /**
  113506. * Is this effect rendering to several color attachments ?
  113507. */
  113508. multiTarget?: boolean;
  113509. }
  113510. /**
  113511. * Effect containing vertex and fragment shader that can be executed on an object.
  113512. */
  113513. export class Effect implements IDisposable {
  113514. /**
  113515. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113516. */
  113517. static ShadersRepository: string;
  113518. /**
  113519. * Enable logging of the shader code when a compilation error occurs
  113520. */
  113521. static LogShaderCodeOnCompilationError: boolean;
  113522. /**
  113523. * Name of the effect.
  113524. */
  113525. name: any;
  113526. /**
  113527. * String container all the define statements that should be set on the shader.
  113528. */
  113529. defines: string;
  113530. /**
  113531. * Callback that will be called when the shader is compiled.
  113532. */
  113533. onCompiled: Nullable<(effect: Effect) => void>;
  113534. /**
  113535. * Callback that will be called if an error occurs during shader compilation.
  113536. */
  113537. onError: Nullable<(effect: Effect, errors: string) => void>;
  113538. /**
  113539. * Callback that will be called when effect is bound.
  113540. */
  113541. onBind: Nullable<(effect: Effect) => void>;
  113542. /**
  113543. * Unique ID of the effect.
  113544. */
  113545. uniqueId: number;
  113546. /**
  113547. * Observable that will be called when the shader is compiled.
  113548. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  113549. */
  113550. onCompileObservable: Observable<Effect>;
  113551. /**
  113552. * Observable that will be called if an error occurs during shader compilation.
  113553. */
  113554. onErrorObservable: Observable<Effect>;
  113555. /** @hidden */
  113556. _onBindObservable: Nullable<Observable<Effect>>;
  113557. /**
  113558. * @hidden
  113559. * Specifies if the effect was previously ready
  113560. */
  113561. _wasPreviouslyReady: boolean;
  113562. /**
  113563. * Observable that will be called when effect is bound.
  113564. */
  113565. get onBindObservable(): Observable<Effect>;
  113566. /** @hidden */
  113567. _bonesComputationForcedToCPU: boolean;
  113568. /** @hidden */
  113569. _multiTarget: boolean;
  113570. private static _uniqueIdSeed;
  113571. private _engine;
  113572. private _uniformBuffersNames;
  113573. private _uniformBuffersNamesList;
  113574. private _uniformsNames;
  113575. private _samplerList;
  113576. private _samplers;
  113577. private _isReady;
  113578. private _compilationError;
  113579. private _allFallbacksProcessed;
  113580. private _attributesNames;
  113581. private _attributes;
  113582. private _attributeLocationByName;
  113583. private _uniforms;
  113584. /**
  113585. * Key for the effect.
  113586. * @hidden
  113587. */
  113588. _key: string;
  113589. private _indexParameters;
  113590. private _fallbacks;
  113591. private _vertexSourceCode;
  113592. private _fragmentSourceCode;
  113593. private _vertexSourceCodeOverride;
  113594. private _fragmentSourceCodeOverride;
  113595. private _transformFeedbackVaryings;
  113596. /**
  113597. * Compiled shader to webGL program.
  113598. * @hidden
  113599. */
  113600. _pipelineContext: Nullable<IPipelineContext>;
  113601. private _valueCache;
  113602. private static _baseCache;
  113603. /**
  113604. * Instantiates an effect.
  113605. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113606. * @param baseName Name of the effect.
  113607. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113608. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113609. * @param samplers List of sampler variables that will be passed to the shader.
  113610. * @param engine Engine to be used to render the effect
  113611. * @param defines Define statements to be added to the shader.
  113612. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113613. * @param onCompiled Callback that will be called when the shader is compiled.
  113614. * @param onError Callback that will be called if an error occurs during shader compilation.
  113615. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113616. */
  113617. 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);
  113618. private _useFinalCode;
  113619. /**
  113620. * Unique key for this effect
  113621. */
  113622. get key(): string;
  113623. /**
  113624. * If the effect has been compiled and prepared.
  113625. * @returns if the effect is compiled and prepared.
  113626. */
  113627. isReady(): boolean;
  113628. private _isReadyInternal;
  113629. /**
  113630. * The engine the effect was initialized with.
  113631. * @returns the engine.
  113632. */
  113633. getEngine(): Engine;
  113634. /**
  113635. * The pipeline context for this effect
  113636. * @returns the associated pipeline context
  113637. */
  113638. getPipelineContext(): Nullable<IPipelineContext>;
  113639. /**
  113640. * The set of names of attribute variables for the shader.
  113641. * @returns An array of attribute names.
  113642. */
  113643. getAttributesNames(): string[];
  113644. /**
  113645. * Returns the attribute at the given index.
  113646. * @param index The index of the attribute.
  113647. * @returns The location of the attribute.
  113648. */
  113649. getAttributeLocation(index: number): number;
  113650. /**
  113651. * Returns the attribute based on the name of the variable.
  113652. * @param name of the attribute to look up.
  113653. * @returns the attribute location.
  113654. */
  113655. getAttributeLocationByName(name: string): number;
  113656. /**
  113657. * The number of attributes.
  113658. * @returns the numnber of attributes.
  113659. */
  113660. getAttributesCount(): number;
  113661. /**
  113662. * Gets the index of a uniform variable.
  113663. * @param uniformName of the uniform to look up.
  113664. * @returns the index.
  113665. */
  113666. getUniformIndex(uniformName: string): number;
  113667. /**
  113668. * Returns the attribute based on the name of the variable.
  113669. * @param uniformName of the uniform to look up.
  113670. * @returns the location of the uniform.
  113671. */
  113672. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113673. /**
  113674. * Returns an array of sampler variable names
  113675. * @returns The array of sampler variable names.
  113676. */
  113677. getSamplers(): string[];
  113678. /**
  113679. * Returns an array of uniform variable names
  113680. * @returns The array of uniform variable names.
  113681. */
  113682. getUniformNames(): string[];
  113683. /**
  113684. * Returns an array of uniform buffer variable names
  113685. * @returns The array of uniform buffer variable names.
  113686. */
  113687. getUniformBuffersNames(): string[];
  113688. /**
  113689. * Returns the index parameters used to create the effect
  113690. * @returns The index parameters object
  113691. */
  113692. getIndexParameters(): any;
  113693. /**
  113694. * The error from the last compilation.
  113695. * @returns the error string.
  113696. */
  113697. getCompilationError(): string;
  113698. /**
  113699. * Gets a boolean indicating that all fallbacks were used during compilation
  113700. * @returns true if all fallbacks were used
  113701. */
  113702. allFallbacksProcessed(): boolean;
  113703. /**
  113704. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113705. * @param func The callback to be used.
  113706. */
  113707. executeWhenCompiled(func: (effect: Effect) => void): void;
  113708. private _checkIsReady;
  113709. private _loadShader;
  113710. /**
  113711. * Gets the vertex shader source code of this effect
  113712. */
  113713. get vertexSourceCode(): string;
  113714. /**
  113715. * Gets the fragment shader source code of this effect
  113716. */
  113717. get fragmentSourceCode(): string;
  113718. /**
  113719. * Recompiles the webGL program
  113720. * @param vertexSourceCode The source code for the vertex shader.
  113721. * @param fragmentSourceCode The source code for the fragment shader.
  113722. * @param onCompiled Callback called when completed.
  113723. * @param onError Callback called on error.
  113724. * @hidden
  113725. */
  113726. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113727. /**
  113728. * Prepares the effect
  113729. * @hidden
  113730. */
  113731. _prepareEffect(): void;
  113732. private _getShaderCodeAndErrorLine;
  113733. private _processCompilationErrors;
  113734. /**
  113735. * Checks if the effect is supported. (Must be called after compilation)
  113736. */
  113737. get isSupported(): boolean;
  113738. /**
  113739. * Binds a texture to the engine to be used as output of the shader.
  113740. * @param channel Name of the output variable.
  113741. * @param texture Texture to bind.
  113742. * @hidden
  113743. */
  113744. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113745. /**
  113746. * Sets a texture on the engine to be used in the shader.
  113747. * @param channel Name of the sampler variable.
  113748. * @param texture Texture to set.
  113749. */
  113750. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113751. /**
  113752. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113753. * @param channel Name of the sampler variable.
  113754. * @param texture Texture to set.
  113755. */
  113756. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113757. /**
  113758. * Sets an array of textures on the engine to be used in the shader.
  113759. * @param channel Name of the variable.
  113760. * @param textures Textures to set.
  113761. */
  113762. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113763. /**
  113764. * 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)
  113765. * @param channel Name of the sampler variable.
  113766. * @param postProcess Post process to get the input texture from.
  113767. */
  113768. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113769. /**
  113770. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113771. * 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)
  113772. * @param channel Name of the sampler variable.
  113773. * @param postProcess Post process to get the output texture from.
  113774. */
  113775. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113776. /** @hidden */
  113777. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113778. /** @hidden */
  113779. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113780. /** @hidden */
  113781. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113782. /** @hidden */
  113783. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113784. /**
  113785. * Binds a buffer to a uniform.
  113786. * @param buffer Buffer to bind.
  113787. * @param name Name of the uniform variable to bind to.
  113788. */
  113789. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113790. /**
  113791. * Binds block to a uniform.
  113792. * @param blockName Name of the block to bind.
  113793. * @param index Index to bind.
  113794. */
  113795. bindUniformBlock(blockName: string, index: number): void;
  113796. /**
  113797. * Sets an interger value on a uniform variable.
  113798. * @param uniformName Name of the variable.
  113799. * @param value Value to be set.
  113800. * @returns this effect.
  113801. */
  113802. setInt(uniformName: string, value: number): Effect;
  113803. /**
  113804. * Sets an int array on a uniform variable.
  113805. * @param uniformName Name of the variable.
  113806. * @param array array to be set.
  113807. * @returns this effect.
  113808. */
  113809. setIntArray(uniformName: string, array: Int32Array): Effect;
  113810. /**
  113811. * 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)
  113812. * @param uniformName Name of the variable.
  113813. * @param array array to be set.
  113814. * @returns this effect.
  113815. */
  113816. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113817. /**
  113818. * 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)
  113819. * @param uniformName Name of the variable.
  113820. * @param array array to be set.
  113821. * @returns this effect.
  113822. */
  113823. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113824. /**
  113825. * 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)
  113826. * @param uniformName Name of the variable.
  113827. * @param array array to be set.
  113828. * @returns this effect.
  113829. */
  113830. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113831. /**
  113832. * Sets an float array on a uniform variable.
  113833. * @param uniformName Name of the variable.
  113834. * @param array array to be set.
  113835. * @returns this effect.
  113836. */
  113837. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113838. /**
  113839. * 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)
  113840. * @param uniformName Name of the variable.
  113841. * @param array array to be set.
  113842. * @returns this effect.
  113843. */
  113844. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113845. /**
  113846. * 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)
  113847. * @param uniformName Name of the variable.
  113848. * @param array array to be set.
  113849. * @returns this effect.
  113850. */
  113851. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113852. /**
  113853. * 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)
  113854. * @param uniformName Name of the variable.
  113855. * @param array array to be set.
  113856. * @returns this effect.
  113857. */
  113858. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113859. /**
  113860. * Sets an array on a uniform variable.
  113861. * @param uniformName Name of the variable.
  113862. * @param array array to be set.
  113863. * @returns this effect.
  113864. */
  113865. setArray(uniformName: string, array: number[]): Effect;
  113866. /**
  113867. * 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)
  113868. * @param uniformName Name of the variable.
  113869. * @param array array to be set.
  113870. * @returns this effect.
  113871. */
  113872. setArray2(uniformName: string, array: number[]): Effect;
  113873. /**
  113874. * 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)
  113875. * @param uniformName Name of the variable.
  113876. * @param array array to be set.
  113877. * @returns this effect.
  113878. */
  113879. setArray3(uniformName: string, array: number[]): Effect;
  113880. /**
  113881. * 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)
  113882. * @param uniformName Name of the variable.
  113883. * @param array array to be set.
  113884. * @returns this effect.
  113885. */
  113886. setArray4(uniformName: string, array: number[]): Effect;
  113887. /**
  113888. * Sets matrices on a uniform variable.
  113889. * @param uniformName Name of the variable.
  113890. * @param matrices matrices to be set.
  113891. * @returns this effect.
  113892. */
  113893. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113894. /**
  113895. * Sets matrix on a uniform variable.
  113896. * @param uniformName Name of the variable.
  113897. * @param matrix matrix to be set.
  113898. * @returns this effect.
  113899. */
  113900. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113901. /**
  113902. * 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)
  113903. * @param uniformName Name of the variable.
  113904. * @param matrix matrix to be set.
  113905. * @returns this effect.
  113906. */
  113907. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113908. /**
  113909. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113910. * @param uniformName Name of the variable.
  113911. * @param matrix matrix to be set.
  113912. * @returns this effect.
  113913. */
  113914. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113915. /**
  113916. * Sets a float on a uniform variable.
  113917. * @param uniformName Name of the variable.
  113918. * @param value value to be set.
  113919. * @returns this effect.
  113920. */
  113921. setFloat(uniformName: string, value: number): Effect;
  113922. /**
  113923. * Sets a boolean on a uniform variable.
  113924. * @param uniformName Name of the variable.
  113925. * @param bool value to be set.
  113926. * @returns this effect.
  113927. */
  113928. setBool(uniformName: string, bool: boolean): Effect;
  113929. /**
  113930. * Sets a Vector2 on a uniform variable.
  113931. * @param uniformName Name of the variable.
  113932. * @param vector2 vector2 to be set.
  113933. * @returns this effect.
  113934. */
  113935. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113936. /**
  113937. * Sets a float2 on a uniform variable.
  113938. * @param uniformName Name of the variable.
  113939. * @param x First float in float2.
  113940. * @param y Second float in float2.
  113941. * @returns this effect.
  113942. */
  113943. setFloat2(uniformName: string, x: number, y: number): Effect;
  113944. /**
  113945. * Sets a Vector3 on a uniform variable.
  113946. * @param uniformName Name of the variable.
  113947. * @param vector3 Value to be set.
  113948. * @returns this effect.
  113949. */
  113950. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113951. /**
  113952. * Sets a float3 on a uniform variable.
  113953. * @param uniformName Name of the variable.
  113954. * @param x First float in float3.
  113955. * @param y Second float in float3.
  113956. * @param z Third float in float3.
  113957. * @returns this effect.
  113958. */
  113959. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113960. /**
  113961. * Sets a Vector4 on a uniform variable.
  113962. * @param uniformName Name of the variable.
  113963. * @param vector4 Value to be set.
  113964. * @returns this effect.
  113965. */
  113966. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113967. /**
  113968. * Sets a float4 on a uniform variable.
  113969. * @param uniformName Name of the variable.
  113970. * @param x First float in float4.
  113971. * @param y Second float in float4.
  113972. * @param z Third float in float4.
  113973. * @param w Fourth float in float4.
  113974. * @returns this effect.
  113975. */
  113976. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113977. /**
  113978. * Sets a Color3 on a uniform variable.
  113979. * @param uniformName Name of the variable.
  113980. * @param color3 Value to be set.
  113981. * @returns this effect.
  113982. */
  113983. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113984. /**
  113985. * Sets a Color4 on a uniform variable.
  113986. * @param uniformName Name of the variable.
  113987. * @param color3 Value to be set.
  113988. * @param alpha Alpha value to be set.
  113989. * @returns this effect.
  113990. */
  113991. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113992. /**
  113993. * Sets a Color4 on a uniform variable
  113994. * @param uniformName defines the name of the variable
  113995. * @param color4 defines the value to be set
  113996. * @returns this effect.
  113997. */
  113998. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113999. /** Release all associated resources */
  114000. dispose(): void;
  114001. /**
  114002. * This function will add a new shader to the shader store
  114003. * @param name the name of the shader
  114004. * @param pixelShader optional pixel shader content
  114005. * @param vertexShader optional vertex shader content
  114006. */
  114007. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114008. /**
  114009. * Store of each shader (The can be looked up using effect.key)
  114010. */
  114011. static ShadersStore: {
  114012. [key: string]: string;
  114013. };
  114014. /**
  114015. * Store of each included file for a shader (The can be looked up using effect.key)
  114016. */
  114017. static IncludesShadersStore: {
  114018. [key: string]: string;
  114019. };
  114020. /**
  114021. * Resets the cache of effects.
  114022. */
  114023. static ResetCache(): void;
  114024. }
  114025. }
  114026. declare module BABYLON {
  114027. /**
  114028. * Interface used to describe the capabilities of the engine relatively to the current browser
  114029. */
  114030. export interface EngineCapabilities {
  114031. /** Maximum textures units per fragment shader */
  114032. maxTexturesImageUnits: number;
  114033. /** Maximum texture units per vertex shader */
  114034. maxVertexTextureImageUnits: number;
  114035. /** Maximum textures units in the entire pipeline */
  114036. maxCombinedTexturesImageUnits: number;
  114037. /** Maximum texture size */
  114038. maxTextureSize: number;
  114039. /** Maximum texture samples */
  114040. maxSamples?: number;
  114041. /** Maximum cube texture size */
  114042. maxCubemapTextureSize: number;
  114043. /** Maximum render texture size */
  114044. maxRenderTextureSize: number;
  114045. /** Maximum number of vertex attributes */
  114046. maxVertexAttribs: number;
  114047. /** Maximum number of varyings */
  114048. maxVaryingVectors: number;
  114049. /** Maximum number of uniforms per vertex shader */
  114050. maxVertexUniformVectors: number;
  114051. /** Maximum number of uniforms per fragment shader */
  114052. maxFragmentUniformVectors: number;
  114053. /** Defines if standard derivates (dx/dy) are supported */
  114054. standardDerivatives: boolean;
  114055. /** Defines if s3tc texture compression is supported */
  114056. s3tc?: WEBGL_compressed_texture_s3tc;
  114057. /** Defines if pvrtc texture compression is supported */
  114058. pvrtc: any;
  114059. /** Defines if etc1 texture compression is supported */
  114060. etc1: any;
  114061. /** Defines if etc2 texture compression is supported */
  114062. etc2: any;
  114063. /** Defines if astc texture compression is supported */
  114064. astc: any;
  114065. /** Defines if float textures are supported */
  114066. textureFloat: boolean;
  114067. /** Defines if vertex array objects are supported */
  114068. vertexArrayObject: boolean;
  114069. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114070. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114071. /** Gets the maximum level of anisotropy supported */
  114072. maxAnisotropy: number;
  114073. /** Defines if instancing is supported */
  114074. instancedArrays: boolean;
  114075. /** Defines if 32 bits indices are supported */
  114076. uintIndices: boolean;
  114077. /** Defines if high precision shaders are supported */
  114078. highPrecisionShaderSupported: boolean;
  114079. /** Defines if depth reading in the fragment shader is supported */
  114080. fragmentDepthSupported: boolean;
  114081. /** Defines if float texture linear filtering is supported*/
  114082. textureFloatLinearFiltering: boolean;
  114083. /** Defines if rendering to float textures is supported */
  114084. textureFloatRender: boolean;
  114085. /** Defines if half float textures are supported*/
  114086. textureHalfFloat: boolean;
  114087. /** Defines if half float texture linear filtering is supported*/
  114088. textureHalfFloatLinearFiltering: boolean;
  114089. /** Defines if rendering to half float textures is supported */
  114090. textureHalfFloatRender: boolean;
  114091. /** Defines if textureLOD shader command is supported */
  114092. textureLOD: boolean;
  114093. /** Defines if draw buffers extension is supported */
  114094. drawBuffersExtension: boolean;
  114095. /** Defines if depth textures are supported */
  114096. depthTextureExtension: boolean;
  114097. /** Defines if float color buffer are supported */
  114098. colorBufferFloat: boolean;
  114099. /** Gets disjoint timer query extension (null if not supported) */
  114100. timerQuery?: EXT_disjoint_timer_query;
  114101. /** Defines if timestamp can be used with timer query */
  114102. canUseTimestampForTimerQuery: boolean;
  114103. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114104. multiview?: any;
  114105. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114106. oculusMultiview?: any;
  114107. /** Function used to let the system compiles shaders in background */
  114108. parallelShaderCompile?: {
  114109. COMPLETION_STATUS_KHR: number;
  114110. };
  114111. /** Max number of texture samples for MSAA */
  114112. maxMSAASamples: number;
  114113. /** Defines if the blend min max extension is supported */
  114114. blendMinMax: boolean;
  114115. }
  114116. }
  114117. declare module BABYLON {
  114118. /**
  114119. * @hidden
  114120. **/
  114121. export class DepthCullingState {
  114122. private _isDepthTestDirty;
  114123. private _isDepthMaskDirty;
  114124. private _isDepthFuncDirty;
  114125. private _isCullFaceDirty;
  114126. private _isCullDirty;
  114127. private _isZOffsetDirty;
  114128. private _isFrontFaceDirty;
  114129. private _depthTest;
  114130. private _depthMask;
  114131. private _depthFunc;
  114132. private _cull;
  114133. private _cullFace;
  114134. private _zOffset;
  114135. private _frontFace;
  114136. /**
  114137. * Initializes the state.
  114138. */
  114139. constructor();
  114140. get isDirty(): boolean;
  114141. get zOffset(): number;
  114142. set zOffset(value: number);
  114143. get cullFace(): Nullable<number>;
  114144. set cullFace(value: Nullable<number>);
  114145. get cull(): Nullable<boolean>;
  114146. set cull(value: Nullable<boolean>);
  114147. get depthFunc(): Nullable<number>;
  114148. set depthFunc(value: Nullable<number>);
  114149. get depthMask(): boolean;
  114150. set depthMask(value: boolean);
  114151. get depthTest(): boolean;
  114152. set depthTest(value: boolean);
  114153. get frontFace(): Nullable<number>;
  114154. set frontFace(value: Nullable<number>);
  114155. reset(): void;
  114156. apply(gl: WebGLRenderingContext): void;
  114157. }
  114158. }
  114159. declare module BABYLON {
  114160. /**
  114161. * @hidden
  114162. **/
  114163. export class StencilState {
  114164. /** 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 */
  114165. static readonly ALWAYS: number;
  114166. /** Passed to stencilOperation to specify that stencil value must be kept */
  114167. static readonly KEEP: number;
  114168. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114169. static readonly REPLACE: number;
  114170. private _isStencilTestDirty;
  114171. private _isStencilMaskDirty;
  114172. private _isStencilFuncDirty;
  114173. private _isStencilOpDirty;
  114174. private _stencilTest;
  114175. private _stencilMask;
  114176. private _stencilFunc;
  114177. private _stencilFuncRef;
  114178. private _stencilFuncMask;
  114179. private _stencilOpStencilFail;
  114180. private _stencilOpDepthFail;
  114181. private _stencilOpStencilDepthPass;
  114182. get isDirty(): boolean;
  114183. get stencilFunc(): number;
  114184. set stencilFunc(value: number);
  114185. get stencilFuncRef(): number;
  114186. set stencilFuncRef(value: number);
  114187. get stencilFuncMask(): number;
  114188. set stencilFuncMask(value: number);
  114189. get stencilOpStencilFail(): number;
  114190. set stencilOpStencilFail(value: number);
  114191. get stencilOpDepthFail(): number;
  114192. set stencilOpDepthFail(value: number);
  114193. get stencilOpStencilDepthPass(): number;
  114194. set stencilOpStencilDepthPass(value: number);
  114195. get stencilMask(): number;
  114196. set stencilMask(value: number);
  114197. get stencilTest(): boolean;
  114198. set stencilTest(value: boolean);
  114199. constructor();
  114200. reset(): void;
  114201. apply(gl: WebGLRenderingContext): void;
  114202. }
  114203. }
  114204. declare module BABYLON {
  114205. /**
  114206. * @hidden
  114207. **/
  114208. export class AlphaState {
  114209. private _isAlphaBlendDirty;
  114210. private _isBlendFunctionParametersDirty;
  114211. private _isBlendEquationParametersDirty;
  114212. private _isBlendConstantsDirty;
  114213. private _alphaBlend;
  114214. private _blendFunctionParameters;
  114215. private _blendEquationParameters;
  114216. private _blendConstants;
  114217. /**
  114218. * Initializes the state.
  114219. */
  114220. constructor();
  114221. get isDirty(): boolean;
  114222. get alphaBlend(): boolean;
  114223. set alphaBlend(value: boolean);
  114224. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  114225. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  114226. setAlphaEquationParameters(rgb: number, alpha: number): void;
  114227. reset(): void;
  114228. apply(gl: WebGLRenderingContext): void;
  114229. }
  114230. }
  114231. declare module BABYLON {
  114232. /** @hidden */
  114233. export class WebGL2ShaderProcessor implements IShaderProcessor {
  114234. attributeProcessor(attribute: string): string;
  114235. varyingProcessor(varying: string, isFragment: boolean): string;
  114236. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114237. }
  114238. }
  114239. declare module BABYLON {
  114240. /**
  114241. * Interface for attribute information associated with buffer instanciation
  114242. */
  114243. export interface InstancingAttributeInfo {
  114244. /**
  114245. * Name of the GLSL attribute
  114246. * if attribute index is not specified, this is used to retrieve the index from the effect
  114247. */
  114248. attributeName: string;
  114249. /**
  114250. * Index/offset of the attribute in the vertex shader
  114251. * if not specified, this will be computes from the name.
  114252. */
  114253. index?: number;
  114254. /**
  114255. * size of the attribute, 1, 2, 3 or 4
  114256. */
  114257. attributeSize: number;
  114258. /**
  114259. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  114260. */
  114261. offset: number;
  114262. /**
  114263. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  114264. * default to 1
  114265. */
  114266. divisor?: number;
  114267. /**
  114268. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  114269. * default is FLOAT
  114270. */
  114271. attributeType?: number;
  114272. /**
  114273. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  114274. */
  114275. normalized?: boolean;
  114276. }
  114277. }
  114278. declare module BABYLON {
  114279. interface ThinEngine {
  114280. /**
  114281. * Update a video texture
  114282. * @param texture defines the texture to update
  114283. * @param video defines the video element to use
  114284. * @param invertY defines if data must be stored with Y axis inverted
  114285. */
  114286. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  114287. }
  114288. }
  114289. declare module BABYLON {
  114290. interface ThinEngine {
  114291. /**
  114292. * Creates a dynamic texture
  114293. * @param width defines the width of the texture
  114294. * @param height defines the height of the texture
  114295. * @param generateMipMaps defines if the engine should generate the mip levels
  114296. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  114297. * @returns the dynamic texture inside an InternalTexture
  114298. */
  114299. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  114300. /**
  114301. * Update the content of a dynamic texture
  114302. * @param texture defines the texture to update
  114303. * @param canvas defines the canvas containing the source
  114304. * @param invertY defines if data must be stored with Y axis inverted
  114305. * @param premulAlpha defines if alpha is stored as premultiplied
  114306. * @param format defines the format of the data
  114307. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114308. */
  114309. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  114310. }
  114311. }
  114312. declare module BABYLON {
  114313. /**
  114314. * Settings for finer control over video usage
  114315. */
  114316. export interface VideoTextureSettings {
  114317. /**
  114318. * Applies `autoplay` to video, if specified
  114319. */
  114320. autoPlay?: boolean;
  114321. /**
  114322. * Applies `loop` to video, if specified
  114323. */
  114324. loop?: boolean;
  114325. /**
  114326. * Automatically updates internal texture from video at every frame in the render loop
  114327. */
  114328. autoUpdateTexture: boolean;
  114329. /**
  114330. * Image src displayed during the video loading or until the user interacts with the video.
  114331. */
  114332. poster?: string;
  114333. }
  114334. /**
  114335. * If you want to display a video in your scene, this is the special texture for that.
  114336. * This special texture works similar to other textures, with the exception of a few parameters.
  114337. * @see https://doc.babylonjs.com/how_to/video_texture
  114338. */
  114339. export class VideoTexture extends Texture {
  114340. /**
  114341. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  114342. */
  114343. readonly autoUpdateTexture: boolean;
  114344. /**
  114345. * The video instance used by the texture internally
  114346. */
  114347. readonly video: HTMLVideoElement;
  114348. private _onUserActionRequestedObservable;
  114349. /**
  114350. * Event triggerd when a dom action is required by the user to play the video.
  114351. * This happens due to recent changes in browser policies preventing video to auto start.
  114352. */
  114353. get onUserActionRequestedObservable(): Observable<Texture>;
  114354. private _generateMipMaps;
  114355. private _stillImageCaptured;
  114356. private _displayingPosterTexture;
  114357. private _settings;
  114358. private _createInternalTextureOnEvent;
  114359. private _frameId;
  114360. private _currentSrc;
  114361. /**
  114362. * Creates a video texture.
  114363. * If you want to display a video in your scene, this is the special texture for that.
  114364. * This special texture works similar to other textures, with the exception of a few parameters.
  114365. * @see https://doc.babylonjs.com/how_to/video_texture
  114366. * @param name optional name, will detect from video source, if not defined
  114367. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  114368. * @param scene is obviously the current scene.
  114369. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  114370. * @param invertY is false by default but can be used to invert video on Y axis
  114371. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  114372. * @param settings allows finer control over video usage
  114373. */
  114374. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  114375. private _getName;
  114376. private _getVideo;
  114377. private _createInternalTexture;
  114378. private reset;
  114379. /**
  114380. * @hidden Internal method to initiate `update`.
  114381. */
  114382. _rebuild(): void;
  114383. /**
  114384. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  114385. */
  114386. update(): void;
  114387. /**
  114388. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114389. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114390. */
  114391. updateTexture(isVisible: boolean): void;
  114392. protected _updateInternalTexture: () => void;
  114393. /**
  114394. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114395. * @param url New url.
  114396. */
  114397. updateURL(url: string): void;
  114398. /**
  114399. * Clones the texture.
  114400. * @returns the cloned texture
  114401. */
  114402. clone(): VideoTexture;
  114403. /**
  114404. * Dispose the texture and release its associated resources.
  114405. */
  114406. dispose(): void;
  114407. /**
  114408. * Creates a video texture straight from a stream.
  114409. * @param scene Define the scene the texture should be created in
  114410. * @param stream Define the stream the texture should be created from
  114411. * @returns The created video texture as a promise
  114412. */
  114413. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114414. /**
  114415. * Creates a video texture straight from your WebCam video feed.
  114416. * @param scene Define the scene the texture should be created in
  114417. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114418. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114419. * @returns The created video texture as a promise
  114420. */
  114421. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114422. minWidth: number;
  114423. maxWidth: number;
  114424. minHeight: number;
  114425. maxHeight: number;
  114426. deviceId: string;
  114427. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114428. /**
  114429. * Creates a video texture straight from your WebCam video feed.
  114430. * @param scene Define the scene the texture should be created in
  114431. * @param onReady Define a callback to triggered once the texture will be ready
  114432. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114433. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114434. */
  114435. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114436. minWidth: number;
  114437. maxWidth: number;
  114438. minHeight: number;
  114439. maxHeight: number;
  114440. deviceId: string;
  114441. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114442. }
  114443. }
  114444. declare module BABYLON {
  114445. /**
  114446. * Defines the interface used by objects working like Scene
  114447. * @hidden
  114448. */
  114449. export interface ISceneLike {
  114450. _addPendingData(data: any): void;
  114451. _removePendingData(data: any): void;
  114452. offlineProvider: IOfflineProvider;
  114453. }
  114454. /** Interface defining initialization parameters for Engine class */
  114455. export interface EngineOptions extends WebGLContextAttributes {
  114456. /**
  114457. * Defines if the engine should no exceed a specified device ratio
  114458. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  114459. */
  114460. limitDeviceRatio?: number;
  114461. /**
  114462. * Defines if webvr should be enabled automatically
  114463. * @see https://doc.babylonjs.com/how_to/webvr_camera
  114464. */
  114465. autoEnableWebVR?: boolean;
  114466. /**
  114467. * Defines if webgl2 should be turned off even if supported
  114468. * @see https://doc.babylonjs.com/features/webgl2
  114469. */
  114470. disableWebGL2Support?: boolean;
  114471. /**
  114472. * Defines if webaudio should be initialized as well
  114473. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114474. */
  114475. audioEngine?: boolean;
  114476. /**
  114477. * Defines if animations should run using a deterministic lock step
  114478. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114479. */
  114480. deterministicLockstep?: boolean;
  114481. /** Defines the maximum steps to use with deterministic lock step mode */
  114482. lockstepMaxSteps?: number;
  114483. /** Defines the seconds between each deterministic lock step */
  114484. timeStep?: number;
  114485. /**
  114486. * Defines that engine should ignore context lost events
  114487. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  114488. */
  114489. doNotHandleContextLost?: boolean;
  114490. /**
  114491. * Defines that engine should ignore modifying touch action attribute and style
  114492. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  114493. */
  114494. doNotHandleTouchAction?: boolean;
  114495. /**
  114496. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  114497. */
  114498. useHighPrecisionFloats?: boolean;
  114499. /**
  114500. * Make the canvas XR Compatible for XR sessions
  114501. */
  114502. xrCompatible?: boolean;
  114503. /**
  114504. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  114505. */
  114506. useHighPrecisionMatrix?: boolean;
  114507. }
  114508. /**
  114509. * The base engine class (root of all engines)
  114510. */
  114511. export class ThinEngine {
  114512. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  114513. static ExceptionList: ({
  114514. key: string;
  114515. capture: string;
  114516. captureConstraint: number;
  114517. targets: string[];
  114518. } | {
  114519. key: string;
  114520. capture: null;
  114521. captureConstraint: null;
  114522. targets: string[];
  114523. })[];
  114524. /** @hidden */
  114525. static _TextureLoaders: IInternalTextureLoader[];
  114526. /**
  114527. * Returns the current npm package of the sdk
  114528. */
  114529. static get NpmPackage(): string;
  114530. /**
  114531. * Returns the current version of the framework
  114532. */
  114533. static get Version(): string;
  114534. /**
  114535. * Returns a string describing the current engine
  114536. */
  114537. get description(): string;
  114538. /**
  114539. * Gets or sets the epsilon value used by collision engine
  114540. */
  114541. static CollisionsEpsilon: number;
  114542. /**
  114543. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114544. */
  114545. static get ShadersRepository(): string;
  114546. static set ShadersRepository(value: string);
  114547. /** @hidden */
  114548. _shaderProcessor: IShaderProcessor;
  114549. /**
  114550. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  114551. */
  114552. forcePOTTextures: boolean;
  114553. /**
  114554. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  114555. */
  114556. isFullscreen: boolean;
  114557. /**
  114558. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  114559. */
  114560. cullBackFaces: boolean;
  114561. /**
  114562. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  114563. */
  114564. renderEvenInBackground: boolean;
  114565. /**
  114566. * Gets or sets a boolean indicating that cache can be kept between frames
  114567. */
  114568. preventCacheWipeBetweenFrames: boolean;
  114569. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  114570. validateShaderPrograms: boolean;
  114571. /**
  114572. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  114573. * This can provide greater z depth for distant objects.
  114574. */
  114575. useReverseDepthBuffer: boolean;
  114576. /**
  114577. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  114578. */
  114579. disableUniformBuffers: boolean;
  114580. /** @hidden */
  114581. _uniformBuffers: UniformBuffer[];
  114582. /**
  114583. * Gets a boolean indicating that the engine supports uniform buffers
  114584. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  114585. */
  114586. get supportsUniformBuffers(): boolean;
  114587. /** @hidden */
  114588. _gl: WebGLRenderingContext;
  114589. /** @hidden */
  114590. _webGLVersion: number;
  114591. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114592. protected _windowIsBackground: boolean;
  114593. protected _creationOptions: EngineOptions;
  114594. protected _highPrecisionShadersAllowed: boolean;
  114595. /** @hidden */
  114596. get _shouldUseHighPrecisionShader(): boolean;
  114597. /**
  114598. * Gets a boolean indicating that only power of 2 textures are supported
  114599. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114600. */
  114601. get needPOTTextures(): boolean;
  114602. /** @hidden */
  114603. _badOS: boolean;
  114604. /** @hidden */
  114605. _badDesktopOS: boolean;
  114606. private _hardwareScalingLevel;
  114607. /** @hidden */
  114608. _caps: EngineCapabilities;
  114609. private _isStencilEnable;
  114610. private _glVersion;
  114611. private _glRenderer;
  114612. private _glVendor;
  114613. /** @hidden */
  114614. _videoTextureSupported: boolean;
  114615. protected _renderingQueueLaunched: boolean;
  114616. protected _activeRenderLoops: (() => void)[];
  114617. /**
  114618. * Observable signaled when a context lost event is raised
  114619. */
  114620. onContextLostObservable: Observable<ThinEngine>;
  114621. /**
  114622. * Observable signaled when a context restored event is raised
  114623. */
  114624. onContextRestoredObservable: Observable<ThinEngine>;
  114625. private _onContextLost;
  114626. private _onContextRestored;
  114627. protected _contextWasLost: boolean;
  114628. /** @hidden */
  114629. _doNotHandleContextLost: boolean;
  114630. /**
  114631. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114632. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114633. */
  114634. get doNotHandleContextLost(): boolean;
  114635. set doNotHandleContextLost(value: boolean);
  114636. /**
  114637. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114638. */
  114639. disableVertexArrayObjects: boolean;
  114640. /** @hidden */
  114641. protected _colorWrite: boolean;
  114642. /** @hidden */
  114643. protected _colorWriteChanged: boolean;
  114644. /** @hidden */
  114645. protected _depthCullingState: DepthCullingState;
  114646. /** @hidden */
  114647. protected _stencilState: StencilState;
  114648. /** @hidden */
  114649. _alphaState: AlphaState;
  114650. /** @hidden */
  114651. _alphaMode: number;
  114652. /** @hidden */
  114653. _alphaEquation: number;
  114654. /** @hidden */
  114655. _internalTexturesCache: InternalTexture[];
  114656. /** @hidden */
  114657. protected _activeChannel: number;
  114658. private _currentTextureChannel;
  114659. /** @hidden */
  114660. protected _boundTexturesCache: {
  114661. [key: string]: Nullable<InternalTexture>;
  114662. };
  114663. /** @hidden */
  114664. protected _currentEffect: Nullable<Effect>;
  114665. /** @hidden */
  114666. protected _currentProgram: Nullable<WebGLProgram>;
  114667. private _compiledEffects;
  114668. private _vertexAttribArraysEnabled;
  114669. /** @hidden */
  114670. protected _cachedViewport: Nullable<IViewportLike>;
  114671. private _cachedVertexArrayObject;
  114672. /** @hidden */
  114673. protected _cachedVertexBuffers: any;
  114674. /** @hidden */
  114675. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114676. /** @hidden */
  114677. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114678. /** @hidden */
  114679. _currentRenderTarget: Nullable<InternalTexture>;
  114680. private _uintIndicesCurrentlySet;
  114681. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114682. /** @hidden */
  114683. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114684. /** @hidden */
  114685. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114686. private _currentBufferPointers;
  114687. private _currentInstanceLocations;
  114688. private _currentInstanceBuffers;
  114689. private _textureUnits;
  114690. /** @hidden */
  114691. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114692. /** @hidden */
  114693. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114694. /** @hidden */
  114695. _boundRenderFunction: any;
  114696. private _vaoRecordInProgress;
  114697. private _mustWipeVertexAttributes;
  114698. private _emptyTexture;
  114699. private _emptyCubeTexture;
  114700. private _emptyTexture3D;
  114701. private _emptyTexture2DArray;
  114702. /** @hidden */
  114703. _frameHandler: number;
  114704. private _nextFreeTextureSlots;
  114705. private _maxSimultaneousTextures;
  114706. private _activeRequests;
  114707. /** @hidden */
  114708. _transformTextureUrl: Nullable<(url: string) => string>;
  114709. protected get _supportsHardwareTextureRescaling(): boolean;
  114710. private _framebufferDimensionsObject;
  114711. /**
  114712. * sets the object from which width and height will be taken from when getting render width and height
  114713. * Will fallback to the gl object
  114714. * @param dimensions the framebuffer width and height that will be used.
  114715. */
  114716. set framebufferDimensionsObject(dimensions: Nullable<{
  114717. framebufferWidth: number;
  114718. framebufferHeight: number;
  114719. }>);
  114720. /**
  114721. * Gets the current viewport
  114722. */
  114723. get currentViewport(): Nullable<IViewportLike>;
  114724. /**
  114725. * Gets the default empty texture
  114726. */
  114727. get emptyTexture(): InternalTexture;
  114728. /**
  114729. * Gets the default empty 3D texture
  114730. */
  114731. get emptyTexture3D(): InternalTexture;
  114732. /**
  114733. * Gets the default empty 2D array texture
  114734. */
  114735. get emptyTexture2DArray(): InternalTexture;
  114736. /**
  114737. * Gets the default empty cube texture
  114738. */
  114739. get emptyCubeTexture(): InternalTexture;
  114740. /**
  114741. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114742. */
  114743. readonly premultipliedAlpha: boolean;
  114744. /**
  114745. * Observable event triggered before each texture is initialized
  114746. */
  114747. onBeforeTextureInitObservable: Observable<Texture>;
  114748. /**
  114749. * Creates a new engine
  114750. * @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
  114751. * @param antialias defines enable antialiasing (default: false)
  114752. * @param options defines further options to be sent to the getContext() function
  114753. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114754. */
  114755. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114756. private _rebuildInternalTextures;
  114757. private _rebuildEffects;
  114758. /**
  114759. * Gets a boolean indicating if all created effects are ready
  114760. * @returns true if all effects are ready
  114761. */
  114762. areAllEffectsReady(): boolean;
  114763. protected _rebuildBuffers(): void;
  114764. protected _initGLContext(): void;
  114765. /**
  114766. * Gets version of the current webGL context
  114767. */
  114768. get webGLVersion(): number;
  114769. /**
  114770. * Gets a string identifying the name of the class
  114771. * @returns "Engine" string
  114772. */
  114773. getClassName(): string;
  114774. /**
  114775. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114776. */
  114777. get isStencilEnable(): boolean;
  114778. /** @hidden */
  114779. _prepareWorkingCanvas(): void;
  114780. /**
  114781. * Reset the texture cache to empty state
  114782. */
  114783. resetTextureCache(): void;
  114784. /**
  114785. * Gets an object containing information about the current webGL context
  114786. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114787. */
  114788. getGlInfo(): {
  114789. vendor: string;
  114790. renderer: string;
  114791. version: string;
  114792. };
  114793. /**
  114794. * Defines the hardware scaling level.
  114795. * By default the hardware scaling level is computed from the window device ratio.
  114796. * 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.
  114797. * @param level defines the level to use
  114798. */
  114799. setHardwareScalingLevel(level: number): void;
  114800. /**
  114801. * Gets the current hardware scaling level.
  114802. * By default the hardware scaling level is computed from the window device ratio.
  114803. * 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.
  114804. * @returns a number indicating the current hardware scaling level
  114805. */
  114806. getHardwareScalingLevel(): number;
  114807. /**
  114808. * Gets the list of loaded textures
  114809. * @returns an array containing all loaded textures
  114810. */
  114811. getLoadedTexturesCache(): InternalTexture[];
  114812. /**
  114813. * Gets the object containing all engine capabilities
  114814. * @returns the EngineCapabilities object
  114815. */
  114816. getCaps(): EngineCapabilities;
  114817. /**
  114818. * stop executing a render loop function and remove it from the execution array
  114819. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114820. */
  114821. stopRenderLoop(renderFunction?: () => void): void;
  114822. /** @hidden */
  114823. _renderLoop(): void;
  114824. /**
  114825. * Gets the HTML canvas attached with the current webGL context
  114826. * @returns a HTML canvas
  114827. */
  114828. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114829. /**
  114830. * Gets host window
  114831. * @returns the host window object
  114832. */
  114833. getHostWindow(): Nullable<Window>;
  114834. /**
  114835. * Gets the current render width
  114836. * @param useScreen defines if screen size must be used (or the current render target if any)
  114837. * @returns a number defining the current render width
  114838. */
  114839. getRenderWidth(useScreen?: boolean): number;
  114840. /**
  114841. * Gets the current render height
  114842. * @param useScreen defines if screen size must be used (or the current render target if any)
  114843. * @returns a number defining the current render height
  114844. */
  114845. getRenderHeight(useScreen?: boolean): number;
  114846. /**
  114847. * Can be used to override the current requestAnimationFrame requester.
  114848. * @hidden
  114849. */
  114850. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114851. /**
  114852. * Register and execute a render loop. The engine can have more than one render function
  114853. * @param renderFunction defines the function to continuously execute
  114854. */
  114855. runRenderLoop(renderFunction: () => void): void;
  114856. /**
  114857. * Clear the current render buffer or the current render target (if any is set up)
  114858. * @param color defines the color to use
  114859. * @param backBuffer defines if the back buffer must be cleared
  114860. * @param depth defines if the depth buffer must be cleared
  114861. * @param stencil defines if the stencil buffer must be cleared
  114862. */
  114863. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114864. private _viewportCached;
  114865. /** @hidden */
  114866. _viewport(x: number, y: number, width: number, height: number): void;
  114867. /**
  114868. * Set the WebGL's viewport
  114869. * @param viewport defines the viewport element to be used
  114870. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114871. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114872. */
  114873. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114874. /**
  114875. * Begin a new frame
  114876. */
  114877. beginFrame(): void;
  114878. /**
  114879. * Enf the current frame
  114880. */
  114881. endFrame(): void;
  114882. /**
  114883. * Resize the view according to the canvas' size
  114884. */
  114885. resize(): void;
  114886. /**
  114887. * Force a specific size of the canvas
  114888. * @param width defines the new canvas' width
  114889. * @param height defines the new canvas' height
  114890. * @returns true if the size was changed
  114891. */
  114892. setSize(width: number, height: number): boolean;
  114893. /**
  114894. * Binds the frame buffer to the specified texture.
  114895. * @param texture The texture to render to or null for the default canvas
  114896. * @param faceIndex The face of the texture to render to in case of cube texture
  114897. * @param requiredWidth The width of the target to render to
  114898. * @param requiredHeight The height of the target to render to
  114899. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114900. * @param lodLevel defines the lod level to bind to the frame buffer
  114901. * @param layer defines the 2d array index to bind to frame buffer to
  114902. */
  114903. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114904. /** @hidden */
  114905. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114906. /**
  114907. * Unbind the current render target texture from the webGL context
  114908. * @param texture defines the render target texture to unbind
  114909. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114910. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114911. */
  114912. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114913. /**
  114914. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114915. */
  114916. flushFramebuffer(): void;
  114917. /**
  114918. * Unbind the current render target and bind the default framebuffer
  114919. */
  114920. restoreDefaultFramebuffer(): void;
  114921. /** @hidden */
  114922. protected _resetVertexBufferBinding(): void;
  114923. /**
  114924. * Creates a vertex buffer
  114925. * @param data the data for the vertex buffer
  114926. * @returns the new WebGL static buffer
  114927. */
  114928. createVertexBuffer(data: DataArray): DataBuffer;
  114929. private _createVertexBuffer;
  114930. /**
  114931. * Creates a dynamic vertex buffer
  114932. * @param data the data for the dynamic vertex buffer
  114933. * @returns the new WebGL dynamic buffer
  114934. */
  114935. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114936. protected _resetIndexBufferBinding(): void;
  114937. /**
  114938. * Creates a new index buffer
  114939. * @param indices defines the content of the index buffer
  114940. * @param updatable defines if the index buffer must be updatable
  114941. * @returns a new webGL buffer
  114942. */
  114943. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114944. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114945. /**
  114946. * Bind a webGL buffer to the webGL context
  114947. * @param buffer defines the buffer to bind
  114948. */
  114949. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114950. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114951. private bindBuffer;
  114952. /**
  114953. * update the bound buffer with the given data
  114954. * @param data defines the data to update
  114955. */
  114956. updateArrayBuffer(data: Float32Array): void;
  114957. private _vertexAttribPointer;
  114958. /** @hidden */
  114959. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114960. private _bindVertexBuffersAttributes;
  114961. /**
  114962. * Records a vertex array object
  114963. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114964. * @param vertexBuffers defines the list of vertex buffers to store
  114965. * @param indexBuffer defines the index buffer to store
  114966. * @param effect defines the effect to store
  114967. * @returns the new vertex array object
  114968. */
  114969. recordVertexArrayObject(vertexBuffers: {
  114970. [key: string]: VertexBuffer;
  114971. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114972. /**
  114973. * Bind a specific vertex array object
  114974. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114975. * @param vertexArrayObject defines the vertex array object to bind
  114976. * @param indexBuffer defines the index buffer to bind
  114977. */
  114978. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114979. /**
  114980. * Bind webGl buffers directly to the webGL context
  114981. * @param vertexBuffer defines the vertex buffer to bind
  114982. * @param indexBuffer defines the index buffer to bind
  114983. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114984. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114985. * @param effect defines the effect associated with the vertex buffer
  114986. */
  114987. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114988. private _unbindVertexArrayObject;
  114989. /**
  114990. * Bind a list of vertex buffers to the webGL context
  114991. * @param vertexBuffers defines the list of vertex buffers to bind
  114992. * @param indexBuffer defines the index buffer to bind
  114993. * @param effect defines the effect associated with the vertex buffers
  114994. */
  114995. bindBuffers(vertexBuffers: {
  114996. [key: string]: Nullable<VertexBuffer>;
  114997. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114998. /**
  114999. * Unbind all instance attributes
  115000. */
  115001. unbindInstanceAttributes(): void;
  115002. /**
  115003. * Release and free the memory of a vertex array object
  115004. * @param vao defines the vertex array object to delete
  115005. */
  115006. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115007. /** @hidden */
  115008. _releaseBuffer(buffer: DataBuffer): boolean;
  115009. protected _deleteBuffer(buffer: DataBuffer): void;
  115010. /**
  115011. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115012. * @param instancesBuffer defines the webGL buffer to update and bind
  115013. * @param data defines the data to store in the buffer
  115014. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115015. */
  115016. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115017. /**
  115018. * Bind the content of a webGL buffer used with instantiation
  115019. * @param instancesBuffer defines the webGL buffer to bind
  115020. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115021. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115022. */
  115023. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115024. /**
  115025. * Disable the instance attribute corresponding to the name in parameter
  115026. * @param name defines the name of the attribute to disable
  115027. */
  115028. disableInstanceAttributeByName(name: string): void;
  115029. /**
  115030. * Disable the instance attribute corresponding to the location in parameter
  115031. * @param attributeLocation defines the attribute location of the attribute to disable
  115032. */
  115033. disableInstanceAttribute(attributeLocation: number): void;
  115034. /**
  115035. * Disable the attribute corresponding to the location in parameter
  115036. * @param attributeLocation defines the attribute location of the attribute to disable
  115037. */
  115038. disableAttributeByIndex(attributeLocation: number): void;
  115039. /**
  115040. * Send a draw order
  115041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115042. * @param indexStart defines the starting index
  115043. * @param indexCount defines the number of index to draw
  115044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115045. */
  115046. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115047. /**
  115048. * Draw a list of points
  115049. * @param verticesStart defines the index of first vertex to draw
  115050. * @param verticesCount defines the count of vertices to draw
  115051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115052. */
  115053. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115054. /**
  115055. * Draw a list of unindexed primitives
  115056. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115057. * @param verticesStart defines the index of first vertex to draw
  115058. * @param verticesCount defines the count of vertices to draw
  115059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115060. */
  115061. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115062. /**
  115063. * Draw a list of indexed primitives
  115064. * @param fillMode defines the primitive to use
  115065. * @param indexStart defines the starting index
  115066. * @param indexCount defines the number of index to draw
  115067. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115068. */
  115069. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115070. /**
  115071. * Draw a list of unindexed primitives
  115072. * @param fillMode defines the primitive to use
  115073. * @param verticesStart defines the index of first vertex to draw
  115074. * @param verticesCount defines the count of vertices to draw
  115075. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115076. */
  115077. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115078. private _drawMode;
  115079. /** @hidden */
  115080. protected _reportDrawCall(): void;
  115081. /** @hidden */
  115082. _releaseEffect(effect: Effect): void;
  115083. /** @hidden */
  115084. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115085. /**
  115086. * Create a new effect (used to store vertex/fragment shaders)
  115087. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115088. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115089. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115090. * @param samplers defines an array of string used to represent textures
  115091. * @param defines defines the string containing the defines to use to compile the shaders
  115092. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115093. * @param onCompiled defines a function to call when the effect creation is successful
  115094. * @param onError defines a function to call when the effect creation has failed
  115095. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115096. * @returns the new Effect
  115097. */
  115098. 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;
  115099. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115100. private _compileShader;
  115101. private _compileRawShader;
  115102. /** @hidden */
  115103. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115104. /**
  115105. * Directly creates a webGL program
  115106. * @param pipelineContext defines the pipeline context to attach to
  115107. * @param vertexCode defines the vertex shader code to use
  115108. * @param fragmentCode defines the fragment shader code to use
  115109. * @param context defines the webGL context to use (if not set, the current one will be used)
  115110. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115111. * @returns the new webGL program
  115112. */
  115113. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115114. /**
  115115. * Creates a webGL program
  115116. * @param pipelineContext defines the pipeline context to attach to
  115117. * @param vertexCode defines the vertex shader code to use
  115118. * @param fragmentCode defines the fragment shader code to use
  115119. * @param defines defines the string containing the defines to use to compile the shaders
  115120. * @param context defines the webGL context to use (if not set, the current one will be used)
  115121. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115122. * @returns the new webGL program
  115123. */
  115124. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115125. /**
  115126. * Creates a new pipeline context
  115127. * @returns the new pipeline
  115128. */
  115129. createPipelineContext(): IPipelineContext;
  115130. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115131. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115132. /** @hidden */
  115133. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115134. /** @hidden */
  115135. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115136. /** @hidden */
  115137. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115138. /**
  115139. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115140. * @param pipelineContext defines the pipeline context to use
  115141. * @param uniformsNames defines the list of uniform names
  115142. * @returns an array of webGL uniform locations
  115143. */
  115144. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115145. /**
  115146. * Gets the lsit of active attributes for a given webGL program
  115147. * @param pipelineContext defines the pipeline context to use
  115148. * @param attributesNames defines the list of attribute names to get
  115149. * @returns an array of indices indicating the offset of each attribute
  115150. */
  115151. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115152. /**
  115153. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115154. * @param effect defines the effect to activate
  115155. */
  115156. enableEffect(effect: Nullable<Effect>): void;
  115157. /**
  115158. * Set the value of an uniform to a number (int)
  115159. * @param uniform defines the webGL uniform location where to store the value
  115160. * @param value defines the int number to store
  115161. */
  115162. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115163. /**
  115164. * Set the value of an uniform to an array of int32
  115165. * @param uniform defines the webGL uniform location where to store the value
  115166. * @param array defines the array of int32 to store
  115167. */
  115168. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115169. /**
  115170. * Set the value of an uniform to an array of int32 (stored as vec2)
  115171. * @param uniform defines the webGL uniform location where to store the value
  115172. * @param array defines the array of int32 to store
  115173. */
  115174. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115175. /**
  115176. * Set the value of an uniform to an array of int32 (stored as vec3)
  115177. * @param uniform defines the webGL uniform location where to store the value
  115178. * @param array defines the array of int32 to store
  115179. */
  115180. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115181. /**
  115182. * Set the value of an uniform to an array of int32 (stored as vec4)
  115183. * @param uniform defines the webGL uniform location where to store the value
  115184. * @param array defines the array of int32 to store
  115185. */
  115186. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115187. /**
  115188. * Set the value of an uniform to an array of number
  115189. * @param uniform defines the webGL uniform location where to store the value
  115190. * @param array defines the array of number to store
  115191. */
  115192. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115193. /**
  115194. * Set the value of an uniform to an array of number (stored as vec2)
  115195. * @param uniform defines the webGL uniform location where to store the value
  115196. * @param array defines the array of number to store
  115197. */
  115198. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115199. /**
  115200. * Set the value of an uniform to an array of number (stored as vec3)
  115201. * @param uniform defines the webGL uniform location where to store the value
  115202. * @param array defines the array of number to store
  115203. */
  115204. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115205. /**
  115206. * Set the value of an uniform to an array of number (stored as vec4)
  115207. * @param uniform defines the webGL uniform location where to store the value
  115208. * @param array defines the array of number to store
  115209. */
  115210. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115211. /**
  115212. * Set the value of an uniform to an array of float32 (stored as matrices)
  115213. * @param uniform defines the webGL uniform location where to store the value
  115214. * @param matrices defines the array of float32 to store
  115215. */
  115216. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  115217. /**
  115218. * Set the value of an uniform to a matrix (3x3)
  115219. * @param uniform defines the webGL uniform location where to store the value
  115220. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115221. */
  115222. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115223. /**
  115224. * Set the value of an uniform to a matrix (2x2)
  115225. * @param uniform defines the webGL uniform location where to store the value
  115226. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115227. */
  115228. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115229. /**
  115230. * Set the value of an uniform to a number (float)
  115231. * @param uniform defines the webGL uniform location where to store the value
  115232. * @param value defines the float number to store
  115233. */
  115234. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115235. /**
  115236. * Set the value of an uniform to a vec2
  115237. * @param uniform defines the webGL uniform location where to store the value
  115238. * @param x defines the 1st component of the value
  115239. * @param y defines the 2nd component of the value
  115240. */
  115241. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  115242. /**
  115243. * Set the value of an uniform to a vec3
  115244. * @param uniform defines the webGL uniform location where to store the value
  115245. * @param x defines the 1st component of the value
  115246. * @param y defines the 2nd component of the value
  115247. * @param z defines the 3rd component of the value
  115248. */
  115249. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  115250. /**
  115251. * Set the value of an uniform to a vec4
  115252. * @param uniform defines the webGL uniform location where to store the value
  115253. * @param x defines the 1st component of the value
  115254. * @param y defines the 2nd component of the value
  115255. * @param z defines the 3rd component of the value
  115256. * @param w defines the 4th component of the value
  115257. */
  115258. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  115259. /**
  115260. * Apply all cached states (depth, culling, stencil and alpha)
  115261. */
  115262. applyStates(): void;
  115263. /**
  115264. * Enable or disable color writing
  115265. * @param enable defines the state to set
  115266. */
  115267. setColorWrite(enable: boolean): void;
  115268. /**
  115269. * Gets a boolean indicating if color writing is enabled
  115270. * @returns the current color writing state
  115271. */
  115272. getColorWrite(): boolean;
  115273. /**
  115274. * Gets the depth culling state manager
  115275. */
  115276. get depthCullingState(): DepthCullingState;
  115277. /**
  115278. * Gets the alpha state manager
  115279. */
  115280. get alphaState(): AlphaState;
  115281. /**
  115282. * Gets the stencil state manager
  115283. */
  115284. get stencilState(): StencilState;
  115285. /**
  115286. * Clears the list of texture accessible through engine.
  115287. * This can help preventing texture load conflict due to name collision.
  115288. */
  115289. clearInternalTexturesCache(): void;
  115290. /**
  115291. * Force the entire cache to be cleared
  115292. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115293. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115294. */
  115295. wipeCaches(bruteForce?: boolean): void;
  115296. /** @hidden */
  115297. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  115298. min: number;
  115299. mag: number;
  115300. };
  115301. /** @hidden */
  115302. _createTexture(): WebGLTexture;
  115303. /**
  115304. * Usually called from Texture.ts.
  115305. * Passed information to create a WebGLTexture
  115306. * @param url defines a value which contains one of the following:
  115307. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115308. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115309. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115310. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115311. * @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)
  115312. * @param scene needed for loading to the correct scene
  115313. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115314. * @param onLoad optional callback to be called upon successful completion
  115315. * @param onError optional callback to be called upon failure
  115316. * @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
  115317. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115318. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115319. * @param forcedExtension defines the extension to use to pick the right loader
  115320. * @param mimeType defines an optional mime type
  115321. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115322. */
  115323. 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;
  115324. /**
  115325. * Loads an image as an HTMLImageElement.
  115326. * @param input url string, ArrayBuffer, or Blob to load
  115327. * @param onLoad callback called when the image successfully loads
  115328. * @param onError callback called when the image fails to load
  115329. * @param offlineProvider offline provider for caching
  115330. * @param mimeType optional mime type
  115331. * @returns the HTMLImageElement of the loaded image
  115332. * @hidden
  115333. */
  115334. 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>;
  115335. /**
  115336. * @hidden
  115337. */
  115338. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115339. private _unpackFlipYCached;
  115340. /**
  115341. * In case you are sharing the context with other applications, it might
  115342. * be interested to not cache the unpack flip y state to ensure a consistent
  115343. * value would be set.
  115344. */
  115345. enableUnpackFlipYCached: boolean;
  115346. /** @hidden */
  115347. _unpackFlipY(value: boolean): void;
  115348. /** @hidden */
  115349. _getUnpackAlignement(): number;
  115350. private _getTextureTarget;
  115351. /**
  115352. * Update the sampling mode of a given texture
  115353. * @param samplingMode defines the required sampling mode
  115354. * @param texture defines the texture to update
  115355. * @param generateMipMaps defines whether to generate mipmaps for the texture
  115356. */
  115357. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  115358. /**
  115359. * Update the sampling mode of a given texture
  115360. * @param texture defines the texture to update
  115361. * @param wrapU defines the texture wrap mode of the u coordinates
  115362. * @param wrapV defines the texture wrap mode of the v coordinates
  115363. * @param wrapR defines the texture wrap mode of the r coordinates
  115364. */
  115365. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  115366. /** @hidden */
  115367. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  115368. width: number;
  115369. height: number;
  115370. layers?: number;
  115371. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  115372. /** @hidden */
  115373. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115374. /** @hidden */
  115375. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  115376. /**
  115377. * Update a portion of an internal texture
  115378. * @param texture defines the texture to update
  115379. * @param imageData defines the data to store into the texture
  115380. * @param xOffset defines the x coordinates of the update rectangle
  115381. * @param yOffset defines the y coordinates of the update rectangle
  115382. * @param width defines the width of the update rectangle
  115383. * @param height defines the height of the update rectangle
  115384. * @param faceIndex defines the face index if texture is a cube (0 by default)
  115385. * @param lod defines the lod level to update (0 by default)
  115386. */
  115387. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  115388. /** @hidden */
  115389. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115390. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115391. private _prepareWebGLTexture;
  115392. /** @hidden */
  115393. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115394. private _getDepthStencilBuffer;
  115395. /** @hidden */
  115396. _releaseFramebufferObjects(texture: InternalTexture): void;
  115397. /** @hidden */
  115398. _releaseTexture(texture: InternalTexture): void;
  115399. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115400. protected _setProgram(program: WebGLProgram): void;
  115401. protected _boundUniforms: {
  115402. [key: number]: WebGLUniformLocation;
  115403. };
  115404. /**
  115405. * Binds an effect to the webGL context
  115406. * @param effect defines the effect to bind
  115407. */
  115408. bindSamplers(effect: Effect): void;
  115409. private _activateCurrentTexture;
  115410. /** @hidden */
  115411. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115412. /** @hidden */
  115413. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115414. /**
  115415. * Unbind all textures from the webGL context
  115416. */
  115417. unbindAllTextures(): void;
  115418. /**
  115419. * Sets a texture to the according uniform.
  115420. * @param channel The texture channel
  115421. * @param uniform The uniform to set
  115422. * @param texture The texture to apply
  115423. */
  115424. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115425. private _bindSamplerUniformToChannel;
  115426. private _getTextureWrapMode;
  115427. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115428. /**
  115429. * Sets an array of texture to the webGL context
  115430. * @param channel defines the channel where the texture array must be set
  115431. * @param uniform defines the associated uniform location
  115432. * @param textures defines the array of textures to bind
  115433. */
  115434. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115435. /** @hidden */
  115436. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115437. private _setTextureParameterFloat;
  115438. private _setTextureParameterInteger;
  115439. /**
  115440. * Unbind all vertex attributes from the webGL context
  115441. */
  115442. unbindAllAttributes(): void;
  115443. /**
  115444. * 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
  115445. */
  115446. releaseEffects(): void;
  115447. /**
  115448. * Dispose and release all associated resources
  115449. */
  115450. dispose(): void;
  115451. /**
  115452. * Attach a new callback raised when context lost event is fired
  115453. * @param callback defines the callback to call
  115454. */
  115455. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115456. /**
  115457. * Attach a new callback raised when context restored event is fired
  115458. * @param callback defines the callback to call
  115459. */
  115460. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115461. /**
  115462. * Get the current error code of the webGL context
  115463. * @returns the error code
  115464. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115465. */
  115466. getError(): number;
  115467. private _canRenderToFloatFramebuffer;
  115468. private _canRenderToHalfFloatFramebuffer;
  115469. private _canRenderToFramebuffer;
  115470. /** @hidden */
  115471. _getWebGLTextureType(type: number): number;
  115472. /** @hidden */
  115473. _getInternalFormat(format: number): number;
  115474. /** @hidden */
  115475. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  115476. /** @hidden */
  115477. _getRGBAMultiSampleBufferFormat(type: number): number;
  115478. /** @hidden */
  115479. _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;
  115480. /**
  115481. * Loads a file from a url
  115482. * @param url url to load
  115483. * @param onSuccess callback called when the file successfully loads
  115484. * @param onProgress callback called while file is loading (if the server supports this mode)
  115485. * @param offlineProvider defines the offline provider for caching
  115486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115487. * @param onError callback called when the file fails to load
  115488. * @returns a file request object
  115489. * @hidden
  115490. */
  115491. 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;
  115492. /**
  115493. * Reads pixels from the current frame buffer. Please note that this function can be slow
  115494. * @param x defines the x coordinate of the rectangle where pixels must be read
  115495. * @param y defines the y coordinate of the rectangle where pixels must be read
  115496. * @param width defines the width of the rectangle where pixels must be read
  115497. * @param height defines the height of the rectangle where pixels must be read
  115498. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  115499. * @returns a Uint8Array containing RGBA colors
  115500. */
  115501. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  115502. private static _isSupported;
  115503. /**
  115504. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  115505. * @returns true if the engine can be created
  115506. * @ignorenaming
  115507. */
  115508. static isSupported(): boolean;
  115509. /**
  115510. * Find the next highest power of two.
  115511. * @param x Number to start search from.
  115512. * @return Next highest power of two.
  115513. */
  115514. static CeilingPOT(x: number): number;
  115515. /**
  115516. * Find the next lowest power of two.
  115517. * @param x Number to start search from.
  115518. * @return Next lowest power of two.
  115519. */
  115520. static FloorPOT(x: number): number;
  115521. /**
  115522. * Find the nearest power of two.
  115523. * @param x Number to start search from.
  115524. * @return Next nearest power of two.
  115525. */
  115526. static NearestPOT(x: number): number;
  115527. /**
  115528. * Get the closest exponent of two
  115529. * @param value defines the value to approximate
  115530. * @param max defines the maximum value to return
  115531. * @param mode defines how to define the closest value
  115532. * @returns closest exponent of two of the given value
  115533. */
  115534. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  115535. /**
  115536. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  115537. * @param func - the function to be called
  115538. * @param requester - the object that will request the next frame. Falls back to window.
  115539. * @returns frame number
  115540. */
  115541. static QueueNewFrame(func: () => void, requester?: any): number;
  115542. /**
  115543. * Gets host document
  115544. * @returns the host document object
  115545. */
  115546. getHostDocument(): Nullable<Document>;
  115547. }
  115548. }
  115549. declare module BABYLON {
  115550. /**
  115551. * Class representing spherical harmonics coefficients to the 3rd degree
  115552. */
  115553. export class SphericalHarmonics {
  115554. /**
  115555. * Defines whether or not the harmonics have been prescaled for rendering.
  115556. */
  115557. preScaled: boolean;
  115558. /**
  115559. * The l0,0 coefficients of the spherical harmonics
  115560. */
  115561. l00: Vector3;
  115562. /**
  115563. * The l1,-1 coefficients of the spherical harmonics
  115564. */
  115565. l1_1: Vector3;
  115566. /**
  115567. * The l1,0 coefficients of the spherical harmonics
  115568. */
  115569. l10: Vector3;
  115570. /**
  115571. * The l1,1 coefficients of the spherical harmonics
  115572. */
  115573. l11: Vector3;
  115574. /**
  115575. * The l2,-2 coefficients of the spherical harmonics
  115576. */
  115577. l2_2: Vector3;
  115578. /**
  115579. * The l2,-1 coefficients of the spherical harmonics
  115580. */
  115581. l2_1: Vector3;
  115582. /**
  115583. * The l2,0 coefficients of the spherical harmonics
  115584. */
  115585. l20: Vector3;
  115586. /**
  115587. * The l2,1 coefficients of the spherical harmonics
  115588. */
  115589. l21: Vector3;
  115590. /**
  115591. * The l2,2 coefficients of the spherical harmonics
  115592. */
  115593. l22: Vector3;
  115594. /**
  115595. * Adds a light to the spherical harmonics
  115596. * @param direction the direction of the light
  115597. * @param color the color of the light
  115598. * @param deltaSolidAngle the delta solid angle of the light
  115599. */
  115600. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115601. /**
  115602. * Scales the spherical harmonics by the given amount
  115603. * @param scale the amount to scale
  115604. */
  115605. scaleInPlace(scale: number): void;
  115606. /**
  115607. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115608. *
  115609. * ```
  115610. * E_lm = A_l * L_lm
  115611. * ```
  115612. *
  115613. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115614. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115615. * the scaling factors are given in equation 9.
  115616. */
  115617. convertIncidentRadianceToIrradiance(): void;
  115618. /**
  115619. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115620. *
  115621. * ```
  115622. * L = (1/pi) * E * rho
  115623. * ```
  115624. *
  115625. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115626. */
  115627. convertIrradianceToLambertianRadiance(): void;
  115628. /**
  115629. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115630. * required operations at run time.
  115631. *
  115632. * This is simply done by scaling back the SH with Ylm constants parameter.
  115633. * The trigonometric part being applied by the shader at run time.
  115634. */
  115635. preScaleForRendering(): void;
  115636. /**
  115637. * Constructs a spherical harmonics from an array.
  115638. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115639. * @returns the spherical harmonics
  115640. */
  115641. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115642. /**
  115643. * Gets the spherical harmonics from polynomial
  115644. * @param polynomial the spherical polynomial
  115645. * @returns the spherical harmonics
  115646. */
  115647. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115648. }
  115649. /**
  115650. * Class representing spherical polynomial coefficients to the 3rd degree
  115651. */
  115652. export class SphericalPolynomial {
  115653. private _harmonics;
  115654. /**
  115655. * The spherical harmonics used to create the polynomials.
  115656. */
  115657. get preScaledHarmonics(): SphericalHarmonics;
  115658. /**
  115659. * The x coefficients of the spherical polynomial
  115660. */
  115661. x: Vector3;
  115662. /**
  115663. * The y coefficients of the spherical polynomial
  115664. */
  115665. y: Vector3;
  115666. /**
  115667. * The z coefficients of the spherical polynomial
  115668. */
  115669. z: Vector3;
  115670. /**
  115671. * The xx coefficients of the spherical polynomial
  115672. */
  115673. xx: Vector3;
  115674. /**
  115675. * The yy coefficients of the spherical polynomial
  115676. */
  115677. yy: Vector3;
  115678. /**
  115679. * The zz coefficients of the spherical polynomial
  115680. */
  115681. zz: Vector3;
  115682. /**
  115683. * The xy coefficients of the spherical polynomial
  115684. */
  115685. xy: Vector3;
  115686. /**
  115687. * The yz coefficients of the spherical polynomial
  115688. */
  115689. yz: Vector3;
  115690. /**
  115691. * The zx coefficients of the spherical polynomial
  115692. */
  115693. zx: Vector3;
  115694. /**
  115695. * Adds an ambient color to the spherical polynomial
  115696. * @param color the color to add
  115697. */
  115698. addAmbient(color: Color3): void;
  115699. /**
  115700. * Scales the spherical polynomial by the given amount
  115701. * @param scale the amount to scale
  115702. */
  115703. scaleInPlace(scale: number): void;
  115704. /**
  115705. * Gets the spherical polynomial from harmonics
  115706. * @param harmonics the spherical harmonics
  115707. * @returns the spherical polynomial
  115708. */
  115709. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115710. /**
  115711. * Constructs a spherical polynomial from an array.
  115712. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115713. * @returns the spherical polynomial
  115714. */
  115715. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115716. }
  115717. }
  115718. declare module BABYLON {
  115719. /**
  115720. * Defines the source of the internal texture
  115721. */
  115722. export enum InternalTextureSource {
  115723. /**
  115724. * The source of the texture data is unknown
  115725. */
  115726. Unknown = 0,
  115727. /**
  115728. * Texture data comes from an URL
  115729. */
  115730. Url = 1,
  115731. /**
  115732. * Texture data is only used for temporary storage
  115733. */
  115734. Temp = 2,
  115735. /**
  115736. * Texture data comes from raw data (ArrayBuffer)
  115737. */
  115738. Raw = 3,
  115739. /**
  115740. * Texture content is dynamic (video or dynamic texture)
  115741. */
  115742. Dynamic = 4,
  115743. /**
  115744. * Texture content is generated by rendering to it
  115745. */
  115746. RenderTarget = 5,
  115747. /**
  115748. * Texture content is part of a multi render target process
  115749. */
  115750. MultiRenderTarget = 6,
  115751. /**
  115752. * Texture data comes from a cube data file
  115753. */
  115754. Cube = 7,
  115755. /**
  115756. * Texture data comes from a raw cube data
  115757. */
  115758. CubeRaw = 8,
  115759. /**
  115760. * Texture data come from a prefiltered cube data file
  115761. */
  115762. CubePrefiltered = 9,
  115763. /**
  115764. * Texture content is raw 3D data
  115765. */
  115766. Raw3D = 10,
  115767. /**
  115768. * Texture content is raw 2D array data
  115769. */
  115770. Raw2DArray = 11,
  115771. /**
  115772. * Texture content is a depth texture
  115773. */
  115774. Depth = 12,
  115775. /**
  115776. * Texture data comes from a raw cube data encoded with RGBD
  115777. */
  115778. CubeRawRGBD = 13
  115779. }
  115780. /**
  115781. * Class used to store data associated with WebGL texture data for the engine
  115782. * This class should not be used directly
  115783. */
  115784. export class InternalTexture {
  115785. /** @hidden */
  115786. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115787. /**
  115788. * Defines if the texture is ready
  115789. */
  115790. isReady: boolean;
  115791. /**
  115792. * Defines if the texture is a cube texture
  115793. */
  115794. isCube: boolean;
  115795. /**
  115796. * Defines if the texture contains 3D data
  115797. */
  115798. is3D: boolean;
  115799. /**
  115800. * Defines if the texture contains 2D array data
  115801. */
  115802. is2DArray: boolean;
  115803. /**
  115804. * Defines if the texture contains multiview data
  115805. */
  115806. isMultiview: boolean;
  115807. /**
  115808. * Gets the URL used to load this texture
  115809. */
  115810. url: string;
  115811. /**
  115812. * Gets the sampling mode of the texture
  115813. */
  115814. samplingMode: number;
  115815. /**
  115816. * Gets a boolean indicating if the texture needs mipmaps generation
  115817. */
  115818. generateMipMaps: boolean;
  115819. /**
  115820. * Gets the number of samples used by the texture (WebGL2+ only)
  115821. */
  115822. samples: number;
  115823. /**
  115824. * Gets the type of the texture (int, float...)
  115825. */
  115826. type: number;
  115827. /**
  115828. * Gets the format of the texture (RGB, RGBA...)
  115829. */
  115830. format: number;
  115831. /**
  115832. * Observable called when the texture is loaded
  115833. */
  115834. onLoadedObservable: Observable<InternalTexture>;
  115835. /**
  115836. * Gets the width of the texture
  115837. */
  115838. width: number;
  115839. /**
  115840. * Gets the height of the texture
  115841. */
  115842. height: number;
  115843. /**
  115844. * Gets the depth of the texture
  115845. */
  115846. depth: number;
  115847. /**
  115848. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115849. */
  115850. baseWidth: number;
  115851. /**
  115852. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115853. */
  115854. baseHeight: number;
  115855. /**
  115856. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115857. */
  115858. baseDepth: number;
  115859. /**
  115860. * Gets a boolean indicating if the texture is inverted on Y axis
  115861. */
  115862. invertY: boolean;
  115863. /** @hidden */
  115864. _invertVScale: boolean;
  115865. /** @hidden */
  115866. _associatedChannel: number;
  115867. /** @hidden */
  115868. _source: InternalTextureSource;
  115869. /** @hidden */
  115870. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115871. /** @hidden */
  115872. _bufferView: Nullable<ArrayBufferView>;
  115873. /** @hidden */
  115874. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115875. /** @hidden */
  115876. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115877. /** @hidden */
  115878. _size: number;
  115879. /** @hidden */
  115880. _extension: string;
  115881. /** @hidden */
  115882. _files: Nullable<string[]>;
  115883. /** @hidden */
  115884. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115885. /** @hidden */
  115886. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115887. /** @hidden */
  115888. _framebuffer: Nullable<WebGLFramebuffer>;
  115889. /** @hidden */
  115890. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115891. /** @hidden */
  115892. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115893. /** @hidden */
  115894. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115895. /** @hidden */
  115896. _attachments: Nullable<number[]>;
  115897. /** @hidden */
  115898. _textureArray: Nullable<InternalTexture[]>;
  115899. /** @hidden */
  115900. _cachedCoordinatesMode: Nullable<number>;
  115901. /** @hidden */
  115902. _cachedWrapU: Nullable<number>;
  115903. /** @hidden */
  115904. _cachedWrapV: Nullable<number>;
  115905. /** @hidden */
  115906. _cachedWrapR: Nullable<number>;
  115907. /** @hidden */
  115908. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115909. /** @hidden */
  115910. _isDisabled: boolean;
  115911. /** @hidden */
  115912. _compression: Nullable<string>;
  115913. /** @hidden */
  115914. _generateStencilBuffer: boolean;
  115915. /** @hidden */
  115916. _generateDepthBuffer: boolean;
  115917. /** @hidden */
  115918. _comparisonFunction: number;
  115919. /** @hidden */
  115920. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115921. /** @hidden */
  115922. _lodGenerationScale: number;
  115923. /** @hidden */
  115924. _lodGenerationOffset: number;
  115925. /** @hidden */
  115926. _depthStencilTexture: Nullable<InternalTexture>;
  115927. /** @hidden */
  115928. _colorTextureArray: Nullable<WebGLTexture>;
  115929. /** @hidden */
  115930. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115931. /** @hidden */
  115932. _lodTextureHigh: Nullable<BaseTexture>;
  115933. /** @hidden */
  115934. _lodTextureMid: Nullable<BaseTexture>;
  115935. /** @hidden */
  115936. _lodTextureLow: Nullable<BaseTexture>;
  115937. /** @hidden */
  115938. _isRGBD: boolean;
  115939. /** @hidden */
  115940. _linearSpecularLOD: boolean;
  115941. /** @hidden */
  115942. _irradianceTexture: Nullable<BaseTexture>;
  115943. /** @hidden */
  115944. _webGLTexture: Nullable<WebGLTexture>;
  115945. /** @hidden */
  115946. _references: number;
  115947. private _engine;
  115948. /**
  115949. * Gets the Engine the texture belongs to.
  115950. * @returns The babylon engine
  115951. */
  115952. getEngine(): ThinEngine;
  115953. /**
  115954. * Gets the data source type of the texture
  115955. */
  115956. get source(): InternalTextureSource;
  115957. /**
  115958. * Creates a new InternalTexture
  115959. * @param engine defines the engine to use
  115960. * @param source defines the type of data that will be used
  115961. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115962. */
  115963. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115964. /**
  115965. * Increments the number of references (ie. the number of Texture that point to it)
  115966. */
  115967. incrementReferences(): void;
  115968. /**
  115969. * Change the size of the texture (not the size of the content)
  115970. * @param width defines the new width
  115971. * @param height defines the new height
  115972. * @param depth defines the new depth (1 by default)
  115973. */
  115974. updateSize(width: int, height: int, depth?: int): void;
  115975. /** @hidden */
  115976. _rebuild(): void;
  115977. /** @hidden */
  115978. _swapAndDie(target: InternalTexture): void;
  115979. /**
  115980. * Dispose the current allocated resources
  115981. */
  115982. dispose(): void;
  115983. }
  115984. }
  115985. declare module BABYLON {
  115986. /**
  115987. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115989. */
  115990. export class Analyser {
  115991. /**
  115992. * Gets or sets the smoothing
  115993. * @ignorenaming
  115994. */
  115995. SMOOTHING: number;
  115996. /**
  115997. * Gets or sets the FFT table size
  115998. * @ignorenaming
  115999. */
  116000. FFT_SIZE: number;
  116001. /**
  116002. * Gets or sets the bar graph amplitude
  116003. * @ignorenaming
  116004. */
  116005. BARGRAPHAMPLITUDE: number;
  116006. /**
  116007. * Gets or sets the position of the debug canvas
  116008. * @ignorenaming
  116009. */
  116010. DEBUGCANVASPOS: {
  116011. x: number;
  116012. y: number;
  116013. };
  116014. /**
  116015. * Gets or sets the debug canvas size
  116016. * @ignorenaming
  116017. */
  116018. DEBUGCANVASSIZE: {
  116019. width: number;
  116020. height: number;
  116021. };
  116022. private _byteFreqs;
  116023. private _byteTime;
  116024. private _floatFreqs;
  116025. private _webAudioAnalyser;
  116026. private _debugCanvas;
  116027. private _debugCanvasContext;
  116028. private _scene;
  116029. private _registerFunc;
  116030. private _audioEngine;
  116031. /**
  116032. * Creates a new analyser
  116033. * @param scene defines hosting scene
  116034. */
  116035. constructor(scene: Scene);
  116036. /**
  116037. * Get the number of data values you will have to play with for the visualization
  116038. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116039. * @returns a number
  116040. */
  116041. getFrequencyBinCount(): number;
  116042. /**
  116043. * Gets the current frequency data as a byte array
  116044. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116045. * @returns a Uint8Array
  116046. */
  116047. getByteFrequencyData(): Uint8Array;
  116048. /**
  116049. * Gets the current waveform as a byte array
  116050. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116051. * @returns a Uint8Array
  116052. */
  116053. getByteTimeDomainData(): Uint8Array;
  116054. /**
  116055. * Gets the current frequency data as a float array
  116056. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116057. * @returns a Float32Array
  116058. */
  116059. getFloatFrequencyData(): Float32Array;
  116060. /**
  116061. * Renders the debug canvas
  116062. */
  116063. drawDebugCanvas(): void;
  116064. /**
  116065. * Stops rendering the debug canvas and removes it
  116066. */
  116067. stopDebugCanvas(): void;
  116068. /**
  116069. * Connects two audio nodes
  116070. * @param inputAudioNode defines first node to connect
  116071. * @param outputAudioNode defines second node to connect
  116072. */
  116073. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116074. /**
  116075. * Releases all associated resources
  116076. */
  116077. dispose(): void;
  116078. }
  116079. }
  116080. declare module BABYLON {
  116081. /**
  116082. * This represents an audio engine and it is responsible
  116083. * to play, synchronize and analyse sounds throughout the application.
  116084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116085. */
  116086. export interface IAudioEngine extends IDisposable {
  116087. /**
  116088. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116089. */
  116090. readonly canUseWebAudio: boolean;
  116091. /**
  116092. * Gets the current AudioContext if available.
  116093. */
  116094. readonly audioContext: Nullable<AudioContext>;
  116095. /**
  116096. * The master gain node defines the global audio volume of your audio engine.
  116097. */
  116098. readonly masterGain: GainNode;
  116099. /**
  116100. * Gets whether or not mp3 are supported by your browser.
  116101. */
  116102. readonly isMP3supported: boolean;
  116103. /**
  116104. * Gets whether or not ogg are supported by your browser.
  116105. */
  116106. readonly isOGGsupported: boolean;
  116107. /**
  116108. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116109. * @ignoreNaming
  116110. */
  116111. WarnedWebAudioUnsupported: boolean;
  116112. /**
  116113. * Defines if the audio engine relies on a custom unlocked button.
  116114. * In this case, the embedded button will not be displayed.
  116115. */
  116116. useCustomUnlockedButton: boolean;
  116117. /**
  116118. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116119. */
  116120. readonly unlocked: boolean;
  116121. /**
  116122. * Event raised when audio has been unlocked on the browser.
  116123. */
  116124. onAudioUnlockedObservable: Observable<AudioEngine>;
  116125. /**
  116126. * Event raised when audio has been locked on the browser.
  116127. */
  116128. onAudioLockedObservable: Observable<AudioEngine>;
  116129. /**
  116130. * Flags the audio engine in Locked state.
  116131. * This happens due to new browser policies preventing audio to autoplay.
  116132. */
  116133. lock(): void;
  116134. /**
  116135. * Unlocks the audio engine once a user action has been done on the dom.
  116136. * This is helpful to resume play once browser policies have been satisfied.
  116137. */
  116138. unlock(): void;
  116139. /**
  116140. * Gets the global volume sets on the master gain.
  116141. * @returns the global volume if set or -1 otherwise
  116142. */
  116143. getGlobalVolume(): number;
  116144. /**
  116145. * Sets the global volume of your experience (sets on the master gain).
  116146. * @param newVolume Defines the new global volume of the application
  116147. */
  116148. setGlobalVolume(newVolume: number): void;
  116149. /**
  116150. * Connect the audio engine to an audio analyser allowing some amazing
  116151. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116153. * @param analyser The analyser to connect to the engine
  116154. */
  116155. connectToAnalyser(analyser: Analyser): void;
  116156. }
  116157. /**
  116158. * This represents the default audio engine used in babylon.
  116159. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116160. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116161. */
  116162. export class AudioEngine implements IAudioEngine {
  116163. private _audioContext;
  116164. private _audioContextInitialized;
  116165. private _muteButton;
  116166. private _hostElement;
  116167. /**
  116168. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116169. */
  116170. canUseWebAudio: boolean;
  116171. /**
  116172. * The master gain node defines the global audio volume of your audio engine.
  116173. */
  116174. masterGain: GainNode;
  116175. /**
  116176. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116177. * @ignoreNaming
  116178. */
  116179. WarnedWebAudioUnsupported: boolean;
  116180. /**
  116181. * Gets whether or not mp3 are supported by your browser.
  116182. */
  116183. isMP3supported: boolean;
  116184. /**
  116185. * Gets whether or not ogg are supported by your browser.
  116186. */
  116187. isOGGsupported: boolean;
  116188. /**
  116189. * Gets whether audio has been unlocked on the device.
  116190. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116191. * a user interaction has happened.
  116192. */
  116193. unlocked: boolean;
  116194. /**
  116195. * Defines if the audio engine relies on a custom unlocked button.
  116196. * In this case, the embedded button will not be displayed.
  116197. */
  116198. useCustomUnlockedButton: boolean;
  116199. /**
  116200. * Event raised when audio has been unlocked on the browser.
  116201. */
  116202. onAudioUnlockedObservable: Observable<AudioEngine>;
  116203. /**
  116204. * Event raised when audio has been locked on the browser.
  116205. */
  116206. onAudioLockedObservable: Observable<AudioEngine>;
  116207. /**
  116208. * Gets the current AudioContext if available.
  116209. */
  116210. get audioContext(): Nullable<AudioContext>;
  116211. private _connectedAnalyser;
  116212. /**
  116213. * Instantiates a new audio engine.
  116214. *
  116215. * There should be only one per page as some browsers restrict the number
  116216. * of audio contexts you can create.
  116217. * @param hostElement defines the host element where to display the mute icon if necessary
  116218. */
  116219. constructor(hostElement?: Nullable<HTMLElement>);
  116220. /**
  116221. * Flags the audio engine in Locked state.
  116222. * This happens due to new browser policies preventing audio to autoplay.
  116223. */
  116224. lock(): void;
  116225. /**
  116226. * Unlocks the audio engine once a user action has been done on the dom.
  116227. * This is helpful to resume play once browser policies have been satisfied.
  116228. */
  116229. unlock(): void;
  116230. private _resumeAudioContext;
  116231. private _initializeAudioContext;
  116232. private _tryToRun;
  116233. private _triggerRunningState;
  116234. private _triggerSuspendedState;
  116235. private _displayMuteButton;
  116236. private _moveButtonToTopLeft;
  116237. private _onResize;
  116238. private _hideMuteButton;
  116239. /**
  116240. * Destroy and release the resources associated with the audio ccontext.
  116241. */
  116242. dispose(): void;
  116243. /**
  116244. * Gets the global volume sets on the master gain.
  116245. * @returns the global volume if set or -1 otherwise
  116246. */
  116247. getGlobalVolume(): number;
  116248. /**
  116249. * Sets the global volume of your experience (sets on the master gain).
  116250. * @param newVolume Defines the new global volume of the application
  116251. */
  116252. setGlobalVolume(newVolume: number): void;
  116253. /**
  116254. * Connect the audio engine to an audio analyser allowing some amazing
  116255. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116256. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116257. * @param analyser The analyser to connect to the engine
  116258. */
  116259. connectToAnalyser(analyser: Analyser): void;
  116260. }
  116261. }
  116262. declare module BABYLON {
  116263. /**
  116264. * Interface used to present a loading screen while loading a scene
  116265. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116266. */
  116267. export interface ILoadingScreen {
  116268. /**
  116269. * Function called to display the loading screen
  116270. */
  116271. displayLoadingUI: () => void;
  116272. /**
  116273. * Function called to hide the loading screen
  116274. */
  116275. hideLoadingUI: () => void;
  116276. /**
  116277. * Gets or sets the color to use for the background
  116278. */
  116279. loadingUIBackgroundColor: string;
  116280. /**
  116281. * Gets or sets the text to display while loading
  116282. */
  116283. loadingUIText: string;
  116284. }
  116285. /**
  116286. * Class used for the default loading screen
  116287. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116288. */
  116289. export class DefaultLoadingScreen implements ILoadingScreen {
  116290. private _renderingCanvas;
  116291. private _loadingText;
  116292. private _loadingDivBackgroundColor;
  116293. private _loadingDiv;
  116294. private _loadingTextDiv;
  116295. /** Gets or sets the logo url to use for the default loading screen */
  116296. static DefaultLogoUrl: string;
  116297. /** Gets or sets the spinner url to use for the default loading screen */
  116298. static DefaultSpinnerUrl: string;
  116299. /**
  116300. * Creates a new default loading screen
  116301. * @param _renderingCanvas defines the canvas used to render the scene
  116302. * @param _loadingText defines the default text to display
  116303. * @param _loadingDivBackgroundColor defines the default background color
  116304. */
  116305. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  116306. /**
  116307. * Function called to display the loading screen
  116308. */
  116309. displayLoadingUI(): void;
  116310. /**
  116311. * Function called to hide the loading screen
  116312. */
  116313. hideLoadingUI(): void;
  116314. /**
  116315. * Gets or sets the text to display while loading
  116316. */
  116317. set loadingUIText(text: string);
  116318. get loadingUIText(): string;
  116319. /**
  116320. * Gets or sets the color to use for the background
  116321. */
  116322. get loadingUIBackgroundColor(): string;
  116323. set loadingUIBackgroundColor(color: string);
  116324. private _resizeLoadingUI;
  116325. }
  116326. }
  116327. declare module BABYLON {
  116328. /**
  116329. * Interface for any object that can request an animation frame
  116330. */
  116331. export interface ICustomAnimationFrameRequester {
  116332. /**
  116333. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  116334. */
  116335. renderFunction?: Function;
  116336. /**
  116337. * Called to request the next frame to render to
  116338. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  116339. */
  116340. requestAnimationFrame: Function;
  116341. /**
  116342. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  116343. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  116344. */
  116345. requestID?: number;
  116346. }
  116347. }
  116348. declare module BABYLON {
  116349. /**
  116350. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  116351. */
  116352. export class PerformanceMonitor {
  116353. private _enabled;
  116354. private _rollingFrameTime;
  116355. private _lastFrameTimeMs;
  116356. /**
  116357. * constructor
  116358. * @param frameSampleSize The number of samples required to saturate the sliding window
  116359. */
  116360. constructor(frameSampleSize?: number);
  116361. /**
  116362. * Samples current frame
  116363. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  116364. */
  116365. sampleFrame(timeMs?: number): void;
  116366. /**
  116367. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116368. */
  116369. get averageFrameTime(): number;
  116370. /**
  116371. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116372. */
  116373. get averageFrameTimeVariance(): number;
  116374. /**
  116375. * Returns the frame time of the most recent frame
  116376. */
  116377. get instantaneousFrameTime(): number;
  116378. /**
  116379. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  116380. */
  116381. get averageFPS(): number;
  116382. /**
  116383. * Returns the average framerate in frames per second using the most recent frame time
  116384. */
  116385. get instantaneousFPS(): number;
  116386. /**
  116387. * Returns true if enough samples have been taken to completely fill the sliding window
  116388. */
  116389. get isSaturated(): boolean;
  116390. /**
  116391. * Enables contributions to the sliding window sample set
  116392. */
  116393. enable(): void;
  116394. /**
  116395. * Disables contributions to the sliding window sample set
  116396. * Samples will not be interpolated over the disabled period
  116397. */
  116398. disable(): void;
  116399. /**
  116400. * Returns true if sampling is enabled
  116401. */
  116402. get isEnabled(): boolean;
  116403. /**
  116404. * Resets performance monitor
  116405. */
  116406. reset(): void;
  116407. }
  116408. /**
  116409. * RollingAverage
  116410. *
  116411. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116412. */
  116413. export class RollingAverage {
  116414. /**
  116415. * Current average
  116416. */
  116417. average: number;
  116418. /**
  116419. * Current variance
  116420. */
  116421. variance: number;
  116422. protected _samples: Array<number>;
  116423. protected _sampleCount: number;
  116424. protected _pos: number;
  116425. protected _m2: number;
  116426. /**
  116427. * constructor
  116428. * @param length The number of samples required to saturate the sliding window
  116429. */
  116430. constructor(length: number);
  116431. /**
  116432. * Adds a sample to the sample set
  116433. * @param v The sample value
  116434. */
  116435. add(v: number): void;
  116436. /**
  116437. * Returns previously added values or null if outside of history or outside the sliding window domain
  116438. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116439. * @return Value previously recorded with add() or null if outside of range
  116440. */
  116441. history(i: number): number;
  116442. /**
  116443. * Returns true if enough samples have been taken to completely fill the sliding window
  116444. * @return true if sample-set saturated
  116445. */
  116446. isSaturated(): boolean;
  116447. /**
  116448. * Resets the rolling average (equivalent to 0 samples taken so far)
  116449. */
  116450. reset(): void;
  116451. /**
  116452. * Wraps a value around the sample range boundaries
  116453. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  116454. * @return Wrapped position in sample range
  116455. */
  116456. protected _wrapPosition(i: number): number;
  116457. }
  116458. }
  116459. declare module BABYLON {
  116460. /**
  116461. * This class is used to track a performance counter which is number based.
  116462. * The user has access to many properties which give statistics of different nature.
  116463. *
  116464. * The implementer can track two kinds of Performance Counter: time and count.
  116465. * 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.
  116466. * 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.
  116467. */
  116468. export class PerfCounter {
  116469. /**
  116470. * Gets or sets a global boolean to turn on and off all the counters
  116471. */
  116472. static Enabled: boolean;
  116473. /**
  116474. * Returns the smallest value ever
  116475. */
  116476. get min(): number;
  116477. /**
  116478. * Returns the biggest value ever
  116479. */
  116480. get max(): number;
  116481. /**
  116482. * Returns the average value since the performance counter is running
  116483. */
  116484. get average(): number;
  116485. /**
  116486. * Returns the average value of the last second the counter was monitored
  116487. */
  116488. get lastSecAverage(): number;
  116489. /**
  116490. * Returns the current value
  116491. */
  116492. get current(): number;
  116493. /**
  116494. * Gets the accumulated total
  116495. */
  116496. get total(): number;
  116497. /**
  116498. * Gets the total value count
  116499. */
  116500. get count(): number;
  116501. /**
  116502. * Creates a new counter
  116503. */
  116504. constructor();
  116505. /**
  116506. * Call this method to start monitoring a new frame.
  116507. * 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.
  116508. */
  116509. fetchNewFrame(): void;
  116510. /**
  116511. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  116512. * @param newCount the count value to add to the monitored count
  116513. * @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.
  116514. */
  116515. addCount(newCount: number, fetchResult: boolean): void;
  116516. /**
  116517. * Start monitoring this performance counter
  116518. */
  116519. beginMonitoring(): void;
  116520. /**
  116521. * Compute the time lapsed since the previous beginMonitoring() call.
  116522. * @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
  116523. */
  116524. endMonitoring(newFrame?: boolean): void;
  116525. private _fetchResult;
  116526. private _startMonitoringTime;
  116527. private _min;
  116528. private _max;
  116529. private _average;
  116530. private _current;
  116531. private _totalValueCount;
  116532. private _totalAccumulated;
  116533. private _lastSecAverage;
  116534. private _lastSecAccumulated;
  116535. private _lastSecTime;
  116536. private _lastSecValueCount;
  116537. }
  116538. }
  116539. declare module BABYLON {
  116540. interface ThinEngine {
  116541. /** @hidden */
  116542. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  116543. }
  116544. }
  116545. declare module BABYLON {
  116546. /**
  116547. * Defines the interface used by display changed events
  116548. */
  116549. export interface IDisplayChangedEventArgs {
  116550. /** Gets the vrDisplay object (if any) */
  116551. vrDisplay: Nullable<any>;
  116552. /** Gets a boolean indicating if webVR is supported */
  116553. vrSupported: boolean;
  116554. }
  116555. /**
  116556. * Defines the interface used by objects containing a viewport (like a camera)
  116557. */
  116558. interface IViewportOwnerLike {
  116559. /**
  116560. * Gets or sets the viewport
  116561. */
  116562. viewport: IViewportLike;
  116563. }
  116564. /**
  116565. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116566. */
  116567. export class Engine extends ThinEngine {
  116568. /** Defines that alpha blending is disabled */
  116569. static readonly ALPHA_DISABLE: number;
  116570. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116571. static readonly ALPHA_ADD: number;
  116572. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116573. static readonly ALPHA_COMBINE: number;
  116574. /** Defines that alpha blending to DEST - SRC * DEST */
  116575. static readonly ALPHA_SUBTRACT: number;
  116576. /** Defines that alpha blending to SRC * DEST */
  116577. static readonly ALPHA_MULTIPLY: number;
  116578. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116579. static readonly ALPHA_MAXIMIZED: number;
  116580. /** Defines that alpha blending to SRC + DEST */
  116581. static readonly ALPHA_ONEONE: number;
  116582. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116583. static readonly ALPHA_PREMULTIPLIED: number;
  116584. /**
  116585. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116586. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116587. */
  116588. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116589. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116590. static readonly ALPHA_INTERPOLATE: number;
  116591. /**
  116592. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116593. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116594. */
  116595. static readonly ALPHA_SCREENMODE: number;
  116596. /** Defines that the ressource is not delayed*/
  116597. static readonly DELAYLOADSTATE_NONE: number;
  116598. /** Defines that the ressource was successfully delay loaded */
  116599. static readonly DELAYLOADSTATE_LOADED: number;
  116600. /** Defines that the ressource is currently delay loading */
  116601. static readonly DELAYLOADSTATE_LOADING: number;
  116602. /** Defines that the ressource is delayed and has not started loading */
  116603. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116604. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116605. static readonly NEVER: number;
  116606. /** 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 */
  116607. static readonly ALWAYS: number;
  116608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116609. static readonly LESS: number;
  116610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116611. static readonly EQUAL: number;
  116612. /** 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 */
  116613. static readonly LEQUAL: number;
  116614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116615. static readonly GREATER: number;
  116616. /** 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 */
  116617. static readonly GEQUAL: number;
  116618. /** 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 */
  116619. static readonly NOTEQUAL: number;
  116620. /** Passed to stencilOperation to specify that stencil value must be kept */
  116621. static readonly KEEP: number;
  116622. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116623. static readonly REPLACE: number;
  116624. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116625. static readonly INCR: number;
  116626. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116627. static readonly DECR: number;
  116628. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116629. static readonly INVERT: number;
  116630. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116631. static readonly INCR_WRAP: number;
  116632. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116633. static readonly DECR_WRAP: number;
  116634. /** Texture is not repeating outside of 0..1 UVs */
  116635. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116636. /** Texture is repeating outside of 0..1 UVs */
  116637. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116638. /** Texture is repeating and mirrored */
  116639. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116640. /** ALPHA */
  116641. static readonly TEXTUREFORMAT_ALPHA: number;
  116642. /** LUMINANCE */
  116643. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116644. /** LUMINANCE_ALPHA */
  116645. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116646. /** RGB */
  116647. static readonly TEXTUREFORMAT_RGB: number;
  116648. /** RGBA */
  116649. static readonly TEXTUREFORMAT_RGBA: number;
  116650. /** RED */
  116651. static readonly TEXTUREFORMAT_RED: number;
  116652. /** RED (2nd reference) */
  116653. static readonly TEXTUREFORMAT_R: number;
  116654. /** RG */
  116655. static readonly TEXTUREFORMAT_RG: number;
  116656. /** RED_INTEGER */
  116657. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116658. /** RED_INTEGER (2nd reference) */
  116659. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116660. /** RG_INTEGER */
  116661. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116662. /** RGB_INTEGER */
  116663. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116664. /** RGBA_INTEGER */
  116665. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116666. /** UNSIGNED_BYTE */
  116667. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116668. /** UNSIGNED_BYTE (2nd reference) */
  116669. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116670. /** FLOAT */
  116671. static readonly TEXTURETYPE_FLOAT: number;
  116672. /** HALF_FLOAT */
  116673. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116674. /** BYTE */
  116675. static readonly TEXTURETYPE_BYTE: number;
  116676. /** SHORT */
  116677. static readonly TEXTURETYPE_SHORT: number;
  116678. /** UNSIGNED_SHORT */
  116679. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116680. /** INT */
  116681. static readonly TEXTURETYPE_INT: number;
  116682. /** UNSIGNED_INT */
  116683. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116684. /** UNSIGNED_SHORT_4_4_4_4 */
  116685. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116686. /** UNSIGNED_SHORT_5_5_5_1 */
  116687. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116688. /** UNSIGNED_SHORT_5_6_5 */
  116689. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116690. /** UNSIGNED_INT_2_10_10_10_REV */
  116691. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116692. /** UNSIGNED_INT_24_8 */
  116693. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116694. /** UNSIGNED_INT_10F_11F_11F_REV */
  116695. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116696. /** UNSIGNED_INT_5_9_9_9_REV */
  116697. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116698. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116699. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116700. /** nearest is mag = nearest and min = nearest and mip = linear */
  116701. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116702. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116703. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116704. /** Trilinear is mag = linear and min = linear and mip = linear */
  116705. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116706. /** nearest is mag = nearest and min = nearest and mip = linear */
  116707. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116708. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116709. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116710. /** Trilinear is mag = linear and min = linear and mip = linear */
  116711. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116712. /** mag = nearest and min = nearest and mip = nearest */
  116713. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116714. /** mag = nearest and min = linear and mip = nearest */
  116715. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116716. /** mag = nearest and min = linear and mip = linear */
  116717. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116718. /** mag = nearest and min = linear and mip = none */
  116719. static readonly TEXTURE_NEAREST_LINEAR: number;
  116720. /** mag = nearest and min = nearest and mip = none */
  116721. static readonly TEXTURE_NEAREST_NEAREST: number;
  116722. /** mag = linear and min = nearest and mip = nearest */
  116723. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116724. /** mag = linear and min = nearest and mip = linear */
  116725. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116726. /** mag = linear and min = linear and mip = none */
  116727. static readonly TEXTURE_LINEAR_LINEAR: number;
  116728. /** mag = linear and min = nearest and mip = none */
  116729. static readonly TEXTURE_LINEAR_NEAREST: number;
  116730. /** Explicit coordinates mode */
  116731. static readonly TEXTURE_EXPLICIT_MODE: number;
  116732. /** Spherical coordinates mode */
  116733. static readonly TEXTURE_SPHERICAL_MODE: number;
  116734. /** Planar coordinates mode */
  116735. static readonly TEXTURE_PLANAR_MODE: number;
  116736. /** Cubic coordinates mode */
  116737. static readonly TEXTURE_CUBIC_MODE: number;
  116738. /** Projection coordinates mode */
  116739. static readonly TEXTURE_PROJECTION_MODE: number;
  116740. /** Skybox coordinates mode */
  116741. static readonly TEXTURE_SKYBOX_MODE: number;
  116742. /** Inverse Cubic coordinates mode */
  116743. static readonly TEXTURE_INVCUBIC_MODE: number;
  116744. /** Equirectangular coordinates mode */
  116745. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116746. /** Equirectangular Fixed coordinates mode */
  116747. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116748. /** Equirectangular Fixed Mirrored coordinates mode */
  116749. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116750. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116751. static readonly SCALEMODE_FLOOR: number;
  116752. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116753. static readonly SCALEMODE_NEAREST: number;
  116754. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116755. static readonly SCALEMODE_CEILING: number;
  116756. /**
  116757. * Returns the current npm package of the sdk
  116758. */
  116759. static get NpmPackage(): string;
  116760. /**
  116761. * Returns the current version of the framework
  116762. */
  116763. static get Version(): string;
  116764. /** Gets the list of created engines */
  116765. static get Instances(): Engine[];
  116766. /**
  116767. * Gets the latest created engine
  116768. */
  116769. static get LastCreatedEngine(): Nullable<Engine>;
  116770. /**
  116771. * Gets the latest created scene
  116772. */
  116773. static get LastCreatedScene(): Nullable<Scene>;
  116774. /**
  116775. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116776. * @param flag defines which part of the materials must be marked as dirty
  116777. * @param predicate defines a predicate used to filter which materials should be affected
  116778. */
  116779. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116780. /**
  116781. * Method called to create the default loading screen.
  116782. * This can be overriden in your own app.
  116783. * @param canvas The rendering canvas element
  116784. * @returns The loading screen
  116785. */
  116786. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116787. /**
  116788. * Method called to create the default rescale post process on each engine.
  116789. */
  116790. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116791. /**
  116792. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116793. **/
  116794. enableOfflineSupport: boolean;
  116795. /**
  116796. * 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)
  116797. **/
  116798. disableManifestCheck: boolean;
  116799. /**
  116800. * Gets the list of created scenes
  116801. */
  116802. scenes: Scene[];
  116803. /**
  116804. * Event raised when a new scene is created
  116805. */
  116806. onNewSceneAddedObservable: Observable<Scene>;
  116807. /**
  116808. * Gets the list of created postprocesses
  116809. */
  116810. postProcesses: PostProcess[];
  116811. /**
  116812. * Gets a boolean indicating if the pointer is currently locked
  116813. */
  116814. isPointerLock: boolean;
  116815. /**
  116816. * Observable event triggered each time the rendering canvas is resized
  116817. */
  116818. onResizeObservable: Observable<Engine>;
  116819. /**
  116820. * Observable event triggered each time the canvas loses focus
  116821. */
  116822. onCanvasBlurObservable: Observable<Engine>;
  116823. /**
  116824. * Observable event triggered each time the canvas gains focus
  116825. */
  116826. onCanvasFocusObservable: Observable<Engine>;
  116827. /**
  116828. * Observable event triggered each time the canvas receives pointerout event
  116829. */
  116830. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116831. /**
  116832. * Observable raised when the engine begins a new frame
  116833. */
  116834. onBeginFrameObservable: Observable<Engine>;
  116835. /**
  116836. * If set, will be used to request the next animation frame for the render loop
  116837. */
  116838. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116839. /**
  116840. * Observable raised when the engine ends the current frame
  116841. */
  116842. onEndFrameObservable: Observable<Engine>;
  116843. /**
  116844. * Observable raised when the engine is about to compile a shader
  116845. */
  116846. onBeforeShaderCompilationObservable: Observable<Engine>;
  116847. /**
  116848. * Observable raised when the engine has jsut compiled a shader
  116849. */
  116850. onAfterShaderCompilationObservable: Observable<Engine>;
  116851. /**
  116852. * Gets the audio engine
  116853. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116854. * @ignorenaming
  116855. */
  116856. static audioEngine: IAudioEngine;
  116857. /**
  116858. * Default AudioEngine factory responsible of creating the Audio Engine.
  116859. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116860. */
  116861. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116862. /**
  116863. * Default offline support factory responsible of creating a tool used to store data locally.
  116864. * By default, this will create a Database object if the workload has been embedded.
  116865. */
  116866. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116867. private _loadingScreen;
  116868. private _pointerLockRequested;
  116869. private _rescalePostProcess;
  116870. private _deterministicLockstep;
  116871. private _lockstepMaxSteps;
  116872. private _timeStep;
  116873. protected get _supportsHardwareTextureRescaling(): boolean;
  116874. private _fps;
  116875. private _deltaTime;
  116876. /** @hidden */
  116877. _drawCalls: PerfCounter;
  116878. /** 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 */
  116879. canvasTabIndex: number;
  116880. /**
  116881. * Turn this value on if you want to pause FPS computation when in background
  116882. */
  116883. disablePerformanceMonitorInBackground: boolean;
  116884. private _performanceMonitor;
  116885. /**
  116886. * Gets the performance monitor attached to this engine
  116887. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116888. */
  116889. get performanceMonitor(): PerformanceMonitor;
  116890. private _onFocus;
  116891. private _onBlur;
  116892. private _onCanvasPointerOut;
  116893. private _onCanvasBlur;
  116894. private _onCanvasFocus;
  116895. private _onFullscreenChange;
  116896. private _onPointerLockChange;
  116897. /**
  116898. * Gets the HTML element used to attach event listeners
  116899. * @returns a HTML element
  116900. */
  116901. getInputElement(): Nullable<HTMLElement>;
  116902. /**
  116903. * Creates a new engine
  116904. * @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
  116905. * @param antialias defines enable antialiasing (default: false)
  116906. * @param options defines further options to be sent to the getContext() function
  116907. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116908. */
  116909. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116910. /**
  116911. * Gets current aspect ratio
  116912. * @param viewportOwner defines the camera to use to get the aspect ratio
  116913. * @param useScreen defines if screen size must be used (or the current render target if any)
  116914. * @returns a number defining the aspect ratio
  116915. */
  116916. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116917. /**
  116918. * Gets current screen aspect ratio
  116919. * @returns a number defining the aspect ratio
  116920. */
  116921. getScreenAspectRatio(): number;
  116922. /**
  116923. * Gets the client rect of the HTML canvas attached with the current webGL context
  116924. * @returns a client rectanglee
  116925. */
  116926. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116927. /**
  116928. * Gets the client rect of the HTML element used for events
  116929. * @returns a client rectanglee
  116930. */
  116931. getInputElementClientRect(): Nullable<ClientRect>;
  116932. /**
  116933. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116934. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116935. * @returns true if engine is in deterministic lock step mode
  116936. */
  116937. isDeterministicLockStep(): boolean;
  116938. /**
  116939. * Gets the max steps when engine is running in deterministic lock step
  116940. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116941. * @returns the max steps
  116942. */
  116943. getLockstepMaxSteps(): number;
  116944. /**
  116945. * Returns the time in ms between steps when using deterministic lock step.
  116946. * @returns time step in (ms)
  116947. */
  116948. getTimeStep(): number;
  116949. /**
  116950. * Force the mipmap generation for the given render target texture
  116951. * @param texture defines the render target texture to use
  116952. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116953. */
  116954. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116955. /** States */
  116956. /**
  116957. * Set various states to the webGL context
  116958. * @param culling defines backface culling state
  116959. * @param zOffset defines the value to apply to zOffset (0 by default)
  116960. * @param force defines if states must be applied even if cache is up to date
  116961. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116962. */
  116963. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116964. /**
  116965. * Set the z offset to apply to current rendering
  116966. * @param value defines the offset to apply
  116967. */
  116968. setZOffset(value: number): void;
  116969. /**
  116970. * Gets the current value of the zOffset
  116971. * @returns the current zOffset state
  116972. */
  116973. getZOffset(): number;
  116974. /**
  116975. * Enable or disable depth buffering
  116976. * @param enable defines the state to set
  116977. */
  116978. setDepthBuffer(enable: boolean): void;
  116979. /**
  116980. * Gets a boolean indicating if depth writing is enabled
  116981. * @returns the current depth writing state
  116982. */
  116983. getDepthWrite(): boolean;
  116984. /**
  116985. * Enable or disable depth writing
  116986. * @param enable defines the state to set
  116987. */
  116988. setDepthWrite(enable: boolean): void;
  116989. /**
  116990. * Gets a boolean indicating if stencil buffer is enabled
  116991. * @returns the current stencil buffer state
  116992. */
  116993. getStencilBuffer(): boolean;
  116994. /**
  116995. * Enable or disable the stencil buffer
  116996. * @param enable defines if the stencil buffer must be enabled or disabled
  116997. */
  116998. setStencilBuffer(enable: boolean): void;
  116999. /**
  117000. * Gets the current stencil mask
  117001. * @returns a number defining the new stencil mask to use
  117002. */
  117003. getStencilMask(): number;
  117004. /**
  117005. * Sets the current stencil mask
  117006. * @param mask defines the new stencil mask to use
  117007. */
  117008. setStencilMask(mask: number): void;
  117009. /**
  117010. * Gets the current stencil function
  117011. * @returns a number defining the stencil function to use
  117012. */
  117013. getStencilFunction(): number;
  117014. /**
  117015. * Gets the current stencil reference value
  117016. * @returns a number defining the stencil reference value to use
  117017. */
  117018. getStencilFunctionReference(): number;
  117019. /**
  117020. * Gets the current stencil mask
  117021. * @returns a number defining the stencil mask to use
  117022. */
  117023. getStencilFunctionMask(): number;
  117024. /**
  117025. * Sets the current stencil function
  117026. * @param stencilFunc defines the new stencil function to use
  117027. */
  117028. setStencilFunction(stencilFunc: number): void;
  117029. /**
  117030. * Sets the current stencil reference
  117031. * @param reference defines the new stencil reference to use
  117032. */
  117033. setStencilFunctionReference(reference: number): void;
  117034. /**
  117035. * Sets the current stencil mask
  117036. * @param mask defines the new stencil mask to use
  117037. */
  117038. setStencilFunctionMask(mask: number): void;
  117039. /**
  117040. * Gets the current stencil operation when stencil fails
  117041. * @returns a number defining stencil operation to use when stencil fails
  117042. */
  117043. getStencilOperationFail(): number;
  117044. /**
  117045. * Gets the current stencil operation when depth fails
  117046. * @returns a number defining stencil operation to use when depth fails
  117047. */
  117048. getStencilOperationDepthFail(): number;
  117049. /**
  117050. * Gets the current stencil operation when stencil passes
  117051. * @returns a number defining stencil operation to use when stencil passes
  117052. */
  117053. getStencilOperationPass(): number;
  117054. /**
  117055. * Sets the stencil operation to use when stencil fails
  117056. * @param operation defines the stencil operation to use when stencil fails
  117057. */
  117058. setStencilOperationFail(operation: number): void;
  117059. /**
  117060. * Sets the stencil operation to use when depth fails
  117061. * @param operation defines the stencil operation to use when depth fails
  117062. */
  117063. setStencilOperationDepthFail(operation: number): void;
  117064. /**
  117065. * Sets the stencil operation to use when stencil passes
  117066. * @param operation defines the stencil operation to use when stencil passes
  117067. */
  117068. setStencilOperationPass(operation: number): void;
  117069. /**
  117070. * Sets a boolean indicating if the dithering state is enabled or disabled
  117071. * @param value defines the dithering state
  117072. */
  117073. setDitheringState(value: boolean): void;
  117074. /**
  117075. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117076. * @param value defines the rasterizer state
  117077. */
  117078. setRasterizerState(value: boolean): void;
  117079. /**
  117080. * Gets the current depth function
  117081. * @returns a number defining the depth function
  117082. */
  117083. getDepthFunction(): Nullable<number>;
  117084. /**
  117085. * Sets the current depth function
  117086. * @param depthFunc defines the function to use
  117087. */
  117088. setDepthFunction(depthFunc: number): void;
  117089. /**
  117090. * Sets the current depth function to GREATER
  117091. */
  117092. setDepthFunctionToGreater(): void;
  117093. /**
  117094. * Sets the current depth function to GEQUAL
  117095. */
  117096. setDepthFunctionToGreaterOrEqual(): void;
  117097. /**
  117098. * Sets the current depth function to LESS
  117099. */
  117100. setDepthFunctionToLess(): void;
  117101. /**
  117102. * Sets the current depth function to LEQUAL
  117103. */
  117104. setDepthFunctionToLessOrEqual(): void;
  117105. private _cachedStencilBuffer;
  117106. private _cachedStencilFunction;
  117107. private _cachedStencilMask;
  117108. private _cachedStencilOperationPass;
  117109. private _cachedStencilOperationFail;
  117110. private _cachedStencilOperationDepthFail;
  117111. private _cachedStencilReference;
  117112. /**
  117113. * Caches the the state of the stencil buffer
  117114. */
  117115. cacheStencilState(): void;
  117116. /**
  117117. * Restores the state of the stencil buffer
  117118. */
  117119. restoreStencilState(): void;
  117120. /**
  117121. * Directly set the WebGL Viewport
  117122. * @param x defines the x coordinate of the viewport (in screen space)
  117123. * @param y defines the y coordinate of the viewport (in screen space)
  117124. * @param width defines the width of the viewport (in screen space)
  117125. * @param height defines the height of the viewport (in screen space)
  117126. * @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
  117127. */
  117128. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117129. /**
  117130. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117131. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117132. * @param y defines the y-coordinate of the corner of the clear rectangle
  117133. * @param width defines the width of the clear rectangle
  117134. * @param height defines the height of the clear rectangle
  117135. * @param clearColor defines the clear color
  117136. */
  117137. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117138. /**
  117139. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117140. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117141. * @param y defines the y-coordinate of the corner of the clear rectangle
  117142. * @param width defines the width of the clear rectangle
  117143. * @param height defines the height of the clear rectangle
  117144. */
  117145. enableScissor(x: number, y: number, width: number, height: number): void;
  117146. /**
  117147. * Disable previously set scissor test rectangle
  117148. */
  117149. disableScissor(): void;
  117150. protected _reportDrawCall(): void;
  117151. /**
  117152. * Initializes a webVR display and starts listening to display change events
  117153. * The onVRDisplayChangedObservable will be notified upon these changes
  117154. * @returns The onVRDisplayChangedObservable
  117155. */
  117156. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117157. /** @hidden */
  117158. _prepareVRComponent(): void;
  117159. /** @hidden */
  117160. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117161. /** @hidden */
  117162. _submitVRFrame(): void;
  117163. /**
  117164. * Call this function to leave webVR mode
  117165. * Will do nothing if webVR is not supported or if there is no webVR device
  117166. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117167. */
  117168. disableVR(): void;
  117169. /**
  117170. * Gets a boolean indicating that the system is in VR mode and is presenting
  117171. * @returns true if VR mode is engaged
  117172. */
  117173. isVRPresenting(): boolean;
  117174. /** @hidden */
  117175. _requestVRFrame(): void;
  117176. /** @hidden */
  117177. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117178. /**
  117179. * Gets the source code of the vertex shader associated with a specific webGL program
  117180. * @param program defines the program to use
  117181. * @returns a string containing the source code of the vertex shader associated with the program
  117182. */
  117183. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117184. /**
  117185. * Gets the source code of the fragment shader associated with a specific webGL program
  117186. * @param program defines the program to use
  117187. * @returns a string containing the source code of the fragment shader associated with the program
  117188. */
  117189. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117190. /**
  117191. * Sets a depth stencil texture from a render target to the according uniform.
  117192. * @param channel The texture channel
  117193. * @param uniform The uniform to set
  117194. * @param texture The render target texture containing the depth stencil texture to apply
  117195. */
  117196. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117197. /**
  117198. * Sets a texture to the webGL context from a postprocess
  117199. * @param channel defines the channel to use
  117200. * @param postProcess defines the source postprocess
  117201. */
  117202. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  117203. /**
  117204. * Binds the output of the passed in post process to the texture channel specified
  117205. * @param channel The channel the texture should be bound to
  117206. * @param postProcess The post process which's output should be bound
  117207. */
  117208. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  117209. protected _rebuildBuffers(): void;
  117210. /** @hidden */
  117211. _renderFrame(): void;
  117212. _renderLoop(): void;
  117213. /** @hidden */
  117214. _renderViews(): boolean;
  117215. /**
  117216. * Toggle full screen mode
  117217. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117218. */
  117219. switchFullscreen(requestPointerLock: boolean): void;
  117220. /**
  117221. * Enters full screen mode
  117222. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117223. */
  117224. enterFullscreen(requestPointerLock: boolean): void;
  117225. /**
  117226. * Exits full screen mode
  117227. */
  117228. exitFullscreen(): void;
  117229. /**
  117230. * Enters Pointerlock mode
  117231. */
  117232. enterPointerlock(): void;
  117233. /**
  117234. * Exits Pointerlock mode
  117235. */
  117236. exitPointerlock(): void;
  117237. /**
  117238. * Begin a new frame
  117239. */
  117240. beginFrame(): void;
  117241. /**
  117242. * Enf the current frame
  117243. */
  117244. endFrame(): void;
  117245. resize(): void;
  117246. /**
  117247. * Force a specific size of the canvas
  117248. * @param width defines the new canvas' width
  117249. * @param height defines the new canvas' height
  117250. * @returns true if the size was changed
  117251. */
  117252. setSize(width: number, height: number): boolean;
  117253. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117254. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117255. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117256. _releaseTexture(texture: InternalTexture): void;
  117257. /**
  117258. * @hidden
  117259. * Rescales a texture
  117260. * @param source input texutre
  117261. * @param destination destination texture
  117262. * @param scene scene to use to render the resize
  117263. * @param internalFormat format to use when resizing
  117264. * @param onComplete callback to be called when resize has completed
  117265. */
  117266. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  117267. /**
  117268. * Gets the current framerate
  117269. * @returns a number representing the framerate
  117270. */
  117271. getFps(): number;
  117272. /**
  117273. * Gets the time spent between current and previous frame
  117274. * @returns a number representing the delta time in ms
  117275. */
  117276. getDeltaTime(): number;
  117277. private _measureFps;
  117278. /** @hidden */
  117279. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  117280. /**
  117281. * Updates the sample count of a render target texture
  117282. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117283. * @param texture defines the texture to update
  117284. * @param samples defines the sample count to set
  117285. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117286. */
  117287. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117288. /**
  117289. * Updates a depth texture Comparison Mode and Function.
  117290. * If the comparison Function is equal to 0, the mode will be set to none.
  117291. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117292. * @param texture The texture to set the comparison function for
  117293. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117294. */
  117295. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117296. /**
  117297. * Creates a webGL buffer to use with instanciation
  117298. * @param capacity defines the size of the buffer
  117299. * @returns the webGL buffer
  117300. */
  117301. createInstancesBuffer(capacity: number): DataBuffer;
  117302. /**
  117303. * Delete a webGL buffer used with instanciation
  117304. * @param buffer defines the webGL buffer to delete
  117305. */
  117306. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117307. private _clientWaitAsync;
  117308. /** @hidden */
  117309. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117310. dispose(): void;
  117311. private _disableTouchAction;
  117312. /**
  117313. * Display the loading screen
  117314. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117315. */
  117316. displayLoadingUI(): void;
  117317. /**
  117318. * Hide the loading screen
  117319. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117320. */
  117321. hideLoadingUI(): void;
  117322. /**
  117323. * Gets the current loading screen object
  117324. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117325. */
  117326. get loadingScreen(): ILoadingScreen;
  117327. /**
  117328. * Sets the current loading screen object
  117329. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117330. */
  117331. set loadingScreen(loadingScreen: ILoadingScreen);
  117332. /**
  117333. * Sets the current loading screen text
  117334. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117335. */
  117336. set loadingUIText(text: string);
  117337. /**
  117338. * Sets the current loading screen background color
  117339. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117340. */
  117341. set loadingUIBackgroundColor(color: string);
  117342. /** Pointerlock and fullscreen */
  117343. /**
  117344. * Ask the browser to promote the current element to pointerlock mode
  117345. * @param element defines the DOM element to promote
  117346. */
  117347. static _RequestPointerlock(element: HTMLElement): void;
  117348. /**
  117349. * Asks the browser to exit pointerlock mode
  117350. */
  117351. static _ExitPointerlock(): void;
  117352. /**
  117353. * Ask the browser to promote the current element to fullscreen rendering mode
  117354. * @param element defines the DOM element to promote
  117355. */
  117356. static _RequestFullscreen(element: HTMLElement): void;
  117357. /**
  117358. * Asks the browser to exit fullscreen mode
  117359. */
  117360. static _ExitFullscreen(): void;
  117361. }
  117362. }
  117363. declare module BABYLON {
  117364. /**
  117365. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117366. * during the life time of the application.
  117367. */
  117368. export class EngineStore {
  117369. /** Gets the list of created engines */
  117370. static Instances: Engine[];
  117371. /** @hidden */
  117372. static _LastCreatedScene: Nullable<Scene>;
  117373. /**
  117374. * Gets the latest created engine
  117375. */
  117376. static get LastCreatedEngine(): Nullable<Engine>;
  117377. /**
  117378. * Gets the latest created scene
  117379. */
  117380. static get LastCreatedScene(): Nullable<Scene>;
  117381. /**
  117382. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117383. * @ignorenaming
  117384. */
  117385. static UseFallbackTexture: boolean;
  117386. /**
  117387. * Texture content used if a texture cannot loaded
  117388. * @ignorenaming
  117389. */
  117390. static FallbackTexture: string;
  117391. }
  117392. }
  117393. declare module BABYLON {
  117394. /**
  117395. * Helper class that provides a small promise polyfill
  117396. */
  117397. export class PromisePolyfill {
  117398. /**
  117399. * Static function used to check if the polyfill is required
  117400. * If this is the case then the function will inject the polyfill to window.Promise
  117401. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117402. */
  117403. static Apply(force?: boolean): void;
  117404. }
  117405. }
  117406. declare module BABYLON {
  117407. /**
  117408. * Interface for screenshot methods with describe argument called `size` as object with options
  117409. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117410. */
  117411. export interface IScreenshotSize {
  117412. /**
  117413. * number in pixels for canvas height
  117414. */
  117415. height?: number;
  117416. /**
  117417. * multiplier allowing render at a higher or lower resolution
  117418. * If value is defined then height and width will be ignored and taken from camera
  117419. */
  117420. precision?: number;
  117421. /**
  117422. * number in pixels for canvas width
  117423. */
  117424. width?: number;
  117425. }
  117426. }
  117427. declare module BABYLON {
  117428. interface IColor4Like {
  117429. r: float;
  117430. g: float;
  117431. b: float;
  117432. a: float;
  117433. }
  117434. /**
  117435. * Class containing a set of static utilities functions
  117436. */
  117437. export class Tools {
  117438. /**
  117439. * Gets or sets the base URL to use to load assets
  117440. */
  117441. static get BaseUrl(): string;
  117442. static set BaseUrl(value: string);
  117443. /**
  117444. * Enable/Disable Custom HTTP Request Headers globally.
  117445. * default = false
  117446. * @see CustomRequestHeaders
  117447. */
  117448. static UseCustomRequestHeaders: boolean;
  117449. /**
  117450. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117451. * i.e. when loading files, where the server/service expects an Authorization header
  117452. */
  117453. static CustomRequestHeaders: {
  117454. [key: string]: string;
  117455. };
  117456. /**
  117457. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117458. */
  117459. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117460. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117461. /**
  117462. * Default behaviour for cors in the application.
  117463. * It can be a string if the expected behavior is identical in the entire app.
  117464. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117465. */
  117466. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117467. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117468. /**
  117469. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117470. * @ignorenaming
  117471. */
  117472. static get UseFallbackTexture(): boolean;
  117473. static set UseFallbackTexture(value: boolean);
  117474. /**
  117475. * Use this object to register external classes like custom textures or material
  117476. * to allow the laoders to instantiate them
  117477. */
  117478. static get RegisteredExternalClasses(): {
  117479. [key: string]: Object;
  117480. };
  117481. static set RegisteredExternalClasses(classes: {
  117482. [key: string]: Object;
  117483. });
  117484. /**
  117485. * Texture content used if a texture cannot loaded
  117486. * @ignorenaming
  117487. */
  117488. static get fallbackTexture(): string;
  117489. static set fallbackTexture(value: string);
  117490. /**
  117491. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  117492. * @param u defines the coordinate on X axis
  117493. * @param v defines the coordinate on Y axis
  117494. * @param width defines the width of the source data
  117495. * @param height defines the height of the source data
  117496. * @param pixels defines the source byte array
  117497. * @param color defines the output color
  117498. */
  117499. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  117500. /**
  117501. * Interpolates between a and b via alpha
  117502. * @param a The lower value (returned when alpha = 0)
  117503. * @param b The upper value (returned when alpha = 1)
  117504. * @param alpha The interpolation-factor
  117505. * @return The mixed value
  117506. */
  117507. static Mix(a: number, b: number, alpha: number): number;
  117508. /**
  117509. * Tries to instantiate a new object from a given class name
  117510. * @param className defines the class name to instantiate
  117511. * @returns the new object or null if the system was not able to do the instantiation
  117512. */
  117513. static Instantiate(className: string): any;
  117514. /**
  117515. * Provides a slice function that will work even on IE
  117516. * @param data defines the array to slice
  117517. * @param start defines the start of the data (optional)
  117518. * @param end defines the end of the data (optional)
  117519. * @returns the new sliced array
  117520. */
  117521. static Slice<T>(data: T, start?: number, end?: number): T;
  117522. /**
  117523. * Polyfill for setImmediate
  117524. * @param action defines the action to execute after the current execution block
  117525. */
  117526. static SetImmediate(action: () => void): void;
  117527. /**
  117528. * Function indicating if a number is an exponent of 2
  117529. * @param value defines the value to test
  117530. * @returns true if the value is an exponent of 2
  117531. */
  117532. static IsExponentOfTwo(value: number): boolean;
  117533. private static _tmpFloatArray;
  117534. /**
  117535. * Returns the nearest 32-bit single precision float representation of a Number
  117536. * @param value A Number. If the parameter is of a different type, it will get converted
  117537. * to a number or to NaN if it cannot be converted
  117538. * @returns number
  117539. */
  117540. static FloatRound(value: number): number;
  117541. /**
  117542. * Extracts the filename from a path
  117543. * @param path defines the path to use
  117544. * @returns the filename
  117545. */
  117546. static GetFilename(path: string): string;
  117547. /**
  117548. * Extracts the "folder" part of a path (everything before the filename).
  117549. * @param uri The URI to extract the info from
  117550. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117551. * @returns The "folder" part of the path
  117552. */
  117553. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117554. /**
  117555. * Extracts text content from a DOM element hierarchy
  117556. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117557. */
  117558. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117559. /**
  117560. * Convert an angle in radians to degrees
  117561. * @param angle defines the angle to convert
  117562. * @returns the angle in degrees
  117563. */
  117564. static ToDegrees(angle: number): number;
  117565. /**
  117566. * Convert an angle in degrees to radians
  117567. * @param angle defines the angle to convert
  117568. * @returns the angle in radians
  117569. */
  117570. static ToRadians(angle: number): number;
  117571. /**
  117572. * Returns an array if obj is not an array
  117573. * @param obj defines the object to evaluate as an array
  117574. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117575. * @returns either obj directly if obj is an array or a new array containing obj
  117576. */
  117577. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117578. /**
  117579. * Gets the pointer prefix to use
  117580. * @param engine defines the engine we are finding the prefix for
  117581. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117582. */
  117583. static GetPointerPrefix(engine: Engine): string;
  117584. /**
  117585. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117586. * @param url define the url we are trying
  117587. * @param element define the dom element where to configure the cors policy
  117588. */
  117589. static SetCorsBehavior(url: string | string[], element: {
  117590. crossOrigin: string | null;
  117591. }): void;
  117592. /**
  117593. * Removes unwanted characters from an url
  117594. * @param url defines the url to clean
  117595. * @returns the cleaned url
  117596. */
  117597. static CleanUrl(url: string): string;
  117598. /**
  117599. * Gets or sets a function used to pre-process url before using them to load assets
  117600. */
  117601. static get PreprocessUrl(): (url: string) => string;
  117602. static set PreprocessUrl(processor: (url: string) => string);
  117603. /**
  117604. * Loads an image as an HTMLImageElement.
  117605. * @param input url string, ArrayBuffer, or Blob to load
  117606. * @param onLoad callback called when the image successfully loads
  117607. * @param onError callback called when the image fails to load
  117608. * @param offlineProvider offline provider for caching
  117609. * @param mimeType optional mime type
  117610. * @returns the HTMLImageElement of the loaded image
  117611. */
  117612. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117613. /**
  117614. * Loads a file from a url
  117615. * @param url url string, ArrayBuffer, or Blob to load
  117616. * @param onSuccess callback called when the file successfully loads
  117617. * @param onProgress callback called while file is loading (if the server supports this mode)
  117618. * @param offlineProvider defines the offline provider for caching
  117619. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117620. * @param onError callback called when the file fails to load
  117621. * @returns a file request object
  117622. */
  117623. 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;
  117624. /**
  117625. * Loads a file from a url
  117626. * @param url the file url to load
  117627. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117628. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117629. */
  117630. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117631. /**
  117632. * Load a script (identified by an url). When the url returns, the
  117633. * content of this file is added into a new script element, attached to the DOM (body element)
  117634. * @param scriptUrl defines the url of the script to laod
  117635. * @param onSuccess defines the callback called when the script is loaded
  117636. * @param onError defines the callback to call if an error occurs
  117637. * @param scriptId defines the id of the script element
  117638. */
  117639. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117640. /**
  117641. * Load an asynchronous script (identified by an url). When the url returns, the
  117642. * content of this file is added into a new script element, attached to the DOM (body element)
  117643. * @param scriptUrl defines the url of the script to laod
  117644. * @param scriptId defines the id of the script element
  117645. * @returns a promise request object
  117646. */
  117647. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117648. /**
  117649. * Loads a file from a blob
  117650. * @param fileToLoad defines the blob to use
  117651. * @param callback defines the callback to call when data is loaded
  117652. * @param progressCallback defines the callback to call during loading process
  117653. * @returns a file request object
  117654. */
  117655. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117656. /**
  117657. * Reads a file from a File object
  117658. * @param file defines the file to load
  117659. * @param onSuccess defines the callback to call when data is loaded
  117660. * @param onProgress defines the callback to call during loading process
  117661. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117662. * @param onError defines the callback to call when an error occurs
  117663. * @returns a file request object
  117664. */
  117665. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117666. /**
  117667. * Creates a data url from a given string content
  117668. * @param content defines the content to convert
  117669. * @returns the new data url link
  117670. */
  117671. static FileAsURL(content: string): string;
  117672. /**
  117673. * Format the given number to a specific decimal format
  117674. * @param value defines the number to format
  117675. * @param decimals defines the number of decimals to use
  117676. * @returns the formatted string
  117677. */
  117678. static Format(value: number, decimals?: number): string;
  117679. /**
  117680. * Tries to copy an object by duplicating every property
  117681. * @param source defines the source object
  117682. * @param destination defines the target object
  117683. * @param doNotCopyList defines a list of properties to avoid
  117684. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117685. */
  117686. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117687. /**
  117688. * Gets a boolean indicating if the given object has no own property
  117689. * @param obj defines the object to test
  117690. * @returns true if object has no own property
  117691. */
  117692. static IsEmpty(obj: any): boolean;
  117693. /**
  117694. * Function used to register events at window level
  117695. * @param windowElement defines the Window object to use
  117696. * @param events defines the events to register
  117697. */
  117698. static RegisterTopRootEvents(windowElement: Window, events: {
  117699. name: string;
  117700. handler: Nullable<(e: FocusEvent) => any>;
  117701. }[]): void;
  117702. /**
  117703. * Function used to unregister events from window level
  117704. * @param windowElement defines the Window object to use
  117705. * @param events defines the events to unregister
  117706. */
  117707. static UnregisterTopRootEvents(windowElement: Window, events: {
  117708. name: string;
  117709. handler: Nullable<(e: FocusEvent) => any>;
  117710. }[]): void;
  117711. /**
  117712. * @ignore
  117713. */
  117714. static _ScreenshotCanvas: HTMLCanvasElement;
  117715. /**
  117716. * Dumps the current bound framebuffer
  117717. * @param width defines the rendering width
  117718. * @param height defines the rendering height
  117719. * @param engine defines the hosting engine
  117720. * @param successCallback defines the callback triggered once the data are available
  117721. * @param mimeType defines the mime type of the result
  117722. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117723. */
  117724. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117725. /**
  117726. * Converts the canvas data to blob.
  117727. * This acts as a polyfill for browsers not supporting the to blob function.
  117728. * @param canvas Defines the canvas to extract the data from
  117729. * @param successCallback Defines the callback triggered once the data are available
  117730. * @param mimeType Defines the mime type of the result
  117731. */
  117732. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117733. /**
  117734. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117735. * @param successCallback defines the callback triggered once the data are available
  117736. * @param mimeType defines the mime type of the result
  117737. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117738. */
  117739. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117740. /**
  117741. * Downloads a blob in the browser
  117742. * @param blob defines the blob to download
  117743. * @param fileName defines the name of the downloaded file
  117744. */
  117745. static Download(blob: Blob, fileName: string): void;
  117746. /**
  117747. * Captures a screenshot of the current rendering
  117748. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117749. * @param engine defines the rendering engine
  117750. * @param camera defines the source camera
  117751. * @param size This parameter can be set to a single number or to an object with the
  117752. * following (optional) properties: precision, width, height. If a single number is passed,
  117753. * it will be used for both width and height. If an object is passed, the screenshot size
  117754. * will be derived from the parameters. The precision property is a multiplier allowing
  117755. * rendering at a higher or lower resolution
  117756. * @param successCallback defines the callback receives a single parameter which contains the
  117757. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117758. * src parameter of an <img> to display it
  117759. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117760. * Check your browser for supported MIME types
  117761. */
  117762. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117763. /**
  117764. * Captures a screenshot of the current rendering
  117765. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117766. * @param engine defines the rendering engine
  117767. * @param camera defines the source camera
  117768. * @param size This parameter can be set to a single number or to an object with the
  117769. * following (optional) properties: precision, width, height. If a single number is passed,
  117770. * it will be used for both width and height. If an object is passed, the screenshot size
  117771. * will be derived from the parameters. The precision property is a multiplier allowing
  117772. * rendering at a higher or lower resolution
  117773. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117774. * Check your browser for supported MIME types
  117775. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117776. * to the src parameter of an <img> to display it
  117777. */
  117778. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117779. /**
  117780. * Generates an image screenshot from the specified camera.
  117781. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117782. * @param engine The engine to use for rendering
  117783. * @param camera The camera to use for rendering
  117784. * @param size This parameter can be set to a single number or to an object with the
  117785. * following (optional) properties: precision, width, height. If a single number is passed,
  117786. * it will be used for both width and height. If an object is passed, the screenshot size
  117787. * will be derived from the parameters. The precision property is a multiplier allowing
  117788. * rendering at a higher or lower resolution
  117789. * @param successCallback The callback receives a single parameter which contains the
  117790. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117791. * src parameter of an <img> to display it
  117792. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117793. * Check your browser for supported MIME types
  117794. * @param samples Texture samples (default: 1)
  117795. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117796. * @param fileName A name for for the downloaded file.
  117797. */
  117798. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117799. /**
  117800. * Generates an image screenshot from the specified camera.
  117801. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117802. * @param engine The engine to use for rendering
  117803. * @param camera The camera to use for rendering
  117804. * @param size This parameter can be set to a single number or to an object with the
  117805. * following (optional) properties: precision, width, height. If a single number is passed,
  117806. * it will be used for both width and height. If an object is passed, the screenshot size
  117807. * will be derived from the parameters. The precision property is a multiplier allowing
  117808. * rendering at a higher or lower resolution
  117809. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117810. * Check your browser for supported MIME types
  117811. * @param samples Texture samples (default: 1)
  117812. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117813. * @param fileName A name for for the downloaded file.
  117814. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117815. * to the src parameter of an <img> to display it
  117816. */
  117817. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117818. /**
  117819. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117820. * Be aware Math.random() could cause collisions, but:
  117821. * "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"
  117822. * @returns a pseudo random id
  117823. */
  117824. static RandomId(): string;
  117825. /**
  117826. * Test if the given uri is a base64 string
  117827. * @param uri The uri to test
  117828. * @return True if the uri is a base64 string or false otherwise
  117829. */
  117830. static IsBase64(uri: string): boolean;
  117831. /**
  117832. * Decode the given base64 uri.
  117833. * @param uri The uri to decode
  117834. * @return The decoded base64 data.
  117835. */
  117836. static DecodeBase64(uri: string): ArrayBuffer;
  117837. /**
  117838. * Gets the absolute url.
  117839. * @param url the input url
  117840. * @return the absolute url
  117841. */
  117842. static GetAbsoluteUrl(url: string): string;
  117843. /**
  117844. * No log
  117845. */
  117846. static readonly NoneLogLevel: number;
  117847. /**
  117848. * Only message logs
  117849. */
  117850. static readonly MessageLogLevel: number;
  117851. /**
  117852. * Only warning logs
  117853. */
  117854. static readonly WarningLogLevel: number;
  117855. /**
  117856. * Only error logs
  117857. */
  117858. static readonly ErrorLogLevel: number;
  117859. /**
  117860. * All logs
  117861. */
  117862. static readonly AllLogLevel: number;
  117863. /**
  117864. * Gets a value indicating the number of loading errors
  117865. * @ignorenaming
  117866. */
  117867. static get errorsCount(): number;
  117868. /**
  117869. * Callback called when a new log is added
  117870. */
  117871. static OnNewCacheEntry: (entry: string) => void;
  117872. /**
  117873. * Log a message to the console
  117874. * @param message defines the message to log
  117875. */
  117876. static Log(message: string): void;
  117877. /**
  117878. * Write a warning message to the console
  117879. * @param message defines the message to log
  117880. */
  117881. static Warn(message: string): void;
  117882. /**
  117883. * Write an error message to the console
  117884. * @param message defines the message to log
  117885. */
  117886. static Error(message: string): void;
  117887. /**
  117888. * Gets current log cache (list of logs)
  117889. */
  117890. static get LogCache(): string;
  117891. /**
  117892. * Clears the log cache
  117893. */
  117894. static ClearLogCache(): void;
  117895. /**
  117896. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117897. */
  117898. static set LogLevels(level: number);
  117899. /**
  117900. * Checks if the window object exists
  117901. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117902. */
  117903. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117904. /**
  117905. * No performance log
  117906. */
  117907. static readonly PerformanceNoneLogLevel: number;
  117908. /**
  117909. * Use user marks to log performance
  117910. */
  117911. static readonly PerformanceUserMarkLogLevel: number;
  117912. /**
  117913. * Log performance to the console
  117914. */
  117915. static readonly PerformanceConsoleLogLevel: number;
  117916. private static _performance;
  117917. /**
  117918. * Sets the current performance log level
  117919. */
  117920. static set PerformanceLogLevel(level: number);
  117921. private static _StartPerformanceCounterDisabled;
  117922. private static _EndPerformanceCounterDisabled;
  117923. private static _StartUserMark;
  117924. private static _EndUserMark;
  117925. private static _StartPerformanceConsole;
  117926. private static _EndPerformanceConsole;
  117927. /**
  117928. * Starts a performance counter
  117929. */
  117930. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117931. /**
  117932. * Ends a specific performance coutner
  117933. */
  117934. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117935. /**
  117936. * Gets either window.performance.now() if supported or Date.now() else
  117937. */
  117938. static get Now(): number;
  117939. /**
  117940. * This method will return the name of the class used to create the instance of the given object.
  117941. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117942. * @param object the object to get the class name from
  117943. * @param isType defines if the object is actually a type
  117944. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117945. */
  117946. static GetClassName(object: any, isType?: boolean): string;
  117947. /**
  117948. * Gets the first element of an array satisfying a given predicate
  117949. * @param array defines the array to browse
  117950. * @param predicate defines the predicate to use
  117951. * @returns null if not found or the element
  117952. */
  117953. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117954. /**
  117955. * This method will return the name of the full name of the class, including its owning module (if any).
  117956. * 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).
  117957. * @param object the object to get the class name from
  117958. * @param isType defines if the object is actually a type
  117959. * @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.
  117960. * @ignorenaming
  117961. */
  117962. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117963. /**
  117964. * Returns a promise that resolves after the given amount of time.
  117965. * @param delay Number of milliseconds to delay
  117966. * @returns Promise that resolves after the given amount of time
  117967. */
  117968. static DelayAsync(delay: number): Promise<void>;
  117969. /**
  117970. * Utility function to detect if the current user agent is Safari
  117971. * @returns whether or not the current user agent is safari
  117972. */
  117973. static IsSafari(): boolean;
  117974. }
  117975. /**
  117976. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117977. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117978. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117979. * @param name The name of the class, case should be preserved
  117980. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117981. */
  117982. export function className(name: string, module?: string): (target: Object) => void;
  117983. /**
  117984. * An implementation of a loop for asynchronous functions.
  117985. */
  117986. export class AsyncLoop {
  117987. /**
  117988. * Defines the number of iterations for the loop
  117989. */
  117990. iterations: number;
  117991. /**
  117992. * Defines the current index of the loop.
  117993. */
  117994. index: number;
  117995. private _done;
  117996. private _fn;
  117997. private _successCallback;
  117998. /**
  117999. * Constructor.
  118000. * @param iterations the number of iterations.
  118001. * @param func the function to run each iteration
  118002. * @param successCallback the callback that will be called upon succesful execution
  118003. * @param offset starting offset.
  118004. */
  118005. constructor(
  118006. /**
  118007. * Defines the number of iterations for the loop
  118008. */
  118009. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118010. /**
  118011. * Execute the next iteration. Must be called after the last iteration was finished.
  118012. */
  118013. executeNext(): void;
  118014. /**
  118015. * Break the loop and run the success callback.
  118016. */
  118017. breakLoop(): void;
  118018. /**
  118019. * Create and run an async loop.
  118020. * @param iterations the number of iterations.
  118021. * @param fn the function to run each iteration
  118022. * @param successCallback the callback that will be called upon succesful execution
  118023. * @param offset starting offset.
  118024. * @returns the created async loop object
  118025. */
  118026. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118027. /**
  118028. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118029. * @param iterations total number of iterations
  118030. * @param syncedIterations number of synchronous iterations in each async iteration.
  118031. * @param fn the function to call each iteration.
  118032. * @param callback a success call back that will be called when iterating stops.
  118033. * @param breakFunction a break condition (optional)
  118034. * @param timeout timeout settings for the setTimeout function. default - 0.
  118035. * @returns the created async loop object
  118036. */
  118037. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118038. }
  118039. }
  118040. declare module BABYLON {
  118041. /**
  118042. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118043. * The underlying implementation relies on an associative array to ensure the best performances.
  118044. * The value can be anything including 'null' but except 'undefined'
  118045. */
  118046. export class StringDictionary<T> {
  118047. /**
  118048. * This will clear this dictionary and copy the content from the 'source' one.
  118049. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118050. * @param source the dictionary to take the content from and copy to this dictionary
  118051. */
  118052. copyFrom(source: StringDictionary<T>): void;
  118053. /**
  118054. * Get a value based from its key
  118055. * @param key the given key to get the matching value from
  118056. * @return the value if found, otherwise undefined is returned
  118057. */
  118058. get(key: string): T | undefined;
  118059. /**
  118060. * Get a value from its key or add it if it doesn't exist.
  118061. * This method will ensure you that a given key/data will be present in the dictionary.
  118062. * @param key the given key to get the matching value from
  118063. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118064. * The factory will only be invoked if there's no data for the given key.
  118065. * @return the value corresponding to the key.
  118066. */
  118067. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118068. /**
  118069. * Get a value from its key if present in the dictionary otherwise add it
  118070. * @param key the key to get the value from
  118071. * @param val if there's no such key/value pair in the dictionary add it with this value
  118072. * @return the value corresponding to the key
  118073. */
  118074. getOrAdd(key: string, val: T): T;
  118075. /**
  118076. * Check if there's a given key in the dictionary
  118077. * @param key the key to check for
  118078. * @return true if the key is present, false otherwise
  118079. */
  118080. contains(key: string): boolean;
  118081. /**
  118082. * Add a new key and its corresponding value
  118083. * @param key the key to add
  118084. * @param value the value corresponding to the key
  118085. * @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
  118086. */
  118087. add(key: string, value: T): boolean;
  118088. /**
  118089. * Update a specific value associated to a key
  118090. * @param key defines the key to use
  118091. * @param value defines the value to store
  118092. * @returns true if the value was updated (or false if the key was not found)
  118093. */
  118094. set(key: string, value: T): boolean;
  118095. /**
  118096. * Get the element of the given key and remove it from the dictionary
  118097. * @param key defines the key to search
  118098. * @returns the value associated with the key or null if not found
  118099. */
  118100. getAndRemove(key: string): Nullable<T>;
  118101. /**
  118102. * Remove a key/value from the dictionary.
  118103. * @param key the key to remove
  118104. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118105. */
  118106. remove(key: string): boolean;
  118107. /**
  118108. * Clear the whole content of the dictionary
  118109. */
  118110. clear(): void;
  118111. /**
  118112. * Gets the current count
  118113. */
  118114. get count(): number;
  118115. /**
  118116. * Execute a callback on each key/val of the dictionary.
  118117. * Note that you can remove any element in this dictionary in the callback implementation
  118118. * @param callback the callback to execute on a given key/value pair
  118119. */
  118120. forEach(callback: (key: string, val: T) => void): void;
  118121. /**
  118122. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118123. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118124. * Note that you can remove any element in this dictionary in the callback implementation
  118125. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118126. * @returns the first item
  118127. */
  118128. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118129. private _count;
  118130. private _data;
  118131. }
  118132. }
  118133. declare module BABYLON {
  118134. /** @hidden */
  118135. export interface ICollisionCoordinator {
  118136. createCollider(): Collider;
  118137. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118138. init(scene: Scene): void;
  118139. }
  118140. /** @hidden */
  118141. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118142. private _scene;
  118143. private _scaledPosition;
  118144. private _scaledVelocity;
  118145. private _finalPosition;
  118146. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118147. createCollider(): Collider;
  118148. init(scene: Scene): void;
  118149. private _collideWithWorld;
  118150. }
  118151. }
  118152. declare module BABYLON {
  118153. /**
  118154. * Class used to manage all inputs for the scene.
  118155. */
  118156. export class InputManager {
  118157. /** The distance in pixel that you have to move to prevent some events */
  118158. static DragMovementThreshold: number;
  118159. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118160. static LongPressDelay: number;
  118161. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118162. static DoubleClickDelay: number;
  118163. /** If you need to check double click without raising a single click at first click, enable this flag */
  118164. static ExclusiveDoubleClickMode: boolean;
  118165. /** 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. */
  118166. private _alreadyAttached;
  118167. private _wheelEventName;
  118168. private _onPointerMove;
  118169. private _onPointerDown;
  118170. private _onPointerUp;
  118171. private _initClickEvent;
  118172. private _initActionManager;
  118173. private _delayedSimpleClick;
  118174. private _delayedSimpleClickTimeout;
  118175. private _previousDelayedSimpleClickTimeout;
  118176. private _meshPickProceed;
  118177. private _previousButtonPressed;
  118178. private _currentPickResult;
  118179. private _previousPickResult;
  118180. private _totalPointersPressed;
  118181. private _doubleClickOccured;
  118182. private _pointerOverMesh;
  118183. private _pickedDownMesh;
  118184. private _pickedUpMesh;
  118185. private _pointerX;
  118186. private _pointerY;
  118187. private _unTranslatedPointerX;
  118188. private _unTranslatedPointerY;
  118189. private _startingPointerPosition;
  118190. private _previousStartingPointerPosition;
  118191. private _startingPointerTime;
  118192. private _previousStartingPointerTime;
  118193. private _pointerCaptures;
  118194. private _onKeyDown;
  118195. private _onKeyUp;
  118196. private _onCanvasFocusObserver;
  118197. private _onCanvasBlurObserver;
  118198. private _scene;
  118199. /**
  118200. * Creates a new InputManager
  118201. * @param scene defines the hosting scene
  118202. */
  118203. constructor(scene: Scene);
  118204. /**
  118205. * Gets the mesh that is currently under the pointer
  118206. */
  118207. get meshUnderPointer(): Nullable<AbstractMesh>;
  118208. /**
  118209. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  118210. */
  118211. get unTranslatedPointer(): Vector2;
  118212. /**
  118213. * Gets or sets the current on-screen X position of the pointer
  118214. */
  118215. get pointerX(): number;
  118216. set pointerX(value: number);
  118217. /**
  118218. * Gets or sets the current on-screen Y position of the pointer
  118219. */
  118220. get pointerY(): number;
  118221. set pointerY(value: number);
  118222. private _updatePointerPosition;
  118223. private _processPointerMove;
  118224. private _setRayOnPointerInfo;
  118225. private _checkPrePointerObservable;
  118226. /**
  118227. * Use this method to simulate a pointer move on a mesh
  118228. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118229. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118230. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118231. */
  118232. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118233. /**
  118234. * Use this method to simulate a pointer down on a mesh
  118235. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118236. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118237. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118238. */
  118239. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118240. private _processPointerDown;
  118241. /** @hidden */
  118242. _isPointerSwiping(): boolean;
  118243. /**
  118244. * Use this method to simulate a pointer up on a mesh
  118245. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118246. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118247. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118248. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118249. */
  118250. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  118251. private _processPointerUp;
  118252. /**
  118253. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118254. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118255. * @returns true if the pointer was captured
  118256. */
  118257. isPointerCaptured(pointerId?: number): boolean;
  118258. /**
  118259. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118260. * @param attachUp defines if you want to attach events to pointerup
  118261. * @param attachDown defines if you want to attach events to pointerdown
  118262. * @param attachMove defines if you want to attach events to pointermove
  118263. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  118264. */
  118265. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  118266. /**
  118267. * Detaches all event handlers
  118268. */
  118269. detachControl(): void;
  118270. /**
  118271. * Force the value of meshUnderPointer
  118272. * @param mesh defines the mesh to use
  118273. */
  118274. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118275. /**
  118276. * Gets the mesh under the pointer
  118277. * @returns a Mesh or null if no mesh is under the pointer
  118278. */
  118279. getPointerOverMesh(): Nullable<AbstractMesh>;
  118280. }
  118281. }
  118282. declare module BABYLON {
  118283. /**
  118284. * This class defines the direct association between an animation and a target
  118285. */
  118286. export class TargetedAnimation {
  118287. /**
  118288. * Animation to perform
  118289. */
  118290. animation: Animation;
  118291. /**
  118292. * Target to animate
  118293. */
  118294. target: any;
  118295. /**
  118296. * Returns the string "TargetedAnimation"
  118297. * @returns "TargetedAnimation"
  118298. */
  118299. getClassName(): string;
  118300. /**
  118301. * Serialize the object
  118302. * @returns the JSON object representing the current entity
  118303. */
  118304. serialize(): any;
  118305. }
  118306. /**
  118307. * Use this class to create coordinated animations on multiple targets
  118308. */
  118309. export class AnimationGroup implements IDisposable {
  118310. /** The name of the animation group */
  118311. name: string;
  118312. private _scene;
  118313. private _targetedAnimations;
  118314. private _animatables;
  118315. private _from;
  118316. private _to;
  118317. private _isStarted;
  118318. private _isPaused;
  118319. private _speedRatio;
  118320. private _loopAnimation;
  118321. private _isAdditive;
  118322. /**
  118323. * Gets or sets the unique id of the node
  118324. */
  118325. uniqueId: number;
  118326. /**
  118327. * This observable will notify when one animation have ended
  118328. */
  118329. onAnimationEndObservable: Observable<TargetedAnimation>;
  118330. /**
  118331. * Observer raised when one animation loops
  118332. */
  118333. onAnimationLoopObservable: Observable<TargetedAnimation>;
  118334. /**
  118335. * Observer raised when all animations have looped
  118336. */
  118337. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  118338. /**
  118339. * This observable will notify when all animations have ended.
  118340. */
  118341. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118342. /**
  118343. * This observable will notify when all animations have paused.
  118344. */
  118345. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118346. /**
  118347. * This observable will notify when all animations are playing.
  118348. */
  118349. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118350. /**
  118351. * Gets the first frame
  118352. */
  118353. get from(): number;
  118354. /**
  118355. * Gets the last frame
  118356. */
  118357. get to(): number;
  118358. /**
  118359. * Define if the animations are started
  118360. */
  118361. get isStarted(): boolean;
  118362. /**
  118363. * Gets a value indicating that the current group is playing
  118364. */
  118365. get isPlaying(): boolean;
  118366. /**
  118367. * Gets or sets the speed ratio to use for all animations
  118368. */
  118369. get speedRatio(): number;
  118370. /**
  118371. * Gets or sets the speed ratio to use for all animations
  118372. */
  118373. set speedRatio(value: number);
  118374. /**
  118375. * Gets or sets if all animations should loop or not
  118376. */
  118377. get loopAnimation(): boolean;
  118378. set loopAnimation(value: boolean);
  118379. /**
  118380. * Gets or sets if all animations should be evaluated additively
  118381. */
  118382. get isAdditive(): boolean;
  118383. set isAdditive(value: boolean);
  118384. /**
  118385. * Gets the targeted animations for this animation group
  118386. */
  118387. get targetedAnimations(): Array<TargetedAnimation>;
  118388. /**
  118389. * returning the list of animatables controlled by this animation group.
  118390. */
  118391. get animatables(): Array<Animatable>;
  118392. /**
  118393. * Gets the list of target animations
  118394. */
  118395. get children(): TargetedAnimation[];
  118396. /**
  118397. * Instantiates a new Animation Group.
  118398. * This helps managing several animations at once.
  118399. * @see https://doc.babylonjs.com/how_to/group
  118400. * @param name Defines the name of the group
  118401. * @param scene Defines the scene the group belongs to
  118402. */
  118403. constructor(
  118404. /** The name of the animation group */
  118405. name: string, scene?: Nullable<Scene>);
  118406. /**
  118407. * Add an animation (with its target) in the group
  118408. * @param animation defines the animation we want to add
  118409. * @param target defines the target of the animation
  118410. * @returns the TargetedAnimation object
  118411. */
  118412. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118413. /**
  118414. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118415. * It can add constant keys at begin or end
  118416. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118417. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118418. * @returns the animation group
  118419. */
  118420. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118421. private _animationLoopCount;
  118422. private _animationLoopFlags;
  118423. private _processLoop;
  118424. /**
  118425. * Start all animations on given targets
  118426. * @param loop defines if animations must loop
  118427. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118428. * @param from defines the from key (optional)
  118429. * @param to defines the to key (optional)
  118430. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118431. * @returns the current animation group
  118432. */
  118433. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118434. /**
  118435. * Pause all animations
  118436. * @returns the animation group
  118437. */
  118438. pause(): AnimationGroup;
  118439. /**
  118440. * Play all animations to initial state
  118441. * This function will start() the animations if they were not started or will restart() them if they were paused
  118442. * @param loop defines if animations must loop
  118443. * @returns the animation group
  118444. */
  118445. play(loop?: boolean): AnimationGroup;
  118446. /**
  118447. * Reset all animations to initial state
  118448. * @returns the animation group
  118449. */
  118450. reset(): AnimationGroup;
  118451. /**
  118452. * Restart animations from key 0
  118453. * @returns the animation group
  118454. */
  118455. restart(): AnimationGroup;
  118456. /**
  118457. * Stop all animations
  118458. * @returns the animation group
  118459. */
  118460. stop(): AnimationGroup;
  118461. /**
  118462. * Set animation weight for all animatables
  118463. * @param weight defines the weight to use
  118464. * @return the animationGroup
  118465. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118466. */
  118467. setWeightForAllAnimatables(weight: number): AnimationGroup;
  118468. /**
  118469. * Synchronize and normalize all animatables with a source animatable
  118470. * @param root defines the root animatable to synchronize with
  118471. * @return the animationGroup
  118472. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118473. */
  118474. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  118475. /**
  118476. * Goes to a specific frame in this animation group
  118477. * @param frame the frame number to go to
  118478. * @return the animationGroup
  118479. */
  118480. goToFrame(frame: number): AnimationGroup;
  118481. /**
  118482. * Dispose all associated resources
  118483. */
  118484. dispose(): void;
  118485. private _checkAnimationGroupEnded;
  118486. /**
  118487. * Clone the current animation group and returns a copy
  118488. * @param newName defines the name of the new group
  118489. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  118490. * @returns the new aniamtion group
  118491. */
  118492. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  118493. /**
  118494. * Serializes the animationGroup to an object
  118495. * @returns Serialized object
  118496. */
  118497. serialize(): any;
  118498. /**
  118499. * Returns a new AnimationGroup object parsed from the source provided.
  118500. * @param parsedAnimationGroup defines the source
  118501. * @param scene defines the scene that will receive the animationGroup
  118502. * @returns a new AnimationGroup
  118503. */
  118504. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  118505. /**
  118506. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118507. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  118508. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118509. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  118510. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  118511. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  118512. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  118513. */
  118514. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  118515. /**
  118516. * Returns the string "AnimationGroup"
  118517. * @returns "AnimationGroup"
  118518. */
  118519. getClassName(): string;
  118520. /**
  118521. * Creates a detailled string about the object
  118522. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  118523. * @returns a string representing the object
  118524. */
  118525. toString(fullDetails?: boolean): string;
  118526. }
  118527. }
  118528. declare module BABYLON {
  118529. /**
  118530. * Define an interface for all classes that will hold resources
  118531. */
  118532. export interface IDisposable {
  118533. /**
  118534. * Releases all held resources
  118535. */
  118536. dispose(): void;
  118537. }
  118538. /** Interface defining initialization parameters for Scene class */
  118539. export interface SceneOptions {
  118540. /**
  118541. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118542. * It will improve performance when the number of geometries becomes important.
  118543. */
  118544. useGeometryUniqueIdsMap?: boolean;
  118545. /**
  118546. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118547. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118548. */
  118549. useMaterialMeshMap?: boolean;
  118550. /**
  118551. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118552. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118553. */
  118554. useClonedMeshMap?: boolean;
  118555. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118556. virtual?: boolean;
  118557. }
  118558. /**
  118559. * Represents a scene to be rendered by the engine.
  118560. * @see https://doc.babylonjs.com/features/scene
  118561. */
  118562. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  118563. /** The fog is deactivated */
  118564. static readonly FOGMODE_NONE: number;
  118565. /** The fog density is following an exponential function */
  118566. static readonly FOGMODE_EXP: number;
  118567. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118568. static readonly FOGMODE_EXP2: number;
  118569. /** The fog density is following a linear function. */
  118570. static readonly FOGMODE_LINEAR: number;
  118571. /**
  118572. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118574. */
  118575. static MinDeltaTime: number;
  118576. /**
  118577. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118579. */
  118580. static MaxDeltaTime: number;
  118581. /**
  118582. * Factory used to create the default material.
  118583. * @param name The name of the material to create
  118584. * @param scene The scene to create the material for
  118585. * @returns The default material
  118586. */
  118587. static DefaultMaterialFactory(scene: Scene): Material;
  118588. /**
  118589. * Factory used to create the a collision coordinator.
  118590. * @returns The collision coordinator
  118591. */
  118592. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118593. /** @hidden */
  118594. _inputManager: InputManager;
  118595. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118596. cameraToUseForPointers: Nullable<Camera>;
  118597. /** @hidden */
  118598. readonly _isScene: boolean;
  118599. /** @hidden */
  118600. _blockEntityCollection: boolean;
  118601. /**
  118602. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118603. */
  118604. autoClear: boolean;
  118605. /**
  118606. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118607. */
  118608. autoClearDepthAndStencil: boolean;
  118609. /**
  118610. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118611. */
  118612. clearColor: Color4;
  118613. /**
  118614. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118615. */
  118616. ambientColor: Color3;
  118617. /**
  118618. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118619. * It should only be one of the following (if not the default embedded one):
  118620. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118621. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118622. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118623. * The material properties need to be setup according to the type of texture in use.
  118624. */
  118625. environmentBRDFTexture: BaseTexture;
  118626. /** @hidden */
  118627. protected _environmentTexture: Nullable<BaseTexture>;
  118628. /**
  118629. * Texture used in all pbr material as the reflection texture.
  118630. * As in the majority of the scene they are the same (exception for multi room and so on),
  118631. * this is easier to reference from here than from all the materials.
  118632. */
  118633. get environmentTexture(): Nullable<BaseTexture>;
  118634. /**
  118635. * Texture used in all pbr material as the reflection texture.
  118636. * As in the majority of the scene they are the same (exception for multi room and so on),
  118637. * this is easier to set here than in all the materials.
  118638. */
  118639. set environmentTexture(value: Nullable<BaseTexture>);
  118640. /** @hidden */
  118641. protected _environmentIntensity: number;
  118642. /**
  118643. * Intensity of the environment in all pbr material.
  118644. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118645. * As in the majority of the scene they are the same (exception for multi room and so on),
  118646. * this is easier to reference from here than from all the materials.
  118647. */
  118648. get environmentIntensity(): number;
  118649. /**
  118650. * Intensity of the environment in all pbr material.
  118651. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118652. * As in the majority of the scene they are the same (exception for multi room and so on),
  118653. * this is easier to set here than in all the materials.
  118654. */
  118655. set environmentIntensity(value: number);
  118656. /** @hidden */
  118657. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118658. /**
  118659. * Default image processing configuration used either in the rendering
  118660. * Forward main pass or through the imageProcessingPostProcess if present.
  118661. * As in the majority of the scene they are the same (exception for multi camera),
  118662. * this is easier to reference from here than from all the materials and post process.
  118663. *
  118664. * No setter as we it is a shared configuration, you can set the values instead.
  118665. */
  118666. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118667. private _forceWireframe;
  118668. /**
  118669. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118670. */
  118671. set forceWireframe(value: boolean);
  118672. get forceWireframe(): boolean;
  118673. private _skipFrustumClipping;
  118674. /**
  118675. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118676. */
  118677. set skipFrustumClipping(value: boolean);
  118678. get skipFrustumClipping(): boolean;
  118679. private _forcePointsCloud;
  118680. /**
  118681. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118682. */
  118683. set forcePointsCloud(value: boolean);
  118684. get forcePointsCloud(): boolean;
  118685. /**
  118686. * Gets or sets the active clipplane 1
  118687. */
  118688. clipPlane: Nullable<Plane>;
  118689. /**
  118690. * Gets or sets the active clipplane 2
  118691. */
  118692. clipPlane2: Nullable<Plane>;
  118693. /**
  118694. * Gets or sets the active clipplane 3
  118695. */
  118696. clipPlane3: Nullable<Plane>;
  118697. /**
  118698. * Gets or sets the active clipplane 4
  118699. */
  118700. clipPlane4: Nullable<Plane>;
  118701. /**
  118702. * Gets or sets the active clipplane 5
  118703. */
  118704. clipPlane5: Nullable<Plane>;
  118705. /**
  118706. * Gets or sets the active clipplane 6
  118707. */
  118708. clipPlane6: Nullable<Plane>;
  118709. /**
  118710. * Gets or sets a boolean indicating if animations are enabled
  118711. */
  118712. animationsEnabled: boolean;
  118713. private _animationPropertiesOverride;
  118714. /**
  118715. * Gets or sets the animation properties override
  118716. */
  118717. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118718. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118719. /**
  118720. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118721. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118722. */
  118723. useConstantAnimationDeltaTime: boolean;
  118724. /**
  118725. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118726. * Please note that it requires to run a ray cast through the scene on every frame
  118727. */
  118728. constantlyUpdateMeshUnderPointer: boolean;
  118729. /**
  118730. * Defines the HTML cursor to use when hovering over interactive elements
  118731. */
  118732. hoverCursor: string;
  118733. /**
  118734. * Defines the HTML default cursor to use (empty by default)
  118735. */
  118736. defaultCursor: string;
  118737. /**
  118738. * Defines whether cursors are handled by the scene.
  118739. */
  118740. doNotHandleCursors: boolean;
  118741. /**
  118742. * This is used to call preventDefault() on pointer down
  118743. * in order to block unwanted artifacts like system double clicks
  118744. */
  118745. preventDefaultOnPointerDown: boolean;
  118746. /**
  118747. * This is used to call preventDefault() on pointer up
  118748. * in order to block unwanted artifacts like system double clicks
  118749. */
  118750. preventDefaultOnPointerUp: boolean;
  118751. /**
  118752. * Gets or sets user defined metadata
  118753. */
  118754. metadata: any;
  118755. /**
  118756. * For internal use only. Please do not use.
  118757. */
  118758. reservedDataStore: any;
  118759. /**
  118760. * Gets the name of the plugin used to load this scene (null by default)
  118761. */
  118762. loadingPluginName: string;
  118763. /**
  118764. * Use this array to add regular expressions used to disable offline support for specific urls
  118765. */
  118766. disableOfflineSupportExceptionRules: RegExp[];
  118767. /**
  118768. * An event triggered when the scene is disposed.
  118769. */
  118770. onDisposeObservable: Observable<Scene>;
  118771. private _onDisposeObserver;
  118772. /** Sets a function to be executed when this scene is disposed. */
  118773. set onDispose(callback: () => void);
  118774. /**
  118775. * An event triggered before rendering the scene (right after animations and physics)
  118776. */
  118777. onBeforeRenderObservable: Observable<Scene>;
  118778. private _onBeforeRenderObserver;
  118779. /** Sets a function to be executed before rendering this scene */
  118780. set beforeRender(callback: Nullable<() => void>);
  118781. /**
  118782. * An event triggered after rendering the scene
  118783. */
  118784. onAfterRenderObservable: Observable<Scene>;
  118785. /**
  118786. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118787. */
  118788. onAfterRenderCameraObservable: Observable<Camera>;
  118789. private _onAfterRenderObserver;
  118790. /** Sets a function to be executed after rendering this scene */
  118791. set afterRender(callback: Nullable<() => void>);
  118792. /**
  118793. * An event triggered before animating the scene
  118794. */
  118795. onBeforeAnimationsObservable: Observable<Scene>;
  118796. /**
  118797. * An event triggered after animations processing
  118798. */
  118799. onAfterAnimationsObservable: Observable<Scene>;
  118800. /**
  118801. * An event triggered before draw calls are ready to be sent
  118802. */
  118803. onBeforeDrawPhaseObservable: Observable<Scene>;
  118804. /**
  118805. * An event triggered after draw calls have been sent
  118806. */
  118807. onAfterDrawPhaseObservable: Observable<Scene>;
  118808. /**
  118809. * An event triggered when the scene is ready
  118810. */
  118811. onReadyObservable: Observable<Scene>;
  118812. /**
  118813. * An event triggered before rendering a camera
  118814. */
  118815. onBeforeCameraRenderObservable: Observable<Camera>;
  118816. private _onBeforeCameraRenderObserver;
  118817. /** Sets a function to be executed before rendering a camera*/
  118818. set beforeCameraRender(callback: () => void);
  118819. /**
  118820. * An event triggered after rendering a camera
  118821. */
  118822. onAfterCameraRenderObservable: Observable<Camera>;
  118823. private _onAfterCameraRenderObserver;
  118824. /** Sets a function to be executed after rendering a camera*/
  118825. set afterCameraRender(callback: () => void);
  118826. /**
  118827. * An event triggered when active meshes evaluation is about to start
  118828. */
  118829. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118830. /**
  118831. * An event triggered when active meshes evaluation is done
  118832. */
  118833. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118834. /**
  118835. * An event triggered when particles rendering is about to start
  118836. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118837. */
  118838. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118839. /**
  118840. * An event triggered when particles rendering is done
  118841. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118842. */
  118843. onAfterParticlesRenderingObservable: Observable<Scene>;
  118844. /**
  118845. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118846. */
  118847. onDataLoadedObservable: Observable<Scene>;
  118848. /**
  118849. * An event triggered when a camera is created
  118850. */
  118851. onNewCameraAddedObservable: Observable<Camera>;
  118852. /**
  118853. * An event triggered when a camera is removed
  118854. */
  118855. onCameraRemovedObservable: Observable<Camera>;
  118856. /**
  118857. * An event triggered when a light is created
  118858. */
  118859. onNewLightAddedObservable: Observable<Light>;
  118860. /**
  118861. * An event triggered when a light is removed
  118862. */
  118863. onLightRemovedObservable: Observable<Light>;
  118864. /**
  118865. * An event triggered when a geometry is created
  118866. */
  118867. onNewGeometryAddedObservable: Observable<Geometry>;
  118868. /**
  118869. * An event triggered when a geometry is removed
  118870. */
  118871. onGeometryRemovedObservable: Observable<Geometry>;
  118872. /**
  118873. * An event triggered when a transform node is created
  118874. */
  118875. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118876. /**
  118877. * An event triggered when a transform node is removed
  118878. */
  118879. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118880. /**
  118881. * An event triggered when a mesh is created
  118882. */
  118883. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118884. /**
  118885. * An event triggered when a mesh is removed
  118886. */
  118887. onMeshRemovedObservable: Observable<AbstractMesh>;
  118888. /**
  118889. * An event triggered when a skeleton is created
  118890. */
  118891. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118892. /**
  118893. * An event triggered when a skeleton is removed
  118894. */
  118895. onSkeletonRemovedObservable: Observable<Skeleton>;
  118896. /**
  118897. * An event triggered when a material is created
  118898. */
  118899. onNewMaterialAddedObservable: Observable<Material>;
  118900. /**
  118901. * An event triggered when a material is removed
  118902. */
  118903. onMaterialRemovedObservable: Observable<Material>;
  118904. /**
  118905. * An event triggered when a texture is created
  118906. */
  118907. onNewTextureAddedObservable: Observable<BaseTexture>;
  118908. /**
  118909. * An event triggered when a texture is removed
  118910. */
  118911. onTextureRemovedObservable: Observable<BaseTexture>;
  118912. /**
  118913. * An event triggered when render targets are about to be rendered
  118914. * Can happen multiple times per frame.
  118915. */
  118916. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118917. /**
  118918. * An event triggered when render targets were rendered.
  118919. * Can happen multiple times per frame.
  118920. */
  118921. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118922. /**
  118923. * An event triggered before calculating deterministic simulation step
  118924. */
  118925. onBeforeStepObservable: Observable<Scene>;
  118926. /**
  118927. * An event triggered after calculating deterministic simulation step
  118928. */
  118929. onAfterStepObservable: Observable<Scene>;
  118930. /**
  118931. * An event triggered when the activeCamera property is updated
  118932. */
  118933. onActiveCameraChanged: Observable<Scene>;
  118934. /**
  118935. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118936. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118937. * 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)
  118938. */
  118939. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118940. /**
  118941. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118942. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118943. * 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)
  118944. */
  118945. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118946. /**
  118947. * This Observable will when a mesh has been imported into the scene.
  118948. */
  118949. onMeshImportedObservable: Observable<AbstractMesh>;
  118950. /**
  118951. * This Observable will when an animation file has been imported into the scene.
  118952. */
  118953. onAnimationFileImportedObservable: Observable<Scene>;
  118954. /**
  118955. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118956. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118957. */
  118958. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118959. /** @hidden */
  118960. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118961. /**
  118962. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118963. */
  118964. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118965. /**
  118966. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118967. */
  118968. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118969. /**
  118970. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118971. */
  118972. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118973. /** Callback called when a pointer move is detected */
  118974. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118975. /** Callback called when a pointer down is detected */
  118976. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118977. /** Callback called when a pointer up is detected */
  118978. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118979. /** Callback called when a pointer pick is detected */
  118980. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118981. /**
  118982. * 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).
  118983. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118984. */
  118985. onPrePointerObservable: Observable<PointerInfoPre>;
  118986. /**
  118987. * Observable event triggered each time an input event is received from the rendering canvas
  118988. */
  118989. onPointerObservable: Observable<PointerInfo>;
  118990. /**
  118991. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118992. */
  118993. get unTranslatedPointer(): Vector2;
  118994. /**
  118995. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118996. */
  118997. static get DragMovementThreshold(): number;
  118998. static set DragMovementThreshold(value: number);
  118999. /**
  119000. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119001. */
  119002. static get LongPressDelay(): number;
  119003. static set LongPressDelay(value: number);
  119004. /**
  119005. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119006. */
  119007. static get DoubleClickDelay(): number;
  119008. static set DoubleClickDelay(value: number);
  119009. /** If you need to check double click without raising a single click at first click, enable this flag */
  119010. static get ExclusiveDoubleClickMode(): boolean;
  119011. static set ExclusiveDoubleClickMode(value: boolean);
  119012. /** @hidden */
  119013. _mirroredCameraPosition: Nullable<Vector3>;
  119014. /**
  119015. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119016. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119017. */
  119018. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119019. /**
  119020. * Observable event triggered each time an keyboard event is received from the hosting window
  119021. */
  119022. onKeyboardObservable: Observable<KeyboardInfo>;
  119023. private _useRightHandedSystem;
  119024. /**
  119025. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119026. */
  119027. set useRightHandedSystem(value: boolean);
  119028. get useRightHandedSystem(): boolean;
  119029. private _timeAccumulator;
  119030. private _currentStepId;
  119031. private _currentInternalStep;
  119032. /**
  119033. * Sets the step Id used by deterministic lock step
  119034. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119035. * @param newStepId defines the step Id
  119036. */
  119037. setStepId(newStepId: number): void;
  119038. /**
  119039. * Gets the step Id used by deterministic lock step
  119040. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119041. * @returns the step Id
  119042. */
  119043. getStepId(): number;
  119044. /**
  119045. * Gets the internal step used by deterministic lock step
  119046. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119047. * @returns the internal step
  119048. */
  119049. getInternalStep(): number;
  119050. private _fogEnabled;
  119051. /**
  119052. * Gets or sets a boolean indicating if fog is enabled on this scene
  119053. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119054. * (Default is true)
  119055. */
  119056. set fogEnabled(value: boolean);
  119057. get fogEnabled(): boolean;
  119058. private _fogMode;
  119059. /**
  119060. * Gets or sets the fog mode to use
  119061. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119062. * | mode | value |
  119063. * | --- | --- |
  119064. * | FOGMODE_NONE | 0 |
  119065. * | FOGMODE_EXP | 1 |
  119066. * | FOGMODE_EXP2 | 2 |
  119067. * | FOGMODE_LINEAR | 3 |
  119068. */
  119069. set fogMode(value: number);
  119070. get fogMode(): number;
  119071. /**
  119072. * Gets or sets the fog color to use
  119073. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119074. * (Default is Color3(0.2, 0.2, 0.3))
  119075. */
  119076. fogColor: Color3;
  119077. /**
  119078. * Gets or sets the fog density to use
  119079. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119080. * (Default is 0.1)
  119081. */
  119082. fogDensity: number;
  119083. /**
  119084. * Gets or sets the fog start distance to use
  119085. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119086. * (Default is 0)
  119087. */
  119088. fogStart: number;
  119089. /**
  119090. * Gets or sets the fog end distance to use
  119091. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119092. * (Default is 1000)
  119093. */
  119094. fogEnd: number;
  119095. /**
  119096. * Flag indicating that the frame buffer binding is handled by another component
  119097. */
  119098. prePass: boolean;
  119099. private _shadowsEnabled;
  119100. /**
  119101. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119102. */
  119103. set shadowsEnabled(value: boolean);
  119104. get shadowsEnabled(): boolean;
  119105. private _lightsEnabled;
  119106. /**
  119107. * Gets or sets a boolean indicating if lights are enabled on this scene
  119108. */
  119109. set lightsEnabled(value: boolean);
  119110. get lightsEnabled(): boolean;
  119111. /** All of the active cameras added to this scene. */
  119112. activeCameras: Camera[];
  119113. /** @hidden */
  119114. _activeCamera: Nullable<Camera>;
  119115. /** Gets or sets the current active camera */
  119116. get activeCamera(): Nullable<Camera>;
  119117. set activeCamera(value: Nullable<Camera>);
  119118. private _defaultMaterial;
  119119. /** The default material used on meshes when no material is affected */
  119120. get defaultMaterial(): Material;
  119121. /** The default material used on meshes when no material is affected */
  119122. set defaultMaterial(value: Material);
  119123. private _texturesEnabled;
  119124. /**
  119125. * Gets or sets a boolean indicating if textures are enabled on this scene
  119126. */
  119127. set texturesEnabled(value: boolean);
  119128. get texturesEnabled(): boolean;
  119129. /**
  119130. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119131. */
  119132. physicsEnabled: boolean;
  119133. /**
  119134. * Gets or sets a boolean indicating if particles are enabled on this scene
  119135. */
  119136. particlesEnabled: boolean;
  119137. /**
  119138. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119139. */
  119140. spritesEnabled: boolean;
  119141. private _skeletonsEnabled;
  119142. /**
  119143. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119144. */
  119145. set skeletonsEnabled(value: boolean);
  119146. get skeletonsEnabled(): boolean;
  119147. /**
  119148. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119149. */
  119150. lensFlaresEnabled: boolean;
  119151. /**
  119152. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119153. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119154. */
  119155. collisionsEnabled: boolean;
  119156. private _collisionCoordinator;
  119157. /** @hidden */
  119158. get collisionCoordinator(): ICollisionCoordinator;
  119159. /**
  119160. * Defines the gravity applied to this scene (used only for collisions)
  119161. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119162. */
  119163. gravity: Vector3;
  119164. /**
  119165. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119166. */
  119167. postProcessesEnabled: boolean;
  119168. /**
  119169. * Gets the current postprocess manager
  119170. */
  119171. postProcessManager: PostProcessManager;
  119172. /**
  119173. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119174. */
  119175. renderTargetsEnabled: boolean;
  119176. /**
  119177. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119178. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119179. */
  119180. dumpNextRenderTargets: boolean;
  119181. /**
  119182. * The list of user defined render targets added to the scene
  119183. */
  119184. customRenderTargets: RenderTargetTexture[];
  119185. /**
  119186. * Defines if texture loading must be delayed
  119187. * If true, textures will only be loaded when they need to be rendered
  119188. */
  119189. useDelayedTextureLoading: boolean;
  119190. /**
  119191. * Gets the list of meshes imported to the scene through SceneLoader
  119192. */
  119193. importedMeshesFiles: String[];
  119194. /**
  119195. * Gets or sets a boolean indicating if probes are enabled on this scene
  119196. */
  119197. probesEnabled: boolean;
  119198. /**
  119199. * Gets or sets the current offline provider to use to store scene data
  119200. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119201. */
  119202. offlineProvider: IOfflineProvider;
  119203. /**
  119204. * Gets or sets the action manager associated with the scene
  119205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119206. */
  119207. actionManager: AbstractActionManager;
  119208. private _meshesForIntersections;
  119209. /**
  119210. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  119211. */
  119212. proceduralTexturesEnabled: boolean;
  119213. private _engine;
  119214. private _totalVertices;
  119215. /** @hidden */
  119216. _activeIndices: PerfCounter;
  119217. /** @hidden */
  119218. _activeParticles: PerfCounter;
  119219. /** @hidden */
  119220. _activeBones: PerfCounter;
  119221. private _animationRatio;
  119222. /** @hidden */
  119223. _animationTimeLast: number;
  119224. /** @hidden */
  119225. _animationTime: number;
  119226. /**
  119227. * Gets or sets a general scale for animation speed
  119228. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  119229. */
  119230. animationTimeScale: number;
  119231. /** @hidden */
  119232. _cachedMaterial: Nullable<Material>;
  119233. /** @hidden */
  119234. _cachedEffect: Nullable<Effect>;
  119235. /** @hidden */
  119236. _cachedVisibility: Nullable<number>;
  119237. private _renderId;
  119238. private _frameId;
  119239. private _executeWhenReadyTimeoutId;
  119240. private _intermediateRendering;
  119241. private _viewUpdateFlag;
  119242. private _projectionUpdateFlag;
  119243. /** @hidden */
  119244. _toBeDisposed: Nullable<IDisposable>[];
  119245. private _activeRequests;
  119246. /** @hidden */
  119247. _pendingData: any[];
  119248. private _isDisposed;
  119249. /**
  119250. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  119251. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  119252. */
  119253. dispatchAllSubMeshesOfActiveMeshes: boolean;
  119254. private _activeMeshes;
  119255. private _processedMaterials;
  119256. private _renderTargets;
  119257. /** @hidden */
  119258. _activeParticleSystems: SmartArray<IParticleSystem>;
  119259. private _activeSkeletons;
  119260. private _softwareSkinnedMeshes;
  119261. private _renderingManager;
  119262. /** @hidden */
  119263. _activeAnimatables: Animatable[];
  119264. private _transformMatrix;
  119265. private _sceneUbo;
  119266. /** @hidden */
  119267. _viewMatrix: Matrix;
  119268. private _projectionMatrix;
  119269. /** @hidden */
  119270. _forcedViewPosition: Nullable<Vector3>;
  119271. /** @hidden */
  119272. _frustumPlanes: Plane[];
  119273. /**
  119274. * Gets the list of frustum planes (built from the active camera)
  119275. */
  119276. get frustumPlanes(): Plane[];
  119277. /**
  119278. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119279. * This is useful if there are more lights that the maximum simulteanous authorized
  119280. */
  119281. requireLightSorting: boolean;
  119282. /** @hidden */
  119283. readonly useMaterialMeshMap: boolean;
  119284. /** @hidden */
  119285. readonly useClonedMeshMap: boolean;
  119286. private _externalData;
  119287. private _uid;
  119288. /**
  119289. * @hidden
  119290. * Backing store of defined scene components.
  119291. */
  119292. _components: ISceneComponent[];
  119293. /**
  119294. * @hidden
  119295. * Backing store of defined scene components.
  119296. */
  119297. _serializableComponents: ISceneSerializableComponent[];
  119298. /**
  119299. * List of components to register on the next registration step.
  119300. */
  119301. private _transientComponents;
  119302. /**
  119303. * Registers the transient components if needed.
  119304. */
  119305. private _registerTransientComponents;
  119306. /**
  119307. * @hidden
  119308. * Add a component to the scene.
  119309. * Note that the ccomponent could be registered on th next frame if this is called after
  119310. * the register component stage.
  119311. * @param component Defines the component to add to the scene
  119312. */
  119313. _addComponent(component: ISceneComponent): void;
  119314. /**
  119315. * @hidden
  119316. * Gets a component from the scene.
  119317. * @param name defines the name of the component to retrieve
  119318. * @returns the component or null if not present
  119319. */
  119320. _getComponent(name: string): Nullable<ISceneComponent>;
  119321. /**
  119322. * @hidden
  119323. * Defines the actions happening before camera updates.
  119324. */
  119325. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  119326. /**
  119327. * @hidden
  119328. * Defines the actions happening before clear the canvas.
  119329. */
  119330. _beforeClearStage: Stage<SimpleStageAction>;
  119331. /**
  119332. * @hidden
  119333. * Defines the actions when collecting render targets for the frame.
  119334. */
  119335. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119336. /**
  119337. * @hidden
  119338. * Defines the actions happening for one camera in the frame.
  119339. */
  119340. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119341. /**
  119342. * @hidden
  119343. * Defines the actions happening during the per mesh ready checks.
  119344. */
  119345. _isReadyForMeshStage: Stage<MeshStageAction>;
  119346. /**
  119347. * @hidden
  119348. * Defines the actions happening before evaluate active mesh checks.
  119349. */
  119350. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119351. /**
  119352. * @hidden
  119353. * Defines the actions happening during the evaluate sub mesh checks.
  119354. */
  119355. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119356. /**
  119357. * @hidden
  119358. * Defines the actions happening during the active mesh stage.
  119359. */
  119360. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119361. /**
  119362. * @hidden
  119363. * Defines the actions happening during the per camera render target step.
  119364. */
  119365. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119366. /**
  119367. * @hidden
  119368. * Defines the actions happening just before the active camera is drawing.
  119369. */
  119370. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119371. /**
  119372. * @hidden
  119373. * Defines the actions happening just before a render target is drawing.
  119374. */
  119375. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119376. /**
  119377. * @hidden
  119378. * Defines the actions happening just before a rendering group is drawing.
  119379. */
  119380. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119381. /**
  119382. * @hidden
  119383. * Defines the actions happening just before a mesh is drawing.
  119384. */
  119385. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119386. /**
  119387. * @hidden
  119388. * Defines the actions happening just after a mesh has been drawn.
  119389. */
  119390. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119391. /**
  119392. * @hidden
  119393. * Defines the actions happening just after a rendering group has been drawn.
  119394. */
  119395. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119396. /**
  119397. * @hidden
  119398. * Defines the actions happening just after the active camera has been drawn.
  119399. */
  119400. _afterCameraDrawStage: Stage<CameraStageAction>;
  119401. /**
  119402. * @hidden
  119403. * Defines the actions happening just after a render target has been drawn.
  119404. */
  119405. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119406. /**
  119407. * @hidden
  119408. * Defines the actions happening just after rendering all cameras and computing intersections.
  119409. */
  119410. _afterRenderStage: Stage<SimpleStageAction>;
  119411. /**
  119412. * @hidden
  119413. * Defines the actions happening when a pointer move event happens.
  119414. */
  119415. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119416. /**
  119417. * @hidden
  119418. * Defines the actions happening when a pointer down event happens.
  119419. */
  119420. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119421. /**
  119422. * @hidden
  119423. * Defines the actions happening when a pointer up event happens.
  119424. */
  119425. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119426. /**
  119427. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119428. */
  119429. private geometriesByUniqueId;
  119430. /**
  119431. * Creates a new Scene
  119432. * @param engine defines the engine to use to render this scene
  119433. * @param options defines the scene options
  119434. */
  119435. constructor(engine: Engine, options?: SceneOptions);
  119436. /**
  119437. * Gets a string identifying the name of the class
  119438. * @returns "Scene" string
  119439. */
  119440. getClassName(): string;
  119441. private _defaultMeshCandidates;
  119442. /**
  119443. * @hidden
  119444. */
  119445. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119446. private _defaultSubMeshCandidates;
  119447. /**
  119448. * @hidden
  119449. */
  119450. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119451. /**
  119452. * Sets the default candidate providers for the scene.
  119453. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119454. * and getCollidingSubMeshCandidates to their default function
  119455. */
  119456. setDefaultCandidateProviders(): void;
  119457. /**
  119458. * Gets the mesh that is currently under the pointer
  119459. */
  119460. get meshUnderPointer(): Nullable<AbstractMesh>;
  119461. /**
  119462. * Gets or sets the current on-screen X position of the pointer
  119463. */
  119464. get pointerX(): number;
  119465. set pointerX(value: number);
  119466. /**
  119467. * Gets or sets the current on-screen Y position of the pointer
  119468. */
  119469. get pointerY(): number;
  119470. set pointerY(value: number);
  119471. /**
  119472. * Gets the cached material (ie. the latest rendered one)
  119473. * @returns the cached material
  119474. */
  119475. getCachedMaterial(): Nullable<Material>;
  119476. /**
  119477. * Gets the cached effect (ie. the latest rendered one)
  119478. * @returns the cached effect
  119479. */
  119480. getCachedEffect(): Nullable<Effect>;
  119481. /**
  119482. * Gets the cached visibility state (ie. the latest rendered one)
  119483. * @returns the cached visibility state
  119484. */
  119485. getCachedVisibility(): Nullable<number>;
  119486. /**
  119487. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  119488. * @param material defines the current material
  119489. * @param effect defines the current effect
  119490. * @param visibility defines the current visibility state
  119491. * @returns true if one parameter is not cached
  119492. */
  119493. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  119494. /**
  119495. * Gets the engine associated with the scene
  119496. * @returns an Engine
  119497. */
  119498. getEngine(): Engine;
  119499. /**
  119500. * Gets the total number of vertices rendered per frame
  119501. * @returns the total number of vertices rendered per frame
  119502. */
  119503. getTotalVertices(): number;
  119504. /**
  119505. * Gets the performance counter for total vertices
  119506. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119507. */
  119508. get totalVerticesPerfCounter(): PerfCounter;
  119509. /**
  119510. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  119511. * @returns the total number of active indices rendered per frame
  119512. */
  119513. getActiveIndices(): number;
  119514. /**
  119515. * Gets the performance counter for active indices
  119516. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119517. */
  119518. get totalActiveIndicesPerfCounter(): PerfCounter;
  119519. /**
  119520. * Gets the total number of active particles rendered per frame
  119521. * @returns the total number of active particles rendered per frame
  119522. */
  119523. getActiveParticles(): number;
  119524. /**
  119525. * Gets the performance counter for active particles
  119526. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119527. */
  119528. get activeParticlesPerfCounter(): PerfCounter;
  119529. /**
  119530. * Gets the total number of active bones rendered per frame
  119531. * @returns the total number of active bones rendered per frame
  119532. */
  119533. getActiveBones(): number;
  119534. /**
  119535. * Gets the performance counter for active bones
  119536. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119537. */
  119538. get activeBonesPerfCounter(): PerfCounter;
  119539. /**
  119540. * Gets the array of active meshes
  119541. * @returns an array of AbstractMesh
  119542. */
  119543. getActiveMeshes(): SmartArray<AbstractMesh>;
  119544. /**
  119545. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119546. * @returns a number
  119547. */
  119548. getAnimationRatio(): number;
  119549. /**
  119550. * Gets an unique Id for the current render phase
  119551. * @returns a number
  119552. */
  119553. getRenderId(): number;
  119554. /**
  119555. * Gets an unique Id for the current frame
  119556. * @returns a number
  119557. */
  119558. getFrameId(): number;
  119559. /** Call this function if you want to manually increment the render Id*/
  119560. incrementRenderId(): void;
  119561. private _createUbo;
  119562. /**
  119563. * Use this method to simulate a pointer move on a mesh
  119564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119567. * @returns the current scene
  119568. */
  119569. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119570. /**
  119571. * Use this method to simulate a pointer down on a mesh
  119572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119575. * @returns the current scene
  119576. */
  119577. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119578. /**
  119579. * Use this method to simulate a pointer up on a mesh
  119580. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119581. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119582. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119583. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119584. * @returns the current scene
  119585. */
  119586. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119587. /**
  119588. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119589. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119590. * @returns true if the pointer was captured
  119591. */
  119592. isPointerCaptured(pointerId?: number): boolean;
  119593. /**
  119594. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119595. * @param attachUp defines if you want to attach events to pointerup
  119596. * @param attachDown defines if you want to attach events to pointerdown
  119597. * @param attachMove defines if you want to attach events to pointermove
  119598. */
  119599. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119600. /** Detaches all event handlers*/
  119601. detachControl(): void;
  119602. /**
  119603. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119604. * Delay loaded resources are not taking in account
  119605. * @return true if all required resources are ready
  119606. */
  119607. isReady(): boolean;
  119608. /** Resets all cached information relative to material (including effect and visibility) */
  119609. resetCachedMaterial(): void;
  119610. /**
  119611. * Registers a function to be called before every frame render
  119612. * @param func defines the function to register
  119613. */
  119614. registerBeforeRender(func: () => void): void;
  119615. /**
  119616. * Unregisters a function called before every frame render
  119617. * @param func defines the function to unregister
  119618. */
  119619. unregisterBeforeRender(func: () => void): void;
  119620. /**
  119621. * Registers a function to be called after every frame render
  119622. * @param func defines the function to register
  119623. */
  119624. registerAfterRender(func: () => void): void;
  119625. /**
  119626. * Unregisters a function called after every frame render
  119627. * @param func defines the function to unregister
  119628. */
  119629. unregisterAfterRender(func: () => void): void;
  119630. private _executeOnceBeforeRender;
  119631. /**
  119632. * The provided function will run before render once and will be disposed afterwards.
  119633. * A timeout delay can be provided so that the function will be executed in N ms.
  119634. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119635. * @param func The function to be executed.
  119636. * @param timeout optional delay in ms
  119637. */
  119638. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119639. /** @hidden */
  119640. _addPendingData(data: any): void;
  119641. /** @hidden */
  119642. _removePendingData(data: any): void;
  119643. /**
  119644. * Returns the number of items waiting to be loaded
  119645. * @returns the number of items waiting to be loaded
  119646. */
  119647. getWaitingItemsCount(): number;
  119648. /**
  119649. * Returns a boolean indicating if the scene is still loading data
  119650. */
  119651. get isLoading(): boolean;
  119652. /**
  119653. * Registers a function to be executed when the scene is ready
  119654. * @param {Function} func - the function to be executed
  119655. */
  119656. executeWhenReady(func: () => void): void;
  119657. /**
  119658. * Returns a promise that resolves when the scene is ready
  119659. * @returns A promise that resolves when the scene is ready
  119660. */
  119661. whenReadyAsync(): Promise<void>;
  119662. /** @hidden */
  119663. _checkIsReady(): void;
  119664. /**
  119665. * Gets all animatable attached to the scene
  119666. */
  119667. get animatables(): Animatable[];
  119668. /**
  119669. * Resets the last animation time frame.
  119670. * Useful to override when animations start running when loading a scene for the first time.
  119671. */
  119672. resetLastAnimationTimeFrame(): void;
  119673. /**
  119674. * Gets the current view matrix
  119675. * @returns a Matrix
  119676. */
  119677. getViewMatrix(): Matrix;
  119678. /**
  119679. * Gets the current projection matrix
  119680. * @returns a Matrix
  119681. */
  119682. getProjectionMatrix(): Matrix;
  119683. /**
  119684. * Gets the current transform matrix
  119685. * @returns a Matrix made of View * Projection
  119686. */
  119687. getTransformMatrix(): Matrix;
  119688. /**
  119689. * Sets the current transform matrix
  119690. * @param viewL defines the View matrix to use
  119691. * @param projectionL defines the Projection matrix to use
  119692. * @param viewR defines the right View matrix to use (if provided)
  119693. * @param projectionR defines the right Projection matrix to use (if provided)
  119694. */
  119695. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119696. /**
  119697. * Gets the uniform buffer used to store scene data
  119698. * @returns a UniformBuffer
  119699. */
  119700. getSceneUniformBuffer(): UniformBuffer;
  119701. /**
  119702. * Gets an unique (relatively to the current scene) Id
  119703. * @returns an unique number for the scene
  119704. */
  119705. getUniqueId(): number;
  119706. /**
  119707. * Add a mesh to the list of scene's meshes
  119708. * @param newMesh defines the mesh to add
  119709. * @param recursive if all child meshes should also be added to the scene
  119710. */
  119711. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119712. /**
  119713. * Remove a mesh for the list of scene's meshes
  119714. * @param toRemove defines the mesh to remove
  119715. * @param recursive if all child meshes should also be removed from the scene
  119716. * @returns the index where the mesh was in the mesh list
  119717. */
  119718. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119719. /**
  119720. * Add a transform node to the list of scene's transform nodes
  119721. * @param newTransformNode defines the transform node to add
  119722. */
  119723. addTransformNode(newTransformNode: TransformNode): void;
  119724. /**
  119725. * Remove a transform node for the list of scene's transform nodes
  119726. * @param toRemove defines the transform node to remove
  119727. * @returns the index where the transform node was in the transform node list
  119728. */
  119729. removeTransformNode(toRemove: TransformNode): number;
  119730. /**
  119731. * Remove a skeleton for the list of scene's skeletons
  119732. * @param toRemove defines the skeleton to remove
  119733. * @returns the index where the skeleton was in the skeleton list
  119734. */
  119735. removeSkeleton(toRemove: Skeleton): number;
  119736. /**
  119737. * Remove a morph target for the list of scene's morph targets
  119738. * @param toRemove defines the morph target to remove
  119739. * @returns the index where the morph target was in the morph target list
  119740. */
  119741. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119742. /**
  119743. * Remove a light for the list of scene's lights
  119744. * @param toRemove defines the light to remove
  119745. * @returns the index where the light was in the light list
  119746. */
  119747. removeLight(toRemove: Light): number;
  119748. /**
  119749. * Remove a camera for the list of scene's cameras
  119750. * @param toRemove defines the camera to remove
  119751. * @returns the index where the camera was in the camera list
  119752. */
  119753. removeCamera(toRemove: Camera): number;
  119754. /**
  119755. * Remove a particle system for the list of scene's particle systems
  119756. * @param toRemove defines the particle system to remove
  119757. * @returns the index where the particle system was in the particle system list
  119758. */
  119759. removeParticleSystem(toRemove: IParticleSystem): number;
  119760. /**
  119761. * Remove a animation for the list of scene's animations
  119762. * @param toRemove defines the animation to remove
  119763. * @returns the index where the animation was in the animation list
  119764. */
  119765. removeAnimation(toRemove: Animation): number;
  119766. /**
  119767. * Will stop the animation of the given target
  119768. * @param target - the target
  119769. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119770. * @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)
  119771. */
  119772. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119773. /**
  119774. * Removes the given animation group from this scene.
  119775. * @param toRemove The animation group to remove
  119776. * @returns The index of the removed animation group
  119777. */
  119778. removeAnimationGroup(toRemove: AnimationGroup): number;
  119779. /**
  119780. * Removes the given multi-material from this scene.
  119781. * @param toRemove The multi-material to remove
  119782. * @returns The index of the removed multi-material
  119783. */
  119784. removeMultiMaterial(toRemove: MultiMaterial): number;
  119785. /**
  119786. * Removes the given material from this scene.
  119787. * @param toRemove The material to remove
  119788. * @returns The index of the removed material
  119789. */
  119790. removeMaterial(toRemove: Material): number;
  119791. /**
  119792. * Removes the given action manager from this scene.
  119793. * @param toRemove The action manager to remove
  119794. * @returns The index of the removed action manager
  119795. */
  119796. removeActionManager(toRemove: AbstractActionManager): number;
  119797. /**
  119798. * Removes the given texture from this scene.
  119799. * @param toRemove The texture to remove
  119800. * @returns The index of the removed texture
  119801. */
  119802. removeTexture(toRemove: BaseTexture): number;
  119803. /**
  119804. * Adds the given light to this scene
  119805. * @param newLight The light to add
  119806. */
  119807. addLight(newLight: Light): void;
  119808. /**
  119809. * Sorts the list list based on light priorities
  119810. */
  119811. sortLightsByPriority(): void;
  119812. /**
  119813. * Adds the given camera to this scene
  119814. * @param newCamera The camera to add
  119815. */
  119816. addCamera(newCamera: Camera): void;
  119817. /**
  119818. * Adds the given skeleton to this scene
  119819. * @param newSkeleton The skeleton to add
  119820. */
  119821. addSkeleton(newSkeleton: Skeleton): void;
  119822. /**
  119823. * Adds the given particle system to this scene
  119824. * @param newParticleSystem The particle system to add
  119825. */
  119826. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119827. /**
  119828. * Adds the given animation to this scene
  119829. * @param newAnimation The animation to add
  119830. */
  119831. addAnimation(newAnimation: Animation): void;
  119832. /**
  119833. * Adds the given animation group to this scene.
  119834. * @param newAnimationGroup The animation group to add
  119835. */
  119836. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119837. /**
  119838. * Adds the given multi-material to this scene
  119839. * @param newMultiMaterial The multi-material to add
  119840. */
  119841. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119842. /**
  119843. * Adds the given material to this scene
  119844. * @param newMaterial The material to add
  119845. */
  119846. addMaterial(newMaterial: Material): void;
  119847. /**
  119848. * Adds the given morph target to this scene
  119849. * @param newMorphTargetManager The morph target to add
  119850. */
  119851. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119852. /**
  119853. * Adds the given geometry to this scene
  119854. * @param newGeometry The geometry to add
  119855. */
  119856. addGeometry(newGeometry: Geometry): void;
  119857. /**
  119858. * Adds the given action manager to this scene
  119859. * @param newActionManager The action manager to add
  119860. */
  119861. addActionManager(newActionManager: AbstractActionManager): void;
  119862. /**
  119863. * Adds the given texture to this scene.
  119864. * @param newTexture The texture to add
  119865. */
  119866. addTexture(newTexture: BaseTexture): void;
  119867. /**
  119868. * Switch active camera
  119869. * @param newCamera defines the new active camera
  119870. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119871. */
  119872. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119873. /**
  119874. * sets the active camera of the scene using its ID
  119875. * @param id defines the camera's ID
  119876. * @return the new active camera or null if none found.
  119877. */
  119878. setActiveCameraByID(id: string): Nullable<Camera>;
  119879. /**
  119880. * sets the active camera of the scene using its name
  119881. * @param name defines the camera's name
  119882. * @returns the new active camera or null if none found.
  119883. */
  119884. setActiveCameraByName(name: string): Nullable<Camera>;
  119885. /**
  119886. * get an animation group using its name
  119887. * @param name defines the material's name
  119888. * @return the animation group or null if none found.
  119889. */
  119890. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119891. /**
  119892. * Get a material using its unique id
  119893. * @param uniqueId defines the material's unique id
  119894. * @return the material or null if none found.
  119895. */
  119896. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119897. /**
  119898. * get a material using its id
  119899. * @param id defines the material's ID
  119900. * @return the material or null if none found.
  119901. */
  119902. getMaterialByID(id: string): Nullable<Material>;
  119903. /**
  119904. * Gets a the last added material using a given id
  119905. * @param id defines the material's ID
  119906. * @return the last material with the given id or null if none found.
  119907. */
  119908. getLastMaterialByID(id: string): Nullable<Material>;
  119909. /**
  119910. * Gets a material using its name
  119911. * @param name defines the material's name
  119912. * @return the material or null if none found.
  119913. */
  119914. getMaterialByName(name: string): Nullable<Material>;
  119915. /**
  119916. * Get a texture using its unique id
  119917. * @param uniqueId defines the texture's unique id
  119918. * @return the texture or null if none found.
  119919. */
  119920. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119921. /**
  119922. * Gets a camera using its id
  119923. * @param id defines the id to look for
  119924. * @returns the camera or null if not found
  119925. */
  119926. getCameraByID(id: string): Nullable<Camera>;
  119927. /**
  119928. * Gets a camera using its unique id
  119929. * @param uniqueId defines the unique id to look for
  119930. * @returns the camera or null if not found
  119931. */
  119932. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119933. /**
  119934. * Gets a camera using its name
  119935. * @param name defines the camera's name
  119936. * @return the camera or null if none found.
  119937. */
  119938. getCameraByName(name: string): Nullable<Camera>;
  119939. /**
  119940. * Gets a bone using its id
  119941. * @param id defines the bone's id
  119942. * @return the bone or null if not found
  119943. */
  119944. getBoneByID(id: string): Nullable<Bone>;
  119945. /**
  119946. * Gets a bone using its id
  119947. * @param name defines the bone's name
  119948. * @return the bone or null if not found
  119949. */
  119950. getBoneByName(name: string): Nullable<Bone>;
  119951. /**
  119952. * Gets a light node using its name
  119953. * @param name defines the the light's name
  119954. * @return the light or null if none found.
  119955. */
  119956. getLightByName(name: string): Nullable<Light>;
  119957. /**
  119958. * Gets a light node using its id
  119959. * @param id defines the light's id
  119960. * @return the light or null if none found.
  119961. */
  119962. getLightByID(id: string): Nullable<Light>;
  119963. /**
  119964. * Gets a light node using its scene-generated unique ID
  119965. * @param uniqueId defines the light's unique id
  119966. * @return the light or null if none found.
  119967. */
  119968. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119969. /**
  119970. * Gets a particle system by id
  119971. * @param id defines the particle system id
  119972. * @return the corresponding system or null if none found
  119973. */
  119974. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119975. /**
  119976. * Gets a geometry using its ID
  119977. * @param id defines the geometry's id
  119978. * @return the geometry or null if none found.
  119979. */
  119980. getGeometryByID(id: string): Nullable<Geometry>;
  119981. private _getGeometryByUniqueID;
  119982. /**
  119983. * Add a new geometry to this scene
  119984. * @param geometry defines the geometry to be added to the scene.
  119985. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119986. * @return a boolean defining if the geometry was added or not
  119987. */
  119988. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119989. /**
  119990. * Removes an existing geometry
  119991. * @param geometry defines the geometry to be removed from the scene
  119992. * @return a boolean defining if the geometry was removed or not
  119993. */
  119994. removeGeometry(geometry: Geometry): boolean;
  119995. /**
  119996. * Gets the list of geometries attached to the scene
  119997. * @returns an array of Geometry
  119998. */
  119999. getGeometries(): Geometry[];
  120000. /**
  120001. * Gets the first added mesh found of a given ID
  120002. * @param id defines the id to search for
  120003. * @return the mesh found or null if not found at all
  120004. */
  120005. getMeshByID(id: string): Nullable<AbstractMesh>;
  120006. /**
  120007. * Gets a list of meshes using their id
  120008. * @param id defines the id to search for
  120009. * @returns a list of meshes
  120010. */
  120011. getMeshesByID(id: string): Array<AbstractMesh>;
  120012. /**
  120013. * Gets the first added transform node found of a given ID
  120014. * @param id defines the id to search for
  120015. * @return the found transform node or null if not found at all.
  120016. */
  120017. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120018. /**
  120019. * Gets a transform node with its auto-generated unique id
  120020. * @param uniqueId efines the unique id to search for
  120021. * @return the found transform node or null if not found at all.
  120022. */
  120023. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120024. /**
  120025. * Gets a list of transform nodes using their id
  120026. * @param id defines the id to search for
  120027. * @returns a list of transform nodes
  120028. */
  120029. getTransformNodesByID(id: string): Array<TransformNode>;
  120030. /**
  120031. * Gets a mesh with its auto-generated unique id
  120032. * @param uniqueId defines the unique id to search for
  120033. * @return the found mesh or null if not found at all.
  120034. */
  120035. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120036. /**
  120037. * Gets a the last added mesh using a given id
  120038. * @param id defines the id to search for
  120039. * @return the found mesh or null if not found at all.
  120040. */
  120041. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120042. /**
  120043. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120044. * @param id defines the id to search for
  120045. * @return the found node or null if not found at all
  120046. */
  120047. getLastEntryByID(id: string): Nullable<Node>;
  120048. /**
  120049. * Gets a node (Mesh, Camera, Light) using a given id
  120050. * @param id defines the id to search for
  120051. * @return the found node or null if not found at all
  120052. */
  120053. getNodeByID(id: string): Nullable<Node>;
  120054. /**
  120055. * Gets a node (Mesh, Camera, Light) using a given name
  120056. * @param name defines the name to search for
  120057. * @return the found node or null if not found at all.
  120058. */
  120059. getNodeByName(name: string): Nullable<Node>;
  120060. /**
  120061. * Gets a mesh using a given name
  120062. * @param name defines the name to search for
  120063. * @return the found mesh or null if not found at all.
  120064. */
  120065. getMeshByName(name: string): Nullable<AbstractMesh>;
  120066. /**
  120067. * Gets a transform node using a given name
  120068. * @param name defines the name to search for
  120069. * @return the found transform node or null if not found at all.
  120070. */
  120071. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120072. /**
  120073. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120074. * @param id defines the id to search for
  120075. * @return the found skeleton or null if not found at all.
  120076. */
  120077. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120078. /**
  120079. * Gets a skeleton using a given auto generated unique id
  120080. * @param uniqueId defines the unique id to search for
  120081. * @return the found skeleton or null if not found at all.
  120082. */
  120083. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120084. /**
  120085. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120086. * @param id defines the id to search for
  120087. * @return the found skeleton or null if not found at all.
  120088. */
  120089. getSkeletonById(id: string): Nullable<Skeleton>;
  120090. /**
  120091. * Gets a skeleton using a given name
  120092. * @param name defines the name to search for
  120093. * @return the found skeleton or null if not found at all.
  120094. */
  120095. getSkeletonByName(name: string): Nullable<Skeleton>;
  120096. /**
  120097. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120098. * @param id defines the id to search for
  120099. * @return the found morph target manager or null if not found at all.
  120100. */
  120101. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120102. /**
  120103. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120104. * @param id defines the id to search for
  120105. * @return the found morph target or null if not found at all.
  120106. */
  120107. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120108. /**
  120109. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120110. * @param name defines the name to search for
  120111. * @return the found morph target or null if not found at all.
  120112. */
  120113. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120114. /**
  120115. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120116. * @param name defines the name to search for
  120117. * @return the found post process or null if not found at all.
  120118. */
  120119. getPostProcessByName(name: string): Nullable<PostProcess>;
  120120. /**
  120121. * Gets a boolean indicating if the given mesh is active
  120122. * @param mesh defines the mesh to look for
  120123. * @returns true if the mesh is in the active list
  120124. */
  120125. isActiveMesh(mesh: AbstractMesh): boolean;
  120126. /**
  120127. * Return a unique id as a string which can serve as an identifier for the scene
  120128. */
  120129. get uid(): string;
  120130. /**
  120131. * Add an externaly attached data from its key.
  120132. * This method call will fail and return false, if such key already exists.
  120133. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120134. * @param key the unique key that identifies the data
  120135. * @param data the data object to associate to the key for this Engine instance
  120136. * @return true if no such key were already present and the data was added successfully, false otherwise
  120137. */
  120138. addExternalData<T>(key: string, data: T): boolean;
  120139. /**
  120140. * Get an externaly attached data from its key
  120141. * @param key the unique key that identifies the data
  120142. * @return the associated data, if present (can be null), or undefined if not present
  120143. */
  120144. getExternalData<T>(key: string): Nullable<T>;
  120145. /**
  120146. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120147. * @param key the unique key that identifies the data
  120148. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120149. * @return the associated data, can be null if the factory returned null.
  120150. */
  120151. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120152. /**
  120153. * Remove an externaly attached data from the Engine instance
  120154. * @param key the unique key that identifies the data
  120155. * @return true if the data was successfully removed, false if it doesn't exist
  120156. */
  120157. removeExternalData(key: string): boolean;
  120158. private _evaluateSubMesh;
  120159. /**
  120160. * Clear the processed materials smart array preventing retention point in material dispose.
  120161. */
  120162. freeProcessedMaterials(): void;
  120163. private _preventFreeActiveMeshesAndRenderingGroups;
  120164. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120165. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120166. * when disposing several meshes in a row or a hierarchy of meshes.
  120167. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120168. */
  120169. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120170. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120171. /**
  120172. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120173. */
  120174. freeActiveMeshes(): void;
  120175. /**
  120176. * Clear the info related to rendering groups preventing retention points during dispose.
  120177. */
  120178. freeRenderingGroups(): void;
  120179. /** @hidden */
  120180. _isInIntermediateRendering(): boolean;
  120181. /**
  120182. * Lambda returning the list of potentially active meshes.
  120183. */
  120184. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120185. /**
  120186. * Lambda returning the list of potentially active sub meshes.
  120187. */
  120188. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120189. /**
  120190. * Lambda returning the list of potentially intersecting sub meshes.
  120191. */
  120192. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120193. /**
  120194. * Lambda returning the list of potentially colliding sub meshes.
  120195. */
  120196. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  120197. private _activeMeshesFrozen;
  120198. private _skipEvaluateActiveMeshesCompletely;
  120199. /**
  120200. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  120201. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  120202. * @returns the current scene
  120203. */
  120204. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  120205. /**
  120206. * Use this function to restart evaluating active meshes on every frame
  120207. * @returns the current scene
  120208. */
  120209. unfreezeActiveMeshes(): Scene;
  120210. private _evaluateActiveMeshes;
  120211. private _activeMesh;
  120212. /**
  120213. * Update the transform matrix to update from the current active camera
  120214. * @param force defines a boolean used to force the update even if cache is up to date
  120215. */
  120216. updateTransformMatrix(force?: boolean): void;
  120217. private _bindFrameBuffer;
  120218. /** @hidden */
  120219. _allowPostProcessClearColor: boolean;
  120220. /** @hidden */
  120221. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  120222. private _processSubCameras;
  120223. private _checkIntersections;
  120224. /** @hidden */
  120225. _advancePhysicsEngineStep(step: number): void;
  120226. /**
  120227. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  120228. */
  120229. getDeterministicFrameTime: () => number;
  120230. /** @hidden */
  120231. _animate(): void;
  120232. /** Execute all animations (for a frame) */
  120233. animate(): void;
  120234. /**
  120235. * Render the scene
  120236. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  120237. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  120238. */
  120239. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  120240. /**
  120241. * Freeze all materials
  120242. * A frozen material will not be updatable but should be faster to render
  120243. */
  120244. freezeMaterials(): void;
  120245. /**
  120246. * Unfreeze all materials
  120247. * A frozen material will not be updatable but should be faster to render
  120248. */
  120249. unfreezeMaterials(): void;
  120250. /**
  120251. * Releases all held ressources
  120252. */
  120253. dispose(): void;
  120254. /**
  120255. * Gets if the scene is already disposed
  120256. */
  120257. get isDisposed(): boolean;
  120258. /**
  120259. * Call this function to reduce memory footprint of the scene.
  120260. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  120261. */
  120262. clearCachedVertexData(): void;
  120263. /**
  120264. * This function will remove the local cached buffer data from texture.
  120265. * It will save memory but will prevent the texture from being rebuilt
  120266. */
  120267. cleanCachedTextureBuffer(): void;
  120268. /**
  120269. * Get the world extend vectors with an optional filter
  120270. *
  120271. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  120272. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  120273. */
  120274. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  120275. min: Vector3;
  120276. max: Vector3;
  120277. };
  120278. /**
  120279. * Creates a ray that can be used to pick in the scene
  120280. * @param x defines the x coordinate of the origin (on-screen)
  120281. * @param y defines the y coordinate of the origin (on-screen)
  120282. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120283. * @param camera defines the camera to use for the picking
  120284. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120285. * @returns a Ray
  120286. */
  120287. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120288. /**
  120289. * Creates a ray that can be used to pick in the scene
  120290. * @param x defines the x coordinate of the origin (on-screen)
  120291. * @param y defines the y coordinate of the origin (on-screen)
  120292. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120293. * @param result defines the ray where to store the picking ray
  120294. * @param camera defines the camera to use for the picking
  120295. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120296. * @returns the current scene
  120297. */
  120298. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120299. /**
  120300. * Creates a ray that can be used to pick in the scene
  120301. * @param x defines the x coordinate of the origin (on-screen)
  120302. * @param y defines the y coordinate of the origin (on-screen)
  120303. * @param camera defines the camera to use for the picking
  120304. * @returns a Ray
  120305. */
  120306. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120307. /**
  120308. * Creates a ray that can be used to pick in the scene
  120309. * @param x defines the x coordinate of the origin (on-screen)
  120310. * @param y defines the y coordinate of the origin (on-screen)
  120311. * @param result defines the ray where to store the picking ray
  120312. * @param camera defines the camera to use for the picking
  120313. * @returns the current scene
  120314. */
  120315. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120316. /** Launch a ray to try to pick a mesh in the scene
  120317. * @param x position on screen
  120318. * @param y position on screen
  120319. * @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
  120320. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120321. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120322. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120323. * @returns a PickingInfo
  120324. */
  120325. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120326. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  120327. * @param x position on screen
  120328. * @param y position on screen
  120329. * @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
  120330. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120331. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120332. * @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)
  120333. */
  120334. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  120335. /** Use the given ray to pick a mesh in the scene
  120336. * @param ray The ray to use to pick meshes
  120337. * @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
  120338. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120339. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120340. * @returns a PickingInfo
  120341. */
  120342. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120343. /**
  120344. * Launch a ray to try to pick a mesh in the scene
  120345. * @param x X position on screen
  120346. * @param y Y position on screen
  120347. * @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
  120348. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120349. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120350. * @returns an array of PickingInfo
  120351. */
  120352. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120353. /**
  120354. * Launch a ray to try to pick a mesh in the scene
  120355. * @param ray Ray to use
  120356. * @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
  120357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120358. * @returns an array of PickingInfo
  120359. */
  120360. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120361. /**
  120362. * Force the value of meshUnderPointer
  120363. * @param mesh defines the mesh to use
  120364. */
  120365. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  120366. /**
  120367. * Gets the mesh under the pointer
  120368. * @returns a Mesh or null if no mesh is under the pointer
  120369. */
  120370. getPointerOverMesh(): Nullable<AbstractMesh>;
  120371. /** @hidden */
  120372. _rebuildGeometries(): void;
  120373. /** @hidden */
  120374. _rebuildTextures(): void;
  120375. private _getByTags;
  120376. /**
  120377. * Get a list of meshes by tags
  120378. * @param tagsQuery defines the tags query to use
  120379. * @param forEach defines a predicate used to filter results
  120380. * @returns an array of Mesh
  120381. */
  120382. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120383. /**
  120384. * Get a list of cameras by tags
  120385. * @param tagsQuery defines the tags query to use
  120386. * @param forEach defines a predicate used to filter results
  120387. * @returns an array of Camera
  120388. */
  120389. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120390. /**
  120391. * Get a list of lights by tags
  120392. * @param tagsQuery defines the tags query to use
  120393. * @param forEach defines a predicate used to filter results
  120394. * @returns an array of Light
  120395. */
  120396. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120397. /**
  120398. * Get a list of materials by tags
  120399. * @param tagsQuery defines the tags query to use
  120400. * @param forEach defines a predicate used to filter results
  120401. * @returns an array of Material
  120402. */
  120403. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120404. /**
  120405. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120406. * This allowed control for front to back rendering or reversly depending of the special needs.
  120407. *
  120408. * @param renderingGroupId The rendering group id corresponding to its index
  120409. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120410. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120411. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120412. */
  120413. 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;
  120414. /**
  120415. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120416. *
  120417. * @param renderingGroupId The rendering group id corresponding to its index
  120418. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120419. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120420. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120421. */
  120422. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120423. /**
  120424. * Gets the current auto clear configuration for one rendering group of the rendering
  120425. * manager.
  120426. * @param index the rendering group index to get the information for
  120427. * @returns The auto clear setup for the requested rendering group
  120428. */
  120429. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120430. private _blockMaterialDirtyMechanism;
  120431. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120432. get blockMaterialDirtyMechanism(): boolean;
  120433. set blockMaterialDirtyMechanism(value: boolean);
  120434. /**
  120435. * Will flag all materials as dirty to trigger new shader compilation
  120436. * @param flag defines the flag used to specify which material part must be marked as dirty
  120437. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  120438. */
  120439. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  120440. /** @hidden */
  120441. _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;
  120442. /** @hidden */
  120443. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120444. /** @hidden */
  120445. _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;
  120446. /** @hidden */
  120447. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  120448. /** @hidden */
  120449. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  120450. /** @hidden */
  120451. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120452. }
  120453. }
  120454. declare module BABYLON {
  120455. /**
  120456. * Set of assets to keep when moving a scene into an asset container.
  120457. */
  120458. export class KeepAssets extends AbstractScene {
  120459. }
  120460. /**
  120461. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  120462. */
  120463. export class InstantiatedEntries {
  120464. /**
  120465. * List of new root nodes (eg. nodes with no parent)
  120466. */
  120467. rootNodes: TransformNode[];
  120468. /**
  120469. * List of new skeletons
  120470. */
  120471. skeletons: Skeleton[];
  120472. /**
  120473. * List of new animation groups
  120474. */
  120475. animationGroups: AnimationGroup[];
  120476. }
  120477. /**
  120478. * Container with a set of assets that can be added or removed from a scene.
  120479. */
  120480. export class AssetContainer extends AbstractScene {
  120481. private _wasAddedToScene;
  120482. /**
  120483. * The scene the AssetContainer belongs to.
  120484. */
  120485. scene: Scene;
  120486. /**
  120487. * Instantiates an AssetContainer.
  120488. * @param scene The scene the AssetContainer belongs to.
  120489. */
  120490. constructor(scene: Scene);
  120491. /**
  120492. * Instantiate or clone all meshes and add the new ones to the scene.
  120493. * Skeletons and animation groups will all be cloned
  120494. * @param nameFunction defines an optional function used to get new names for clones
  120495. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  120496. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  120497. */
  120498. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  120499. /**
  120500. * Adds all the assets from the container to the scene.
  120501. */
  120502. addAllToScene(): void;
  120503. /**
  120504. * Removes all the assets in the container from the scene
  120505. */
  120506. removeAllFromScene(): void;
  120507. /**
  120508. * Disposes all the assets in the container
  120509. */
  120510. dispose(): void;
  120511. private _moveAssets;
  120512. /**
  120513. * Removes all the assets contained in the scene and adds them to the container.
  120514. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  120515. */
  120516. moveAllFromScene(keepAssets?: KeepAssets): void;
  120517. /**
  120518. * 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.
  120519. * @returns the root mesh
  120520. */
  120521. createRootMesh(): Mesh;
  120522. /**
  120523. * Merge animations (direct and animation groups) from this asset container into a scene
  120524. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120525. * @param animatables set of animatables to retarget to a node from the scene
  120526. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  120527. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  120528. */
  120529. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  120530. }
  120531. }
  120532. declare module BABYLON {
  120533. /**
  120534. * Defines how the parser contract is defined.
  120535. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  120536. */
  120537. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120538. /**
  120539. * Defines how the individual parser contract is defined.
  120540. * These parser can parse an individual asset
  120541. */
  120542. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120543. /**
  120544. * Base class of the scene acting as a container for the different elements composing a scene.
  120545. * This class is dynamically extended by the different components of the scene increasing
  120546. * flexibility and reducing coupling
  120547. */
  120548. export abstract class AbstractScene {
  120549. /**
  120550. * Stores the list of available parsers in the application.
  120551. */
  120552. private static _BabylonFileParsers;
  120553. /**
  120554. * Stores the list of available individual parsers in the application.
  120555. */
  120556. private static _IndividualBabylonFileParsers;
  120557. /**
  120558. * Adds a parser in the list of available ones
  120559. * @param name Defines the name of the parser
  120560. * @param parser Defines the parser to add
  120561. */
  120562. static AddParser(name: string, parser: BabylonFileParser): void;
  120563. /**
  120564. * Gets a general parser from the list of avaialble ones
  120565. * @param name Defines the name of the parser
  120566. * @returns the requested parser or null
  120567. */
  120568. static GetParser(name: string): Nullable<BabylonFileParser>;
  120569. /**
  120570. * Adds n individual parser in the list of available ones
  120571. * @param name Defines the name of the parser
  120572. * @param parser Defines the parser to add
  120573. */
  120574. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120575. /**
  120576. * Gets an individual parser from the list of avaialble ones
  120577. * @param name Defines the name of the parser
  120578. * @returns the requested parser or null
  120579. */
  120580. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120581. /**
  120582. * Parser json data and populate both a scene and its associated container object
  120583. * @param jsonData Defines the data to parse
  120584. * @param scene Defines the scene to parse the data for
  120585. * @param container Defines the container attached to the parsing sequence
  120586. * @param rootUrl Defines the root url of the data
  120587. */
  120588. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120589. /**
  120590. * Gets the list of root nodes (ie. nodes with no parent)
  120591. */
  120592. rootNodes: Node[];
  120593. /** All of the cameras added to this scene
  120594. * @see https://doc.babylonjs.com/babylon101/cameras
  120595. */
  120596. cameras: Camera[];
  120597. /**
  120598. * All of the lights added to this scene
  120599. * @see https://doc.babylonjs.com/babylon101/lights
  120600. */
  120601. lights: Light[];
  120602. /**
  120603. * All of the (abstract) meshes added to this scene
  120604. */
  120605. meshes: AbstractMesh[];
  120606. /**
  120607. * The list of skeletons added to the scene
  120608. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120609. */
  120610. skeletons: Skeleton[];
  120611. /**
  120612. * All of the particle systems added to this scene
  120613. * @see https://doc.babylonjs.com/babylon101/particles
  120614. */
  120615. particleSystems: IParticleSystem[];
  120616. /**
  120617. * Gets a list of Animations associated with the scene
  120618. */
  120619. animations: Animation[];
  120620. /**
  120621. * All of the animation groups added to this scene
  120622. * @see https://doc.babylonjs.com/how_to/group
  120623. */
  120624. animationGroups: AnimationGroup[];
  120625. /**
  120626. * All of the multi-materials added to this scene
  120627. * @see https://doc.babylonjs.com/how_to/multi_materials
  120628. */
  120629. multiMaterials: MultiMaterial[];
  120630. /**
  120631. * All of the materials added to this scene
  120632. * In the context of a Scene, it is not supposed to be modified manually.
  120633. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120634. * Note also that the order of the Material within the array is not significant and might change.
  120635. * @see https://doc.babylonjs.com/babylon101/materials
  120636. */
  120637. materials: Material[];
  120638. /**
  120639. * The list of morph target managers added to the scene
  120640. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120641. */
  120642. morphTargetManagers: MorphTargetManager[];
  120643. /**
  120644. * The list of geometries used in the scene.
  120645. */
  120646. geometries: Geometry[];
  120647. /**
  120648. * All of the tranform nodes added to this scene
  120649. * In the context of a Scene, it is not supposed to be modified manually.
  120650. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120651. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120652. * @see https://doc.babylonjs.com/how_to/transformnode
  120653. */
  120654. transformNodes: TransformNode[];
  120655. /**
  120656. * ActionManagers available on the scene.
  120657. */
  120658. actionManagers: AbstractActionManager[];
  120659. /**
  120660. * Textures to keep.
  120661. */
  120662. textures: BaseTexture[];
  120663. /**
  120664. * Environment texture for the scene
  120665. */
  120666. environmentTexture: Nullable<BaseTexture>;
  120667. /**
  120668. * The list of postprocesses added to the scene
  120669. */
  120670. postProcesses: PostProcess[];
  120671. /**
  120672. * @returns all meshes, lights, cameras, transformNodes and bones
  120673. */
  120674. getNodes(): Array<Node>;
  120675. }
  120676. }
  120677. declare module BABYLON {
  120678. /**
  120679. * Interface used to define options for Sound class
  120680. */
  120681. export interface ISoundOptions {
  120682. /**
  120683. * Does the sound autoplay once loaded.
  120684. */
  120685. autoplay?: boolean;
  120686. /**
  120687. * Does the sound loop after it finishes playing once.
  120688. */
  120689. loop?: boolean;
  120690. /**
  120691. * Sound's volume
  120692. */
  120693. volume?: number;
  120694. /**
  120695. * Is it a spatial sound?
  120696. */
  120697. spatialSound?: boolean;
  120698. /**
  120699. * Maximum distance to hear that sound
  120700. */
  120701. maxDistance?: number;
  120702. /**
  120703. * Uses user defined attenuation function
  120704. */
  120705. useCustomAttenuation?: boolean;
  120706. /**
  120707. * Define the roll off factor of spatial sounds.
  120708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120709. */
  120710. rolloffFactor?: number;
  120711. /**
  120712. * Define the reference distance the sound should be heard perfectly.
  120713. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120714. */
  120715. refDistance?: number;
  120716. /**
  120717. * Define the distance attenuation model the sound will follow.
  120718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120719. */
  120720. distanceModel?: string;
  120721. /**
  120722. * Defines the playback speed (1 by default)
  120723. */
  120724. playbackRate?: number;
  120725. /**
  120726. * Defines if the sound is from a streaming source
  120727. */
  120728. streaming?: boolean;
  120729. /**
  120730. * Defines an optional length (in seconds) inside the sound file
  120731. */
  120732. length?: number;
  120733. /**
  120734. * Defines an optional offset (in seconds) inside the sound file
  120735. */
  120736. offset?: number;
  120737. /**
  120738. * If true, URLs will not be required to state the audio file codec to use.
  120739. */
  120740. skipCodecCheck?: boolean;
  120741. }
  120742. /**
  120743. * Defines a sound that can be played in the application.
  120744. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120746. */
  120747. export class Sound {
  120748. /**
  120749. * The name of the sound in the scene.
  120750. */
  120751. name: string;
  120752. /**
  120753. * Does the sound autoplay once loaded.
  120754. */
  120755. autoplay: boolean;
  120756. /**
  120757. * Does the sound loop after it finishes playing once.
  120758. */
  120759. loop: boolean;
  120760. /**
  120761. * Does the sound use a custom attenuation curve to simulate the falloff
  120762. * happening when the source gets further away from the camera.
  120763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120764. */
  120765. useCustomAttenuation: boolean;
  120766. /**
  120767. * The sound track id this sound belongs to.
  120768. */
  120769. soundTrackId: number;
  120770. /**
  120771. * Is this sound currently played.
  120772. */
  120773. isPlaying: boolean;
  120774. /**
  120775. * Is this sound currently paused.
  120776. */
  120777. isPaused: boolean;
  120778. /**
  120779. * Does this sound enables spatial sound.
  120780. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120781. */
  120782. spatialSound: boolean;
  120783. /**
  120784. * Define the reference distance the sound should be heard perfectly.
  120785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120786. */
  120787. refDistance: number;
  120788. /**
  120789. * Define the roll off factor of spatial sounds.
  120790. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120791. */
  120792. rolloffFactor: number;
  120793. /**
  120794. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120795. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120796. */
  120797. maxDistance: number;
  120798. /**
  120799. * Define the distance attenuation model the sound will follow.
  120800. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120801. */
  120802. distanceModel: string;
  120803. /**
  120804. * @hidden
  120805. * Back Compat
  120806. **/
  120807. onended: () => any;
  120808. /**
  120809. * Gets or sets an object used to store user defined information for the sound.
  120810. */
  120811. metadata: any;
  120812. /**
  120813. * Observable event when the current playing sound finishes.
  120814. */
  120815. onEndedObservable: Observable<Sound>;
  120816. private _panningModel;
  120817. private _playbackRate;
  120818. private _streaming;
  120819. private _startTime;
  120820. private _startOffset;
  120821. private _position;
  120822. /** @hidden */
  120823. _positionInEmitterSpace: boolean;
  120824. private _localDirection;
  120825. private _volume;
  120826. private _isReadyToPlay;
  120827. private _isDirectional;
  120828. private _readyToPlayCallback;
  120829. private _audioBuffer;
  120830. private _soundSource;
  120831. private _streamingSource;
  120832. private _soundPanner;
  120833. private _soundGain;
  120834. private _inputAudioNode;
  120835. private _outputAudioNode;
  120836. private _coneInnerAngle;
  120837. private _coneOuterAngle;
  120838. private _coneOuterGain;
  120839. private _scene;
  120840. private _connectedTransformNode;
  120841. private _customAttenuationFunction;
  120842. private _registerFunc;
  120843. private _isOutputConnected;
  120844. private _htmlAudioElement;
  120845. private _urlType;
  120846. private _length?;
  120847. private _offset?;
  120848. /** @hidden */
  120849. static _SceneComponentInitialization: (scene: Scene) => void;
  120850. /**
  120851. * Create a sound and attach it to a scene
  120852. * @param name Name of your sound
  120853. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120854. * @param scene defines the scene the sound belongs to
  120855. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120856. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120857. */
  120858. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120859. /**
  120860. * Release the sound and its associated resources
  120861. */
  120862. dispose(): void;
  120863. /**
  120864. * Gets if the sounds is ready to be played or not.
  120865. * @returns true if ready, otherwise false
  120866. */
  120867. isReady(): boolean;
  120868. private _soundLoaded;
  120869. /**
  120870. * Sets the data of the sound from an audiobuffer
  120871. * @param audioBuffer The audioBuffer containing the data
  120872. */
  120873. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120874. /**
  120875. * Updates the current sounds options such as maxdistance, loop...
  120876. * @param options A JSON object containing values named as the object properties
  120877. */
  120878. updateOptions(options: ISoundOptions): void;
  120879. private _createSpatialParameters;
  120880. private _updateSpatialParameters;
  120881. /**
  120882. * Switch the panning model to HRTF:
  120883. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120885. */
  120886. switchPanningModelToHRTF(): void;
  120887. /**
  120888. * Switch the panning model to Equal Power:
  120889. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120890. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120891. */
  120892. switchPanningModelToEqualPower(): void;
  120893. private _switchPanningModel;
  120894. /**
  120895. * Connect this sound to a sound track audio node like gain...
  120896. * @param soundTrackAudioNode the sound track audio node to connect to
  120897. */
  120898. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120899. /**
  120900. * Transform this sound into a directional source
  120901. * @param coneInnerAngle Size of the inner cone in degree
  120902. * @param coneOuterAngle Size of the outer cone in degree
  120903. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120904. */
  120905. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120906. /**
  120907. * Gets or sets the inner angle for the directional cone.
  120908. */
  120909. get directionalConeInnerAngle(): number;
  120910. /**
  120911. * Gets or sets the inner angle for the directional cone.
  120912. */
  120913. set directionalConeInnerAngle(value: number);
  120914. /**
  120915. * Gets or sets the outer angle for the directional cone.
  120916. */
  120917. get directionalConeOuterAngle(): number;
  120918. /**
  120919. * Gets or sets the outer angle for the directional cone.
  120920. */
  120921. set directionalConeOuterAngle(value: number);
  120922. /**
  120923. * Sets the position of the emitter if spatial sound is enabled
  120924. * @param newPosition Defines the new posisiton
  120925. */
  120926. setPosition(newPosition: Vector3): void;
  120927. /**
  120928. * Sets the local direction of the emitter if spatial sound is enabled
  120929. * @param newLocalDirection Defines the new local direction
  120930. */
  120931. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120932. private _updateDirection;
  120933. /** @hidden */
  120934. updateDistanceFromListener(): void;
  120935. /**
  120936. * Sets a new custom attenuation function for the sound.
  120937. * @param callback Defines the function used for the attenuation
  120938. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120939. */
  120940. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120941. /**
  120942. * Play the sound
  120943. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120944. * @param offset (optional) Start the sound at a specific time in seconds
  120945. * @param length (optional) Sound duration (in seconds)
  120946. */
  120947. play(time?: number, offset?: number, length?: number): void;
  120948. private _onended;
  120949. /**
  120950. * Stop the sound
  120951. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120952. */
  120953. stop(time?: number): void;
  120954. /**
  120955. * Put the sound in pause
  120956. */
  120957. pause(): void;
  120958. /**
  120959. * Sets a dedicated volume for this sounds
  120960. * @param newVolume Define the new volume of the sound
  120961. * @param time Define time for gradual change to new volume
  120962. */
  120963. setVolume(newVolume: number, time?: number): void;
  120964. /**
  120965. * Set the sound play back rate
  120966. * @param newPlaybackRate Define the playback rate the sound should be played at
  120967. */
  120968. setPlaybackRate(newPlaybackRate: number): void;
  120969. /**
  120970. * Gets the volume of the sound.
  120971. * @returns the volume of the sound
  120972. */
  120973. getVolume(): number;
  120974. /**
  120975. * Attach the sound to a dedicated mesh
  120976. * @param transformNode The transform node to connect the sound with
  120977. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120978. */
  120979. attachToMesh(transformNode: TransformNode): void;
  120980. /**
  120981. * Detach the sound from the previously attached mesh
  120982. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120983. */
  120984. detachFromMesh(): void;
  120985. private _onRegisterAfterWorldMatrixUpdate;
  120986. /**
  120987. * Clone the current sound in the scene.
  120988. * @returns the new sound clone
  120989. */
  120990. clone(): Nullable<Sound>;
  120991. /**
  120992. * Gets the current underlying audio buffer containing the data
  120993. * @returns the audio buffer
  120994. */
  120995. getAudioBuffer(): Nullable<AudioBuffer>;
  120996. /**
  120997. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120998. * @returns the source node
  120999. */
  121000. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121001. /**
  121002. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121003. * @returns the gain node
  121004. */
  121005. getSoundGain(): Nullable<GainNode>;
  121006. /**
  121007. * Serializes the Sound in a JSON representation
  121008. * @returns the JSON representation of the sound
  121009. */
  121010. serialize(): any;
  121011. /**
  121012. * Parse a JSON representation of a sound to innstantiate in a given scene
  121013. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121014. * @param scene Define the scene the new parsed sound should be created in
  121015. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121016. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121017. * @returns the newly parsed sound
  121018. */
  121019. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121020. }
  121021. }
  121022. declare module BABYLON {
  121023. /**
  121024. * This defines an action helpful to play a defined sound on a triggered action.
  121025. */
  121026. export class PlaySoundAction extends Action {
  121027. private _sound;
  121028. /**
  121029. * Instantiate the action
  121030. * @param triggerOptions defines the trigger options
  121031. * @param sound defines the sound to play
  121032. * @param condition defines the trigger related conditions
  121033. */
  121034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121035. /** @hidden */
  121036. _prepare(): void;
  121037. /**
  121038. * Execute the action and play the sound.
  121039. */
  121040. execute(): void;
  121041. /**
  121042. * Serializes the actions and its related information.
  121043. * @param parent defines the object to serialize in
  121044. * @returns the serialized object
  121045. */
  121046. serialize(parent: any): any;
  121047. }
  121048. /**
  121049. * This defines an action helpful to stop a defined sound on a triggered action.
  121050. */
  121051. export class StopSoundAction extends Action {
  121052. private _sound;
  121053. /**
  121054. * Instantiate the action
  121055. * @param triggerOptions defines the trigger options
  121056. * @param sound defines the sound to stop
  121057. * @param condition defines the trigger related conditions
  121058. */
  121059. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121060. /** @hidden */
  121061. _prepare(): void;
  121062. /**
  121063. * Execute the action and stop the sound.
  121064. */
  121065. execute(): void;
  121066. /**
  121067. * Serializes the actions and its related information.
  121068. * @param parent defines the object to serialize in
  121069. * @returns the serialized object
  121070. */
  121071. serialize(parent: any): any;
  121072. }
  121073. }
  121074. declare module BABYLON {
  121075. /**
  121076. * This defines an action responsible to change the value of a property
  121077. * by interpolating between its current value and the newly set one once triggered.
  121078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121079. */
  121080. export class InterpolateValueAction extends Action {
  121081. /**
  121082. * Defines the path of the property where the value should be interpolated
  121083. */
  121084. propertyPath: string;
  121085. /**
  121086. * Defines the target value at the end of the interpolation.
  121087. */
  121088. value: any;
  121089. /**
  121090. * Defines the time it will take for the property to interpolate to the value.
  121091. */
  121092. duration: number;
  121093. /**
  121094. * Defines if the other scene animations should be stopped when the action has been triggered
  121095. */
  121096. stopOtherAnimations?: boolean;
  121097. /**
  121098. * Defines a callback raised once the interpolation animation has been done.
  121099. */
  121100. onInterpolationDone?: () => void;
  121101. /**
  121102. * Observable triggered once the interpolation animation has been done.
  121103. */
  121104. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121105. private _target;
  121106. private _effectiveTarget;
  121107. private _property;
  121108. /**
  121109. * Instantiate the action
  121110. * @param triggerOptions defines the trigger options
  121111. * @param target defines the object containing the value to interpolate
  121112. * @param propertyPath defines the path to the property in the target object
  121113. * @param value defines the target value at the end of the interpolation
  121114. * @param duration deines the time it will take for the property to interpolate to the value.
  121115. * @param condition defines the trigger related conditions
  121116. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121117. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121118. */
  121119. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121120. /** @hidden */
  121121. _prepare(): void;
  121122. /**
  121123. * Execute the action starts the value interpolation.
  121124. */
  121125. execute(): void;
  121126. /**
  121127. * Serializes the actions and its related information.
  121128. * @param parent defines the object to serialize in
  121129. * @returns the serialized object
  121130. */
  121131. serialize(parent: any): any;
  121132. }
  121133. }
  121134. declare module BABYLON {
  121135. /**
  121136. * Options allowed during the creation of a sound track.
  121137. */
  121138. export interface ISoundTrackOptions {
  121139. /**
  121140. * The volume the sound track should take during creation
  121141. */
  121142. volume?: number;
  121143. /**
  121144. * Define if the sound track is the main sound track of the scene
  121145. */
  121146. mainTrack?: boolean;
  121147. }
  121148. /**
  121149. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121150. * It will be also used in a future release to apply effects on a specific track.
  121151. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121152. */
  121153. export class SoundTrack {
  121154. /**
  121155. * The unique identifier of the sound track in the scene.
  121156. */
  121157. id: number;
  121158. /**
  121159. * The list of sounds included in the sound track.
  121160. */
  121161. soundCollection: Array<Sound>;
  121162. private _outputAudioNode;
  121163. private _scene;
  121164. private _connectedAnalyser;
  121165. private _options;
  121166. private _isInitialized;
  121167. /**
  121168. * Creates a new sound track.
  121169. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121170. * @param scene Define the scene the sound track belongs to
  121171. * @param options
  121172. */
  121173. constructor(scene: Scene, options?: ISoundTrackOptions);
  121174. private _initializeSoundTrackAudioGraph;
  121175. /**
  121176. * Release the sound track and its associated resources
  121177. */
  121178. dispose(): void;
  121179. /**
  121180. * Adds a sound to this sound track
  121181. * @param sound define the cound to add
  121182. * @ignoreNaming
  121183. */
  121184. AddSound(sound: Sound): void;
  121185. /**
  121186. * Removes a sound to this sound track
  121187. * @param sound define the cound to remove
  121188. * @ignoreNaming
  121189. */
  121190. RemoveSound(sound: Sound): void;
  121191. /**
  121192. * Set a global volume for the full sound track.
  121193. * @param newVolume Define the new volume of the sound track
  121194. */
  121195. setVolume(newVolume: number): void;
  121196. /**
  121197. * Switch the panning model to HRTF:
  121198. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121200. */
  121201. switchPanningModelToHRTF(): void;
  121202. /**
  121203. * Switch the panning model to Equal Power:
  121204. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121205. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121206. */
  121207. switchPanningModelToEqualPower(): void;
  121208. /**
  121209. * Connect the sound track to an audio analyser allowing some amazing
  121210. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121211. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121212. * @param analyser The analyser to connect to the engine
  121213. */
  121214. connectToAnalyser(analyser: Analyser): void;
  121215. }
  121216. }
  121217. declare module BABYLON {
  121218. interface AbstractScene {
  121219. /**
  121220. * The list of sounds used in the scene.
  121221. */
  121222. sounds: Nullable<Array<Sound>>;
  121223. }
  121224. interface Scene {
  121225. /**
  121226. * @hidden
  121227. * Backing field
  121228. */
  121229. _mainSoundTrack: SoundTrack;
  121230. /**
  121231. * The main sound track played by the scene.
  121232. * It cotains your primary collection of sounds.
  121233. */
  121234. mainSoundTrack: SoundTrack;
  121235. /**
  121236. * The list of sound tracks added to the scene
  121237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121238. */
  121239. soundTracks: Nullable<Array<SoundTrack>>;
  121240. /**
  121241. * Gets a sound using a given name
  121242. * @param name defines the name to search for
  121243. * @return the found sound or null if not found at all.
  121244. */
  121245. getSoundByName(name: string): Nullable<Sound>;
  121246. /**
  121247. * Gets or sets if audio support is enabled
  121248. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121249. */
  121250. audioEnabled: boolean;
  121251. /**
  121252. * Gets or sets if audio will be output to headphones
  121253. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121254. */
  121255. headphone: boolean;
  121256. /**
  121257. * Gets or sets custom audio listener position provider
  121258. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121259. */
  121260. audioListenerPositionProvider: Nullable<() => Vector3>;
  121261. /**
  121262. * Gets or sets a refresh rate when using 3D audio positioning
  121263. */
  121264. audioPositioningRefreshRate: number;
  121265. }
  121266. /**
  121267. * Defines the sound scene component responsible to manage any sounds
  121268. * in a given scene.
  121269. */
  121270. export class AudioSceneComponent implements ISceneSerializableComponent {
  121271. /**
  121272. * The component name helpfull to identify the component in the list of scene components.
  121273. */
  121274. readonly name: string;
  121275. /**
  121276. * The scene the component belongs to.
  121277. */
  121278. scene: Scene;
  121279. private _audioEnabled;
  121280. /**
  121281. * Gets whether audio is enabled or not.
  121282. * Please use related enable/disable method to switch state.
  121283. */
  121284. get audioEnabled(): boolean;
  121285. private _headphone;
  121286. /**
  121287. * Gets whether audio is outputing to headphone or not.
  121288. * Please use the according Switch methods to change output.
  121289. */
  121290. get headphone(): boolean;
  121291. /**
  121292. * Gets or sets a refresh rate when using 3D audio positioning
  121293. */
  121294. audioPositioningRefreshRate: number;
  121295. private _audioListenerPositionProvider;
  121296. /**
  121297. * Gets the current audio listener position provider
  121298. */
  121299. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121300. /**
  121301. * Sets a custom listener position for all sounds in the scene
  121302. * By default, this is the position of the first active camera
  121303. */
  121304. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  121305. /**
  121306. * Creates a new instance of the component for the given scene
  121307. * @param scene Defines the scene to register the component in
  121308. */
  121309. constructor(scene: Scene);
  121310. /**
  121311. * Registers the component in a given scene
  121312. */
  121313. register(): void;
  121314. /**
  121315. * Rebuilds the elements related to this component in case of
  121316. * context lost for instance.
  121317. */
  121318. rebuild(): void;
  121319. /**
  121320. * Serializes the component data to the specified json object
  121321. * @param serializationObject The object to serialize to
  121322. */
  121323. serialize(serializationObject: any): void;
  121324. /**
  121325. * Adds all the elements from the container to the scene
  121326. * @param container the container holding the elements
  121327. */
  121328. addFromContainer(container: AbstractScene): void;
  121329. /**
  121330. * Removes all the elements in the container from the scene
  121331. * @param container contains the elements to remove
  121332. * @param dispose if the removed element should be disposed (default: false)
  121333. */
  121334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121335. /**
  121336. * Disposes the component and the associated ressources.
  121337. */
  121338. dispose(): void;
  121339. /**
  121340. * Disables audio in the associated scene.
  121341. */
  121342. disableAudio(): void;
  121343. /**
  121344. * Enables audio in the associated scene.
  121345. */
  121346. enableAudio(): void;
  121347. /**
  121348. * Switch audio to headphone output.
  121349. */
  121350. switchAudioModeForHeadphones(): void;
  121351. /**
  121352. * Switch audio to normal speakers.
  121353. */
  121354. switchAudioModeForNormalSpeakers(): void;
  121355. private _cachedCameraDirection;
  121356. private _cachedCameraPosition;
  121357. private _lastCheck;
  121358. private _afterRender;
  121359. }
  121360. }
  121361. declare module BABYLON {
  121362. /**
  121363. * Wraps one or more Sound objects and selects one with random weight for playback.
  121364. */
  121365. export class WeightedSound {
  121366. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121367. loop: boolean;
  121368. private _coneInnerAngle;
  121369. private _coneOuterAngle;
  121370. private _volume;
  121371. /** A Sound is currently playing. */
  121372. isPlaying: boolean;
  121373. /** A Sound is currently paused. */
  121374. isPaused: boolean;
  121375. private _sounds;
  121376. private _weights;
  121377. private _currentIndex?;
  121378. /**
  121379. * Creates a new WeightedSound from the list of sounds given.
  121380. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121381. * @param sounds Array of Sounds that will be selected from.
  121382. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121383. */
  121384. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121385. /**
  121386. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121387. */
  121388. get directionalConeInnerAngle(): number;
  121389. /**
  121390. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121391. */
  121392. set directionalConeInnerAngle(value: number);
  121393. /**
  121394. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121395. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121396. */
  121397. get directionalConeOuterAngle(): number;
  121398. /**
  121399. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121400. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121401. */
  121402. set directionalConeOuterAngle(value: number);
  121403. /**
  121404. * Playback volume.
  121405. */
  121406. get volume(): number;
  121407. /**
  121408. * Playback volume.
  121409. */
  121410. set volume(value: number);
  121411. private _onended;
  121412. /**
  121413. * Suspend playback
  121414. */
  121415. pause(): void;
  121416. /**
  121417. * Stop playback
  121418. */
  121419. stop(): void;
  121420. /**
  121421. * Start playback.
  121422. * @param startOffset Position the clip head at a specific time in seconds.
  121423. */
  121424. play(startOffset?: number): void;
  121425. }
  121426. }
  121427. declare module BABYLON {
  121428. /**
  121429. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  121430. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121431. */
  121432. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  121433. /**
  121434. * Gets the name of the behavior.
  121435. */
  121436. get name(): string;
  121437. /**
  121438. * The easing function used by animations
  121439. */
  121440. static EasingFunction: BackEase;
  121441. /**
  121442. * The easing mode used by animations
  121443. */
  121444. static EasingMode: number;
  121445. /**
  121446. * The duration of the animation, in milliseconds
  121447. */
  121448. transitionDuration: number;
  121449. /**
  121450. * Length of the distance animated by the transition when lower radius is reached
  121451. */
  121452. lowerRadiusTransitionRange: number;
  121453. /**
  121454. * Length of the distance animated by the transition when upper radius is reached
  121455. */
  121456. upperRadiusTransitionRange: number;
  121457. private _autoTransitionRange;
  121458. /**
  121459. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121460. */
  121461. get autoTransitionRange(): boolean;
  121462. /**
  121463. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121464. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  121465. */
  121466. set autoTransitionRange(value: boolean);
  121467. private _attachedCamera;
  121468. private _onAfterCheckInputsObserver;
  121469. private _onMeshTargetChangedObserver;
  121470. /**
  121471. * Initializes the behavior.
  121472. */
  121473. init(): void;
  121474. /**
  121475. * Attaches the behavior to its arc rotate camera.
  121476. * @param camera Defines the camera to attach the behavior to
  121477. */
  121478. attach(camera: ArcRotateCamera): void;
  121479. /**
  121480. * Detaches the behavior from its current arc rotate camera.
  121481. */
  121482. detach(): void;
  121483. private _radiusIsAnimating;
  121484. private _radiusBounceTransition;
  121485. private _animatables;
  121486. private _cachedWheelPrecision;
  121487. /**
  121488. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  121489. * @param radiusLimit The limit to check against.
  121490. * @return Bool to indicate if at limit.
  121491. */
  121492. private _isRadiusAtLimit;
  121493. /**
  121494. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  121495. * @param radiusDelta The delta by which to animate to. Can be negative.
  121496. */
  121497. private _applyBoundRadiusAnimation;
  121498. /**
  121499. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  121500. */
  121501. protected _clearAnimationLocks(): void;
  121502. /**
  121503. * Stops and removes all animations that have been applied to the camera
  121504. */
  121505. stopAllAnimations(): void;
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * 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.
  121511. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121512. */
  121513. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  121514. /**
  121515. * Gets the name of the behavior.
  121516. */
  121517. get name(): string;
  121518. private _mode;
  121519. private _radiusScale;
  121520. private _positionScale;
  121521. private _defaultElevation;
  121522. private _elevationReturnTime;
  121523. private _elevationReturnWaitTime;
  121524. private _zoomStopsAnimation;
  121525. private _framingTime;
  121526. /**
  121527. * The easing function used by animations
  121528. */
  121529. static EasingFunction: ExponentialEase;
  121530. /**
  121531. * The easing mode used by animations
  121532. */
  121533. static EasingMode: number;
  121534. /**
  121535. * Sets the current mode used by the behavior
  121536. */
  121537. set mode(mode: number);
  121538. /**
  121539. * Gets current mode used by the behavior.
  121540. */
  121541. get mode(): number;
  121542. /**
  121543. * Sets the scale applied to the radius (1 by default)
  121544. */
  121545. set radiusScale(radius: number);
  121546. /**
  121547. * Gets the scale applied to the radius
  121548. */
  121549. get radiusScale(): number;
  121550. /**
  121551. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121552. */
  121553. set positionScale(scale: number);
  121554. /**
  121555. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121556. */
  121557. get positionScale(): number;
  121558. /**
  121559. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121560. * behaviour is triggered, in radians.
  121561. */
  121562. set defaultElevation(elevation: number);
  121563. /**
  121564. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121565. * behaviour is triggered, in radians.
  121566. */
  121567. get defaultElevation(): number;
  121568. /**
  121569. * Sets the time (in milliseconds) taken to return to the default beta position.
  121570. * Negative value indicates camera should not return to default.
  121571. */
  121572. set elevationReturnTime(speed: number);
  121573. /**
  121574. * Gets the time (in milliseconds) taken to return to the default beta position.
  121575. * Negative value indicates camera should not return to default.
  121576. */
  121577. get elevationReturnTime(): number;
  121578. /**
  121579. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121580. */
  121581. set elevationReturnWaitTime(time: number);
  121582. /**
  121583. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121584. */
  121585. get elevationReturnWaitTime(): number;
  121586. /**
  121587. * Sets the flag that indicates if user zooming should stop animation.
  121588. */
  121589. set zoomStopsAnimation(flag: boolean);
  121590. /**
  121591. * Gets the flag that indicates if user zooming should stop animation.
  121592. */
  121593. get zoomStopsAnimation(): boolean;
  121594. /**
  121595. * Sets the transition time when framing the mesh, in milliseconds
  121596. */
  121597. set framingTime(time: number);
  121598. /**
  121599. * Gets the transition time when framing the mesh, in milliseconds
  121600. */
  121601. get framingTime(): number;
  121602. /**
  121603. * Define if the behavior should automatically change the configured
  121604. * camera limits and sensibilities.
  121605. */
  121606. autoCorrectCameraLimitsAndSensibility: boolean;
  121607. private _onPrePointerObservableObserver;
  121608. private _onAfterCheckInputsObserver;
  121609. private _onMeshTargetChangedObserver;
  121610. private _attachedCamera;
  121611. private _isPointerDown;
  121612. private _lastInteractionTime;
  121613. /**
  121614. * Initializes the behavior.
  121615. */
  121616. init(): void;
  121617. /**
  121618. * Attaches the behavior to its arc rotate camera.
  121619. * @param camera Defines the camera to attach the behavior to
  121620. */
  121621. attach(camera: ArcRotateCamera): void;
  121622. /**
  121623. * Detaches the behavior from its current arc rotate camera.
  121624. */
  121625. detach(): void;
  121626. private _animatables;
  121627. private _betaIsAnimating;
  121628. private _betaTransition;
  121629. private _radiusTransition;
  121630. private _vectorTransition;
  121631. /**
  121632. * Targets the given mesh and updates zoom level accordingly.
  121633. * @param mesh The mesh to target.
  121634. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121635. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121636. */
  121637. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121638. /**
  121639. * Targets the given mesh with its children and updates zoom level accordingly.
  121640. * @param mesh The mesh to target.
  121641. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121642. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121643. */
  121644. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121645. /**
  121646. * Targets the given meshes with their children and updates zoom level accordingly.
  121647. * @param meshes The mesh to target.
  121648. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121649. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121650. */
  121651. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121652. /**
  121653. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121654. * @param minimumWorld Determines the smaller position of the bounding box extend
  121655. * @param maximumWorld Determines the bigger position of the bounding box extend
  121656. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121657. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121658. */
  121659. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121660. /**
  121661. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121662. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121663. * frustum width.
  121664. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121665. * to fully enclose the mesh in the viewing frustum.
  121666. */
  121667. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121668. /**
  121669. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121670. * is automatically returned to its default position (expected to be above ground plane).
  121671. */
  121672. private _maintainCameraAboveGround;
  121673. /**
  121674. * Returns the frustum slope based on the canvas ratio and camera FOV
  121675. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121676. */
  121677. private _getFrustumSlope;
  121678. /**
  121679. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121680. */
  121681. private _clearAnimationLocks;
  121682. /**
  121683. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121684. */
  121685. private _applyUserInteraction;
  121686. /**
  121687. * Stops and removes all animations that have been applied to the camera
  121688. */
  121689. stopAllAnimations(): void;
  121690. /**
  121691. * Gets a value indicating if the user is moving the camera
  121692. */
  121693. get isUserIsMoving(): boolean;
  121694. /**
  121695. * The camera can move all the way towards the mesh.
  121696. */
  121697. static IgnoreBoundsSizeMode: number;
  121698. /**
  121699. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121700. */
  121701. static FitFrustumSidesMode: number;
  121702. }
  121703. }
  121704. declare module BABYLON {
  121705. /**
  121706. * Base class for Camera Pointer Inputs.
  121707. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121708. * for example usage.
  121709. */
  121710. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121711. /**
  121712. * Defines the camera the input is attached to.
  121713. */
  121714. abstract camera: Camera;
  121715. /**
  121716. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121717. */
  121718. protected _altKey: boolean;
  121719. protected _ctrlKey: boolean;
  121720. protected _metaKey: boolean;
  121721. protected _shiftKey: boolean;
  121722. /**
  121723. * Which mouse buttons were pressed at time of last mouse event.
  121724. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121725. */
  121726. protected _buttonsPressed: number;
  121727. /**
  121728. * Defines the buttons associated with the input to handle camera move.
  121729. */
  121730. buttons: number[];
  121731. /**
  121732. * Attach the input controls to a specific dom element to get the input from.
  121733. * @param element Defines the element the controls should be listened from
  121734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121735. */
  121736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121737. /**
  121738. * Detach the current controls from the specified dom element.
  121739. * @param element Defines the element to stop listening the inputs from
  121740. */
  121741. detachControl(element: Nullable<HTMLElement>): void;
  121742. /**
  121743. * Gets the class name of the current input.
  121744. * @returns the class name
  121745. */
  121746. getClassName(): string;
  121747. /**
  121748. * Get the friendly name associated with the input class.
  121749. * @returns the input friendly name
  121750. */
  121751. getSimpleName(): string;
  121752. /**
  121753. * Called on pointer POINTERDOUBLETAP event.
  121754. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121755. */
  121756. protected onDoubleTap(type: string): void;
  121757. /**
  121758. * Called on pointer POINTERMOVE event if only a single touch is active.
  121759. * Override this method to provide functionality.
  121760. */
  121761. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121762. /**
  121763. * Called on pointer POINTERMOVE event if multiple touches are active.
  121764. * Override this method to provide functionality.
  121765. */
  121766. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121767. /**
  121768. * Called on JS contextmenu event.
  121769. * Override this method to provide functionality.
  121770. */
  121771. protected onContextMenu(evt: PointerEvent): void;
  121772. /**
  121773. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121774. * press.
  121775. * Override this method to provide functionality.
  121776. */
  121777. protected onButtonDown(evt: PointerEvent): void;
  121778. /**
  121779. * Called each time a new POINTERUP event occurs. Ie, for each button
  121780. * release.
  121781. * Override this method to provide functionality.
  121782. */
  121783. protected onButtonUp(evt: PointerEvent): void;
  121784. /**
  121785. * Called when window becomes inactive.
  121786. * Override this method to provide functionality.
  121787. */
  121788. protected onLostFocus(): void;
  121789. private _pointerInput;
  121790. private _observer;
  121791. private _onLostFocus;
  121792. private pointA;
  121793. private pointB;
  121794. }
  121795. }
  121796. declare module BABYLON {
  121797. /**
  121798. * Manage the pointers inputs to control an arc rotate camera.
  121799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121800. */
  121801. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121802. /**
  121803. * Defines the camera the input is attached to.
  121804. */
  121805. camera: ArcRotateCamera;
  121806. /**
  121807. * Gets the class name of the current input.
  121808. * @returns the class name
  121809. */
  121810. getClassName(): string;
  121811. /**
  121812. * Defines the buttons associated with the input to handle camera move.
  121813. */
  121814. buttons: number[];
  121815. /**
  121816. * Defines the pointer angular sensibility along the X axis or how fast is
  121817. * the camera rotating.
  121818. */
  121819. angularSensibilityX: number;
  121820. /**
  121821. * Defines the pointer angular sensibility along the Y axis or how fast is
  121822. * the camera rotating.
  121823. */
  121824. angularSensibilityY: number;
  121825. /**
  121826. * Defines the pointer pinch precision or how fast is the camera zooming.
  121827. */
  121828. pinchPrecision: number;
  121829. /**
  121830. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121831. * from 0.
  121832. * It defines the percentage of current camera.radius to use as delta when
  121833. * pinch zoom is used.
  121834. */
  121835. pinchDeltaPercentage: number;
  121836. /**
  121837. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121838. * that any object in the plane at the camera's target point will scale
  121839. * perfectly with finger motion.
  121840. * Overrides pinchDeltaPercentage and pinchPrecision.
  121841. */
  121842. useNaturalPinchZoom: boolean;
  121843. /**
  121844. * Defines the pointer panning sensibility or how fast is the camera moving.
  121845. */
  121846. panningSensibility: number;
  121847. /**
  121848. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121849. */
  121850. multiTouchPanning: boolean;
  121851. /**
  121852. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121853. * zoom (pinch) through multitouch.
  121854. */
  121855. multiTouchPanAndZoom: boolean;
  121856. /**
  121857. * Revers pinch action direction.
  121858. */
  121859. pinchInwards: boolean;
  121860. private _isPanClick;
  121861. private _twoFingerActivityCount;
  121862. private _isPinching;
  121863. /**
  121864. * Called on pointer POINTERMOVE event if only a single touch is active.
  121865. */
  121866. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121867. /**
  121868. * Called on pointer POINTERDOUBLETAP event.
  121869. */
  121870. protected onDoubleTap(type: string): void;
  121871. /**
  121872. * Called on pointer POINTERMOVE event if multiple touches are active.
  121873. */
  121874. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121875. /**
  121876. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121877. * press.
  121878. */
  121879. protected onButtonDown(evt: PointerEvent): void;
  121880. /**
  121881. * Called each time a new POINTERUP event occurs. Ie, for each button
  121882. * release.
  121883. */
  121884. protected onButtonUp(evt: PointerEvent): void;
  121885. /**
  121886. * Called when window becomes inactive.
  121887. */
  121888. protected onLostFocus(): void;
  121889. }
  121890. }
  121891. declare module BABYLON {
  121892. /**
  121893. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121895. */
  121896. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121897. /**
  121898. * Defines the camera the input is attached to.
  121899. */
  121900. camera: ArcRotateCamera;
  121901. /**
  121902. * Defines the list of key codes associated with the up action (increase alpha)
  121903. */
  121904. keysUp: number[];
  121905. /**
  121906. * Defines the list of key codes associated with the down action (decrease alpha)
  121907. */
  121908. keysDown: number[];
  121909. /**
  121910. * Defines the list of key codes associated with the left action (increase beta)
  121911. */
  121912. keysLeft: number[];
  121913. /**
  121914. * Defines the list of key codes associated with the right action (decrease beta)
  121915. */
  121916. keysRight: number[];
  121917. /**
  121918. * Defines the list of key codes associated with the reset action.
  121919. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121920. */
  121921. keysReset: number[];
  121922. /**
  121923. * Defines the panning sensibility of the inputs.
  121924. * (How fast is the camera panning)
  121925. */
  121926. panningSensibility: number;
  121927. /**
  121928. * Defines the zooming sensibility of the inputs.
  121929. * (How fast is the camera zooming)
  121930. */
  121931. zoomingSensibility: number;
  121932. /**
  121933. * Defines whether maintaining the alt key down switch the movement mode from
  121934. * orientation to zoom.
  121935. */
  121936. useAltToZoom: boolean;
  121937. /**
  121938. * Rotation speed of the camera
  121939. */
  121940. angularSpeed: number;
  121941. private _keys;
  121942. private _ctrlPressed;
  121943. private _altPressed;
  121944. private _onCanvasBlurObserver;
  121945. private _onKeyboardObserver;
  121946. private _engine;
  121947. private _scene;
  121948. /**
  121949. * Attach the input controls to a specific dom element to get the input from.
  121950. * @param element Defines the element the controls should be listened from
  121951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121952. */
  121953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121954. /**
  121955. * Detach the current controls from the specified dom element.
  121956. * @param element Defines the element to stop listening the inputs from
  121957. */
  121958. detachControl(element: Nullable<HTMLElement>): void;
  121959. /**
  121960. * Update the current camera state depending on the inputs that have been used this frame.
  121961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121962. */
  121963. checkInputs(): void;
  121964. /**
  121965. * Gets the class name of the current intput.
  121966. * @returns the class name
  121967. */
  121968. getClassName(): string;
  121969. /**
  121970. * Get the friendly name associated with the input class.
  121971. * @returns the input friendly name
  121972. */
  121973. getSimpleName(): string;
  121974. }
  121975. }
  121976. declare module BABYLON {
  121977. /**
  121978. * Manage the mouse wheel inputs to control an arc rotate camera.
  121979. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121980. */
  121981. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121982. /**
  121983. * Defines the camera the input is attached to.
  121984. */
  121985. camera: ArcRotateCamera;
  121986. /**
  121987. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121988. */
  121989. wheelPrecision: number;
  121990. /**
  121991. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121992. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121993. */
  121994. wheelDeltaPercentage: number;
  121995. private _wheel;
  121996. private _observer;
  121997. private computeDeltaFromMouseWheelLegacyEvent;
  121998. /**
  121999. * Attach the input controls to a specific dom element to get the input from.
  122000. * @param element Defines the element the controls should be listened from
  122001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122002. */
  122003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122004. /**
  122005. * Detach the current controls from the specified dom element.
  122006. * @param element Defines the element to stop listening the inputs from
  122007. */
  122008. detachControl(element: Nullable<HTMLElement>): void;
  122009. /**
  122010. * Gets the class name of the current intput.
  122011. * @returns the class name
  122012. */
  122013. getClassName(): string;
  122014. /**
  122015. * Get the friendly name associated with the input class.
  122016. * @returns the input friendly name
  122017. */
  122018. getSimpleName(): string;
  122019. }
  122020. }
  122021. declare module BABYLON {
  122022. /**
  122023. * Default Inputs manager for the ArcRotateCamera.
  122024. * It groups all the default supported inputs for ease of use.
  122025. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122026. */
  122027. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122028. /**
  122029. * Instantiates a new ArcRotateCameraInputsManager.
  122030. * @param camera Defines the camera the inputs belong to
  122031. */
  122032. constructor(camera: ArcRotateCamera);
  122033. /**
  122034. * Add mouse wheel input support to the input manager.
  122035. * @returns the current input manager
  122036. */
  122037. addMouseWheel(): ArcRotateCameraInputsManager;
  122038. /**
  122039. * Add pointers input support to the input manager.
  122040. * @returns the current input manager
  122041. */
  122042. addPointers(): ArcRotateCameraInputsManager;
  122043. /**
  122044. * Add keyboard input support to the input manager.
  122045. * @returns the current input manager
  122046. */
  122047. addKeyboard(): ArcRotateCameraInputsManager;
  122048. }
  122049. }
  122050. declare module BABYLON {
  122051. /**
  122052. * This represents an orbital type of camera.
  122053. *
  122054. * 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.
  122055. * 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.
  122056. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122057. */
  122058. export class ArcRotateCamera extends TargetCamera {
  122059. /**
  122060. * Defines the rotation angle of the camera along the longitudinal axis.
  122061. */
  122062. alpha: number;
  122063. /**
  122064. * Defines the rotation angle of the camera along the latitudinal axis.
  122065. */
  122066. beta: number;
  122067. /**
  122068. * Defines the radius of the camera from it s target point.
  122069. */
  122070. radius: number;
  122071. protected _target: Vector3;
  122072. protected _targetHost: Nullable<AbstractMesh>;
  122073. /**
  122074. * Defines the target point of the camera.
  122075. * The camera looks towards it form the radius distance.
  122076. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122077. */
  122078. get target(): Vector3;
  122079. set target(value: Vector3);
  122080. /**
  122081. * Define the current local position of the camera in the scene
  122082. */
  122083. get position(): Vector3;
  122084. set position(newPosition: Vector3);
  122085. protected _upVector: Vector3;
  122086. protected _upToYMatrix: Matrix;
  122087. protected _YToUpMatrix: Matrix;
  122088. /**
  122089. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122090. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122091. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122092. */
  122093. set upVector(vec: Vector3);
  122094. get upVector(): Vector3;
  122095. /**
  122096. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122097. */
  122098. setMatUp(): void;
  122099. /**
  122100. * Current inertia value on the longitudinal axis.
  122101. * The bigger this number the longer it will take for the camera to stop.
  122102. */
  122103. inertialAlphaOffset: number;
  122104. /**
  122105. * Current inertia value on the latitudinal axis.
  122106. * The bigger this number the longer it will take for the camera to stop.
  122107. */
  122108. inertialBetaOffset: number;
  122109. /**
  122110. * Current inertia value on the radius axis.
  122111. * The bigger this number the longer it will take for the camera to stop.
  122112. */
  122113. inertialRadiusOffset: number;
  122114. /**
  122115. * Minimum allowed angle on the longitudinal axis.
  122116. * This can help limiting how the Camera is able to move in the scene.
  122117. */
  122118. lowerAlphaLimit: Nullable<number>;
  122119. /**
  122120. * Maximum allowed angle on the longitudinal axis.
  122121. * This can help limiting how the Camera is able to move in the scene.
  122122. */
  122123. upperAlphaLimit: Nullable<number>;
  122124. /**
  122125. * Minimum allowed angle on the latitudinal axis.
  122126. * This can help limiting how the Camera is able to move in the scene.
  122127. */
  122128. lowerBetaLimit: number;
  122129. /**
  122130. * Maximum allowed angle on the latitudinal axis.
  122131. * This can help limiting how the Camera is able to move in the scene.
  122132. */
  122133. upperBetaLimit: number;
  122134. /**
  122135. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122136. * This can help limiting how the Camera is able to move in the scene.
  122137. */
  122138. lowerRadiusLimit: Nullable<number>;
  122139. /**
  122140. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122141. * This can help limiting how the Camera is able to move in the scene.
  122142. */
  122143. upperRadiusLimit: Nullable<number>;
  122144. /**
  122145. * Defines the current inertia value used during panning of the camera along the X axis.
  122146. */
  122147. inertialPanningX: number;
  122148. /**
  122149. * Defines the current inertia value used during panning of the camera along the Y axis.
  122150. */
  122151. inertialPanningY: number;
  122152. /**
  122153. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122154. * Basically if your fingers moves away from more than this distance you will be considered
  122155. * in pinch mode.
  122156. */
  122157. pinchToPanMaxDistance: number;
  122158. /**
  122159. * Defines the maximum distance the camera can pan.
  122160. * This could help keeping the cammera always in your scene.
  122161. */
  122162. panningDistanceLimit: Nullable<number>;
  122163. /**
  122164. * Defines the target of the camera before paning.
  122165. */
  122166. panningOriginTarget: Vector3;
  122167. /**
  122168. * Defines the value of the inertia used during panning.
  122169. * 0 would mean stop inertia and one would mean no decelleration at all.
  122170. */
  122171. panningInertia: number;
  122172. /**
  122173. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122174. */
  122175. get angularSensibilityX(): number;
  122176. set angularSensibilityX(value: number);
  122177. /**
  122178. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122179. */
  122180. get angularSensibilityY(): number;
  122181. set angularSensibilityY(value: number);
  122182. /**
  122183. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  122184. */
  122185. get pinchPrecision(): number;
  122186. set pinchPrecision(value: number);
  122187. /**
  122188. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  122189. * It will be used instead of pinchDeltaPrecision if different from 0.
  122190. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122191. */
  122192. get pinchDeltaPercentage(): number;
  122193. set pinchDeltaPercentage(value: number);
  122194. /**
  122195. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  122196. * and pinch delta percentage.
  122197. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122198. * that any object in the plane at the camera's target point will scale
  122199. * perfectly with finger motion.
  122200. */
  122201. get useNaturalPinchZoom(): boolean;
  122202. set useNaturalPinchZoom(value: boolean);
  122203. /**
  122204. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  122205. */
  122206. get panningSensibility(): number;
  122207. set panningSensibility(value: number);
  122208. /**
  122209. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  122210. */
  122211. get keysUp(): number[];
  122212. set keysUp(value: number[]);
  122213. /**
  122214. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  122215. */
  122216. get keysDown(): number[];
  122217. set keysDown(value: number[]);
  122218. /**
  122219. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  122220. */
  122221. get keysLeft(): number[];
  122222. set keysLeft(value: number[]);
  122223. /**
  122224. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  122225. */
  122226. get keysRight(): number[];
  122227. set keysRight(value: number[]);
  122228. /**
  122229. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122230. */
  122231. get wheelPrecision(): number;
  122232. set wheelPrecision(value: number);
  122233. /**
  122234. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  122235. * It will be used instead of pinchDeltaPrecision if different from 0.
  122236. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122237. */
  122238. get wheelDeltaPercentage(): number;
  122239. set wheelDeltaPercentage(value: number);
  122240. /**
  122241. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  122242. */
  122243. zoomOnFactor: number;
  122244. /**
  122245. * Defines a screen offset for the camera position.
  122246. */
  122247. targetScreenOffset: Vector2;
  122248. /**
  122249. * Allows the camera to be completely reversed.
  122250. * If false the camera can not arrive upside down.
  122251. */
  122252. allowUpsideDown: boolean;
  122253. /**
  122254. * Define if double tap/click is used to restore the previously saved state of the camera.
  122255. */
  122256. useInputToRestoreState: boolean;
  122257. /** @hidden */
  122258. _viewMatrix: Matrix;
  122259. /** @hidden */
  122260. _useCtrlForPanning: boolean;
  122261. /** @hidden */
  122262. _panningMouseButton: number;
  122263. /**
  122264. * Defines the input associated to the camera.
  122265. */
  122266. inputs: ArcRotateCameraInputsManager;
  122267. /** @hidden */
  122268. _reset: () => void;
  122269. /**
  122270. * Defines the allowed panning axis.
  122271. */
  122272. panningAxis: Vector3;
  122273. protected _localDirection: Vector3;
  122274. protected _transformedDirection: Vector3;
  122275. private _bouncingBehavior;
  122276. /**
  122277. * Gets the bouncing behavior of the camera if it has been enabled.
  122278. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122279. */
  122280. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122281. /**
  122282. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122283. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122284. */
  122285. get useBouncingBehavior(): boolean;
  122286. set useBouncingBehavior(value: boolean);
  122287. private _framingBehavior;
  122288. /**
  122289. * Gets the framing behavior of the camera if it has been enabled.
  122290. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122291. */
  122292. get framingBehavior(): Nullable<FramingBehavior>;
  122293. /**
  122294. * Defines if the framing behavior of the camera is enabled on the camera.
  122295. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122296. */
  122297. get useFramingBehavior(): boolean;
  122298. set useFramingBehavior(value: boolean);
  122299. private _autoRotationBehavior;
  122300. /**
  122301. * Gets the auto rotation behavior of the camera if it has been enabled.
  122302. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122303. */
  122304. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  122305. /**
  122306. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  122307. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122308. */
  122309. get useAutoRotationBehavior(): boolean;
  122310. set useAutoRotationBehavior(value: boolean);
  122311. /**
  122312. * Observable triggered when the mesh target has been changed on the camera.
  122313. */
  122314. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  122315. /**
  122316. * Event raised when the camera is colliding with a mesh.
  122317. */
  122318. onCollide: (collidedMesh: AbstractMesh) => void;
  122319. /**
  122320. * Defines whether the camera should check collision with the objects oh the scene.
  122321. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  122322. */
  122323. checkCollisions: boolean;
  122324. /**
  122325. * Defines the collision radius of the camera.
  122326. * This simulates a sphere around the camera.
  122327. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122328. */
  122329. collisionRadius: Vector3;
  122330. protected _collider: Collider;
  122331. protected _previousPosition: Vector3;
  122332. protected _collisionVelocity: Vector3;
  122333. protected _newPosition: Vector3;
  122334. protected _previousAlpha: number;
  122335. protected _previousBeta: number;
  122336. protected _previousRadius: number;
  122337. protected _collisionTriggered: boolean;
  122338. protected _targetBoundingCenter: Nullable<Vector3>;
  122339. private _computationVector;
  122340. /**
  122341. * Instantiates a new ArcRotateCamera in a given scene
  122342. * @param name Defines the name of the camera
  122343. * @param alpha Defines the camera rotation along the logitudinal axis
  122344. * @param beta Defines the camera rotation along the latitudinal axis
  122345. * @param radius Defines the camera distance from its target
  122346. * @param target Defines the camera target
  122347. * @param scene Defines the scene the camera belongs to
  122348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122349. */
  122350. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122351. /** @hidden */
  122352. _initCache(): void;
  122353. /** @hidden */
  122354. _updateCache(ignoreParentClass?: boolean): void;
  122355. protected _getTargetPosition(): Vector3;
  122356. private _storedAlpha;
  122357. private _storedBeta;
  122358. private _storedRadius;
  122359. private _storedTarget;
  122360. private _storedTargetScreenOffset;
  122361. /**
  122362. * Stores the current state of the camera (alpha, beta, radius and target)
  122363. * @returns the camera itself
  122364. */
  122365. storeState(): Camera;
  122366. /**
  122367. * @hidden
  122368. * Restored camera state. You must call storeState() first
  122369. */
  122370. _restoreStateValues(): boolean;
  122371. /** @hidden */
  122372. _isSynchronizedViewMatrix(): boolean;
  122373. /**
  122374. * Attached controls to the current camera.
  122375. * @param element Defines the element the controls should be listened from
  122376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122377. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122378. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122379. */
  122380. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122381. /**
  122382. * Detach the current controls from the camera.
  122383. * The camera will stop reacting to inputs.
  122384. * @param element Defines the element to stop listening the inputs from
  122385. */
  122386. detachControl(element: HTMLElement): void;
  122387. /** @hidden */
  122388. _checkInputs(): void;
  122389. protected _checkLimits(): void;
  122390. /**
  122391. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122392. */
  122393. rebuildAnglesAndRadius(): void;
  122394. /**
  122395. * Use a position to define the current camera related information like alpha, beta and radius
  122396. * @param position Defines the position to set the camera at
  122397. */
  122398. setPosition(position: Vector3): void;
  122399. /**
  122400. * Defines the target the camera should look at.
  122401. * This will automatically adapt alpha beta and radius to fit within the new target.
  122402. * @param target Defines the new target as a Vector or a mesh
  122403. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122404. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122405. */
  122406. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122407. /** @hidden */
  122408. _getViewMatrix(): Matrix;
  122409. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122410. /**
  122411. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122412. * @param meshes Defines the mesh to zoom on
  122413. * @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)
  122414. */
  122415. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122416. /**
  122417. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122418. * The target will be changed but the radius
  122419. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122420. * @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)
  122421. */
  122422. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122423. min: Vector3;
  122424. max: Vector3;
  122425. distance: number;
  122426. }, doNotUpdateMaxZ?: boolean): void;
  122427. /**
  122428. * @override
  122429. * Override Camera.createRigCamera
  122430. */
  122431. createRigCamera(name: string, cameraIndex: number): Camera;
  122432. /**
  122433. * @hidden
  122434. * @override
  122435. * Override Camera._updateRigCameras
  122436. */
  122437. _updateRigCameras(): void;
  122438. /**
  122439. * Destroy the camera and release the current resources hold by it.
  122440. */
  122441. dispose(): void;
  122442. /**
  122443. * Gets the current object class name.
  122444. * @return the class name
  122445. */
  122446. getClassName(): string;
  122447. }
  122448. }
  122449. declare module BABYLON {
  122450. /**
  122451. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  122452. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122453. */
  122454. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  122455. /**
  122456. * Gets the name of the behavior.
  122457. */
  122458. get name(): string;
  122459. private _zoomStopsAnimation;
  122460. private _idleRotationSpeed;
  122461. private _idleRotationWaitTime;
  122462. private _idleRotationSpinupTime;
  122463. /**
  122464. * Sets the flag that indicates if user zooming should stop animation.
  122465. */
  122466. set zoomStopsAnimation(flag: boolean);
  122467. /**
  122468. * Gets the flag that indicates if user zooming should stop animation.
  122469. */
  122470. get zoomStopsAnimation(): boolean;
  122471. /**
  122472. * Sets the default speed at which the camera rotates around the model.
  122473. */
  122474. set idleRotationSpeed(speed: number);
  122475. /**
  122476. * Gets the default speed at which the camera rotates around the model.
  122477. */
  122478. get idleRotationSpeed(): number;
  122479. /**
  122480. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  122481. */
  122482. set idleRotationWaitTime(time: number);
  122483. /**
  122484. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  122485. */
  122486. get idleRotationWaitTime(): number;
  122487. /**
  122488. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122489. */
  122490. set idleRotationSpinupTime(time: number);
  122491. /**
  122492. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122493. */
  122494. get idleRotationSpinupTime(): number;
  122495. /**
  122496. * Gets a value indicating if the camera is currently rotating because of this behavior
  122497. */
  122498. get rotationInProgress(): boolean;
  122499. private _onPrePointerObservableObserver;
  122500. private _onAfterCheckInputsObserver;
  122501. private _attachedCamera;
  122502. private _isPointerDown;
  122503. private _lastFrameTime;
  122504. private _lastInteractionTime;
  122505. private _cameraRotationSpeed;
  122506. /**
  122507. * Initializes the behavior.
  122508. */
  122509. init(): void;
  122510. /**
  122511. * Attaches the behavior to its arc rotate camera.
  122512. * @param camera Defines the camera to attach the behavior to
  122513. */
  122514. attach(camera: ArcRotateCamera): void;
  122515. /**
  122516. * Detaches the behavior from its current arc rotate camera.
  122517. */
  122518. detach(): void;
  122519. /**
  122520. * Returns true if user is scrolling.
  122521. * @return true if user is scrolling.
  122522. */
  122523. private _userIsZooming;
  122524. private _lastFrameRadius;
  122525. private _shouldAnimationStopForInteraction;
  122526. /**
  122527. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122528. */
  122529. private _applyUserInteraction;
  122530. private _userIsMoving;
  122531. }
  122532. }
  122533. declare module BABYLON {
  122534. /**
  122535. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  122536. */
  122537. export class AttachToBoxBehavior implements Behavior<Mesh> {
  122538. private ui;
  122539. /**
  122540. * The name of the behavior
  122541. */
  122542. name: string;
  122543. /**
  122544. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122545. */
  122546. distanceAwayFromFace: number;
  122547. /**
  122548. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122549. */
  122550. distanceAwayFromBottomOfFace: number;
  122551. private _faceVectors;
  122552. private _target;
  122553. private _scene;
  122554. private _onRenderObserver;
  122555. private _tmpMatrix;
  122556. private _tmpVector;
  122557. /**
  122558. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122559. * @param ui The transform node that should be attched to the mesh
  122560. */
  122561. constructor(ui: TransformNode);
  122562. /**
  122563. * Initializes the behavior
  122564. */
  122565. init(): void;
  122566. private _closestFace;
  122567. private _zeroVector;
  122568. private _lookAtTmpMatrix;
  122569. private _lookAtToRef;
  122570. /**
  122571. * Attaches the AttachToBoxBehavior to the passed in mesh
  122572. * @param target The mesh that the specified node will be attached to
  122573. */
  122574. attach(target: Mesh): void;
  122575. /**
  122576. * Detaches the behavior from the mesh
  122577. */
  122578. detach(): void;
  122579. }
  122580. }
  122581. declare module BABYLON {
  122582. /**
  122583. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122584. */
  122585. export class FadeInOutBehavior implements Behavior<Mesh> {
  122586. /**
  122587. * Time in milliseconds to delay before fading in (Default: 0)
  122588. */
  122589. delay: number;
  122590. /**
  122591. * Time in milliseconds for the mesh to fade in (Default: 300)
  122592. */
  122593. fadeInTime: number;
  122594. private _millisecondsPerFrame;
  122595. private _hovered;
  122596. private _hoverValue;
  122597. private _ownerNode;
  122598. /**
  122599. * Instatiates the FadeInOutBehavior
  122600. */
  122601. constructor();
  122602. /**
  122603. * The name of the behavior
  122604. */
  122605. get name(): string;
  122606. /**
  122607. * Initializes the behavior
  122608. */
  122609. init(): void;
  122610. /**
  122611. * Attaches the fade behavior on the passed in mesh
  122612. * @param ownerNode The mesh that will be faded in/out once attached
  122613. */
  122614. attach(ownerNode: Mesh): void;
  122615. /**
  122616. * Detaches the behavior from the mesh
  122617. */
  122618. detach(): void;
  122619. /**
  122620. * Triggers the mesh to begin fading in or out
  122621. * @param value if the object should fade in or out (true to fade in)
  122622. */
  122623. fadeIn(value: boolean): void;
  122624. private _update;
  122625. private _setAllVisibility;
  122626. }
  122627. }
  122628. declare module BABYLON {
  122629. /**
  122630. * Class containing a set of static utilities functions for managing Pivots
  122631. * @hidden
  122632. */
  122633. export class PivotTools {
  122634. private static _PivotCached;
  122635. private static _OldPivotPoint;
  122636. private static _PivotTranslation;
  122637. private static _PivotTmpVector;
  122638. /** @hidden */
  122639. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122640. /** @hidden */
  122641. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122642. }
  122643. }
  122644. declare module BABYLON {
  122645. /**
  122646. * Class containing static functions to help procedurally build meshes
  122647. */
  122648. export class PlaneBuilder {
  122649. /**
  122650. * Creates a plane mesh
  122651. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122652. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122653. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122657. * @param name defines the name of the mesh
  122658. * @param options defines the options used to create the mesh
  122659. * @param scene defines the hosting scene
  122660. * @returns the plane mesh
  122661. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122662. */
  122663. static CreatePlane(name: string, options: {
  122664. size?: number;
  122665. width?: number;
  122666. height?: number;
  122667. sideOrientation?: number;
  122668. frontUVs?: Vector4;
  122669. backUVs?: Vector4;
  122670. updatable?: boolean;
  122671. sourcePlane?: Plane;
  122672. }, scene?: Nullable<Scene>): Mesh;
  122673. }
  122674. }
  122675. declare module BABYLON {
  122676. /**
  122677. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122678. */
  122679. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122680. private static _AnyMouseID;
  122681. /**
  122682. * Abstract mesh the behavior is set on
  122683. */
  122684. attachedNode: AbstractMesh;
  122685. private _dragPlane;
  122686. private _scene;
  122687. private _pointerObserver;
  122688. private _beforeRenderObserver;
  122689. private static _planeScene;
  122690. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122691. /**
  122692. * 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)
  122693. */
  122694. maxDragAngle: number;
  122695. /**
  122696. * @hidden
  122697. */
  122698. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122699. /**
  122700. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122701. */
  122702. currentDraggingPointerID: number;
  122703. /**
  122704. * The last position where the pointer hit the drag plane in world space
  122705. */
  122706. lastDragPosition: Vector3;
  122707. /**
  122708. * If the behavior is currently in a dragging state
  122709. */
  122710. dragging: boolean;
  122711. /**
  122712. * 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)
  122713. */
  122714. dragDeltaRatio: number;
  122715. /**
  122716. * If the drag plane orientation should be updated during the dragging (Default: true)
  122717. */
  122718. updateDragPlane: boolean;
  122719. private _debugMode;
  122720. private _moving;
  122721. /**
  122722. * Fires each time the attached mesh is dragged with the pointer
  122723. * * delta between last drag position and current drag position in world space
  122724. * * dragDistance along the drag axis
  122725. * * dragPlaneNormal normal of the current drag plane used during the drag
  122726. * * dragPlanePoint in world space where the drag intersects the drag plane
  122727. */
  122728. onDragObservable: Observable<{
  122729. delta: Vector3;
  122730. dragPlanePoint: Vector3;
  122731. dragPlaneNormal: Vector3;
  122732. dragDistance: number;
  122733. pointerId: number;
  122734. }>;
  122735. /**
  122736. * Fires each time a drag begins (eg. mouse down on mesh)
  122737. */
  122738. onDragStartObservable: Observable<{
  122739. dragPlanePoint: Vector3;
  122740. pointerId: number;
  122741. }>;
  122742. /**
  122743. * Fires each time a drag ends (eg. mouse release after drag)
  122744. */
  122745. onDragEndObservable: Observable<{
  122746. dragPlanePoint: Vector3;
  122747. pointerId: number;
  122748. }>;
  122749. /**
  122750. * If the attached mesh should be moved when dragged
  122751. */
  122752. moveAttached: boolean;
  122753. /**
  122754. * If the drag behavior will react to drag events (Default: true)
  122755. */
  122756. enabled: boolean;
  122757. /**
  122758. * If pointer events should start and release the drag (Default: true)
  122759. */
  122760. startAndReleaseDragOnPointerEvents: boolean;
  122761. /**
  122762. * If camera controls should be detached during the drag
  122763. */
  122764. detachCameraControls: boolean;
  122765. /**
  122766. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122767. */
  122768. useObjectOrientationForDragging: boolean;
  122769. private _options;
  122770. /**
  122771. * Gets the options used by the behavior
  122772. */
  122773. get options(): {
  122774. dragAxis?: Vector3;
  122775. dragPlaneNormal?: Vector3;
  122776. };
  122777. /**
  122778. * Sets the options used by the behavior
  122779. */
  122780. set options(options: {
  122781. dragAxis?: Vector3;
  122782. dragPlaneNormal?: Vector3;
  122783. });
  122784. /**
  122785. * Creates a pointer drag behavior that can be attached to a mesh
  122786. * @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)
  122787. */
  122788. constructor(options?: {
  122789. dragAxis?: Vector3;
  122790. dragPlaneNormal?: Vector3;
  122791. });
  122792. /**
  122793. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122794. */
  122795. validateDrag: (targetPosition: Vector3) => boolean;
  122796. /**
  122797. * The name of the behavior
  122798. */
  122799. get name(): string;
  122800. /**
  122801. * Initializes the behavior
  122802. */
  122803. init(): void;
  122804. private _tmpVector;
  122805. private _alternatePickedPoint;
  122806. private _worldDragAxis;
  122807. private _targetPosition;
  122808. private _attachedElement;
  122809. /**
  122810. * Attaches the drag behavior the passed in mesh
  122811. * @param ownerNode The mesh that will be dragged around once attached
  122812. * @param predicate Predicate to use for pick filtering
  122813. */
  122814. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122815. /**
  122816. * Force relase the drag action by code.
  122817. */
  122818. releaseDrag(): void;
  122819. private _startDragRay;
  122820. private _lastPointerRay;
  122821. /**
  122822. * Simulates the start of a pointer drag event on the behavior
  122823. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122824. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122825. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122826. */
  122827. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122828. private _startDrag;
  122829. private _dragDelta;
  122830. private _moveDrag;
  122831. private _pickWithRayOnDragPlane;
  122832. private _pointA;
  122833. private _pointC;
  122834. private _localAxis;
  122835. private _lookAt;
  122836. private _updateDragPlanePosition;
  122837. /**
  122838. * Detaches the behavior from the mesh
  122839. */
  122840. detach(): void;
  122841. }
  122842. }
  122843. declare module BABYLON {
  122844. /**
  122845. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122846. */
  122847. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122848. private _dragBehaviorA;
  122849. private _dragBehaviorB;
  122850. private _startDistance;
  122851. private _initialScale;
  122852. private _targetScale;
  122853. private _ownerNode;
  122854. private _sceneRenderObserver;
  122855. /**
  122856. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122857. */
  122858. constructor();
  122859. /**
  122860. * The name of the behavior
  122861. */
  122862. get name(): string;
  122863. /**
  122864. * Initializes the behavior
  122865. */
  122866. init(): void;
  122867. private _getCurrentDistance;
  122868. /**
  122869. * Attaches the scale behavior the passed in mesh
  122870. * @param ownerNode The mesh that will be scaled around once attached
  122871. */
  122872. attach(ownerNode: Mesh): void;
  122873. /**
  122874. * Detaches the behavior from the mesh
  122875. */
  122876. detach(): void;
  122877. }
  122878. }
  122879. declare module BABYLON {
  122880. /**
  122881. * 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
  122882. */
  122883. export class SixDofDragBehavior implements Behavior<Mesh> {
  122884. private static _virtualScene;
  122885. private _ownerNode;
  122886. private _sceneRenderObserver;
  122887. private _scene;
  122888. private _targetPosition;
  122889. private _virtualOriginMesh;
  122890. private _virtualDragMesh;
  122891. private _pointerObserver;
  122892. private _moving;
  122893. private _startingOrientation;
  122894. private _attachedElement;
  122895. /**
  122896. * 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)
  122897. */
  122898. private zDragFactor;
  122899. /**
  122900. * If the object should rotate to face the drag origin
  122901. */
  122902. rotateDraggedObject: boolean;
  122903. /**
  122904. * If the behavior is currently in a dragging state
  122905. */
  122906. dragging: boolean;
  122907. /**
  122908. * 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)
  122909. */
  122910. dragDeltaRatio: number;
  122911. /**
  122912. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122913. */
  122914. currentDraggingPointerID: number;
  122915. /**
  122916. * If camera controls should be detached during the drag
  122917. */
  122918. detachCameraControls: boolean;
  122919. /**
  122920. * Fires each time a drag starts
  122921. */
  122922. onDragStartObservable: Observable<{}>;
  122923. /**
  122924. * Fires each time a drag ends (eg. mouse release after drag)
  122925. */
  122926. onDragEndObservable: Observable<{}>;
  122927. /**
  122928. * 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
  122929. */
  122930. constructor();
  122931. /**
  122932. * The name of the behavior
  122933. */
  122934. get name(): string;
  122935. /**
  122936. * Initializes the behavior
  122937. */
  122938. init(): void;
  122939. /**
  122940. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122941. */
  122942. private get _pointerCamera();
  122943. /**
  122944. * Attaches the scale behavior the passed in mesh
  122945. * @param ownerNode The mesh that will be scaled around once attached
  122946. */
  122947. attach(ownerNode: Mesh): void;
  122948. /**
  122949. * Detaches the behavior from the mesh
  122950. */
  122951. detach(): void;
  122952. }
  122953. }
  122954. declare module BABYLON {
  122955. /**
  122956. * Class used to apply inverse kinematics to bones
  122957. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122958. */
  122959. export class BoneIKController {
  122960. private static _tmpVecs;
  122961. private static _tmpQuat;
  122962. private static _tmpMats;
  122963. /**
  122964. * Gets or sets the target mesh
  122965. */
  122966. targetMesh: AbstractMesh;
  122967. /** Gets or sets the mesh used as pole */
  122968. poleTargetMesh: AbstractMesh;
  122969. /**
  122970. * Gets or sets the bone used as pole
  122971. */
  122972. poleTargetBone: Nullable<Bone>;
  122973. /**
  122974. * Gets or sets the target position
  122975. */
  122976. targetPosition: Vector3;
  122977. /**
  122978. * Gets or sets the pole target position
  122979. */
  122980. poleTargetPosition: Vector3;
  122981. /**
  122982. * Gets or sets the pole target local offset
  122983. */
  122984. poleTargetLocalOffset: Vector3;
  122985. /**
  122986. * Gets or sets the pole angle
  122987. */
  122988. poleAngle: number;
  122989. /**
  122990. * Gets or sets the mesh associated with the controller
  122991. */
  122992. mesh: AbstractMesh;
  122993. /**
  122994. * 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)
  122995. */
  122996. slerpAmount: number;
  122997. private _bone1Quat;
  122998. private _bone1Mat;
  122999. private _bone2Ang;
  123000. private _bone1;
  123001. private _bone2;
  123002. private _bone1Length;
  123003. private _bone2Length;
  123004. private _maxAngle;
  123005. private _maxReach;
  123006. private _rightHandedSystem;
  123007. private _bendAxis;
  123008. private _slerping;
  123009. private _adjustRoll;
  123010. /**
  123011. * Gets or sets maximum allowed angle
  123012. */
  123013. get maxAngle(): number;
  123014. set maxAngle(value: number);
  123015. /**
  123016. * Creates a new BoneIKController
  123017. * @param mesh defines the mesh to control
  123018. * @param bone defines the bone to control
  123019. * @param options defines options to set up the controller
  123020. */
  123021. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123022. targetMesh?: AbstractMesh;
  123023. poleTargetMesh?: AbstractMesh;
  123024. poleTargetBone?: Bone;
  123025. poleTargetLocalOffset?: Vector3;
  123026. poleAngle?: number;
  123027. bendAxis?: Vector3;
  123028. maxAngle?: number;
  123029. slerpAmount?: number;
  123030. });
  123031. private _setMaxAngle;
  123032. /**
  123033. * Force the controller to update the bones
  123034. */
  123035. update(): void;
  123036. }
  123037. }
  123038. declare module BABYLON {
  123039. /**
  123040. * Class used to make a bone look toward a point in space
  123041. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123042. */
  123043. export class BoneLookController {
  123044. private static _tmpVecs;
  123045. private static _tmpQuat;
  123046. private static _tmpMats;
  123047. /**
  123048. * The target Vector3 that the bone will look at
  123049. */
  123050. target: Vector3;
  123051. /**
  123052. * The mesh that the bone is attached to
  123053. */
  123054. mesh: AbstractMesh;
  123055. /**
  123056. * The bone that will be looking to the target
  123057. */
  123058. bone: Bone;
  123059. /**
  123060. * The up axis of the coordinate system that is used when the bone is rotated
  123061. */
  123062. upAxis: Vector3;
  123063. /**
  123064. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123065. */
  123066. upAxisSpace: Space;
  123067. /**
  123068. * Used to make an adjustment to the yaw of the bone
  123069. */
  123070. adjustYaw: number;
  123071. /**
  123072. * Used to make an adjustment to the pitch of the bone
  123073. */
  123074. adjustPitch: number;
  123075. /**
  123076. * Used to make an adjustment to the roll of the bone
  123077. */
  123078. adjustRoll: number;
  123079. /**
  123080. * 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)
  123081. */
  123082. slerpAmount: number;
  123083. private _minYaw;
  123084. private _maxYaw;
  123085. private _minPitch;
  123086. private _maxPitch;
  123087. private _minYawSin;
  123088. private _minYawCos;
  123089. private _maxYawSin;
  123090. private _maxYawCos;
  123091. private _midYawConstraint;
  123092. private _minPitchTan;
  123093. private _maxPitchTan;
  123094. private _boneQuat;
  123095. private _slerping;
  123096. private _transformYawPitch;
  123097. private _transformYawPitchInv;
  123098. private _firstFrameSkipped;
  123099. private _yawRange;
  123100. private _fowardAxis;
  123101. /**
  123102. * Gets or sets the minimum yaw angle that the bone can look to
  123103. */
  123104. get minYaw(): number;
  123105. set minYaw(value: number);
  123106. /**
  123107. * Gets or sets the maximum yaw angle that the bone can look to
  123108. */
  123109. get maxYaw(): number;
  123110. set maxYaw(value: number);
  123111. /**
  123112. * Gets or sets the minimum pitch angle that the bone can look to
  123113. */
  123114. get minPitch(): number;
  123115. set minPitch(value: number);
  123116. /**
  123117. * Gets or sets the maximum pitch angle that the bone can look to
  123118. */
  123119. get maxPitch(): number;
  123120. set maxPitch(value: number);
  123121. /**
  123122. * Create a BoneLookController
  123123. * @param mesh the mesh that the bone belongs to
  123124. * @param bone the bone that will be looking to the target
  123125. * @param target the target Vector3 to look at
  123126. * @param options optional settings:
  123127. * * maxYaw: the maximum angle the bone will yaw to
  123128. * * minYaw: the minimum angle the bone will yaw to
  123129. * * maxPitch: the maximum angle the bone will pitch to
  123130. * * minPitch: the minimum angle the bone will yaw to
  123131. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123132. * * upAxis: the up axis of the coordinate system
  123133. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123134. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123135. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123136. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123137. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123138. * * adjustRoll: used to make an adjustment to the roll of the bone
  123139. **/
  123140. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123141. maxYaw?: number;
  123142. minYaw?: number;
  123143. maxPitch?: number;
  123144. minPitch?: number;
  123145. slerpAmount?: number;
  123146. upAxis?: Vector3;
  123147. upAxisSpace?: Space;
  123148. yawAxis?: Vector3;
  123149. pitchAxis?: Vector3;
  123150. adjustYaw?: number;
  123151. adjustPitch?: number;
  123152. adjustRoll?: number;
  123153. });
  123154. /**
  123155. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123156. */
  123157. update(): void;
  123158. private _getAngleDiff;
  123159. private _getAngleBetween;
  123160. private _isAngleBetween;
  123161. }
  123162. }
  123163. declare module BABYLON {
  123164. /**
  123165. * Manage the gamepad inputs to control an arc rotate camera.
  123166. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123167. */
  123168. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123169. /**
  123170. * Defines the camera the input is attached to.
  123171. */
  123172. camera: ArcRotateCamera;
  123173. /**
  123174. * Defines the gamepad the input is gathering event from.
  123175. */
  123176. gamepad: Nullable<Gamepad>;
  123177. /**
  123178. * Defines the gamepad rotation sensiblity.
  123179. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123180. */
  123181. gamepadRotationSensibility: number;
  123182. /**
  123183. * Defines the gamepad move sensiblity.
  123184. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123185. */
  123186. gamepadMoveSensibility: number;
  123187. private _yAxisScale;
  123188. /**
  123189. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123190. */
  123191. get invertYAxis(): boolean;
  123192. set invertYAxis(value: boolean);
  123193. private _onGamepadConnectedObserver;
  123194. private _onGamepadDisconnectedObserver;
  123195. /**
  123196. * Attach the input controls to a specific dom element to get the input from.
  123197. * @param element Defines the element the controls should be listened from
  123198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123199. */
  123200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123201. /**
  123202. * Detach the current controls from the specified dom element.
  123203. * @param element Defines the element to stop listening the inputs from
  123204. */
  123205. detachControl(element: Nullable<HTMLElement>): void;
  123206. /**
  123207. * Update the current camera state depending on the inputs that have been used this frame.
  123208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123209. */
  123210. checkInputs(): void;
  123211. /**
  123212. * Gets the class name of the current intput.
  123213. * @returns the class name
  123214. */
  123215. getClassName(): string;
  123216. /**
  123217. * Get the friendly name associated with the input class.
  123218. * @returns the input friendly name
  123219. */
  123220. getSimpleName(): string;
  123221. }
  123222. }
  123223. declare module BABYLON {
  123224. interface ArcRotateCameraInputsManager {
  123225. /**
  123226. * Add orientation input support to the input manager.
  123227. * @returns the current input manager
  123228. */
  123229. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  123230. }
  123231. /**
  123232. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  123233. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123234. */
  123235. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  123236. /**
  123237. * Defines the camera the input is attached to.
  123238. */
  123239. camera: ArcRotateCamera;
  123240. /**
  123241. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  123242. */
  123243. alphaCorrection: number;
  123244. /**
  123245. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  123246. */
  123247. gammaCorrection: number;
  123248. private _alpha;
  123249. private _gamma;
  123250. private _dirty;
  123251. private _deviceOrientationHandler;
  123252. /**
  123253. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  123254. */
  123255. constructor();
  123256. /**
  123257. * Attach the input controls to a specific dom element to get the input from.
  123258. * @param element Defines the element the controls should be listened from
  123259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123260. */
  123261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123262. /** @hidden */
  123263. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  123264. /**
  123265. * Update the current camera state depending on the inputs that have been used this frame.
  123266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123267. */
  123268. checkInputs(): void;
  123269. /**
  123270. * Detach the current controls from the specified dom element.
  123271. * @param element Defines the element to stop listening the inputs from
  123272. */
  123273. detachControl(element: Nullable<HTMLElement>): void;
  123274. /**
  123275. * Gets the class name of the current intput.
  123276. * @returns the class name
  123277. */
  123278. getClassName(): string;
  123279. /**
  123280. * Get the friendly name associated with the input class.
  123281. * @returns the input friendly name
  123282. */
  123283. getSimpleName(): string;
  123284. }
  123285. }
  123286. declare module BABYLON {
  123287. /**
  123288. * Listen to mouse events to control the camera.
  123289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123290. */
  123291. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123292. /**
  123293. * Defines the camera the input is attached to.
  123294. */
  123295. camera: FlyCamera;
  123296. /**
  123297. * Defines if touch is enabled. (Default is true.)
  123298. */
  123299. touchEnabled: boolean;
  123300. /**
  123301. * Defines the buttons associated with the input to handle camera rotation.
  123302. */
  123303. buttons: number[];
  123304. /**
  123305. * Assign buttons for Yaw control.
  123306. */
  123307. buttonsYaw: number[];
  123308. /**
  123309. * Assign buttons for Pitch control.
  123310. */
  123311. buttonsPitch: number[];
  123312. /**
  123313. * Assign buttons for Roll control.
  123314. */
  123315. buttonsRoll: number[];
  123316. /**
  123317. * Detect if any button is being pressed while mouse is moved.
  123318. * -1 = Mouse locked.
  123319. * 0 = Left button.
  123320. * 1 = Middle Button.
  123321. * 2 = Right Button.
  123322. */
  123323. activeButton: number;
  123324. /**
  123325. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  123326. * Higher values reduce its sensitivity.
  123327. */
  123328. angularSensibility: number;
  123329. private _mousemoveCallback;
  123330. private _observer;
  123331. private _rollObserver;
  123332. private previousPosition;
  123333. private noPreventDefault;
  123334. private element;
  123335. /**
  123336. * Listen to mouse events to control the camera.
  123337. * @param touchEnabled Define if touch is enabled. (Default is true.)
  123338. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123339. */
  123340. constructor(touchEnabled?: boolean);
  123341. /**
  123342. * Attach the mouse control to the HTML DOM element.
  123343. * @param element Defines the element that listens to the input events.
  123344. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123345. */
  123346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123347. /**
  123348. * Detach the current controls from the specified dom element.
  123349. * @param element Defines the element to stop listening the inputs from
  123350. */
  123351. detachControl(element: Nullable<HTMLElement>): void;
  123352. /**
  123353. * Gets the class name of the current input.
  123354. * @returns the class name.
  123355. */
  123356. getClassName(): string;
  123357. /**
  123358. * Get the friendly name associated with the input class.
  123359. * @returns the input's friendly name.
  123360. */
  123361. getSimpleName(): string;
  123362. private _pointerInput;
  123363. private _onMouseMove;
  123364. /**
  123365. * Rotate camera by mouse offset.
  123366. */
  123367. private rotateCamera;
  123368. }
  123369. }
  123370. declare module BABYLON {
  123371. /**
  123372. * Default Inputs manager for the FlyCamera.
  123373. * It groups all the default supported inputs for ease of use.
  123374. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123375. */
  123376. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123377. /**
  123378. * Instantiates a new FlyCameraInputsManager.
  123379. * @param camera Defines the camera the inputs belong to.
  123380. */
  123381. constructor(camera: FlyCamera);
  123382. /**
  123383. * Add keyboard input support to the input manager.
  123384. * @returns the new FlyCameraKeyboardMoveInput().
  123385. */
  123386. addKeyboard(): FlyCameraInputsManager;
  123387. /**
  123388. * Add mouse input support to the input manager.
  123389. * @param touchEnabled Enable touch screen support.
  123390. * @returns the new FlyCameraMouseInput().
  123391. */
  123392. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123393. }
  123394. }
  123395. declare module BABYLON {
  123396. /**
  123397. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123398. * such as in a 3D Space Shooter or a Flight Simulator.
  123399. */
  123400. export class FlyCamera extends TargetCamera {
  123401. /**
  123402. * Define the collision ellipsoid of the camera.
  123403. * This is helpful for simulating a camera body, like a player's body.
  123404. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123405. */
  123406. ellipsoid: Vector3;
  123407. /**
  123408. * Define an offset for the position of the ellipsoid around the camera.
  123409. * This can be helpful if the camera is attached away from the player's body center,
  123410. * such as at its head.
  123411. */
  123412. ellipsoidOffset: Vector3;
  123413. /**
  123414. * Enable or disable collisions of the camera with the rest of the scene objects.
  123415. */
  123416. checkCollisions: boolean;
  123417. /**
  123418. * Enable or disable gravity on the camera.
  123419. */
  123420. applyGravity: boolean;
  123421. /**
  123422. * Define the current direction the camera is moving to.
  123423. */
  123424. cameraDirection: Vector3;
  123425. /**
  123426. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  123427. * This overrides and empties cameraRotation.
  123428. */
  123429. rotationQuaternion: Quaternion;
  123430. /**
  123431. * Track Roll to maintain the wanted Rolling when looking around.
  123432. */
  123433. _trackRoll: number;
  123434. /**
  123435. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  123436. */
  123437. rollCorrect: number;
  123438. /**
  123439. * Mimic a banked turn, Rolling the camera when Yawing.
  123440. * It's recommended to use rollCorrect = 10 for faster banking correction.
  123441. */
  123442. bankedTurn: boolean;
  123443. /**
  123444. * Limit in radians for how much Roll banking will add. (Default: 90°)
  123445. */
  123446. bankedTurnLimit: number;
  123447. /**
  123448. * Value of 0 disables the banked Roll.
  123449. * Value of 1 is equal to the Yaw angle in radians.
  123450. */
  123451. bankedTurnMultiplier: number;
  123452. /**
  123453. * The inputs manager loads all the input sources, such as keyboard and mouse.
  123454. */
  123455. inputs: FlyCameraInputsManager;
  123456. /**
  123457. * Gets the input sensibility for mouse input.
  123458. * Higher values reduce sensitivity.
  123459. */
  123460. get angularSensibility(): number;
  123461. /**
  123462. * Sets the input sensibility for a mouse input.
  123463. * Higher values reduce sensitivity.
  123464. */
  123465. set angularSensibility(value: number);
  123466. /**
  123467. * Get the keys for camera movement forward.
  123468. */
  123469. get keysForward(): number[];
  123470. /**
  123471. * Set the keys for camera movement forward.
  123472. */
  123473. set keysForward(value: number[]);
  123474. /**
  123475. * Get the keys for camera movement backward.
  123476. */
  123477. get keysBackward(): number[];
  123478. set keysBackward(value: number[]);
  123479. /**
  123480. * Get the keys for camera movement up.
  123481. */
  123482. get keysUp(): number[];
  123483. /**
  123484. * Set the keys for camera movement up.
  123485. */
  123486. set keysUp(value: number[]);
  123487. /**
  123488. * Get the keys for camera movement down.
  123489. */
  123490. get keysDown(): number[];
  123491. /**
  123492. * Set the keys for camera movement down.
  123493. */
  123494. set keysDown(value: number[]);
  123495. /**
  123496. * Get the keys for camera movement left.
  123497. */
  123498. get keysLeft(): number[];
  123499. /**
  123500. * Set the keys for camera movement left.
  123501. */
  123502. set keysLeft(value: number[]);
  123503. /**
  123504. * Set the keys for camera movement right.
  123505. */
  123506. get keysRight(): number[];
  123507. /**
  123508. * Set the keys for camera movement right.
  123509. */
  123510. set keysRight(value: number[]);
  123511. /**
  123512. * Event raised when the camera collides with a mesh in the scene.
  123513. */
  123514. onCollide: (collidedMesh: AbstractMesh) => void;
  123515. private _collider;
  123516. private _needMoveForGravity;
  123517. private _oldPosition;
  123518. private _diffPosition;
  123519. private _newPosition;
  123520. /** @hidden */
  123521. _localDirection: Vector3;
  123522. /** @hidden */
  123523. _transformedDirection: Vector3;
  123524. /**
  123525. * Instantiates a FlyCamera.
  123526. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123527. * such as in a 3D Space Shooter or a Flight Simulator.
  123528. * @param name Define the name of the camera in the scene.
  123529. * @param position Define the starting position of the camera in the scene.
  123530. * @param scene Define the scene the camera belongs to.
  123531. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  123532. */
  123533. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123534. /**
  123535. * Attach a control to the HTML DOM element.
  123536. * @param element Defines the element that listens to the input events.
  123537. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  123538. */
  123539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123540. /**
  123541. * Detach a control from the HTML DOM element.
  123542. * The camera will stop reacting to that input.
  123543. * @param element Defines the element that listens to the input events.
  123544. */
  123545. detachControl(element: HTMLElement): void;
  123546. private _collisionMask;
  123547. /**
  123548. * Get the mask that the camera ignores in collision events.
  123549. */
  123550. get collisionMask(): number;
  123551. /**
  123552. * Set the mask that the camera ignores in collision events.
  123553. */
  123554. set collisionMask(mask: number);
  123555. /** @hidden */
  123556. _collideWithWorld(displacement: Vector3): void;
  123557. /** @hidden */
  123558. private _onCollisionPositionChange;
  123559. /** @hidden */
  123560. _checkInputs(): void;
  123561. /** @hidden */
  123562. _decideIfNeedsToMove(): boolean;
  123563. /** @hidden */
  123564. _updatePosition(): void;
  123565. /**
  123566. * Restore the Roll to its target value at the rate specified.
  123567. * @param rate - Higher means slower restoring.
  123568. * @hidden
  123569. */
  123570. restoreRoll(rate: number): void;
  123571. /**
  123572. * Destroy the camera and release the current resources held by it.
  123573. */
  123574. dispose(): void;
  123575. /**
  123576. * Get the current object class name.
  123577. * @returns the class name.
  123578. */
  123579. getClassName(): string;
  123580. }
  123581. }
  123582. declare module BABYLON {
  123583. /**
  123584. * Listen to keyboard events to control the camera.
  123585. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123586. */
  123587. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123588. /**
  123589. * Defines the camera the input is attached to.
  123590. */
  123591. camera: FlyCamera;
  123592. /**
  123593. * The list of keyboard keys used to control the forward move of the camera.
  123594. */
  123595. keysForward: number[];
  123596. /**
  123597. * The list of keyboard keys used to control the backward move of the camera.
  123598. */
  123599. keysBackward: number[];
  123600. /**
  123601. * The list of keyboard keys used to control the forward move of the camera.
  123602. */
  123603. keysUp: number[];
  123604. /**
  123605. * The list of keyboard keys used to control the backward move of the camera.
  123606. */
  123607. keysDown: number[];
  123608. /**
  123609. * The list of keyboard keys used to control the right strafe move of the camera.
  123610. */
  123611. keysRight: number[];
  123612. /**
  123613. * The list of keyboard keys used to control the left strafe move of the camera.
  123614. */
  123615. keysLeft: number[];
  123616. private _keys;
  123617. private _onCanvasBlurObserver;
  123618. private _onKeyboardObserver;
  123619. private _engine;
  123620. private _scene;
  123621. /**
  123622. * Attach the input controls to a specific dom element to get the input from.
  123623. * @param element Defines the element the controls should be listened from
  123624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123625. */
  123626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123627. /**
  123628. * Detach the current controls from the specified dom element.
  123629. * @param element Defines the element to stop listening the inputs from
  123630. */
  123631. detachControl(element: Nullable<HTMLElement>): void;
  123632. /**
  123633. * Gets the class name of the current intput.
  123634. * @returns the class name
  123635. */
  123636. getClassName(): string;
  123637. /** @hidden */
  123638. _onLostFocus(e: FocusEvent): void;
  123639. /**
  123640. * Get the friendly name associated with the input class.
  123641. * @returns the input friendly name
  123642. */
  123643. getSimpleName(): string;
  123644. /**
  123645. * Update the current camera state depending on the inputs that have been used this frame.
  123646. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123647. */
  123648. checkInputs(): void;
  123649. }
  123650. }
  123651. declare module BABYLON {
  123652. /**
  123653. * Manage the mouse wheel inputs to control a follow camera.
  123654. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123655. */
  123656. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123657. /**
  123658. * Defines the camera the input is attached to.
  123659. */
  123660. camera: FollowCamera;
  123661. /**
  123662. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123663. */
  123664. axisControlRadius: boolean;
  123665. /**
  123666. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123667. */
  123668. axisControlHeight: boolean;
  123669. /**
  123670. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123671. */
  123672. axisControlRotation: boolean;
  123673. /**
  123674. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123675. * relation to mouseWheel events.
  123676. */
  123677. wheelPrecision: number;
  123678. /**
  123679. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123680. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123681. */
  123682. wheelDeltaPercentage: number;
  123683. private _wheel;
  123684. private _observer;
  123685. /**
  123686. * Attach the input controls to a specific dom element to get the input from.
  123687. * @param element Defines the element the controls should be listened from
  123688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123689. */
  123690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123691. /**
  123692. * Detach the current controls from the specified dom element.
  123693. * @param element Defines the element to stop listening the inputs from
  123694. */
  123695. detachControl(element: Nullable<HTMLElement>): void;
  123696. /**
  123697. * Gets the class name of the current intput.
  123698. * @returns the class name
  123699. */
  123700. getClassName(): string;
  123701. /**
  123702. * Get the friendly name associated with the input class.
  123703. * @returns the input friendly name
  123704. */
  123705. getSimpleName(): string;
  123706. }
  123707. }
  123708. declare module BABYLON {
  123709. /**
  123710. * Manage the pointers inputs to control an follow camera.
  123711. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123712. */
  123713. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123714. /**
  123715. * Defines the camera the input is attached to.
  123716. */
  123717. camera: FollowCamera;
  123718. /**
  123719. * Gets the class name of the current input.
  123720. * @returns the class name
  123721. */
  123722. getClassName(): string;
  123723. /**
  123724. * Defines the pointer angular sensibility along the X axis or how fast is
  123725. * the camera rotating.
  123726. * A negative number will reverse the axis direction.
  123727. */
  123728. angularSensibilityX: number;
  123729. /**
  123730. * Defines the pointer angular sensibility along the Y axis or how fast is
  123731. * the camera rotating.
  123732. * A negative number will reverse the axis direction.
  123733. */
  123734. angularSensibilityY: number;
  123735. /**
  123736. * Defines the pointer pinch precision or how fast is the camera zooming.
  123737. * A negative number will reverse the axis direction.
  123738. */
  123739. pinchPrecision: number;
  123740. /**
  123741. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123742. * from 0.
  123743. * It defines the percentage of current camera.radius to use as delta when
  123744. * pinch zoom is used.
  123745. */
  123746. pinchDeltaPercentage: number;
  123747. /**
  123748. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123749. */
  123750. axisXControlRadius: boolean;
  123751. /**
  123752. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123753. */
  123754. axisXControlHeight: boolean;
  123755. /**
  123756. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123757. */
  123758. axisXControlRotation: boolean;
  123759. /**
  123760. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123761. */
  123762. axisYControlRadius: boolean;
  123763. /**
  123764. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123765. */
  123766. axisYControlHeight: boolean;
  123767. /**
  123768. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123769. */
  123770. axisYControlRotation: boolean;
  123771. /**
  123772. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123773. */
  123774. axisPinchControlRadius: boolean;
  123775. /**
  123776. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123777. */
  123778. axisPinchControlHeight: boolean;
  123779. /**
  123780. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123781. */
  123782. axisPinchControlRotation: boolean;
  123783. /**
  123784. * Log error messages if basic misconfiguration has occurred.
  123785. */
  123786. warningEnable: boolean;
  123787. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123788. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123789. private _warningCounter;
  123790. private _warning;
  123791. }
  123792. }
  123793. declare module BABYLON {
  123794. /**
  123795. * Default Inputs manager for the FollowCamera.
  123796. * It groups all the default supported inputs for ease of use.
  123797. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123798. */
  123799. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123800. /**
  123801. * Instantiates a new FollowCameraInputsManager.
  123802. * @param camera Defines the camera the inputs belong to
  123803. */
  123804. constructor(camera: FollowCamera);
  123805. /**
  123806. * Add keyboard input support to the input manager.
  123807. * @returns the current input manager
  123808. */
  123809. addKeyboard(): FollowCameraInputsManager;
  123810. /**
  123811. * Add mouse wheel input support to the input manager.
  123812. * @returns the current input manager
  123813. */
  123814. addMouseWheel(): FollowCameraInputsManager;
  123815. /**
  123816. * Add pointers input support to the input manager.
  123817. * @returns the current input manager
  123818. */
  123819. addPointers(): FollowCameraInputsManager;
  123820. /**
  123821. * Add orientation input support to the input manager.
  123822. * @returns the current input manager
  123823. */
  123824. addVRDeviceOrientation(): FollowCameraInputsManager;
  123825. }
  123826. }
  123827. declare module BABYLON {
  123828. /**
  123829. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123830. * an arc rotate version arcFollowCamera are available.
  123831. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123832. */
  123833. export class FollowCamera extends TargetCamera {
  123834. /**
  123835. * Distance the follow camera should follow an object at
  123836. */
  123837. radius: number;
  123838. /**
  123839. * Minimum allowed distance of the camera to the axis of rotation
  123840. * (The camera can not get closer).
  123841. * This can help limiting how the Camera is able to move in the scene.
  123842. */
  123843. lowerRadiusLimit: Nullable<number>;
  123844. /**
  123845. * Maximum allowed distance of the camera to the axis of rotation
  123846. * (The camera can not get further).
  123847. * This can help limiting how the Camera is able to move in the scene.
  123848. */
  123849. upperRadiusLimit: Nullable<number>;
  123850. /**
  123851. * Define a rotation offset between the camera and the object it follows
  123852. */
  123853. rotationOffset: number;
  123854. /**
  123855. * Minimum allowed angle to camera position relative to target object.
  123856. * This can help limiting how the Camera is able to move in the scene.
  123857. */
  123858. lowerRotationOffsetLimit: Nullable<number>;
  123859. /**
  123860. * Maximum allowed angle to camera position relative to target object.
  123861. * This can help limiting how the Camera is able to move in the scene.
  123862. */
  123863. upperRotationOffsetLimit: Nullable<number>;
  123864. /**
  123865. * Define a height offset between the camera and the object it follows.
  123866. * It can help following an object from the top (like a car chaing a plane)
  123867. */
  123868. heightOffset: number;
  123869. /**
  123870. * Minimum allowed height of camera position relative to target object.
  123871. * This can help limiting how the Camera is able to move in the scene.
  123872. */
  123873. lowerHeightOffsetLimit: Nullable<number>;
  123874. /**
  123875. * Maximum allowed height of camera position relative to target object.
  123876. * This can help limiting how the Camera is able to move in the scene.
  123877. */
  123878. upperHeightOffsetLimit: Nullable<number>;
  123879. /**
  123880. * Define how fast the camera can accelerate to follow it s target.
  123881. */
  123882. cameraAcceleration: number;
  123883. /**
  123884. * Define the speed limit of the camera following an object.
  123885. */
  123886. maxCameraSpeed: number;
  123887. /**
  123888. * Define the target of the camera.
  123889. */
  123890. lockedTarget: Nullable<AbstractMesh>;
  123891. /**
  123892. * Defines the input associated with the camera.
  123893. */
  123894. inputs: FollowCameraInputsManager;
  123895. /**
  123896. * Instantiates the follow camera.
  123897. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123898. * @param name Define the name of the camera in the scene
  123899. * @param position Define the position of the camera
  123900. * @param scene Define the scene the camera belong to
  123901. * @param lockedTarget Define the target of the camera
  123902. */
  123903. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123904. private _follow;
  123905. /**
  123906. * Attached controls to the current camera.
  123907. * @param element Defines the element the controls should be listened from
  123908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123909. */
  123910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123911. /**
  123912. * Detach the current controls from the camera.
  123913. * The camera will stop reacting to inputs.
  123914. * @param element Defines the element to stop listening the inputs from
  123915. */
  123916. detachControl(element: HTMLElement): void;
  123917. /** @hidden */
  123918. _checkInputs(): void;
  123919. private _checkLimits;
  123920. /**
  123921. * Gets the camera class name.
  123922. * @returns the class name
  123923. */
  123924. getClassName(): string;
  123925. }
  123926. /**
  123927. * Arc Rotate version of the follow camera.
  123928. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123929. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123930. */
  123931. export class ArcFollowCamera extends TargetCamera {
  123932. /** The longitudinal angle of the camera */
  123933. alpha: number;
  123934. /** The latitudinal angle of the camera */
  123935. beta: number;
  123936. /** The radius of the camera from its target */
  123937. radius: number;
  123938. private _cartesianCoordinates;
  123939. /** Define the camera target (the mesh it should follow) */
  123940. private _meshTarget;
  123941. /**
  123942. * Instantiates a new ArcFollowCamera
  123943. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123944. * @param name Define the name of the camera
  123945. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123946. * @param beta Define the rotation angle of the camera around the elevation axis
  123947. * @param radius Define the radius of the camera from its target point
  123948. * @param target Define the target of the camera
  123949. * @param scene Define the scene the camera belongs to
  123950. */
  123951. constructor(name: string,
  123952. /** The longitudinal angle of the camera */
  123953. alpha: number,
  123954. /** The latitudinal angle of the camera */
  123955. beta: number,
  123956. /** The radius of the camera from its target */
  123957. radius: number,
  123958. /** Define the camera target (the mesh it should follow) */
  123959. target: Nullable<AbstractMesh>, scene: Scene);
  123960. private _follow;
  123961. /** @hidden */
  123962. _checkInputs(): void;
  123963. /**
  123964. * Returns the class name of the object.
  123965. * It is mostly used internally for serialization purposes.
  123966. */
  123967. getClassName(): string;
  123968. }
  123969. }
  123970. declare module BABYLON {
  123971. /**
  123972. * Manage the keyboard inputs to control the movement of a follow camera.
  123973. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123974. */
  123975. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123976. /**
  123977. * Defines the camera the input is attached to.
  123978. */
  123979. camera: FollowCamera;
  123980. /**
  123981. * Defines the list of key codes associated with the up action (increase heightOffset)
  123982. */
  123983. keysHeightOffsetIncr: number[];
  123984. /**
  123985. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123986. */
  123987. keysHeightOffsetDecr: number[];
  123988. /**
  123989. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123990. */
  123991. keysHeightOffsetModifierAlt: boolean;
  123992. /**
  123993. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123994. */
  123995. keysHeightOffsetModifierCtrl: boolean;
  123996. /**
  123997. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123998. */
  123999. keysHeightOffsetModifierShift: boolean;
  124000. /**
  124001. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124002. */
  124003. keysRotationOffsetIncr: number[];
  124004. /**
  124005. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124006. */
  124007. keysRotationOffsetDecr: number[];
  124008. /**
  124009. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124010. */
  124011. keysRotationOffsetModifierAlt: boolean;
  124012. /**
  124013. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124014. */
  124015. keysRotationOffsetModifierCtrl: boolean;
  124016. /**
  124017. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124018. */
  124019. keysRotationOffsetModifierShift: boolean;
  124020. /**
  124021. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124022. */
  124023. keysRadiusIncr: number[];
  124024. /**
  124025. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124026. */
  124027. keysRadiusDecr: number[];
  124028. /**
  124029. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124030. */
  124031. keysRadiusModifierAlt: boolean;
  124032. /**
  124033. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124034. */
  124035. keysRadiusModifierCtrl: boolean;
  124036. /**
  124037. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124038. */
  124039. keysRadiusModifierShift: boolean;
  124040. /**
  124041. * Defines the rate of change of heightOffset.
  124042. */
  124043. heightSensibility: number;
  124044. /**
  124045. * Defines the rate of change of rotationOffset.
  124046. */
  124047. rotationSensibility: number;
  124048. /**
  124049. * Defines the rate of change of radius.
  124050. */
  124051. radiusSensibility: number;
  124052. private _keys;
  124053. private _ctrlPressed;
  124054. private _altPressed;
  124055. private _shiftPressed;
  124056. private _onCanvasBlurObserver;
  124057. private _onKeyboardObserver;
  124058. private _engine;
  124059. private _scene;
  124060. /**
  124061. * Attach the input controls to a specific dom element to get the input from.
  124062. * @param element Defines the element the controls should be listened from
  124063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124064. */
  124065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124066. /**
  124067. * Detach the current controls from the specified dom element.
  124068. * @param element Defines the element to stop listening the inputs from
  124069. */
  124070. detachControl(element: Nullable<HTMLElement>): void;
  124071. /**
  124072. * Update the current camera state depending on the inputs that have been used this frame.
  124073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124074. */
  124075. checkInputs(): void;
  124076. /**
  124077. * Gets the class name of the current input.
  124078. * @returns the class name
  124079. */
  124080. getClassName(): string;
  124081. /**
  124082. * Get the friendly name associated with the input class.
  124083. * @returns the input friendly name
  124084. */
  124085. getSimpleName(): string;
  124086. /**
  124087. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124088. * allow modification of the heightOffset value.
  124089. */
  124090. private _modifierHeightOffset;
  124091. /**
  124092. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124093. * allow modification of the rotationOffset value.
  124094. */
  124095. private _modifierRotationOffset;
  124096. /**
  124097. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124098. * allow modification of the radius value.
  124099. */
  124100. private _modifierRadius;
  124101. }
  124102. }
  124103. declare module BABYLON {
  124104. interface FreeCameraInputsManager {
  124105. /**
  124106. * @hidden
  124107. */
  124108. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124109. /**
  124110. * Add orientation input support to the input manager.
  124111. * @returns the current input manager
  124112. */
  124113. addDeviceOrientation(): FreeCameraInputsManager;
  124114. }
  124115. /**
  124116. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124117. * Screen rotation is taken into account.
  124118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124119. */
  124120. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124121. private _camera;
  124122. private _screenOrientationAngle;
  124123. private _constantTranform;
  124124. private _screenQuaternion;
  124125. private _alpha;
  124126. private _beta;
  124127. private _gamma;
  124128. /**
  124129. * Can be used to detect if a device orientation sensor is available on a device
  124130. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124131. * @returns a promise that will resolve on orientation change
  124132. */
  124133. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124134. /**
  124135. * @hidden
  124136. */
  124137. _onDeviceOrientationChangedObservable: Observable<void>;
  124138. /**
  124139. * Instantiates a new input
  124140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124141. */
  124142. constructor();
  124143. /**
  124144. * Define the camera controlled by the input.
  124145. */
  124146. get camera(): FreeCamera;
  124147. set camera(camera: FreeCamera);
  124148. /**
  124149. * Attach the input controls to a specific dom element to get the input from.
  124150. * @param element Defines the element the controls should be listened from
  124151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124152. */
  124153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124154. private _orientationChanged;
  124155. private _deviceOrientation;
  124156. /**
  124157. * Detach the current controls from the specified dom element.
  124158. * @param element Defines the element to stop listening the inputs from
  124159. */
  124160. detachControl(element: Nullable<HTMLElement>): void;
  124161. /**
  124162. * Update the current camera state depending on the inputs that have been used this frame.
  124163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124164. */
  124165. checkInputs(): void;
  124166. /**
  124167. * Gets the class name of the current intput.
  124168. * @returns the class name
  124169. */
  124170. getClassName(): string;
  124171. /**
  124172. * Get the friendly name associated with the input class.
  124173. * @returns the input friendly name
  124174. */
  124175. getSimpleName(): string;
  124176. }
  124177. }
  124178. declare module BABYLON {
  124179. /**
  124180. * Manage the gamepad inputs to control a free camera.
  124181. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124182. */
  124183. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  124184. /**
  124185. * Define the camera the input is attached to.
  124186. */
  124187. camera: FreeCamera;
  124188. /**
  124189. * Define the Gamepad controlling the input
  124190. */
  124191. gamepad: Nullable<Gamepad>;
  124192. /**
  124193. * Defines the gamepad rotation sensiblity.
  124194. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124195. */
  124196. gamepadAngularSensibility: number;
  124197. /**
  124198. * Defines the gamepad move sensiblity.
  124199. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124200. */
  124201. gamepadMoveSensibility: number;
  124202. private _yAxisScale;
  124203. /**
  124204. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124205. */
  124206. get invertYAxis(): boolean;
  124207. set invertYAxis(value: boolean);
  124208. private _onGamepadConnectedObserver;
  124209. private _onGamepadDisconnectedObserver;
  124210. private _cameraTransform;
  124211. private _deltaTransform;
  124212. private _vector3;
  124213. private _vector2;
  124214. /**
  124215. * Attach the input controls to a specific dom element to get the input from.
  124216. * @param element Defines the element the controls should be listened from
  124217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124218. */
  124219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124220. /**
  124221. * Detach the current controls from the specified dom element.
  124222. * @param element Defines the element to stop listening the inputs from
  124223. */
  124224. detachControl(element: Nullable<HTMLElement>): void;
  124225. /**
  124226. * Update the current camera state depending on the inputs that have been used this frame.
  124227. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124228. */
  124229. checkInputs(): void;
  124230. /**
  124231. * Gets the class name of the current intput.
  124232. * @returns the class name
  124233. */
  124234. getClassName(): string;
  124235. /**
  124236. * Get the friendly name associated with the input class.
  124237. * @returns the input friendly name
  124238. */
  124239. getSimpleName(): string;
  124240. }
  124241. }
  124242. declare module BABYLON {
  124243. /**
  124244. * Defines the potential axis of a Joystick
  124245. */
  124246. export enum JoystickAxis {
  124247. /** X axis */
  124248. X = 0,
  124249. /** Y axis */
  124250. Y = 1,
  124251. /** Z axis */
  124252. Z = 2
  124253. }
  124254. /**
  124255. * Represents the different customization options available
  124256. * for VirtualJoystick
  124257. */
  124258. interface VirtualJoystickCustomizations {
  124259. /**
  124260. * Size of the joystick's puck
  124261. */
  124262. puckSize: number;
  124263. /**
  124264. * Size of the joystick's container
  124265. */
  124266. containerSize: number;
  124267. /**
  124268. * Color of the joystick && puck
  124269. */
  124270. color: string;
  124271. /**
  124272. * Image URL for the joystick's puck
  124273. */
  124274. puckImage?: string;
  124275. /**
  124276. * Image URL for the joystick's container
  124277. */
  124278. containerImage?: string;
  124279. /**
  124280. * Defines the unmoving position of the joystick container
  124281. */
  124282. position?: {
  124283. x: number;
  124284. y: number;
  124285. };
  124286. /**
  124287. * Defines whether or not the joystick container is always visible
  124288. */
  124289. alwaysVisible: boolean;
  124290. /**
  124291. * Defines whether or not to limit the movement of the puck to the joystick's container
  124292. */
  124293. limitToContainer: boolean;
  124294. }
  124295. /**
  124296. * Class used to define virtual joystick (used in touch mode)
  124297. */
  124298. export class VirtualJoystick {
  124299. /**
  124300. * Gets or sets a boolean indicating that left and right values must be inverted
  124301. */
  124302. reverseLeftRight: boolean;
  124303. /**
  124304. * Gets or sets a boolean indicating that up and down values must be inverted
  124305. */
  124306. reverseUpDown: boolean;
  124307. /**
  124308. * Gets the offset value for the position (ie. the change of the position value)
  124309. */
  124310. deltaPosition: Vector3;
  124311. /**
  124312. * Gets a boolean indicating if the virtual joystick was pressed
  124313. */
  124314. pressed: boolean;
  124315. /**
  124316. * Canvas the virtual joystick will render onto, default z-index of this is 5
  124317. */
  124318. static Canvas: Nullable<HTMLCanvasElement>;
  124319. /**
  124320. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  124321. */
  124322. limitToContainer: boolean;
  124323. private static _globalJoystickIndex;
  124324. private static _alwaysVisibleSticks;
  124325. private static vjCanvasContext;
  124326. private static vjCanvasWidth;
  124327. private static vjCanvasHeight;
  124328. private static halfWidth;
  124329. private static _GetDefaultOptions;
  124330. private _action;
  124331. private _axisTargetedByLeftAndRight;
  124332. private _axisTargetedByUpAndDown;
  124333. private _joystickSensibility;
  124334. private _inversedSensibility;
  124335. private _joystickPointerID;
  124336. private _joystickColor;
  124337. private _joystickPointerPos;
  124338. private _joystickPreviousPointerPos;
  124339. private _joystickPointerStartPos;
  124340. private _deltaJoystickVector;
  124341. private _leftJoystick;
  124342. private _touches;
  124343. private _joystickPosition;
  124344. private _alwaysVisible;
  124345. private _puckImage;
  124346. private _containerImage;
  124347. private _joystickPuckSize;
  124348. private _joystickContainerSize;
  124349. private _clearPuckSize;
  124350. private _clearContainerSize;
  124351. private _clearPuckSizeOffset;
  124352. private _clearContainerSizeOffset;
  124353. private _onPointerDownHandlerRef;
  124354. private _onPointerMoveHandlerRef;
  124355. private _onPointerUpHandlerRef;
  124356. private _onResize;
  124357. /**
  124358. * Creates a new virtual joystick
  124359. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124360. * @param customizations Defines the options we want to customize the VirtualJoystick
  124361. */
  124362. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124363. /**
  124364. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124365. * @param newJoystickSensibility defines the new sensibility
  124366. */
  124367. setJoystickSensibility(newJoystickSensibility: number): void;
  124368. private _onPointerDown;
  124369. private _onPointerMove;
  124370. private _onPointerUp;
  124371. /**
  124372. * Change the color of the virtual joystick
  124373. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124374. */
  124375. setJoystickColor(newColor: string): void;
  124376. /**
  124377. * Size of the joystick's container
  124378. */
  124379. set containerSize(newSize: number);
  124380. get containerSize(): number;
  124381. /**
  124382. * Size of the joystick's puck
  124383. */
  124384. set puckSize(newSize: number);
  124385. get puckSize(): number;
  124386. /**
  124387. * Clears the set position of the joystick
  124388. */
  124389. clearPosition(): void;
  124390. /**
  124391. * Defines whether or not the joystick container is always visible
  124392. */
  124393. set alwaysVisible(value: boolean);
  124394. get alwaysVisible(): boolean;
  124395. /**
  124396. * Sets the constant position of the Joystick container
  124397. * @param x X axis coordinate
  124398. * @param y Y axis coordinate
  124399. */
  124400. setPosition(x: number, y: number): void;
  124401. /**
  124402. * Defines a callback to call when the joystick is touched
  124403. * @param action defines the callback
  124404. */
  124405. setActionOnTouch(action: () => any): void;
  124406. /**
  124407. * Defines which axis you'd like to control for left & right
  124408. * @param axis defines the axis to use
  124409. */
  124410. setAxisForLeftRight(axis: JoystickAxis): void;
  124411. /**
  124412. * Defines which axis you'd like to control for up & down
  124413. * @param axis defines the axis to use
  124414. */
  124415. setAxisForUpDown(axis: JoystickAxis): void;
  124416. /**
  124417. * Clears the canvas from the previous puck / container draw
  124418. */
  124419. private _clearPreviousDraw;
  124420. /**
  124421. * Loads `urlPath` to be used for the container's image
  124422. * @param urlPath defines the urlPath of an image to use
  124423. */
  124424. setContainerImage(urlPath: string): void;
  124425. /**
  124426. * Loads `urlPath` to be used for the puck's image
  124427. * @param urlPath defines the urlPath of an image to use
  124428. */
  124429. setPuckImage(urlPath: string): void;
  124430. /**
  124431. * Draws the Virtual Joystick's container
  124432. */
  124433. private _drawContainer;
  124434. /**
  124435. * Draws the Virtual Joystick's puck
  124436. */
  124437. private _drawPuck;
  124438. private _drawVirtualJoystick;
  124439. /**
  124440. * Release internal HTML canvas
  124441. */
  124442. releaseCanvas(): void;
  124443. }
  124444. }
  124445. declare module BABYLON {
  124446. interface FreeCameraInputsManager {
  124447. /**
  124448. * Add virtual joystick input support to the input manager.
  124449. * @returns the current input manager
  124450. */
  124451. addVirtualJoystick(): FreeCameraInputsManager;
  124452. }
  124453. /**
  124454. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  124455. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124456. */
  124457. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  124458. /**
  124459. * Defines the camera the input is attached to.
  124460. */
  124461. camera: FreeCamera;
  124462. private _leftjoystick;
  124463. private _rightjoystick;
  124464. /**
  124465. * Gets the left stick of the virtual joystick.
  124466. * @returns The virtual Joystick
  124467. */
  124468. getLeftJoystick(): VirtualJoystick;
  124469. /**
  124470. * Gets the right stick of the virtual joystick.
  124471. * @returns The virtual Joystick
  124472. */
  124473. getRightJoystick(): VirtualJoystick;
  124474. /**
  124475. * Update the current camera state depending on the inputs that have been used this frame.
  124476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124477. */
  124478. checkInputs(): void;
  124479. /**
  124480. * Attach the input controls to a specific dom element to get the input from.
  124481. * @param element Defines the element the controls should be listened from
  124482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124483. */
  124484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124485. /**
  124486. * Detach the current controls from the specified dom element.
  124487. * @param element Defines the element to stop listening the inputs from
  124488. */
  124489. detachControl(element: Nullable<HTMLElement>): void;
  124490. /**
  124491. * Gets the class name of the current intput.
  124492. * @returns the class name
  124493. */
  124494. getClassName(): string;
  124495. /**
  124496. * Get the friendly name associated with the input class.
  124497. * @returns the input friendly name
  124498. */
  124499. getSimpleName(): string;
  124500. }
  124501. }
  124502. declare module BABYLON {
  124503. /**
  124504. * This represents a FPS type of camera controlled by touch.
  124505. * This is like a universal camera minus the Gamepad controls.
  124506. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124507. */
  124508. export class TouchCamera extends FreeCamera {
  124509. /**
  124510. * Defines the touch sensibility for rotation.
  124511. * The higher the faster.
  124512. */
  124513. get touchAngularSensibility(): number;
  124514. set touchAngularSensibility(value: number);
  124515. /**
  124516. * Defines the touch sensibility for move.
  124517. * The higher the faster.
  124518. */
  124519. get touchMoveSensibility(): number;
  124520. set touchMoveSensibility(value: number);
  124521. /**
  124522. * Instantiates a new touch camera.
  124523. * This represents a FPS type of camera controlled by touch.
  124524. * This is like a universal camera minus the Gamepad controls.
  124525. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124526. * @param name Define the name of the camera in the scene
  124527. * @param position Define the start position of the camera in the scene
  124528. * @param scene Define the scene the camera belongs to
  124529. */
  124530. constructor(name: string, position: Vector3, scene: Scene);
  124531. /**
  124532. * Gets the current object class name.
  124533. * @return the class name
  124534. */
  124535. getClassName(): string;
  124536. /** @hidden */
  124537. _setupInputs(): void;
  124538. }
  124539. }
  124540. declare module BABYLON {
  124541. /**
  124542. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124543. * being tilted forward or back and left or right.
  124544. */
  124545. export class DeviceOrientationCamera extends FreeCamera {
  124546. private _initialQuaternion;
  124547. private _quaternionCache;
  124548. private _tmpDragQuaternion;
  124549. private _disablePointerInputWhenUsingDeviceOrientation;
  124550. /**
  124551. * Creates a new device orientation camera
  124552. * @param name The name of the camera
  124553. * @param position The start position camera
  124554. * @param scene The scene the camera belongs to
  124555. */
  124556. constructor(name: string, position: Vector3, scene: Scene);
  124557. /**
  124558. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124559. */
  124560. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124561. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124562. private _dragFactor;
  124563. /**
  124564. * Enabled turning on the y axis when the orientation sensor is active
  124565. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124566. */
  124567. enableHorizontalDragging(dragFactor?: number): void;
  124568. /**
  124569. * Gets the current instance class name ("DeviceOrientationCamera").
  124570. * This helps avoiding instanceof at run time.
  124571. * @returns the class name
  124572. */
  124573. getClassName(): string;
  124574. /**
  124575. * @hidden
  124576. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124577. */
  124578. _checkInputs(): void;
  124579. /**
  124580. * Reset the camera to its default orientation on the specified axis only.
  124581. * @param axis The axis to reset
  124582. */
  124583. resetToCurrentRotation(axis?: Axis): void;
  124584. }
  124585. }
  124586. declare module BABYLON {
  124587. /**
  124588. * Defines supported buttons for XBox360 compatible gamepads
  124589. */
  124590. export enum Xbox360Button {
  124591. /** A */
  124592. A = 0,
  124593. /** B */
  124594. B = 1,
  124595. /** X */
  124596. X = 2,
  124597. /** Y */
  124598. Y = 3,
  124599. /** Left button */
  124600. LB = 4,
  124601. /** Right button */
  124602. RB = 5,
  124603. /** Back */
  124604. Back = 8,
  124605. /** Start */
  124606. Start = 9,
  124607. /** Left stick */
  124608. LeftStick = 10,
  124609. /** Right stick */
  124610. RightStick = 11
  124611. }
  124612. /** Defines values for XBox360 DPad */
  124613. export enum Xbox360Dpad {
  124614. /** Up */
  124615. Up = 12,
  124616. /** Down */
  124617. Down = 13,
  124618. /** Left */
  124619. Left = 14,
  124620. /** Right */
  124621. Right = 15
  124622. }
  124623. /**
  124624. * Defines a XBox360 gamepad
  124625. */
  124626. export class Xbox360Pad extends Gamepad {
  124627. private _leftTrigger;
  124628. private _rightTrigger;
  124629. private _onlefttriggerchanged;
  124630. private _onrighttriggerchanged;
  124631. private _onbuttondown;
  124632. private _onbuttonup;
  124633. private _ondpaddown;
  124634. private _ondpadup;
  124635. /** Observable raised when a button is pressed */
  124636. onButtonDownObservable: Observable<Xbox360Button>;
  124637. /** Observable raised when a button is released */
  124638. onButtonUpObservable: Observable<Xbox360Button>;
  124639. /** Observable raised when a pad is pressed */
  124640. onPadDownObservable: Observable<Xbox360Dpad>;
  124641. /** Observable raised when a pad is released */
  124642. onPadUpObservable: Observable<Xbox360Dpad>;
  124643. private _buttonA;
  124644. private _buttonB;
  124645. private _buttonX;
  124646. private _buttonY;
  124647. private _buttonBack;
  124648. private _buttonStart;
  124649. private _buttonLB;
  124650. private _buttonRB;
  124651. private _buttonLeftStick;
  124652. private _buttonRightStick;
  124653. private _dPadUp;
  124654. private _dPadDown;
  124655. private _dPadLeft;
  124656. private _dPadRight;
  124657. private _isXboxOnePad;
  124658. /**
  124659. * Creates a new XBox360 gamepad object
  124660. * @param id defines the id of this gamepad
  124661. * @param index defines its index
  124662. * @param gamepad defines the internal HTML gamepad object
  124663. * @param xboxOne defines if it is a XBox One gamepad
  124664. */
  124665. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124666. /**
  124667. * Defines the callback to call when left trigger is pressed
  124668. * @param callback defines the callback to use
  124669. */
  124670. onlefttriggerchanged(callback: (value: number) => void): void;
  124671. /**
  124672. * Defines the callback to call when right trigger is pressed
  124673. * @param callback defines the callback to use
  124674. */
  124675. onrighttriggerchanged(callback: (value: number) => void): void;
  124676. /**
  124677. * Gets the left trigger value
  124678. */
  124679. get leftTrigger(): number;
  124680. /**
  124681. * Sets the left trigger value
  124682. */
  124683. set leftTrigger(newValue: number);
  124684. /**
  124685. * Gets the right trigger value
  124686. */
  124687. get rightTrigger(): number;
  124688. /**
  124689. * Sets the right trigger value
  124690. */
  124691. set rightTrigger(newValue: number);
  124692. /**
  124693. * Defines the callback to call when a button is pressed
  124694. * @param callback defines the callback to use
  124695. */
  124696. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124697. /**
  124698. * Defines the callback to call when a button is released
  124699. * @param callback defines the callback to use
  124700. */
  124701. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124702. /**
  124703. * Defines the callback to call when a pad is pressed
  124704. * @param callback defines the callback to use
  124705. */
  124706. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124707. /**
  124708. * Defines the callback to call when a pad is released
  124709. * @param callback defines the callback to use
  124710. */
  124711. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124712. private _setButtonValue;
  124713. private _setDPadValue;
  124714. /**
  124715. * Gets the value of the `A` button
  124716. */
  124717. get buttonA(): number;
  124718. /**
  124719. * Sets the value of the `A` button
  124720. */
  124721. set buttonA(value: number);
  124722. /**
  124723. * Gets the value of the `B` button
  124724. */
  124725. get buttonB(): number;
  124726. /**
  124727. * Sets the value of the `B` button
  124728. */
  124729. set buttonB(value: number);
  124730. /**
  124731. * Gets the value of the `X` button
  124732. */
  124733. get buttonX(): number;
  124734. /**
  124735. * Sets the value of the `X` button
  124736. */
  124737. set buttonX(value: number);
  124738. /**
  124739. * Gets the value of the `Y` button
  124740. */
  124741. get buttonY(): number;
  124742. /**
  124743. * Sets the value of the `Y` button
  124744. */
  124745. set buttonY(value: number);
  124746. /**
  124747. * Gets the value of the `Start` button
  124748. */
  124749. get buttonStart(): number;
  124750. /**
  124751. * Sets the value of the `Start` button
  124752. */
  124753. set buttonStart(value: number);
  124754. /**
  124755. * Gets the value of the `Back` button
  124756. */
  124757. get buttonBack(): number;
  124758. /**
  124759. * Sets the value of the `Back` button
  124760. */
  124761. set buttonBack(value: number);
  124762. /**
  124763. * Gets the value of the `Left` button
  124764. */
  124765. get buttonLB(): number;
  124766. /**
  124767. * Sets the value of the `Left` button
  124768. */
  124769. set buttonLB(value: number);
  124770. /**
  124771. * Gets the value of the `Right` button
  124772. */
  124773. get buttonRB(): number;
  124774. /**
  124775. * Sets the value of the `Right` button
  124776. */
  124777. set buttonRB(value: number);
  124778. /**
  124779. * Gets the value of the Left joystick
  124780. */
  124781. get buttonLeftStick(): number;
  124782. /**
  124783. * Sets the value of the Left joystick
  124784. */
  124785. set buttonLeftStick(value: number);
  124786. /**
  124787. * Gets the value of the Right joystick
  124788. */
  124789. get buttonRightStick(): number;
  124790. /**
  124791. * Sets the value of the Right joystick
  124792. */
  124793. set buttonRightStick(value: number);
  124794. /**
  124795. * Gets the value of D-pad up
  124796. */
  124797. get dPadUp(): number;
  124798. /**
  124799. * Sets the value of D-pad up
  124800. */
  124801. set dPadUp(value: number);
  124802. /**
  124803. * Gets the value of D-pad down
  124804. */
  124805. get dPadDown(): number;
  124806. /**
  124807. * Sets the value of D-pad down
  124808. */
  124809. set dPadDown(value: number);
  124810. /**
  124811. * Gets the value of D-pad left
  124812. */
  124813. get dPadLeft(): number;
  124814. /**
  124815. * Sets the value of D-pad left
  124816. */
  124817. set dPadLeft(value: number);
  124818. /**
  124819. * Gets the value of D-pad right
  124820. */
  124821. get dPadRight(): number;
  124822. /**
  124823. * Sets the value of D-pad right
  124824. */
  124825. set dPadRight(value: number);
  124826. /**
  124827. * Force the gamepad to synchronize with device values
  124828. */
  124829. update(): void;
  124830. /**
  124831. * Disposes the gamepad
  124832. */
  124833. dispose(): void;
  124834. }
  124835. }
  124836. declare module BABYLON {
  124837. /**
  124838. * Defines supported buttons for DualShock compatible gamepads
  124839. */
  124840. export enum DualShockButton {
  124841. /** Cross */
  124842. Cross = 0,
  124843. /** Circle */
  124844. Circle = 1,
  124845. /** Square */
  124846. Square = 2,
  124847. /** Triangle */
  124848. Triangle = 3,
  124849. /** L1 */
  124850. L1 = 4,
  124851. /** R1 */
  124852. R1 = 5,
  124853. /** Share */
  124854. Share = 8,
  124855. /** Options */
  124856. Options = 9,
  124857. /** Left stick */
  124858. LeftStick = 10,
  124859. /** Right stick */
  124860. RightStick = 11
  124861. }
  124862. /** Defines values for DualShock DPad */
  124863. export enum DualShockDpad {
  124864. /** Up */
  124865. Up = 12,
  124866. /** Down */
  124867. Down = 13,
  124868. /** Left */
  124869. Left = 14,
  124870. /** Right */
  124871. Right = 15
  124872. }
  124873. /**
  124874. * Defines a DualShock gamepad
  124875. */
  124876. export class DualShockPad extends Gamepad {
  124877. private _leftTrigger;
  124878. private _rightTrigger;
  124879. private _onlefttriggerchanged;
  124880. private _onrighttriggerchanged;
  124881. private _onbuttondown;
  124882. private _onbuttonup;
  124883. private _ondpaddown;
  124884. private _ondpadup;
  124885. /** Observable raised when a button is pressed */
  124886. onButtonDownObservable: Observable<DualShockButton>;
  124887. /** Observable raised when a button is released */
  124888. onButtonUpObservable: Observable<DualShockButton>;
  124889. /** Observable raised when a pad is pressed */
  124890. onPadDownObservable: Observable<DualShockDpad>;
  124891. /** Observable raised when a pad is released */
  124892. onPadUpObservable: Observable<DualShockDpad>;
  124893. private _buttonCross;
  124894. private _buttonCircle;
  124895. private _buttonSquare;
  124896. private _buttonTriangle;
  124897. private _buttonShare;
  124898. private _buttonOptions;
  124899. private _buttonL1;
  124900. private _buttonR1;
  124901. private _buttonLeftStick;
  124902. private _buttonRightStick;
  124903. private _dPadUp;
  124904. private _dPadDown;
  124905. private _dPadLeft;
  124906. private _dPadRight;
  124907. /**
  124908. * Creates a new DualShock gamepad object
  124909. * @param id defines the id of this gamepad
  124910. * @param index defines its index
  124911. * @param gamepad defines the internal HTML gamepad object
  124912. */
  124913. constructor(id: string, index: number, gamepad: any);
  124914. /**
  124915. * Defines the callback to call when left trigger is pressed
  124916. * @param callback defines the callback to use
  124917. */
  124918. onlefttriggerchanged(callback: (value: number) => void): void;
  124919. /**
  124920. * Defines the callback to call when right trigger is pressed
  124921. * @param callback defines the callback to use
  124922. */
  124923. onrighttriggerchanged(callback: (value: number) => void): void;
  124924. /**
  124925. * Gets the left trigger value
  124926. */
  124927. get leftTrigger(): number;
  124928. /**
  124929. * Sets the left trigger value
  124930. */
  124931. set leftTrigger(newValue: number);
  124932. /**
  124933. * Gets the right trigger value
  124934. */
  124935. get rightTrigger(): number;
  124936. /**
  124937. * Sets the right trigger value
  124938. */
  124939. set rightTrigger(newValue: number);
  124940. /**
  124941. * Defines the callback to call when a button is pressed
  124942. * @param callback defines the callback to use
  124943. */
  124944. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124945. /**
  124946. * Defines the callback to call when a button is released
  124947. * @param callback defines the callback to use
  124948. */
  124949. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124950. /**
  124951. * Defines the callback to call when a pad is pressed
  124952. * @param callback defines the callback to use
  124953. */
  124954. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124955. /**
  124956. * Defines the callback to call when a pad is released
  124957. * @param callback defines the callback to use
  124958. */
  124959. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124960. private _setButtonValue;
  124961. private _setDPadValue;
  124962. /**
  124963. * Gets the value of the `Cross` button
  124964. */
  124965. get buttonCross(): number;
  124966. /**
  124967. * Sets the value of the `Cross` button
  124968. */
  124969. set buttonCross(value: number);
  124970. /**
  124971. * Gets the value of the `Circle` button
  124972. */
  124973. get buttonCircle(): number;
  124974. /**
  124975. * Sets the value of the `Circle` button
  124976. */
  124977. set buttonCircle(value: number);
  124978. /**
  124979. * Gets the value of the `Square` button
  124980. */
  124981. get buttonSquare(): number;
  124982. /**
  124983. * Sets the value of the `Square` button
  124984. */
  124985. set buttonSquare(value: number);
  124986. /**
  124987. * Gets the value of the `Triangle` button
  124988. */
  124989. get buttonTriangle(): number;
  124990. /**
  124991. * Sets the value of the `Triangle` button
  124992. */
  124993. set buttonTriangle(value: number);
  124994. /**
  124995. * Gets the value of the `Options` button
  124996. */
  124997. get buttonOptions(): number;
  124998. /**
  124999. * Sets the value of the `Options` button
  125000. */
  125001. set buttonOptions(value: number);
  125002. /**
  125003. * Gets the value of the `Share` button
  125004. */
  125005. get buttonShare(): number;
  125006. /**
  125007. * Sets the value of the `Share` button
  125008. */
  125009. set buttonShare(value: number);
  125010. /**
  125011. * Gets the value of the `L1` button
  125012. */
  125013. get buttonL1(): number;
  125014. /**
  125015. * Sets the value of the `L1` button
  125016. */
  125017. set buttonL1(value: number);
  125018. /**
  125019. * Gets the value of the `R1` button
  125020. */
  125021. get buttonR1(): number;
  125022. /**
  125023. * Sets the value of the `R1` button
  125024. */
  125025. set buttonR1(value: number);
  125026. /**
  125027. * Gets the value of the Left joystick
  125028. */
  125029. get buttonLeftStick(): number;
  125030. /**
  125031. * Sets the value of the Left joystick
  125032. */
  125033. set buttonLeftStick(value: number);
  125034. /**
  125035. * Gets the value of the Right joystick
  125036. */
  125037. get buttonRightStick(): number;
  125038. /**
  125039. * Sets the value of the Right joystick
  125040. */
  125041. set buttonRightStick(value: number);
  125042. /**
  125043. * Gets the value of D-pad up
  125044. */
  125045. get dPadUp(): number;
  125046. /**
  125047. * Sets the value of D-pad up
  125048. */
  125049. set dPadUp(value: number);
  125050. /**
  125051. * Gets the value of D-pad down
  125052. */
  125053. get dPadDown(): number;
  125054. /**
  125055. * Sets the value of D-pad down
  125056. */
  125057. set dPadDown(value: number);
  125058. /**
  125059. * Gets the value of D-pad left
  125060. */
  125061. get dPadLeft(): number;
  125062. /**
  125063. * Sets the value of D-pad left
  125064. */
  125065. set dPadLeft(value: number);
  125066. /**
  125067. * Gets the value of D-pad right
  125068. */
  125069. get dPadRight(): number;
  125070. /**
  125071. * Sets the value of D-pad right
  125072. */
  125073. set dPadRight(value: number);
  125074. /**
  125075. * Force the gamepad to synchronize with device values
  125076. */
  125077. update(): void;
  125078. /**
  125079. * Disposes the gamepad
  125080. */
  125081. dispose(): void;
  125082. }
  125083. }
  125084. declare module BABYLON {
  125085. /**
  125086. * Manager for handling gamepads
  125087. */
  125088. export class GamepadManager {
  125089. private _scene?;
  125090. private _babylonGamepads;
  125091. private _oneGamepadConnected;
  125092. /** @hidden */
  125093. _isMonitoring: boolean;
  125094. private _gamepadEventSupported;
  125095. private _gamepadSupport?;
  125096. /**
  125097. * observable to be triggered when the gamepad controller has been connected
  125098. */
  125099. onGamepadConnectedObservable: Observable<Gamepad>;
  125100. /**
  125101. * observable to be triggered when the gamepad controller has been disconnected
  125102. */
  125103. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125104. private _onGamepadConnectedEvent;
  125105. private _onGamepadDisconnectedEvent;
  125106. /**
  125107. * Initializes the gamepad manager
  125108. * @param _scene BabylonJS scene
  125109. */
  125110. constructor(_scene?: Scene | undefined);
  125111. /**
  125112. * The gamepads in the game pad manager
  125113. */
  125114. get gamepads(): Gamepad[];
  125115. /**
  125116. * Get the gamepad controllers based on type
  125117. * @param type The type of gamepad controller
  125118. * @returns Nullable gamepad
  125119. */
  125120. getGamepadByType(type?: number): Nullable<Gamepad>;
  125121. /**
  125122. * Disposes the gamepad manager
  125123. */
  125124. dispose(): void;
  125125. private _addNewGamepad;
  125126. private _startMonitoringGamepads;
  125127. private _stopMonitoringGamepads;
  125128. /** @hidden */
  125129. _checkGamepadsStatus(): void;
  125130. private _updateGamepadObjects;
  125131. }
  125132. }
  125133. declare module BABYLON {
  125134. interface Scene {
  125135. /** @hidden */
  125136. _gamepadManager: Nullable<GamepadManager>;
  125137. /**
  125138. * Gets the gamepad manager associated with the scene
  125139. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125140. */
  125141. gamepadManager: GamepadManager;
  125142. }
  125143. /**
  125144. * Interface representing a free camera inputs manager
  125145. */
  125146. interface FreeCameraInputsManager {
  125147. /**
  125148. * Adds gamepad input support to the FreeCameraInputsManager.
  125149. * @returns the FreeCameraInputsManager
  125150. */
  125151. addGamepad(): FreeCameraInputsManager;
  125152. }
  125153. /**
  125154. * Interface representing an arc rotate camera inputs manager
  125155. */
  125156. interface ArcRotateCameraInputsManager {
  125157. /**
  125158. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125159. * @returns the camera inputs manager
  125160. */
  125161. addGamepad(): ArcRotateCameraInputsManager;
  125162. }
  125163. /**
  125164. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125165. */
  125166. export class GamepadSystemSceneComponent implements ISceneComponent {
  125167. /**
  125168. * The component name helpfull to identify the component in the list of scene components.
  125169. */
  125170. readonly name: string;
  125171. /**
  125172. * The scene the component belongs to.
  125173. */
  125174. scene: Scene;
  125175. /**
  125176. * Creates a new instance of the component for the given scene
  125177. * @param scene Defines the scene to register the component in
  125178. */
  125179. constructor(scene: Scene);
  125180. /**
  125181. * Registers the component in a given scene
  125182. */
  125183. register(): void;
  125184. /**
  125185. * Rebuilds the elements related to this component in case of
  125186. * context lost for instance.
  125187. */
  125188. rebuild(): void;
  125189. /**
  125190. * Disposes the component and the associated ressources
  125191. */
  125192. dispose(): void;
  125193. private _beforeCameraUpdate;
  125194. }
  125195. }
  125196. declare module BABYLON {
  125197. /**
  125198. * 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,
  125199. * which still works and will still be found in many Playgrounds.
  125200. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125201. */
  125202. export class UniversalCamera extends TouchCamera {
  125203. /**
  125204. * Defines the gamepad rotation sensiblity.
  125205. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125206. */
  125207. get gamepadAngularSensibility(): number;
  125208. set gamepadAngularSensibility(value: number);
  125209. /**
  125210. * Defines the gamepad move sensiblity.
  125211. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125212. */
  125213. get gamepadMoveSensibility(): number;
  125214. set gamepadMoveSensibility(value: number);
  125215. /**
  125216. * 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,
  125217. * which still works and will still be found in many Playgrounds.
  125218. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125219. * @param name Define the name of the camera in the scene
  125220. * @param position Define the start position of the camera in the scene
  125221. * @param scene Define the scene the camera belongs to
  125222. */
  125223. constructor(name: string, position: Vector3, scene: Scene);
  125224. /**
  125225. * Gets the current object class name.
  125226. * @return the class name
  125227. */
  125228. getClassName(): string;
  125229. }
  125230. }
  125231. declare module BABYLON {
  125232. /**
  125233. * This represents a FPS type of camera. This is only here for back compat purpose.
  125234. * Please use the UniversalCamera instead as both are identical.
  125235. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125236. */
  125237. export class GamepadCamera extends UniversalCamera {
  125238. /**
  125239. * Instantiates a new Gamepad Camera
  125240. * This represents a FPS type of camera. This is only here for back compat purpose.
  125241. * Please use the UniversalCamera instead as both are identical.
  125242. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125243. * @param name Define the name of the camera in the scene
  125244. * @param position Define the start position of the camera in the scene
  125245. * @param scene Define the scene the camera belongs to
  125246. */
  125247. constructor(name: string, position: Vector3, scene: Scene);
  125248. /**
  125249. * Gets the current object class name.
  125250. * @return the class name
  125251. */
  125252. getClassName(): string;
  125253. }
  125254. }
  125255. declare module BABYLON {
  125256. /** @hidden */
  125257. export var passPixelShader: {
  125258. name: string;
  125259. shader: string;
  125260. };
  125261. }
  125262. declare module BABYLON {
  125263. /** @hidden */
  125264. export var passCubePixelShader: {
  125265. name: string;
  125266. shader: string;
  125267. };
  125268. }
  125269. declare module BABYLON {
  125270. /**
  125271. * PassPostProcess which produces an output the same as it's input
  125272. */
  125273. export class PassPostProcess extends PostProcess {
  125274. /**
  125275. * Gets a string identifying the name of the class
  125276. * @returns "PassPostProcess" string
  125277. */
  125278. getClassName(): string;
  125279. /**
  125280. * Creates the PassPostProcess
  125281. * @param name The name of the effect.
  125282. * @param options The required width/height ratio to downsize to before computing the render pass.
  125283. * @param camera The camera to apply the render pass to.
  125284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125285. * @param engine The engine which the post process will be applied. (default: current engine)
  125286. * @param reusable If the post process can be reused on the same frame. (default: false)
  125287. * @param textureType The type of texture to be used when performing the post processing.
  125288. * @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)
  125289. */
  125290. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125291. /** @hidden */
  125292. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  125293. }
  125294. /**
  125295. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125296. */
  125297. export class PassCubePostProcess extends PostProcess {
  125298. private _face;
  125299. /**
  125300. * Gets or sets the cube face to display.
  125301. * * 0 is +X
  125302. * * 1 is -X
  125303. * * 2 is +Y
  125304. * * 3 is -Y
  125305. * * 4 is +Z
  125306. * * 5 is -Z
  125307. */
  125308. get face(): number;
  125309. set face(value: number);
  125310. /**
  125311. * Gets a string identifying the name of the class
  125312. * @returns "PassCubePostProcess" string
  125313. */
  125314. getClassName(): string;
  125315. /**
  125316. * Creates the PassCubePostProcess
  125317. * @param name The name of the effect.
  125318. * @param options The required width/height ratio to downsize to before computing the render pass.
  125319. * @param camera The camera to apply the render pass to.
  125320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125321. * @param engine The engine which the post process will be applied. (default: current engine)
  125322. * @param reusable If the post process can be reused on the same frame. (default: false)
  125323. * @param textureType The type of texture to be used when performing the post processing.
  125324. * @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)
  125325. */
  125326. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125327. /** @hidden */
  125328. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  125329. }
  125330. }
  125331. declare module BABYLON {
  125332. /** @hidden */
  125333. export var anaglyphPixelShader: {
  125334. name: string;
  125335. shader: string;
  125336. };
  125337. }
  125338. declare module BABYLON {
  125339. /**
  125340. * Postprocess used to generate anaglyphic rendering
  125341. */
  125342. export class AnaglyphPostProcess extends PostProcess {
  125343. private _passedProcess;
  125344. /**
  125345. * Gets a string identifying the name of the class
  125346. * @returns "AnaglyphPostProcess" string
  125347. */
  125348. getClassName(): string;
  125349. /**
  125350. * Creates a new AnaglyphPostProcess
  125351. * @param name defines postprocess name
  125352. * @param options defines creation options or target ratio scale
  125353. * @param rigCameras defines cameras using this postprocess
  125354. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  125355. * @param engine defines hosting engine
  125356. * @param reusable defines if the postprocess will be reused multiple times per frame
  125357. */
  125358. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  125359. }
  125360. }
  125361. declare module BABYLON {
  125362. /**
  125363. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125364. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125365. */
  125366. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125367. /**
  125368. * Creates a new AnaglyphArcRotateCamera
  125369. * @param name defines camera name
  125370. * @param alpha defines alpha angle (in radians)
  125371. * @param beta defines beta angle (in radians)
  125372. * @param radius defines radius
  125373. * @param target defines camera target
  125374. * @param interaxialDistance defines distance between each color axis
  125375. * @param scene defines the hosting scene
  125376. */
  125377. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125378. /**
  125379. * Gets camera class name
  125380. * @returns AnaglyphArcRotateCamera
  125381. */
  125382. getClassName(): string;
  125383. }
  125384. }
  125385. declare module BABYLON {
  125386. /**
  125387. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125388. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125389. */
  125390. export class AnaglyphFreeCamera extends FreeCamera {
  125391. /**
  125392. * Creates a new AnaglyphFreeCamera
  125393. * @param name defines camera name
  125394. * @param position defines initial position
  125395. * @param interaxialDistance defines distance between each color axis
  125396. * @param scene defines the hosting scene
  125397. */
  125398. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125399. /**
  125400. * Gets camera class name
  125401. * @returns AnaglyphFreeCamera
  125402. */
  125403. getClassName(): string;
  125404. }
  125405. }
  125406. declare module BABYLON {
  125407. /**
  125408. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125409. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125410. */
  125411. export class AnaglyphGamepadCamera extends GamepadCamera {
  125412. /**
  125413. * Creates a new AnaglyphGamepadCamera
  125414. * @param name defines camera name
  125415. * @param position defines initial position
  125416. * @param interaxialDistance defines distance between each color axis
  125417. * @param scene defines the hosting scene
  125418. */
  125419. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125420. /**
  125421. * Gets camera class name
  125422. * @returns AnaglyphGamepadCamera
  125423. */
  125424. getClassName(): string;
  125425. }
  125426. }
  125427. declare module BABYLON {
  125428. /**
  125429. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  125430. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125431. */
  125432. export class AnaglyphUniversalCamera extends UniversalCamera {
  125433. /**
  125434. * Creates a new AnaglyphUniversalCamera
  125435. * @param name defines camera name
  125436. * @param position defines initial position
  125437. * @param interaxialDistance defines distance between each color axis
  125438. * @param scene defines the hosting scene
  125439. */
  125440. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125441. /**
  125442. * Gets camera class name
  125443. * @returns AnaglyphUniversalCamera
  125444. */
  125445. getClassName(): string;
  125446. }
  125447. }
  125448. declare module BABYLON {
  125449. /**
  125450. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  125451. * @see https://doc.babylonjs.com/features/cameras
  125452. */
  125453. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  125454. /**
  125455. * Creates a new StereoscopicArcRotateCamera
  125456. * @param name defines camera name
  125457. * @param alpha defines alpha angle (in radians)
  125458. * @param beta defines beta angle (in radians)
  125459. * @param radius defines radius
  125460. * @param target defines camera target
  125461. * @param interaxialDistance defines distance between each color axis
  125462. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125463. * @param scene defines the hosting scene
  125464. */
  125465. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125466. /**
  125467. * Gets camera class name
  125468. * @returns StereoscopicArcRotateCamera
  125469. */
  125470. getClassName(): string;
  125471. }
  125472. }
  125473. declare module BABYLON {
  125474. /**
  125475. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  125476. * @see https://doc.babylonjs.com/features/cameras
  125477. */
  125478. export class StereoscopicFreeCamera extends FreeCamera {
  125479. /**
  125480. * Creates a new StereoscopicFreeCamera
  125481. * @param name defines camera name
  125482. * @param position defines initial position
  125483. * @param interaxialDistance defines distance between each color axis
  125484. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125485. * @param scene defines the hosting scene
  125486. */
  125487. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125488. /**
  125489. * Gets camera class name
  125490. * @returns StereoscopicFreeCamera
  125491. */
  125492. getClassName(): string;
  125493. }
  125494. }
  125495. declare module BABYLON {
  125496. /**
  125497. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  125498. * @see https://doc.babylonjs.com/features/cameras
  125499. */
  125500. export class StereoscopicGamepadCamera extends GamepadCamera {
  125501. /**
  125502. * Creates a new StereoscopicGamepadCamera
  125503. * @param name defines camera name
  125504. * @param position defines initial position
  125505. * @param interaxialDistance defines distance between each color axis
  125506. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125507. * @param scene defines the hosting scene
  125508. */
  125509. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125510. /**
  125511. * Gets camera class name
  125512. * @returns StereoscopicGamepadCamera
  125513. */
  125514. getClassName(): string;
  125515. }
  125516. }
  125517. declare module BABYLON {
  125518. /**
  125519. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  125520. * @see https://doc.babylonjs.com/features/cameras
  125521. */
  125522. export class StereoscopicUniversalCamera extends UniversalCamera {
  125523. /**
  125524. * Creates a new StereoscopicUniversalCamera
  125525. * @param name defines camera name
  125526. * @param position defines initial position
  125527. * @param interaxialDistance defines distance between each color axis
  125528. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125529. * @param scene defines the hosting scene
  125530. */
  125531. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125532. /**
  125533. * Gets camera class name
  125534. * @returns StereoscopicUniversalCamera
  125535. */
  125536. getClassName(): string;
  125537. }
  125538. }
  125539. declare module BABYLON {
  125540. /**
  125541. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  125542. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125543. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125544. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125545. */
  125546. export class VirtualJoysticksCamera extends FreeCamera {
  125547. /**
  125548. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  125549. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125550. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125551. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125552. * @param name Define the name of the camera in the scene
  125553. * @param position Define the start position of the camera in the scene
  125554. * @param scene Define the scene the camera belongs to
  125555. */
  125556. constructor(name: string, position: Vector3, scene: Scene);
  125557. /**
  125558. * Gets the current object class name.
  125559. * @return the class name
  125560. */
  125561. getClassName(): string;
  125562. }
  125563. }
  125564. declare module BABYLON {
  125565. /**
  125566. * This represents all the required metrics to create a VR camera.
  125567. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125568. */
  125569. export class VRCameraMetrics {
  125570. /**
  125571. * Define the horizontal resolution off the screen.
  125572. */
  125573. hResolution: number;
  125574. /**
  125575. * Define the vertical resolution off the screen.
  125576. */
  125577. vResolution: number;
  125578. /**
  125579. * Define the horizontal screen size.
  125580. */
  125581. hScreenSize: number;
  125582. /**
  125583. * Define the vertical screen size.
  125584. */
  125585. vScreenSize: number;
  125586. /**
  125587. * Define the vertical screen center position.
  125588. */
  125589. vScreenCenter: number;
  125590. /**
  125591. * Define the distance of the eyes to the screen.
  125592. */
  125593. eyeToScreenDistance: number;
  125594. /**
  125595. * Define the distance between both lenses
  125596. */
  125597. lensSeparationDistance: number;
  125598. /**
  125599. * Define the distance between both viewer's eyes.
  125600. */
  125601. interpupillaryDistance: number;
  125602. /**
  125603. * Define the distortion factor of the VR postprocess.
  125604. * Please, touch with care.
  125605. */
  125606. distortionK: number[];
  125607. /**
  125608. * Define the chromatic aberration correction factors for the VR post process.
  125609. */
  125610. chromaAbCorrection: number[];
  125611. /**
  125612. * Define the scale factor of the post process.
  125613. * The smaller the better but the slower.
  125614. */
  125615. postProcessScaleFactor: number;
  125616. /**
  125617. * Define an offset for the lens center.
  125618. */
  125619. lensCenterOffset: number;
  125620. /**
  125621. * Define if the current vr camera should compensate the distortion of the lense or not.
  125622. */
  125623. compensateDistortion: boolean;
  125624. /**
  125625. * Defines if multiview should be enabled when rendering (Default: false)
  125626. */
  125627. multiviewEnabled: boolean;
  125628. /**
  125629. * Gets the rendering aspect ratio based on the provided resolutions.
  125630. */
  125631. get aspectRatio(): number;
  125632. /**
  125633. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125634. */
  125635. get aspectRatioFov(): number;
  125636. /**
  125637. * @hidden
  125638. */
  125639. get leftHMatrix(): Matrix;
  125640. /**
  125641. * @hidden
  125642. */
  125643. get rightHMatrix(): Matrix;
  125644. /**
  125645. * @hidden
  125646. */
  125647. get leftPreViewMatrix(): Matrix;
  125648. /**
  125649. * @hidden
  125650. */
  125651. get rightPreViewMatrix(): Matrix;
  125652. /**
  125653. * Get the default VRMetrics based on the most generic setup.
  125654. * @returns the default vr metrics
  125655. */
  125656. static GetDefault(): VRCameraMetrics;
  125657. }
  125658. }
  125659. declare module BABYLON {
  125660. /** @hidden */
  125661. export var vrDistortionCorrectionPixelShader: {
  125662. name: string;
  125663. shader: string;
  125664. };
  125665. }
  125666. declare module BABYLON {
  125667. /**
  125668. * VRDistortionCorrectionPostProcess used for mobile VR
  125669. */
  125670. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125671. private _isRightEye;
  125672. private _distortionFactors;
  125673. private _postProcessScaleFactor;
  125674. private _lensCenterOffset;
  125675. private _scaleIn;
  125676. private _scaleFactor;
  125677. private _lensCenter;
  125678. /**
  125679. * Gets a string identifying the name of the class
  125680. * @returns "VRDistortionCorrectionPostProcess" string
  125681. */
  125682. getClassName(): string;
  125683. /**
  125684. * Initializes the VRDistortionCorrectionPostProcess
  125685. * @param name The name of the effect.
  125686. * @param camera The camera to apply the render pass to.
  125687. * @param isRightEye If this is for the right eye distortion
  125688. * @param vrMetrics All the required metrics for the VR camera
  125689. */
  125690. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125691. }
  125692. }
  125693. declare module BABYLON {
  125694. /**
  125695. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125696. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125697. */
  125698. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125699. /**
  125700. * Creates a new VRDeviceOrientationArcRotateCamera
  125701. * @param name defines camera name
  125702. * @param alpha defines the camera rotation along the logitudinal axis
  125703. * @param beta defines the camera rotation along the latitudinal axis
  125704. * @param radius defines the camera distance from its target
  125705. * @param target defines the camera target
  125706. * @param scene defines the scene the camera belongs to
  125707. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125708. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125709. */
  125710. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125711. /**
  125712. * Gets camera class name
  125713. * @returns VRDeviceOrientationArcRotateCamera
  125714. */
  125715. getClassName(): string;
  125716. }
  125717. }
  125718. declare module BABYLON {
  125719. /**
  125720. * Camera used to simulate VR rendering (based on FreeCamera)
  125721. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125722. */
  125723. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125724. /**
  125725. * Creates a new VRDeviceOrientationFreeCamera
  125726. * @param name defines camera name
  125727. * @param position defines the start position of the camera
  125728. * @param scene defines the scene the camera belongs to
  125729. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125730. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125731. */
  125732. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125733. /**
  125734. * Gets camera class name
  125735. * @returns VRDeviceOrientationFreeCamera
  125736. */
  125737. getClassName(): string;
  125738. }
  125739. }
  125740. declare module BABYLON {
  125741. /**
  125742. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125743. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125744. */
  125745. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125746. /**
  125747. * Creates a new VRDeviceOrientationGamepadCamera
  125748. * @param name defines camera name
  125749. * @param position defines the start position of the camera
  125750. * @param scene defines the scene the camera belongs to
  125751. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125752. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125753. */
  125754. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125755. /**
  125756. * Gets camera class name
  125757. * @returns VRDeviceOrientationGamepadCamera
  125758. */
  125759. getClassName(): string;
  125760. }
  125761. }
  125762. declare module BABYLON {
  125763. /**
  125764. * A class extending Texture allowing drawing on a texture
  125765. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125766. */
  125767. export class DynamicTexture extends Texture {
  125768. private _generateMipMaps;
  125769. private _canvas;
  125770. private _context;
  125771. /**
  125772. * Creates a DynamicTexture
  125773. * @param name defines the name of the texture
  125774. * @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
  125775. * @param scene defines the scene where you want the texture
  125776. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125777. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125778. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125779. */
  125780. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125781. /**
  125782. * Get the current class name of the texture useful for serialization or dynamic coding.
  125783. * @returns "DynamicTexture"
  125784. */
  125785. getClassName(): string;
  125786. /**
  125787. * Gets the current state of canRescale
  125788. */
  125789. get canRescale(): boolean;
  125790. private _recreate;
  125791. /**
  125792. * Scales the texture
  125793. * @param ratio the scale factor to apply to both width and height
  125794. */
  125795. scale(ratio: number): void;
  125796. /**
  125797. * Resizes the texture
  125798. * @param width the new width
  125799. * @param height the new height
  125800. */
  125801. scaleTo(width: number, height: number): void;
  125802. /**
  125803. * Gets the context of the canvas used by the texture
  125804. * @returns the canvas context of the dynamic texture
  125805. */
  125806. getContext(): CanvasRenderingContext2D;
  125807. /**
  125808. * Clears the texture
  125809. */
  125810. clear(): void;
  125811. /**
  125812. * Updates the texture
  125813. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125814. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125815. */
  125816. update(invertY?: boolean, premulAlpha?: boolean): void;
  125817. /**
  125818. * Draws text onto the texture
  125819. * @param text defines the text to be drawn
  125820. * @param x defines the placement of the text from the left
  125821. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125822. * @param font defines the font to be used with font-style, font-size, font-name
  125823. * @param color defines the color used for the text
  125824. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125825. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125826. * @param update defines whether texture is immediately update (default is true)
  125827. */
  125828. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125829. /**
  125830. * Clones the texture
  125831. * @returns the clone of the texture.
  125832. */
  125833. clone(): DynamicTexture;
  125834. /**
  125835. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125836. * @returns a serialized dynamic texture object
  125837. */
  125838. serialize(): any;
  125839. private _IsCanvasElement;
  125840. /** @hidden */
  125841. _rebuild(): void;
  125842. }
  125843. }
  125844. declare module BABYLON {
  125845. /**
  125846. * Class containing static functions to help procedurally build meshes
  125847. */
  125848. export class GroundBuilder {
  125849. /**
  125850. * Creates a ground mesh
  125851. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125852. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125854. * @param name defines the name of the mesh
  125855. * @param options defines the options used to create the mesh
  125856. * @param scene defines the hosting scene
  125857. * @returns the ground mesh
  125858. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125859. */
  125860. static CreateGround(name: string, options: {
  125861. width?: number;
  125862. height?: number;
  125863. subdivisions?: number;
  125864. subdivisionsX?: number;
  125865. subdivisionsY?: number;
  125866. updatable?: boolean;
  125867. }, scene: any): Mesh;
  125868. /**
  125869. * Creates a tiled ground mesh
  125870. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125871. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125872. * * 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
  125873. * * 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
  125874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125875. * @param name defines the name of the mesh
  125876. * @param options defines the options used to create the mesh
  125877. * @param scene defines the hosting scene
  125878. * @returns the tiled ground mesh
  125879. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125880. */
  125881. static CreateTiledGround(name: string, options: {
  125882. xmin: number;
  125883. zmin: number;
  125884. xmax: number;
  125885. zmax: number;
  125886. subdivisions?: {
  125887. w: number;
  125888. h: number;
  125889. };
  125890. precision?: {
  125891. w: number;
  125892. h: number;
  125893. };
  125894. updatable?: boolean;
  125895. }, scene?: Nullable<Scene>): Mesh;
  125896. /**
  125897. * Creates a ground mesh from a height map
  125898. * * The parameter `url` sets the URL of the height map image resource.
  125899. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125900. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125901. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125902. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125903. * * 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.
  125904. * * 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).
  125905. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125907. * @param name defines the name of the mesh
  125908. * @param url defines the url to the height map
  125909. * @param options defines the options used to create the mesh
  125910. * @param scene defines the hosting scene
  125911. * @returns the ground mesh
  125912. * @see https://doc.babylonjs.com/babylon101/height_map
  125913. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125914. */
  125915. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125916. width?: number;
  125917. height?: number;
  125918. subdivisions?: number;
  125919. minHeight?: number;
  125920. maxHeight?: number;
  125921. colorFilter?: Color3;
  125922. alphaFilter?: number;
  125923. updatable?: boolean;
  125924. onReady?: (mesh: GroundMesh) => void;
  125925. }, scene?: Nullable<Scene>): GroundMesh;
  125926. }
  125927. }
  125928. declare module BABYLON {
  125929. /**
  125930. * Class containing static functions to help procedurally build meshes
  125931. */
  125932. export class TorusBuilder {
  125933. /**
  125934. * Creates a torus mesh
  125935. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125936. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125937. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125941. * @param name defines the name of the mesh
  125942. * @param options defines the options used to create the mesh
  125943. * @param scene defines the hosting scene
  125944. * @returns the torus mesh
  125945. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125946. */
  125947. static CreateTorus(name: string, options: {
  125948. diameter?: number;
  125949. thickness?: number;
  125950. tessellation?: number;
  125951. updatable?: boolean;
  125952. sideOrientation?: number;
  125953. frontUVs?: Vector4;
  125954. backUVs?: Vector4;
  125955. }, scene: any): Mesh;
  125956. }
  125957. }
  125958. declare module BABYLON {
  125959. /**
  125960. * Class containing static functions to help procedurally build meshes
  125961. */
  125962. export class CylinderBuilder {
  125963. /**
  125964. * Creates a cylinder or a cone mesh
  125965. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125966. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125967. * * 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.
  125968. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125969. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125970. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125971. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125972. * * 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).
  125973. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125974. * * 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).
  125975. * * 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
  125976. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125977. * * 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
  125978. * * 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.
  125979. * * If `enclose` is false, a ring surface is one element.
  125980. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125981. * * 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
  125982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125985. * @param name defines the name of the mesh
  125986. * @param options defines the options used to create the mesh
  125987. * @param scene defines the hosting scene
  125988. * @returns the cylinder mesh
  125989. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125990. */
  125991. static CreateCylinder(name: string, options: {
  125992. height?: number;
  125993. diameterTop?: number;
  125994. diameterBottom?: number;
  125995. diameter?: number;
  125996. tessellation?: number;
  125997. subdivisions?: number;
  125998. arc?: number;
  125999. faceColors?: Color4[];
  126000. faceUV?: Vector4[];
  126001. updatable?: boolean;
  126002. hasRings?: boolean;
  126003. enclose?: boolean;
  126004. cap?: number;
  126005. sideOrientation?: number;
  126006. frontUVs?: Vector4;
  126007. backUVs?: Vector4;
  126008. }, scene: any): Mesh;
  126009. }
  126010. }
  126011. declare module BABYLON {
  126012. /**
  126013. * States of the webXR experience
  126014. */
  126015. export enum WebXRState {
  126016. /**
  126017. * Transitioning to being in XR mode
  126018. */
  126019. ENTERING_XR = 0,
  126020. /**
  126021. * Transitioning to non XR mode
  126022. */
  126023. EXITING_XR = 1,
  126024. /**
  126025. * In XR mode and presenting
  126026. */
  126027. IN_XR = 2,
  126028. /**
  126029. * Not entered XR mode
  126030. */
  126031. NOT_IN_XR = 3
  126032. }
  126033. /**
  126034. * Abstraction of the XR render target
  126035. */
  126036. export interface WebXRRenderTarget extends IDisposable {
  126037. /**
  126038. * xrpresent context of the canvas which can be used to display/mirror xr content
  126039. */
  126040. canvasContext: WebGLRenderingContext;
  126041. /**
  126042. * xr layer for the canvas
  126043. */
  126044. xrLayer: Nullable<XRWebGLLayer>;
  126045. /**
  126046. * Initializes the xr layer for the session
  126047. * @param xrSession xr session
  126048. * @returns a promise that will resolve once the XR Layer has been created
  126049. */
  126050. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126051. }
  126052. }
  126053. declare module BABYLON {
  126054. /**
  126055. * COnfiguration object for WebXR output canvas
  126056. */
  126057. export class WebXRManagedOutputCanvasOptions {
  126058. /**
  126059. * An optional canvas in case you wish to create it yourself and provide it here.
  126060. * If not provided, a new canvas will be created
  126061. */
  126062. canvasElement?: HTMLCanvasElement;
  126063. /**
  126064. * Options for this XR Layer output
  126065. */
  126066. canvasOptions?: XRWebGLLayerOptions;
  126067. /**
  126068. * CSS styling for a newly created canvas (if not provided)
  126069. */
  126070. newCanvasCssStyle?: string;
  126071. /**
  126072. * Get the default values of the configuration object
  126073. * @returns default values of this configuration object
  126074. */
  126075. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  126076. }
  126077. /**
  126078. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126079. */
  126080. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126081. private _options;
  126082. private _canvas;
  126083. private _engine;
  126084. private _originalCanvasSize;
  126085. /**
  126086. * Rendering context of the canvas which can be used to display/mirror xr content
  126087. */
  126088. canvasContext: WebGLRenderingContext;
  126089. /**
  126090. * xr layer for the canvas
  126091. */
  126092. xrLayer: Nullable<XRWebGLLayer>;
  126093. /**
  126094. * Obseervers registered here will be triggered when the xr layer was initialized
  126095. */
  126096. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126097. /**
  126098. * Initializes the canvas to be added/removed upon entering/exiting xr
  126099. * @param _xrSessionManager The XR Session manager
  126100. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126101. */
  126102. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126103. /**
  126104. * Disposes of the object
  126105. */
  126106. dispose(): void;
  126107. /**
  126108. * Initializes the xr layer for the session
  126109. * @param xrSession xr session
  126110. * @returns a promise that will resolve once the XR Layer has been created
  126111. */
  126112. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126113. private _addCanvas;
  126114. private _removeCanvas;
  126115. private _setCanvasSize;
  126116. private _setManagedOutputCanvas;
  126117. }
  126118. }
  126119. declare module BABYLON {
  126120. /**
  126121. * Manages an XRSession to work with Babylon's engine
  126122. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126123. */
  126124. export class WebXRSessionManager implements IDisposable {
  126125. /** The scene which the session should be created for */
  126126. scene: Scene;
  126127. private _referenceSpace;
  126128. private _rttProvider;
  126129. private _sessionEnded;
  126130. private _xrNavigator;
  126131. private baseLayer;
  126132. /**
  126133. * The base reference space from which the session started. good if you want to reset your
  126134. * reference space
  126135. */
  126136. baseReferenceSpace: XRReferenceSpace;
  126137. /**
  126138. * Current XR frame
  126139. */
  126140. currentFrame: Nullable<XRFrame>;
  126141. /** WebXR timestamp updated every frame */
  126142. currentTimestamp: number;
  126143. /**
  126144. * Used just in case of a failure to initialize an immersive session.
  126145. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126146. */
  126147. defaultHeightCompensation: number;
  126148. /**
  126149. * Fires every time a new xrFrame arrives which can be used to update the camera
  126150. */
  126151. onXRFrameObservable: Observable<XRFrame>;
  126152. /**
  126153. * Fires when the reference space changed
  126154. */
  126155. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126156. /**
  126157. * Fires when the xr session is ended either by the device or manually done
  126158. */
  126159. onXRSessionEnded: Observable<any>;
  126160. /**
  126161. * Fires when the xr session is ended either by the device or manually done
  126162. */
  126163. onXRSessionInit: Observable<XRSession>;
  126164. /**
  126165. * Underlying xr session
  126166. */
  126167. session: XRSession;
  126168. /**
  126169. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126170. * or get the offset the player is currently at.
  126171. */
  126172. viewerReferenceSpace: XRReferenceSpace;
  126173. /**
  126174. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126175. * @param scene The scene which the session should be created for
  126176. */
  126177. constructor(
  126178. /** The scene which the session should be created for */
  126179. scene: Scene);
  126180. /**
  126181. * The current reference space used in this session. This reference space can constantly change!
  126182. * It is mainly used to offset the camera's position.
  126183. */
  126184. get referenceSpace(): XRReferenceSpace;
  126185. /**
  126186. * Set a new reference space and triggers the observable
  126187. */
  126188. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  126189. /**
  126190. * Disposes of the session manager
  126191. */
  126192. dispose(): void;
  126193. /**
  126194. * Stops the xrSession and restores the render loop
  126195. * @returns Promise which resolves after it exits XR
  126196. */
  126197. exitXRAsync(): Promise<void>;
  126198. /**
  126199. * Gets the correct render target texture to be rendered this frame for this eye
  126200. * @param eye the eye for which to get the render target
  126201. * @returns the render target for the specified eye
  126202. */
  126203. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  126204. /**
  126205. * Creates a WebXRRenderTarget object for the XR session
  126206. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  126207. * @param options optional options to provide when creating a new render target
  126208. * @returns a WebXR render target to which the session can render
  126209. */
  126210. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  126211. /**
  126212. * Initializes the manager
  126213. * After initialization enterXR can be called to start an XR session
  126214. * @returns Promise which resolves after it is initialized
  126215. */
  126216. initializeAsync(): Promise<void>;
  126217. /**
  126218. * Initializes an xr session
  126219. * @param xrSessionMode mode to initialize
  126220. * @param xrSessionInit defines optional and required values to pass to the session builder
  126221. * @returns a promise which will resolve once the session has been initialized
  126222. */
  126223. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  126224. /**
  126225. * Checks if a session would be supported for the creation options specified
  126226. * @param sessionMode session mode to check if supported eg. immersive-vr
  126227. * @returns A Promise that resolves to true if supported and false if not
  126228. */
  126229. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126230. /**
  126231. * Resets the reference space to the one started the session
  126232. */
  126233. resetReferenceSpace(): void;
  126234. /**
  126235. * Starts rendering to the xr layer
  126236. */
  126237. runXRRenderLoop(): void;
  126238. /**
  126239. * Sets the reference space on the xr session
  126240. * @param referenceSpaceType space to set
  126241. * @returns a promise that will resolve once the reference space has been set
  126242. */
  126243. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126244. /**
  126245. * Updates the render state of the session
  126246. * @param state state to set
  126247. * @returns a promise that resolves once the render state has been updated
  126248. */
  126249. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  126250. /**
  126251. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  126252. * @param sessionMode defines the session to test
  126253. * @returns a promise with boolean as final value
  126254. */
  126255. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126256. private _createRenderTargetTexture;
  126257. }
  126258. }
  126259. declare module BABYLON {
  126260. /**
  126261. * WebXR Camera which holds the views for the xrSession
  126262. * @see https://doc.babylonjs.com/how_to/webxr_camera
  126263. */
  126264. export class WebXRCamera extends FreeCamera {
  126265. private _xrSessionManager;
  126266. private _firstFrame;
  126267. private _referenceQuaternion;
  126268. private _referencedPosition;
  126269. private _xrInvPositionCache;
  126270. private _xrInvQuaternionCache;
  126271. /**
  126272. * Observable raised before camera teleportation
  126273. */
  126274. onBeforeCameraTeleport: Observable<Vector3>;
  126275. /**
  126276. * Observable raised after camera teleportation
  126277. */
  126278. onAfterCameraTeleport: Observable<Vector3>;
  126279. /**
  126280. * Should position compensation execute on first frame.
  126281. * This is used when copying the position from a native (non XR) camera
  126282. */
  126283. compensateOnFirstFrame: boolean;
  126284. /**
  126285. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  126286. * @param name the name of the camera
  126287. * @param scene the scene to add the camera to
  126288. * @param _xrSessionManager a constructed xr session manager
  126289. */
  126290. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  126291. /**
  126292. * Return the user's height, unrelated to the current ground.
  126293. * This will be the y position of this camera, when ground level is 0.
  126294. */
  126295. get realWorldHeight(): number;
  126296. /** @hidden */
  126297. _updateForDualEyeDebugging(): void;
  126298. /**
  126299. * Sets this camera's transformation based on a non-vr camera
  126300. * @param otherCamera the non-vr camera to copy the transformation from
  126301. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  126302. */
  126303. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  126304. /**
  126305. * Gets the current instance class name ("WebXRCamera").
  126306. * @returns the class name
  126307. */
  126308. getClassName(): string;
  126309. private _rotate180;
  126310. private _updateFromXRSession;
  126311. private _updateNumberOfRigCameras;
  126312. private _updateReferenceSpace;
  126313. private _updateReferenceSpaceOffset;
  126314. }
  126315. }
  126316. declare module BABYLON {
  126317. /**
  126318. * Defining the interface required for a (webxr) feature
  126319. */
  126320. export interface IWebXRFeature extends IDisposable {
  126321. /**
  126322. * Is this feature attached
  126323. */
  126324. attached: boolean;
  126325. /**
  126326. * Should auto-attach be disabled?
  126327. */
  126328. disableAutoAttach: boolean;
  126329. /**
  126330. * Attach the feature to the session
  126331. * Will usually be called by the features manager
  126332. *
  126333. * @param force should attachment be forced (even when already attached)
  126334. * @returns true if successful.
  126335. */
  126336. attach(force?: boolean): boolean;
  126337. /**
  126338. * Detach the feature from the session
  126339. * Will usually be called by the features manager
  126340. *
  126341. * @returns true if successful.
  126342. */
  126343. detach(): boolean;
  126344. /**
  126345. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126346. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126347. *
  126348. * @returns whether or not the feature is compatible in this environment
  126349. */
  126350. isCompatible(): boolean;
  126351. /**
  126352. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  126353. */
  126354. xrNativeFeatureName?: string;
  126355. }
  126356. /**
  126357. * A list of the currently available features without referencing them
  126358. */
  126359. export class WebXRFeatureName {
  126360. /**
  126361. * The name of the anchor system feature
  126362. */
  126363. static ANCHOR_SYSTEM: string;
  126364. /**
  126365. * The name of the background remover feature
  126366. */
  126367. static BACKGROUND_REMOVER: string;
  126368. /**
  126369. * The name of the hit test feature
  126370. */
  126371. static HIT_TEST: string;
  126372. /**
  126373. * physics impostors for xr controllers feature
  126374. */
  126375. static PHYSICS_CONTROLLERS: string;
  126376. /**
  126377. * The name of the plane detection feature
  126378. */
  126379. static PLANE_DETECTION: string;
  126380. /**
  126381. * The name of the pointer selection feature
  126382. */
  126383. static POINTER_SELECTION: string;
  126384. /**
  126385. * The name of the teleportation feature
  126386. */
  126387. static TELEPORTATION: string;
  126388. }
  126389. /**
  126390. * Defining the constructor of a feature. Used to register the modules.
  126391. */
  126392. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126393. /**
  126394. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126395. * It is mainly used in AR sessions.
  126396. *
  126397. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126398. */
  126399. export class WebXRFeaturesManager implements IDisposable {
  126400. private _xrSessionManager;
  126401. private static readonly _AvailableFeatures;
  126402. private _features;
  126403. /**
  126404. * constructs a new features manages.
  126405. *
  126406. * @param _xrSessionManager an instance of WebXRSessionManager
  126407. */
  126408. constructor(_xrSessionManager: WebXRSessionManager);
  126409. /**
  126410. * Used to register a module. After calling this function a developer can use this feature in the scene.
  126411. * Mainly used internally.
  126412. *
  126413. * @param featureName the name of the feature to register
  126414. * @param constructorFunction the function used to construct the module
  126415. * @param version the (babylon) version of the module
  126416. * @param stable is that a stable version of this module
  126417. */
  126418. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  126419. /**
  126420. * Returns a constructor of a specific feature.
  126421. *
  126422. * @param featureName the name of the feature to construct
  126423. * @param version the version of the feature to load
  126424. * @param xrSessionManager the xrSessionManager. Used to construct the module
  126425. * @param options optional options provided to the module.
  126426. * @returns a function that, when called, will return a new instance of this feature
  126427. */
  126428. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  126429. /**
  126430. * Can be used to return the list of features currently registered
  126431. *
  126432. * @returns an Array of available features
  126433. */
  126434. static GetAvailableFeatures(): string[];
  126435. /**
  126436. * Gets the versions available for a specific feature
  126437. * @param featureName the name of the feature
  126438. * @returns an array with the available versions
  126439. */
  126440. static GetAvailableVersions(featureName: string): string[];
  126441. /**
  126442. * Return the latest unstable version of this feature
  126443. * @param featureName the name of the feature to search
  126444. * @returns the version number. if not found will return -1
  126445. */
  126446. static GetLatestVersionOfFeature(featureName: string): number;
  126447. /**
  126448. * Return the latest stable version of this feature
  126449. * @param featureName the name of the feature to search
  126450. * @returns the version number. if not found will return -1
  126451. */
  126452. static GetStableVersionOfFeature(featureName: string): number;
  126453. /**
  126454. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  126455. * Can be used during a session to start a feature
  126456. * @param featureName the name of feature to attach
  126457. */
  126458. attachFeature(featureName: string): void;
  126459. /**
  126460. * Can be used inside a session or when the session ends to detach a specific feature
  126461. * @param featureName the name of the feature to detach
  126462. */
  126463. detachFeature(featureName: string): void;
  126464. /**
  126465. * Used to disable an already-enabled feature
  126466. * The feature will be disposed and will be recreated once enabled.
  126467. * @param featureName the feature to disable
  126468. * @returns true if disable was successful
  126469. */
  126470. disableFeature(featureName: string | {
  126471. Name: string;
  126472. }): boolean;
  126473. /**
  126474. * dispose this features manager
  126475. */
  126476. dispose(): void;
  126477. /**
  126478. * 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.
  126479. * 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.
  126480. *
  126481. * @param featureName the name of the feature to load or the class of the feature
  126482. * @param version optional version to load. if not provided the latest version will be enabled
  126483. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  126484. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  126485. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  126486. * @returns a new constructed feature or throws an error if feature not found.
  126487. */
  126488. enableFeature(featureName: string | {
  126489. Name: string;
  126490. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  126491. /**
  126492. * get the implementation of an enabled feature.
  126493. * @param featureName the name of the feature to load
  126494. * @returns the feature class, if found
  126495. */
  126496. getEnabledFeature(featureName: string): IWebXRFeature;
  126497. /**
  126498. * Get the list of enabled features
  126499. * @returns an array of enabled features
  126500. */
  126501. getEnabledFeatures(): string[];
  126502. /**
  126503. * This function will exten the session creation configuration object with enabled features.
  126504. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  126505. * according to the defined "required" variable, provided during enableFeature call
  126506. * @param xrSessionInit the xr Session init object to extend
  126507. *
  126508. * @returns an extended XRSessionInit object
  126509. */
  126510. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  126511. }
  126512. }
  126513. declare module BABYLON {
  126514. /**
  126515. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  126516. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  126517. */
  126518. export class WebXRExperienceHelper implements IDisposable {
  126519. private scene;
  126520. private _nonVRCamera;
  126521. private _originalSceneAutoClear;
  126522. private _supported;
  126523. /**
  126524. * Camera used to render xr content
  126525. */
  126526. camera: WebXRCamera;
  126527. /** A features manager for this xr session */
  126528. featuresManager: WebXRFeaturesManager;
  126529. /**
  126530. * Observers registered here will be triggered after the camera's initial transformation is set
  126531. * This can be used to set a different ground level or an extra rotation.
  126532. *
  126533. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  126534. * to the position set after this observable is done executing.
  126535. */
  126536. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  126537. /**
  126538. * Fires when the state of the experience helper has changed
  126539. */
  126540. onStateChangedObservable: Observable<WebXRState>;
  126541. /** Session manager used to keep track of xr session */
  126542. sessionManager: WebXRSessionManager;
  126543. /**
  126544. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  126545. */
  126546. state: WebXRState;
  126547. /**
  126548. * Creates a WebXRExperienceHelper
  126549. * @param scene The scene the helper should be created in
  126550. */
  126551. private constructor();
  126552. /**
  126553. * Creates the experience helper
  126554. * @param scene the scene to attach the experience helper to
  126555. * @returns a promise for the experience helper
  126556. */
  126557. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  126558. /**
  126559. * Disposes of the experience helper
  126560. */
  126561. dispose(): void;
  126562. /**
  126563. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  126564. * @param sessionMode options for the XR session
  126565. * @param referenceSpaceType frame of reference of the XR session
  126566. * @param renderTarget the output canvas that will be used to enter XR mode
  126567. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  126568. * @returns promise that resolves after xr mode has entered
  126569. */
  126570. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  126571. /**
  126572. * Exits XR mode and returns the scene to its original state
  126573. * @returns promise that resolves after xr mode has exited
  126574. */
  126575. exitXRAsync(): Promise<void>;
  126576. private _nonXRToXRCamera;
  126577. private _setState;
  126578. }
  126579. }
  126580. declare module BABYLON {
  126581. /**
  126582. * X-Y values for axes in WebXR
  126583. */
  126584. export interface IWebXRMotionControllerAxesValue {
  126585. /**
  126586. * The value of the x axis
  126587. */
  126588. x: number;
  126589. /**
  126590. * The value of the y-axis
  126591. */
  126592. y: number;
  126593. }
  126594. /**
  126595. * changed / previous values for the values of this component
  126596. */
  126597. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126598. /**
  126599. * current (this frame) value
  126600. */
  126601. current: T;
  126602. /**
  126603. * previous (last change) value
  126604. */
  126605. previous: T;
  126606. }
  126607. /**
  126608. * Represents changes in the component between current frame and last values recorded
  126609. */
  126610. export interface IWebXRMotionControllerComponentChanges {
  126611. /**
  126612. * will be populated with previous and current values if axes changed
  126613. */
  126614. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126615. /**
  126616. * will be populated with previous and current values if pressed changed
  126617. */
  126618. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126619. /**
  126620. * will be populated with previous and current values if touched changed
  126621. */
  126622. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126623. /**
  126624. * will be populated with previous and current values if value changed
  126625. */
  126626. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126627. }
  126628. /**
  126629. * This class represents a single component (for example button or thumbstick) of a motion controller
  126630. */
  126631. export class WebXRControllerComponent implements IDisposable {
  126632. /**
  126633. * the id of this component
  126634. */
  126635. id: string;
  126636. /**
  126637. * the type of the component
  126638. */
  126639. type: MotionControllerComponentType;
  126640. private _buttonIndex;
  126641. private _axesIndices;
  126642. private _axes;
  126643. private _changes;
  126644. private _currentValue;
  126645. private _hasChanges;
  126646. private _pressed;
  126647. private _touched;
  126648. /**
  126649. * button component type
  126650. */
  126651. static BUTTON_TYPE: MotionControllerComponentType;
  126652. /**
  126653. * squeeze component type
  126654. */
  126655. static SQUEEZE_TYPE: MotionControllerComponentType;
  126656. /**
  126657. * Thumbstick component type
  126658. */
  126659. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126660. /**
  126661. * Touchpad component type
  126662. */
  126663. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126664. /**
  126665. * trigger component type
  126666. */
  126667. static TRIGGER_TYPE: MotionControllerComponentType;
  126668. /**
  126669. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126670. * the axes data changes
  126671. */
  126672. onAxisValueChangedObservable: Observable<{
  126673. x: number;
  126674. y: number;
  126675. }>;
  126676. /**
  126677. * Observers registered here will be triggered when the state of a button changes
  126678. * State change is either pressed / touched / value
  126679. */
  126680. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126681. /**
  126682. * Creates a new component for a motion controller.
  126683. * It is created by the motion controller itself
  126684. *
  126685. * @param id the id of this component
  126686. * @param type the type of the component
  126687. * @param _buttonIndex index in the buttons array of the gamepad
  126688. * @param _axesIndices indices of the values in the axes array of the gamepad
  126689. */
  126690. constructor(
  126691. /**
  126692. * the id of this component
  126693. */
  126694. id: string,
  126695. /**
  126696. * the type of the component
  126697. */
  126698. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126699. /**
  126700. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126701. */
  126702. get axes(): IWebXRMotionControllerAxesValue;
  126703. /**
  126704. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126705. */
  126706. get changes(): IWebXRMotionControllerComponentChanges;
  126707. /**
  126708. * Return whether or not the component changed the last frame
  126709. */
  126710. get hasChanges(): boolean;
  126711. /**
  126712. * is the button currently pressed
  126713. */
  126714. get pressed(): boolean;
  126715. /**
  126716. * is the button currently touched
  126717. */
  126718. get touched(): boolean;
  126719. /**
  126720. * Get the current value of this component
  126721. */
  126722. get value(): number;
  126723. /**
  126724. * Dispose this component
  126725. */
  126726. dispose(): void;
  126727. /**
  126728. * Are there axes correlating to this component
  126729. * @return true is axes data is available
  126730. */
  126731. isAxes(): boolean;
  126732. /**
  126733. * Is this component a button (hence - pressable)
  126734. * @returns true if can be pressed
  126735. */
  126736. isButton(): boolean;
  126737. /**
  126738. * update this component using the gamepad object it is in. Called on every frame
  126739. * @param nativeController the native gamepad controller object
  126740. */
  126741. update(nativeController: IMinimalMotionControllerObject): void;
  126742. }
  126743. }
  126744. declare module BABYLON {
  126745. /**
  126746. * Interface used to represent data loading progression
  126747. */
  126748. export interface ISceneLoaderProgressEvent {
  126749. /**
  126750. * Defines if data length to load can be evaluated
  126751. */
  126752. readonly lengthComputable: boolean;
  126753. /**
  126754. * Defines the loaded data length
  126755. */
  126756. readonly loaded: number;
  126757. /**
  126758. * Defines the data length to load
  126759. */
  126760. readonly total: number;
  126761. }
  126762. /**
  126763. * Interface used by SceneLoader plugins to define supported file extensions
  126764. */
  126765. export interface ISceneLoaderPluginExtensions {
  126766. /**
  126767. * Defines the list of supported extensions
  126768. */
  126769. [extension: string]: {
  126770. isBinary: boolean;
  126771. };
  126772. }
  126773. /**
  126774. * Interface used by SceneLoader plugin factory
  126775. */
  126776. export interface ISceneLoaderPluginFactory {
  126777. /**
  126778. * Defines the name of the factory
  126779. */
  126780. name: string;
  126781. /**
  126782. * Function called to create a new plugin
  126783. * @return the new plugin
  126784. */
  126785. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126786. /**
  126787. * The callback that returns true if the data can be directly loaded.
  126788. * @param data string containing the file data
  126789. * @returns if the data can be loaded directly
  126790. */
  126791. canDirectLoad?(data: string): boolean;
  126792. }
  126793. /**
  126794. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126795. */
  126796. export interface ISceneLoaderPluginBase {
  126797. /**
  126798. * The friendly name of this plugin.
  126799. */
  126800. name: string;
  126801. /**
  126802. * The file extensions supported by this plugin.
  126803. */
  126804. extensions: string | ISceneLoaderPluginExtensions;
  126805. /**
  126806. * The callback called when loading from a url.
  126807. * @param scene scene loading this url
  126808. * @param url url to load
  126809. * @param onSuccess callback called when the file successfully loads
  126810. * @param onProgress callback called while file is loading (if the server supports this mode)
  126811. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126812. * @param onError callback called when the file fails to load
  126813. * @returns a file request object
  126814. */
  126815. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126816. /**
  126817. * The callback called when loading from a file object.
  126818. * @param scene scene loading this file
  126819. * @param file defines the file to load
  126820. * @param onSuccess defines the callback to call when data is loaded
  126821. * @param onProgress defines the callback to call during loading process
  126822. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126823. * @param onError defines the callback to call when an error occurs
  126824. * @returns a file request object
  126825. */
  126826. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126827. /**
  126828. * The callback that returns true if the data can be directly loaded.
  126829. * @param data string containing the file data
  126830. * @returns if the data can be loaded directly
  126831. */
  126832. canDirectLoad?(data: string): boolean;
  126833. /**
  126834. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126835. * @param scene scene loading this data
  126836. * @param data string containing the data
  126837. * @returns data to pass to the plugin
  126838. */
  126839. directLoad?(scene: Scene, data: string): any;
  126840. /**
  126841. * The callback that allows custom handling of the root url based on the response url.
  126842. * @param rootUrl the original root url
  126843. * @param responseURL the response url if available
  126844. * @returns the new root url
  126845. */
  126846. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126847. }
  126848. /**
  126849. * Interface used to define a SceneLoader plugin
  126850. */
  126851. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126852. /**
  126853. * Import meshes into a scene.
  126854. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126855. * @param scene The scene to import into
  126856. * @param data The data to import
  126857. * @param rootUrl The root url for scene and resources
  126858. * @param meshes The meshes array to import into
  126859. * @param particleSystems The particle systems array to import into
  126860. * @param skeletons The skeletons array to import into
  126861. * @param onError The callback when import fails
  126862. * @returns True if successful or false otherwise
  126863. */
  126864. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126865. /**
  126866. * Load into a scene.
  126867. * @param scene The scene to load into
  126868. * @param data The data to import
  126869. * @param rootUrl The root url for scene and resources
  126870. * @param onError The callback when import fails
  126871. * @returns True if successful or false otherwise
  126872. */
  126873. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126874. /**
  126875. * Load into an asset container.
  126876. * @param scene The scene to load into
  126877. * @param data The data to import
  126878. * @param rootUrl The root url for scene and resources
  126879. * @param onError The callback when import fails
  126880. * @returns The loaded asset container
  126881. */
  126882. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126883. }
  126884. /**
  126885. * Interface used to define an async SceneLoader plugin
  126886. */
  126887. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126888. /**
  126889. * Import meshes into a scene.
  126890. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126891. * @param scene The scene to import into
  126892. * @param data The data to import
  126893. * @param rootUrl The root url for scene and resources
  126894. * @param onProgress The callback when the load progresses
  126895. * @param fileName Defines the name of the file to load
  126896. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126897. */
  126898. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126899. meshes: AbstractMesh[];
  126900. particleSystems: IParticleSystem[];
  126901. skeletons: Skeleton[];
  126902. animationGroups: AnimationGroup[];
  126903. }>;
  126904. /**
  126905. * Load into a scene.
  126906. * @param scene The scene to load into
  126907. * @param data The data to import
  126908. * @param rootUrl The root url for scene and resources
  126909. * @param onProgress The callback when the load progresses
  126910. * @param fileName Defines the name of the file to load
  126911. * @returns Nothing
  126912. */
  126913. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126914. /**
  126915. * Load into an asset container.
  126916. * @param scene The scene to load into
  126917. * @param data The data to import
  126918. * @param rootUrl The root url for scene and resources
  126919. * @param onProgress The callback when the load progresses
  126920. * @param fileName Defines the name of the file to load
  126921. * @returns The loaded asset container
  126922. */
  126923. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126924. }
  126925. /**
  126926. * Mode that determines how to handle old animation groups before loading new ones.
  126927. */
  126928. export enum SceneLoaderAnimationGroupLoadingMode {
  126929. /**
  126930. * Reset all old animations to initial state then dispose them.
  126931. */
  126932. Clean = 0,
  126933. /**
  126934. * Stop all old animations.
  126935. */
  126936. Stop = 1,
  126937. /**
  126938. * Restart old animations from first frame.
  126939. */
  126940. Sync = 2,
  126941. /**
  126942. * Old animations remains untouched.
  126943. */
  126944. NoSync = 3
  126945. }
  126946. /**
  126947. * Defines a plugin registered by the SceneLoader
  126948. */
  126949. interface IRegisteredPlugin {
  126950. /**
  126951. * Defines the plugin to use
  126952. */
  126953. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126954. /**
  126955. * Defines if the plugin supports binary data
  126956. */
  126957. isBinary: boolean;
  126958. }
  126959. /**
  126960. * Class used to load scene from various file formats using registered plugins
  126961. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126962. */
  126963. export class SceneLoader {
  126964. /**
  126965. * No logging while loading
  126966. */
  126967. static readonly NO_LOGGING: number;
  126968. /**
  126969. * Minimal logging while loading
  126970. */
  126971. static readonly MINIMAL_LOGGING: number;
  126972. /**
  126973. * Summary logging while loading
  126974. */
  126975. static readonly SUMMARY_LOGGING: number;
  126976. /**
  126977. * Detailled logging while loading
  126978. */
  126979. static readonly DETAILED_LOGGING: number;
  126980. /**
  126981. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126982. */
  126983. static get ForceFullSceneLoadingForIncremental(): boolean;
  126984. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126985. /**
  126986. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126987. */
  126988. static get ShowLoadingScreen(): boolean;
  126989. static set ShowLoadingScreen(value: boolean);
  126990. /**
  126991. * Defines the current logging level (while loading the scene)
  126992. * @ignorenaming
  126993. */
  126994. static get loggingLevel(): number;
  126995. static set loggingLevel(value: number);
  126996. /**
  126997. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126998. */
  126999. static get CleanBoneMatrixWeights(): boolean;
  127000. static set CleanBoneMatrixWeights(value: boolean);
  127001. /**
  127002. * Event raised when a plugin is used to load a scene
  127003. */
  127004. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127005. private static _registeredPlugins;
  127006. private static _showingLoadingScreen;
  127007. /**
  127008. * Gets the default plugin (used to load Babylon files)
  127009. * @returns the .babylon plugin
  127010. */
  127011. static GetDefaultPlugin(): IRegisteredPlugin;
  127012. private static _GetPluginForExtension;
  127013. private static _GetPluginForDirectLoad;
  127014. private static _GetPluginForFilename;
  127015. private static _GetDirectLoad;
  127016. private static _LoadData;
  127017. private static _GetFileInfo;
  127018. /**
  127019. * Gets a plugin that can load the given extension
  127020. * @param extension defines the extension to load
  127021. * @returns a plugin or null if none works
  127022. */
  127023. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127024. /**
  127025. * Gets a boolean indicating that the given extension can be loaded
  127026. * @param extension defines the extension to load
  127027. * @returns true if the extension is supported
  127028. */
  127029. static IsPluginForExtensionAvailable(extension: string): boolean;
  127030. /**
  127031. * Adds a new plugin to the list of registered plugins
  127032. * @param plugin defines the plugin to add
  127033. */
  127034. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127035. /**
  127036. * Import meshes into a scene
  127037. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127038. * @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)
  127039. * @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)
  127040. * @param scene the instance of BABYLON.Scene to append to
  127041. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127042. * @param onProgress a callback with a progress event for each file being loaded
  127043. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127044. * @param pluginExtension the extension used to determine the plugin
  127045. * @returns The loaded plugin
  127046. */
  127047. 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>;
  127048. /**
  127049. * Import meshes into a scene
  127050. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127051. * @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)
  127052. * @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)
  127053. * @param scene the instance of BABYLON.Scene to append to
  127054. * @param onProgress a callback with a progress event for each file being loaded
  127055. * @param pluginExtension the extension used to determine the plugin
  127056. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127057. */
  127058. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127059. meshes: AbstractMesh[];
  127060. particleSystems: IParticleSystem[];
  127061. skeletons: Skeleton[];
  127062. animationGroups: AnimationGroup[];
  127063. }>;
  127064. /**
  127065. * Load a scene
  127066. * @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)
  127067. * @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)
  127068. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127069. * @param onSuccess a callback with the scene when import succeeds
  127070. * @param onProgress a callback with a progress event for each file being loaded
  127071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127072. * @param pluginExtension the extension used to determine the plugin
  127073. * @returns The loaded plugin
  127074. */
  127075. 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>;
  127076. /**
  127077. * Load a scene
  127078. * @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)
  127079. * @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)
  127080. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127081. * @param onProgress a callback with a progress event for each file being loaded
  127082. * @param pluginExtension the extension used to determine the plugin
  127083. * @returns The loaded scene
  127084. */
  127085. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127086. /**
  127087. * Append a scene
  127088. * @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)
  127089. * @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)
  127090. * @param scene is the instance of BABYLON.Scene to append to
  127091. * @param onSuccess a callback with the scene when import succeeds
  127092. * @param onProgress a callback with a progress event for each file being loaded
  127093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127094. * @param pluginExtension the extension used to determine the plugin
  127095. * @returns The loaded plugin
  127096. */
  127097. 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>;
  127098. /**
  127099. * Append a scene
  127100. * @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)
  127101. * @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)
  127102. * @param scene is the instance of BABYLON.Scene to append to
  127103. * @param onProgress a callback with a progress event for each file being loaded
  127104. * @param pluginExtension the extension used to determine the plugin
  127105. * @returns The given scene
  127106. */
  127107. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127108. /**
  127109. * Load a scene into an asset container
  127110. * @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)
  127111. * @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)
  127112. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127113. * @param onSuccess a callback with the scene when import succeeds
  127114. * @param onProgress a callback with a progress event for each file being loaded
  127115. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127116. * @param pluginExtension the extension used to determine the plugin
  127117. * @returns The loaded plugin
  127118. */
  127119. 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>;
  127120. /**
  127121. * Load a scene into an asset container
  127122. * @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)
  127123. * @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)
  127124. * @param scene is the instance of Scene to append to
  127125. * @param onProgress a callback with a progress event for each file being loaded
  127126. * @param pluginExtension the extension used to determine the plugin
  127127. * @returns The loaded asset container
  127128. */
  127129. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127130. /**
  127131. * Import animations from a file into a scene
  127132. * @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)
  127133. * @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)
  127134. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127135. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127136. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127137. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127138. * @param onSuccess a callback with the scene when import succeeds
  127139. * @param onProgress a callback with a progress event for each file being loaded
  127140. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127141. * @param pluginExtension the extension used to determine the plugin
  127142. */
  127143. 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;
  127144. /**
  127145. * Import animations from a file into a scene
  127146. * @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)
  127147. * @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)
  127148. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127149. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127150. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127151. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127152. * @param onSuccess a callback with the scene when import succeeds
  127153. * @param onProgress a callback with a progress event for each file being loaded
  127154. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127155. * @param pluginExtension the extension used to determine the plugin
  127156. * @returns the updated scene with imported animations
  127157. */
  127158. 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>;
  127159. }
  127160. }
  127161. declare module BABYLON {
  127162. /**
  127163. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  127164. */
  127165. export type MotionControllerHandedness = "none" | "left" | "right";
  127166. /**
  127167. * The type of components available in motion controllers.
  127168. * This is not the name of the component.
  127169. */
  127170. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  127171. /**
  127172. * The state of a controller component
  127173. */
  127174. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  127175. /**
  127176. * The schema of motion controller layout.
  127177. * No object will be initialized using this interface
  127178. * This is used just to define the profile.
  127179. */
  127180. export interface IMotionControllerLayout {
  127181. /**
  127182. * Path to load the assets. Usually relative to the base path
  127183. */
  127184. assetPath: string;
  127185. /**
  127186. * Available components (unsorted)
  127187. */
  127188. components: {
  127189. /**
  127190. * A map of component Ids
  127191. */
  127192. [componentId: string]: {
  127193. /**
  127194. * The type of input the component outputs
  127195. */
  127196. type: MotionControllerComponentType;
  127197. /**
  127198. * The indices of this component in the gamepad object
  127199. */
  127200. gamepadIndices: {
  127201. /**
  127202. * Index of button
  127203. */
  127204. button?: number;
  127205. /**
  127206. * If available, index of x-axis
  127207. */
  127208. xAxis?: number;
  127209. /**
  127210. * If available, index of y-axis
  127211. */
  127212. yAxis?: number;
  127213. };
  127214. /**
  127215. * The mesh's root node name
  127216. */
  127217. rootNodeName: string;
  127218. /**
  127219. * Animation definitions for this model
  127220. */
  127221. visualResponses: {
  127222. [stateKey: string]: {
  127223. /**
  127224. * What property will be animated
  127225. */
  127226. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  127227. /**
  127228. * What states influence this visual response
  127229. */
  127230. states: MotionControllerComponentStateType[];
  127231. /**
  127232. * Type of animation - movement or visibility
  127233. */
  127234. valueNodeProperty: "transform" | "visibility";
  127235. /**
  127236. * Base node name to move. Its position will be calculated according to the min and max nodes
  127237. */
  127238. valueNodeName?: string;
  127239. /**
  127240. * Minimum movement node
  127241. */
  127242. minNodeName?: string;
  127243. /**
  127244. * Max movement node
  127245. */
  127246. maxNodeName?: string;
  127247. };
  127248. };
  127249. /**
  127250. * If touch enabled, what is the name of node to display user feedback
  127251. */
  127252. touchPointNodeName?: string;
  127253. };
  127254. };
  127255. /**
  127256. * Is it xr standard mapping or not
  127257. */
  127258. gamepadMapping: "" | "xr-standard";
  127259. /**
  127260. * Base root node of this entire model
  127261. */
  127262. rootNodeName: string;
  127263. /**
  127264. * Defines the main button component id
  127265. */
  127266. selectComponentId: string;
  127267. }
  127268. /**
  127269. * A definition for the layout map in the input profile
  127270. */
  127271. export interface IMotionControllerLayoutMap {
  127272. /**
  127273. * Layouts with handedness type as a key
  127274. */
  127275. [handedness: string]: IMotionControllerLayout;
  127276. }
  127277. /**
  127278. * The XR Input profile schema
  127279. * Profiles can be found here:
  127280. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  127281. */
  127282. export interface IMotionControllerProfile {
  127283. /**
  127284. * fallback profiles for this profileId
  127285. */
  127286. fallbackProfileIds: string[];
  127287. /**
  127288. * The layout map, with handedness as key
  127289. */
  127290. layouts: IMotionControllerLayoutMap;
  127291. /**
  127292. * The id of this profile
  127293. * correlates to the profile(s) in the xrInput.profiles array
  127294. */
  127295. profileId: string;
  127296. }
  127297. /**
  127298. * A helper-interface for the 3 meshes needed for controller button animation
  127299. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  127300. */
  127301. export interface IMotionControllerButtonMeshMap {
  127302. /**
  127303. * the mesh that defines the pressed value mesh position.
  127304. * This is used to find the max-position of this button
  127305. */
  127306. pressedMesh: AbstractMesh;
  127307. /**
  127308. * the mesh that defines the unpressed value mesh position.
  127309. * This is used to find the min (or initial) position of this button
  127310. */
  127311. unpressedMesh: AbstractMesh;
  127312. /**
  127313. * The mesh that will be changed when value changes
  127314. */
  127315. valueMesh: AbstractMesh;
  127316. }
  127317. /**
  127318. * A helper-interface for the 3 meshes needed for controller axis animation.
  127319. * This will be expanded when touchpad animations are fully supported
  127320. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  127321. */
  127322. export interface IMotionControllerMeshMap {
  127323. /**
  127324. * the mesh that defines the maximum value mesh position.
  127325. */
  127326. maxMesh?: AbstractMesh;
  127327. /**
  127328. * the mesh that defines the minimum value mesh position.
  127329. */
  127330. minMesh?: AbstractMesh;
  127331. /**
  127332. * The mesh that will be changed when axis value changes
  127333. */
  127334. valueMesh: AbstractMesh;
  127335. }
  127336. /**
  127337. * The elements needed for change-detection of the gamepad objects in motion controllers
  127338. */
  127339. export interface IMinimalMotionControllerObject {
  127340. /**
  127341. * Available axes of this controller
  127342. */
  127343. axes: number[];
  127344. /**
  127345. * An array of available buttons
  127346. */
  127347. buttons: Array<{
  127348. /**
  127349. * Value of the button/trigger
  127350. */
  127351. value: number;
  127352. /**
  127353. * If the button/trigger is currently touched
  127354. */
  127355. touched: boolean;
  127356. /**
  127357. * If the button/trigger is currently pressed
  127358. */
  127359. pressed: boolean;
  127360. }>;
  127361. /**
  127362. * EXPERIMENTAL haptic support.
  127363. */
  127364. hapticActuators?: Array<{
  127365. pulse: (value: number, duration: number) => Promise<boolean>;
  127366. }>;
  127367. }
  127368. /**
  127369. * An Abstract Motion controller
  127370. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127371. * Each component has an observable to check for changes in value and state
  127372. */
  127373. export abstract class WebXRAbstractMotionController implements IDisposable {
  127374. protected scene: Scene;
  127375. protected layout: IMotionControllerLayout;
  127376. /**
  127377. * The gamepad object correlating to this controller
  127378. */
  127379. gamepadObject: IMinimalMotionControllerObject;
  127380. /**
  127381. * handedness (left/right/none) of this controller
  127382. */
  127383. handedness: MotionControllerHandedness;
  127384. private _initComponent;
  127385. private _modelReady;
  127386. /**
  127387. * A map of components (WebXRControllerComponent) in this motion controller
  127388. * Components have a ComponentType and can also have both button and axis definitions
  127389. */
  127390. readonly components: {
  127391. [id: string]: WebXRControllerComponent;
  127392. };
  127393. /**
  127394. * Disable the model's animation. Can be set at any time.
  127395. */
  127396. disableAnimation: boolean;
  127397. /**
  127398. * Observers registered here will be triggered when the model of this controller is done loading
  127399. */
  127400. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127401. /**
  127402. * The profile id of this motion controller
  127403. */
  127404. abstract profileId: string;
  127405. /**
  127406. * The root mesh of the model. It is null if the model was not yet initialized
  127407. */
  127408. rootMesh: Nullable<AbstractMesh>;
  127409. /**
  127410. * constructs a new abstract motion controller
  127411. * @param scene the scene to which the model of the controller will be added
  127412. * @param layout The profile layout to load
  127413. * @param gamepadObject The gamepad object correlating to this controller
  127414. * @param handedness handedness (left/right/none) of this controller
  127415. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  127416. */
  127417. constructor(scene: Scene, layout: IMotionControllerLayout,
  127418. /**
  127419. * The gamepad object correlating to this controller
  127420. */
  127421. gamepadObject: IMinimalMotionControllerObject,
  127422. /**
  127423. * handedness (left/right/none) of this controller
  127424. */
  127425. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  127426. /**
  127427. * Dispose this controller, the model mesh and all its components
  127428. */
  127429. dispose(): void;
  127430. /**
  127431. * Returns all components of specific type
  127432. * @param type the type to search for
  127433. * @return an array of components with this type
  127434. */
  127435. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  127436. /**
  127437. * get a component based an its component id as defined in layout.components
  127438. * @param id the id of the component
  127439. * @returns the component correlates to the id or undefined if not found
  127440. */
  127441. getComponent(id: string): WebXRControllerComponent;
  127442. /**
  127443. * Get the list of components available in this motion controller
  127444. * @returns an array of strings correlating to available components
  127445. */
  127446. getComponentIds(): string[];
  127447. /**
  127448. * Get the first component of specific type
  127449. * @param type type of component to find
  127450. * @return a controller component or null if not found
  127451. */
  127452. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  127453. /**
  127454. * Get the main (Select) component of this controller as defined in the layout
  127455. * @returns the main component of this controller
  127456. */
  127457. getMainComponent(): WebXRControllerComponent;
  127458. /**
  127459. * Loads the model correlating to this controller
  127460. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  127461. * @returns A promise fulfilled with the result of the model loading
  127462. */
  127463. loadModel(): Promise<boolean>;
  127464. /**
  127465. * Update this model using the current XRFrame
  127466. * @param xrFrame the current xr frame to use and update the model
  127467. */
  127468. updateFromXRFrame(xrFrame: XRFrame): void;
  127469. /**
  127470. * Backwards compatibility due to a deeply-integrated typo
  127471. */
  127472. get handness(): XREye;
  127473. /**
  127474. * Pulse (vibrate) this controller
  127475. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  127476. * Consecutive calls to this function will cancel the last pulse call
  127477. *
  127478. * @param value the strength of the pulse in 0.0...1.0 range
  127479. * @param duration Duration of the pulse in milliseconds
  127480. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  127481. * @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
  127482. */
  127483. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  127484. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127485. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127486. /**
  127487. * Moves the axis on the controller mesh based on its current state
  127488. * @param axis the index of the axis
  127489. * @param axisValue the value of the axis which determines the meshes new position
  127490. * @hidden
  127491. */
  127492. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  127493. /**
  127494. * Update the model itself with the current frame data
  127495. * @param xrFrame the frame to use for updating the model mesh
  127496. */
  127497. protected updateModel(xrFrame: XRFrame): void;
  127498. /**
  127499. * Get the filename and path for this controller's model
  127500. * @returns a map of filename and path
  127501. */
  127502. protected abstract _getFilenameAndPath(): {
  127503. filename: string;
  127504. path: string;
  127505. };
  127506. /**
  127507. * This function is called before the mesh is loaded. It checks for loading constraints.
  127508. * For example, this function can check if the GLB loader is available
  127509. * If this function returns false, the generic controller will be loaded instead
  127510. * @returns Is the client ready to load the mesh
  127511. */
  127512. protected abstract _getModelLoadingConstraints(): boolean;
  127513. /**
  127514. * This function will be called after the model was successfully loaded and can be used
  127515. * for mesh transformations before it is available for the user
  127516. * @param meshes the loaded meshes
  127517. */
  127518. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  127519. /**
  127520. * Set the root mesh for this controller. Important for the WebXR controller class
  127521. * @param meshes the loaded meshes
  127522. */
  127523. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  127524. /**
  127525. * A function executed each frame that updates the mesh (if needed)
  127526. * @param xrFrame the current xrFrame
  127527. */
  127528. protected abstract _updateModel(xrFrame: XRFrame): void;
  127529. private _getGenericFilenameAndPath;
  127530. private _getGenericParentMesh;
  127531. }
  127532. }
  127533. declare module BABYLON {
  127534. /**
  127535. * A generic trigger-only motion controller for WebXR
  127536. */
  127537. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  127538. /**
  127539. * Static version of the profile id of this controller
  127540. */
  127541. static ProfileId: string;
  127542. profileId: string;
  127543. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  127544. protected _getFilenameAndPath(): {
  127545. filename: string;
  127546. path: string;
  127547. };
  127548. protected _getModelLoadingConstraints(): boolean;
  127549. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  127550. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127551. protected _updateModel(): void;
  127552. }
  127553. }
  127554. declare module BABYLON {
  127555. /**
  127556. * Class containing static functions to help procedurally build meshes
  127557. */
  127558. export class SphereBuilder {
  127559. /**
  127560. * Creates a sphere mesh
  127561. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127562. * * 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`)
  127563. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127564. * * 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
  127565. * * 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)
  127566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127569. * @param name defines the name of the mesh
  127570. * @param options defines the options used to create the mesh
  127571. * @param scene defines the hosting scene
  127572. * @returns the sphere mesh
  127573. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127574. */
  127575. static CreateSphere(name: string, options: {
  127576. segments?: number;
  127577. diameter?: number;
  127578. diameterX?: number;
  127579. diameterY?: number;
  127580. diameterZ?: number;
  127581. arc?: number;
  127582. slice?: number;
  127583. sideOrientation?: number;
  127584. frontUVs?: Vector4;
  127585. backUVs?: Vector4;
  127586. updatable?: boolean;
  127587. }, scene?: Nullable<Scene>): Mesh;
  127588. }
  127589. }
  127590. declare module BABYLON {
  127591. /**
  127592. * A profiled motion controller has its profile loaded from an online repository.
  127593. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127594. */
  127595. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127596. private _repositoryUrl;
  127597. private _buttonMeshMapping;
  127598. private _touchDots;
  127599. /**
  127600. * The profile ID of this controller. Will be populated when the controller initializes.
  127601. */
  127602. profileId: string;
  127603. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127604. dispose(): void;
  127605. protected _getFilenameAndPath(): {
  127606. filename: string;
  127607. path: string;
  127608. };
  127609. protected _getModelLoadingConstraints(): boolean;
  127610. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127611. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127612. protected _updateModel(_xrFrame: XRFrame): void;
  127613. }
  127614. }
  127615. declare module BABYLON {
  127616. /**
  127617. * A construction function type to create a new controller based on an xrInput object
  127618. */
  127619. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127620. /**
  127621. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127622. *
  127623. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127624. * it should be replaced with auto-loaded controllers.
  127625. *
  127626. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127627. */
  127628. export class WebXRMotionControllerManager {
  127629. private static _AvailableControllers;
  127630. private static _Fallbacks;
  127631. private static _ProfileLoadingPromises;
  127632. private static _ProfilesList;
  127633. /**
  127634. * The base URL of the online controller repository. Can be changed at any time.
  127635. */
  127636. static BaseRepositoryUrl: string;
  127637. /**
  127638. * Which repository gets priority - local or online
  127639. */
  127640. static PrioritizeOnlineRepository: boolean;
  127641. /**
  127642. * Use the online repository, or use only locally-defined controllers
  127643. */
  127644. static UseOnlineRepository: boolean;
  127645. /**
  127646. * Clear the cache used for profile loading and reload when requested again
  127647. */
  127648. static ClearProfilesCache(): void;
  127649. /**
  127650. * Register the default fallbacks.
  127651. * This function is called automatically when this file is imported.
  127652. */
  127653. static DefaultFallbacks(): void;
  127654. /**
  127655. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127656. * @param profileId the profile to which a fallback needs to be found
  127657. * @return an array with corresponding fallback profiles
  127658. */
  127659. static FindFallbackWithProfileId(profileId: string): string[];
  127660. /**
  127661. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127662. * The order of search:
  127663. *
  127664. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127665. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127666. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127667. * 4) return the generic trigger controller if none were found
  127668. *
  127669. * @param xrInput the xrInput to which a new controller is initialized
  127670. * @param scene the scene to which the model will be added
  127671. * @param forceProfile force a certain profile for this controller
  127672. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127673. */
  127674. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127675. /**
  127676. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127677. *
  127678. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127679. *
  127680. * @param type the profile type to register
  127681. * @param constructFunction the function to be called when loading this profile
  127682. */
  127683. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127684. /**
  127685. * Register a fallback to a specific profile.
  127686. * @param profileId the profileId that will receive the fallbacks
  127687. * @param fallbacks A list of fallback profiles
  127688. */
  127689. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127690. /**
  127691. * Will update the list of profiles available in the repository
  127692. * @return a promise that resolves to a map of profiles available online
  127693. */
  127694. static UpdateProfilesList(): Promise<{
  127695. [profile: string]: string;
  127696. }>;
  127697. private static _LoadProfileFromRepository;
  127698. private static _LoadProfilesFromAvailableControllers;
  127699. }
  127700. }
  127701. declare module BABYLON {
  127702. /**
  127703. * Configuration options for the WebXR controller creation
  127704. */
  127705. export interface IWebXRControllerOptions {
  127706. /**
  127707. * Should the controller mesh be animated when a user interacts with it
  127708. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127709. */
  127710. disableMotionControllerAnimation?: boolean;
  127711. /**
  127712. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127713. */
  127714. doNotLoadControllerMesh?: boolean;
  127715. /**
  127716. * Force a specific controller type for this controller.
  127717. * This can be used when creating your own profile or when testing different controllers
  127718. */
  127719. forceControllerProfile?: string;
  127720. /**
  127721. * Defines a rendering group ID for meshes that will be loaded.
  127722. * This is for the default controllers only.
  127723. */
  127724. renderingGroupId?: number;
  127725. }
  127726. /**
  127727. * Represents an XR controller
  127728. */
  127729. export class WebXRInputSource {
  127730. private _scene;
  127731. /** The underlying input source for the controller */
  127732. inputSource: XRInputSource;
  127733. private _options;
  127734. private _tmpVector;
  127735. private _uniqueId;
  127736. /**
  127737. * 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
  127738. */
  127739. grip?: AbstractMesh;
  127740. /**
  127741. * If available, this is the gamepad object related to this controller.
  127742. * Using this object it is possible to get click events and trackpad changes of the
  127743. * webxr controller that is currently being used.
  127744. */
  127745. motionController?: WebXRAbstractMotionController;
  127746. /**
  127747. * Event that fires when the controller is removed/disposed.
  127748. * The object provided as event data is this controller, after associated assets were disposed.
  127749. * uniqueId is still available.
  127750. */
  127751. onDisposeObservable: Observable<WebXRInputSource>;
  127752. /**
  127753. * Will be triggered when the mesh associated with the motion controller is done loading.
  127754. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127755. * A shortened version of controller -> motion controller -> on mesh loaded.
  127756. */
  127757. onMeshLoadedObservable: Observable<AbstractMesh>;
  127758. /**
  127759. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127760. */
  127761. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127762. /**
  127763. * Pointer which can be used to select objects or attach a visible laser to
  127764. */
  127765. pointer: AbstractMesh;
  127766. /**
  127767. * Creates the input source object
  127768. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127769. * @param _scene the scene which the controller should be associated to
  127770. * @param inputSource the underlying input source for the controller
  127771. * @param _options options for this controller creation
  127772. */
  127773. constructor(_scene: Scene,
  127774. /** The underlying input source for the controller */
  127775. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127776. /**
  127777. * Get this controllers unique id
  127778. */
  127779. get uniqueId(): string;
  127780. /**
  127781. * Disposes of the object
  127782. */
  127783. dispose(): void;
  127784. /**
  127785. * Gets a world space ray coming from the pointer or grip
  127786. * @param result the resulting ray
  127787. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127788. */
  127789. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127790. /**
  127791. * Updates the controller pose based on the given XRFrame
  127792. * @param xrFrame xr frame to update the pose with
  127793. * @param referenceSpace reference space to use
  127794. */
  127795. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127796. }
  127797. }
  127798. declare module BABYLON {
  127799. /**
  127800. * The schema for initialization options of the XR Input class
  127801. */
  127802. export interface IWebXRInputOptions {
  127803. /**
  127804. * If set to true no model will be automatically loaded
  127805. */
  127806. doNotLoadControllerMeshes?: boolean;
  127807. /**
  127808. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127809. * If not found, the xr input profile data will be used.
  127810. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127811. */
  127812. forceInputProfile?: string;
  127813. /**
  127814. * Do not send a request to the controller repository to load the profile.
  127815. *
  127816. * Instead, use the controllers available in babylon itself.
  127817. */
  127818. disableOnlineControllerRepository?: boolean;
  127819. /**
  127820. * A custom URL for the controllers repository
  127821. */
  127822. customControllersRepositoryURL?: string;
  127823. /**
  127824. * Should the controller model's components not move according to the user input
  127825. */
  127826. disableControllerAnimation?: boolean;
  127827. /**
  127828. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127829. */
  127830. controllerOptions?: IWebXRControllerOptions;
  127831. }
  127832. /**
  127833. * XR input used to track XR inputs such as controllers/rays
  127834. */
  127835. export class WebXRInput implements IDisposable {
  127836. /**
  127837. * the xr session manager for this session
  127838. */
  127839. xrSessionManager: WebXRSessionManager;
  127840. /**
  127841. * the WebXR camera for this session. Mainly used for teleportation
  127842. */
  127843. xrCamera: WebXRCamera;
  127844. private readonly options;
  127845. /**
  127846. * XR controllers being tracked
  127847. */
  127848. controllers: Array<WebXRInputSource>;
  127849. private _frameObserver;
  127850. private _sessionEndedObserver;
  127851. private _sessionInitObserver;
  127852. /**
  127853. * Event when a controller has been connected/added
  127854. */
  127855. onControllerAddedObservable: Observable<WebXRInputSource>;
  127856. /**
  127857. * Event when a controller has been removed/disconnected
  127858. */
  127859. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127860. /**
  127861. * Initializes the WebXRInput
  127862. * @param xrSessionManager the xr session manager for this session
  127863. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127864. * @param options = initialization options for this xr input
  127865. */
  127866. constructor(
  127867. /**
  127868. * the xr session manager for this session
  127869. */
  127870. xrSessionManager: WebXRSessionManager,
  127871. /**
  127872. * the WebXR camera for this session. Mainly used for teleportation
  127873. */
  127874. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127875. private _onInputSourcesChange;
  127876. private _addAndRemoveControllers;
  127877. /**
  127878. * Disposes of the object
  127879. */
  127880. dispose(): void;
  127881. }
  127882. }
  127883. declare module BABYLON {
  127884. /**
  127885. * This is the base class for all WebXR features.
  127886. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127887. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127888. */
  127889. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127890. protected _xrSessionManager: WebXRSessionManager;
  127891. private _attached;
  127892. private _removeOnDetach;
  127893. /**
  127894. * Should auto-attach be disabled?
  127895. */
  127896. disableAutoAttach: boolean;
  127897. /**
  127898. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127899. */
  127900. xrNativeFeatureName: string;
  127901. /**
  127902. * Construct a new (abstract) WebXR feature
  127903. * @param _xrSessionManager the xr session manager for this feature
  127904. */
  127905. constructor(_xrSessionManager: WebXRSessionManager);
  127906. /**
  127907. * Is this feature attached
  127908. */
  127909. get attached(): boolean;
  127910. /**
  127911. * attach this feature
  127912. *
  127913. * @param force should attachment be forced (even when already attached)
  127914. * @returns true if successful, false is failed or already attached
  127915. */
  127916. attach(force?: boolean): boolean;
  127917. /**
  127918. * detach this feature.
  127919. *
  127920. * @returns true if successful, false if failed or already detached
  127921. */
  127922. detach(): boolean;
  127923. /**
  127924. * Dispose this feature and all of the resources attached
  127925. */
  127926. dispose(): void;
  127927. /**
  127928. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127929. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127930. *
  127931. * @returns whether or not the feature is compatible in this environment
  127932. */
  127933. isCompatible(): boolean;
  127934. /**
  127935. * This is used to register callbacks that will automatically be removed when detach is called.
  127936. * @param observable the observable to which the observer will be attached
  127937. * @param callback the callback to register
  127938. */
  127939. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127940. /**
  127941. * Code in this function will be executed on each xrFrame received from the browser.
  127942. * This function will not execute after the feature is detached.
  127943. * @param _xrFrame the current frame
  127944. */
  127945. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127946. }
  127947. }
  127948. declare module BABYLON {
  127949. /**
  127950. * Renders a layer on top of an existing scene
  127951. */
  127952. export class UtilityLayerRenderer implements IDisposable {
  127953. /** the original scene that will be rendered on top of */
  127954. originalScene: Scene;
  127955. private _pointerCaptures;
  127956. private _lastPointerEvents;
  127957. private static _DefaultUtilityLayer;
  127958. private static _DefaultKeepDepthUtilityLayer;
  127959. private _sharedGizmoLight;
  127960. private _renderCamera;
  127961. /**
  127962. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127963. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127964. * @returns the camera that is used when rendering the utility layer
  127965. */
  127966. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127967. /**
  127968. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127969. * @param cam the camera that should be used when rendering the utility layer
  127970. */
  127971. setRenderCamera(cam: Nullable<Camera>): void;
  127972. /**
  127973. * @hidden
  127974. * Light which used by gizmos to get light shading
  127975. */
  127976. _getSharedGizmoLight(): HemisphericLight;
  127977. /**
  127978. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127979. */
  127980. pickUtilitySceneFirst: boolean;
  127981. /**
  127982. * 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)
  127983. */
  127984. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127985. /**
  127986. * 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)
  127987. */
  127988. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127989. /**
  127990. * The scene that is rendered on top of the original scene
  127991. */
  127992. utilityLayerScene: Scene;
  127993. /**
  127994. * If the utility layer should automatically be rendered on top of existing scene
  127995. */
  127996. shouldRender: boolean;
  127997. /**
  127998. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127999. */
  128000. onlyCheckPointerDownEvents: boolean;
  128001. /**
  128002. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128003. */
  128004. processAllEvents: boolean;
  128005. /**
  128006. * Observable raised when the pointer move from the utility layer scene to the main scene
  128007. */
  128008. onPointerOutObservable: Observable<number>;
  128009. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128010. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128011. private _afterRenderObserver;
  128012. private _sceneDisposeObserver;
  128013. private _originalPointerObserver;
  128014. /**
  128015. * Instantiates a UtilityLayerRenderer
  128016. * @param originalScene the original scene that will be rendered on top of
  128017. * @param handleEvents boolean indicating if the utility layer should handle events
  128018. */
  128019. constructor(
  128020. /** the original scene that will be rendered on top of */
  128021. originalScene: Scene, handleEvents?: boolean);
  128022. private _notifyObservers;
  128023. /**
  128024. * Renders the utility layers scene on top of the original scene
  128025. */
  128026. render(): void;
  128027. /**
  128028. * Disposes of the renderer
  128029. */
  128030. dispose(): void;
  128031. private _updateCamera;
  128032. }
  128033. }
  128034. declare module BABYLON {
  128035. /**
  128036. * Options interface for the pointer selection module
  128037. */
  128038. export interface IWebXRControllerPointerSelectionOptions {
  128039. /**
  128040. * if provided, this scene will be used to render meshes.
  128041. */
  128042. customUtilityLayerScene?: Scene;
  128043. /**
  128044. * 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)
  128045. * If not disabled, the last picked point will be used to execute a pointer up event
  128046. * If disabled, pointer up event will be triggered right after the pointer down event.
  128047. * Used in screen and gaze target ray mode only
  128048. */
  128049. disablePointerUpOnTouchOut: boolean;
  128050. /**
  128051. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128052. */
  128053. forceGazeMode: boolean;
  128054. /**
  128055. * 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
  128056. * to start a new countdown to the pointer down event.
  128057. * Defaults to 1.
  128058. */
  128059. gazeModePointerMovedFactor?: number;
  128060. /**
  128061. * Different button type to use instead of the main component
  128062. */
  128063. overrideButtonId?: string;
  128064. /**
  128065. * use this rendering group id for the meshes (optional)
  128066. */
  128067. renderingGroupId?: number;
  128068. /**
  128069. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128070. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128071. * 3000 means 3 seconds between pointing at something and selecting it
  128072. */
  128073. timeToSelect?: number;
  128074. /**
  128075. * Should meshes created here be added to a utility layer or the main scene
  128076. */
  128077. useUtilityLayer?: boolean;
  128078. /**
  128079. * Optional WebXR camera to be used for gaze selection
  128080. */
  128081. gazeCamera?: WebXRCamera;
  128082. /**
  128083. * the xr input to use with this pointer selection
  128084. */
  128085. xrInput: WebXRInput;
  128086. }
  128087. /**
  128088. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128089. */
  128090. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128091. private readonly _options;
  128092. private static _idCounter;
  128093. private _attachController;
  128094. private _controllers;
  128095. private _scene;
  128096. private _tmpVectorForPickCompare;
  128097. /**
  128098. * The module's name
  128099. */
  128100. static readonly Name: string;
  128101. /**
  128102. * The (Babylon) version of this module.
  128103. * This is an integer representing the implementation version.
  128104. * This number does not correspond to the WebXR specs version
  128105. */
  128106. static readonly Version: number;
  128107. /**
  128108. * Disable lighting on the laser pointer (so it will always be visible)
  128109. */
  128110. disablePointerLighting: boolean;
  128111. /**
  128112. * Disable lighting on the selection mesh (so it will always be visible)
  128113. */
  128114. disableSelectionMeshLighting: boolean;
  128115. /**
  128116. * Should the laser pointer be displayed
  128117. */
  128118. displayLaserPointer: boolean;
  128119. /**
  128120. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128121. */
  128122. displaySelectionMesh: boolean;
  128123. /**
  128124. * This color will be set to the laser pointer when selection is triggered
  128125. */
  128126. laserPointerPickedColor: Color3;
  128127. /**
  128128. * Default color of the laser pointer
  128129. */
  128130. laserPointerDefaultColor: Color3;
  128131. /**
  128132. * default color of the selection ring
  128133. */
  128134. selectionMeshDefaultColor: Color3;
  128135. /**
  128136. * This color will be applied to the selection ring when selection is triggered
  128137. */
  128138. selectionMeshPickedColor: Color3;
  128139. /**
  128140. * Optional filter to be used for ray selection. This predicate shares behavior with
  128141. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128142. */
  128143. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128144. /**
  128145. * constructs a new background remover module
  128146. * @param _xrSessionManager the session manager for this module
  128147. * @param _options read-only options to be used in this module
  128148. */
  128149. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128150. /**
  128151. * attach this feature
  128152. * Will usually be called by the features manager
  128153. *
  128154. * @returns true if successful.
  128155. */
  128156. attach(): boolean;
  128157. /**
  128158. * detach this feature.
  128159. * Will usually be called by the features manager
  128160. *
  128161. * @returns true if successful.
  128162. */
  128163. detach(): boolean;
  128164. /**
  128165. * Will get the mesh under a specific pointer.
  128166. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  128167. * @param controllerId the controllerId to check
  128168. * @returns The mesh under pointer or null if no mesh is under the pointer
  128169. */
  128170. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  128171. /**
  128172. * Get the xr controller that correlates to the pointer id in the pointer event
  128173. *
  128174. * @param id the pointer id to search for
  128175. * @returns the controller that correlates to this id or null if not found
  128176. */
  128177. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  128178. protected _onXRFrame(_xrFrame: XRFrame): void;
  128179. private _attachGazeMode;
  128180. private _attachScreenRayMode;
  128181. private _attachTrackedPointerRayMode;
  128182. private _convertNormalToDirectionOfRay;
  128183. private _detachController;
  128184. private _generateNewMeshPair;
  128185. private _pickingMoved;
  128186. private _updatePointerDistance;
  128187. /** @hidden */
  128188. get lasterPointerDefaultColor(): Color3;
  128189. }
  128190. }
  128191. declare module BABYLON {
  128192. /**
  128193. * Button which can be used to enter a different mode of XR
  128194. */
  128195. export class WebXREnterExitUIButton {
  128196. /** button element */
  128197. element: HTMLElement;
  128198. /** XR initialization options for the button */
  128199. sessionMode: XRSessionMode;
  128200. /** Reference space type */
  128201. referenceSpaceType: XRReferenceSpaceType;
  128202. /**
  128203. * Creates a WebXREnterExitUIButton
  128204. * @param element button element
  128205. * @param sessionMode XR initialization session mode
  128206. * @param referenceSpaceType the type of reference space to be used
  128207. */
  128208. constructor(
  128209. /** button element */
  128210. element: HTMLElement,
  128211. /** XR initialization options for the button */
  128212. sessionMode: XRSessionMode,
  128213. /** Reference space type */
  128214. referenceSpaceType: XRReferenceSpaceType);
  128215. /**
  128216. * Extendable function which can be used to update the button's visuals when the state changes
  128217. * @param activeButton the current active button in the UI
  128218. */
  128219. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  128220. }
  128221. /**
  128222. * Options to create the webXR UI
  128223. */
  128224. export class WebXREnterExitUIOptions {
  128225. /**
  128226. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  128227. */
  128228. customButtons?: Array<WebXREnterExitUIButton>;
  128229. /**
  128230. * A reference space type to use when creating the default button.
  128231. * Default is local-floor
  128232. */
  128233. referenceSpaceType?: XRReferenceSpaceType;
  128234. /**
  128235. * Context to enter xr with
  128236. */
  128237. renderTarget?: Nullable<WebXRRenderTarget>;
  128238. /**
  128239. * A session mode to use when creating the default button.
  128240. * Default is immersive-vr
  128241. */
  128242. sessionMode?: XRSessionMode;
  128243. /**
  128244. * A list of optional features to init the session with
  128245. */
  128246. optionalFeatures?: string[];
  128247. /**
  128248. * A list of optional features to init the session with
  128249. */
  128250. requiredFeatures?: string[];
  128251. }
  128252. /**
  128253. * UI to allow the user to enter/exit XR mode
  128254. */
  128255. export class WebXREnterExitUI implements IDisposable {
  128256. private scene;
  128257. /** version of the options passed to this UI */
  128258. options: WebXREnterExitUIOptions;
  128259. private _activeButton;
  128260. private _buttons;
  128261. private _overlay;
  128262. /**
  128263. * Fired every time the active button is changed.
  128264. *
  128265. * When xr is entered via a button that launches xr that button will be the callback parameter
  128266. *
  128267. * When exiting xr the callback parameter will be null)
  128268. */
  128269. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  128270. /**
  128271. *
  128272. * @param scene babylon scene object to use
  128273. * @param options (read-only) version of the options passed to this UI
  128274. */
  128275. private constructor();
  128276. /**
  128277. * Creates UI to allow the user to enter/exit XR mode
  128278. * @param scene the scene to add the ui to
  128279. * @param helper the xr experience helper to enter/exit xr with
  128280. * @param options options to configure the UI
  128281. * @returns the created ui
  128282. */
  128283. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  128284. /**
  128285. * Disposes of the XR UI component
  128286. */
  128287. dispose(): void;
  128288. private _updateButtons;
  128289. }
  128290. }
  128291. declare module BABYLON {
  128292. /**
  128293. * Class containing static functions to help procedurally build meshes
  128294. */
  128295. export class LinesBuilder {
  128296. /**
  128297. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  128298. * * 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
  128299. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  128300. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  128301. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  128302. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  128303. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128304. * * 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
  128305. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128308. * @param name defines the name of the new line system
  128309. * @param options defines the options used to create the line system
  128310. * @param scene defines the hosting scene
  128311. * @returns a new line system mesh
  128312. */
  128313. static CreateLineSystem(name: string, options: {
  128314. lines: Vector3[][];
  128315. updatable?: boolean;
  128316. instance?: Nullable<LinesMesh>;
  128317. colors?: Nullable<Color4[][]>;
  128318. useVertexAlpha?: boolean;
  128319. }, scene: Nullable<Scene>): LinesMesh;
  128320. /**
  128321. * Creates a line mesh
  128322. * 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
  128323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128324. * * The parameter `points` is an array successive Vector3
  128325. * * 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
  128326. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128327. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128328. * * When updating an instance, remember that only point positions can change, not the number of points
  128329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128331. * @param name defines the name of the new line system
  128332. * @param options defines the options used to create the line system
  128333. * @param scene defines the hosting scene
  128334. * @returns a new line mesh
  128335. */
  128336. static CreateLines(name: string, options: {
  128337. points: Vector3[];
  128338. updatable?: boolean;
  128339. instance?: Nullable<LinesMesh>;
  128340. colors?: Color4[];
  128341. useVertexAlpha?: boolean;
  128342. }, scene?: Nullable<Scene>): LinesMesh;
  128343. /**
  128344. * Creates a dashed line mesh
  128345. * * 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
  128346. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128347. * * The parameter `points` is an array successive Vector3
  128348. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128349. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128350. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128351. * * 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
  128352. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128353. * * When updating an instance, remember that only point positions can change, not the number of points
  128354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128355. * @param name defines the name of the mesh
  128356. * @param options defines the options used to create the mesh
  128357. * @param scene defines the hosting scene
  128358. * @returns the dashed line mesh
  128359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128360. */
  128361. static CreateDashedLines(name: string, options: {
  128362. points: Vector3[];
  128363. dashSize?: number;
  128364. gapSize?: number;
  128365. dashNb?: number;
  128366. updatable?: boolean;
  128367. instance?: LinesMesh;
  128368. useVertexAlpha?: boolean;
  128369. }, scene?: Nullable<Scene>): LinesMesh;
  128370. }
  128371. }
  128372. declare module BABYLON {
  128373. /**
  128374. * Construction options for a timer
  128375. */
  128376. export interface ITimerOptions<T> {
  128377. /**
  128378. * Time-to-end
  128379. */
  128380. timeout: number;
  128381. /**
  128382. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128383. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128384. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128385. */
  128386. contextObservable: Observable<T>;
  128387. /**
  128388. * Optional parameters when adding an observer to the observable
  128389. */
  128390. observableParameters?: {
  128391. mask?: number;
  128392. insertFirst?: boolean;
  128393. scope?: any;
  128394. };
  128395. /**
  128396. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128397. */
  128398. breakCondition?: (data?: ITimerData<T>) => boolean;
  128399. /**
  128400. * Will be triggered when the time condition has met
  128401. */
  128402. onEnded?: (data: ITimerData<any>) => void;
  128403. /**
  128404. * Will be triggered when the break condition has met (prematurely ended)
  128405. */
  128406. onAborted?: (data: ITimerData<any>) => void;
  128407. /**
  128408. * Optional function to execute on each tick (or count)
  128409. */
  128410. onTick?: (data: ITimerData<any>) => void;
  128411. }
  128412. /**
  128413. * An interface defining the data sent by the timer
  128414. */
  128415. export interface ITimerData<T> {
  128416. /**
  128417. * When did it start
  128418. */
  128419. startTime: number;
  128420. /**
  128421. * Time now
  128422. */
  128423. currentTime: number;
  128424. /**
  128425. * Time passed since started
  128426. */
  128427. deltaTime: number;
  128428. /**
  128429. * How much is completed, in [0.0...1.0].
  128430. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  128431. */
  128432. completeRate: number;
  128433. /**
  128434. * What the registered observable sent in the last count
  128435. */
  128436. payload: T;
  128437. }
  128438. /**
  128439. * The current state of the timer
  128440. */
  128441. export enum TimerState {
  128442. /**
  128443. * Timer initialized, not yet started
  128444. */
  128445. INIT = 0,
  128446. /**
  128447. * Timer started and counting
  128448. */
  128449. STARTED = 1,
  128450. /**
  128451. * Timer ended (whether aborted or time reached)
  128452. */
  128453. ENDED = 2
  128454. }
  128455. /**
  128456. * A simple version of the timer. Will take options and start the timer immediately after calling it
  128457. *
  128458. * @param options options with which to initialize this timer
  128459. */
  128460. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  128461. /**
  128462. * An advanced implementation of a timer class
  128463. */
  128464. export class AdvancedTimer<T = any> implements IDisposable {
  128465. /**
  128466. * Will notify each time the timer calculates the remaining time
  128467. */
  128468. onEachCountObservable: Observable<ITimerData<T>>;
  128469. /**
  128470. * Will trigger when the timer was aborted due to the break condition
  128471. */
  128472. onTimerAbortedObservable: Observable<ITimerData<T>>;
  128473. /**
  128474. * Will trigger when the timer ended successfully
  128475. */
  128476. onTimerEndedObservable: Observable<ITimerData<T>>;
  128477. /**
  128478. * Will trigger when the timer state has changed
  128479. */
  128480. onStateChangedObservable: Observable<TimerState>;
  128481. private _observer;
  128482. private _contextObservable;
  128483. private _observableParameters;
  128484. private _startTime;
  128485. private _timer;
  128486. private _state;
  128487. private _breakCondition;
  128488. private _timeToEnd;
  128489. private _breakOnNextTick;
  128490. /**
  128491. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  128492. * @param options construction options for this advanced timer
  128493. */
  128494. constructor(options: ITimerOptions<T>);
  128495. /**
  128496. * set a breaking condition for this timer. Default is to never break during count
  128497. * @param predicate the new break condition. Returns true to break, false otherwise
  128498. */
  128499. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  128500. /**
  128501. * Reset ALL associated observables in this advanced timer
  128502. */
  128503. clearObservables(): void;
  128504. /**
  128505. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  128506. *
  128507. * @param timeToEnd how much time to measure until timer ended
  128508. */
  128509. start(timeToEnd?: number): void;
  128510. /**
  128511. * Will force a stop on the next tick.
  128512. */
  128513. stop(): void;
  128514. /**
  128515. * Dispose this timer, clearing all resources
  128516. */
  128517. dispose(): void;
  128518. private _setState;
  128519. private _tick;
  128520. private _stop;
  128521. }
  128522. }
  128523. declare module BABYLON {
  128524. /**
  128525. * The options container for the teleportation module
  128526. */
  128527. export interface IWebXRTeleportationOptions {
  128528. /**
  128529. * if provided, this scene will be used to render meshes.
  128530. */
  128531. customUtilityLayerScene?: Scene;
  128532. /**
  128533. * Values to configure the default target mesh
  128534. */
  128535. defaultTargetMeshOptions?: {
  128536. /**
  128537. * Fill color of the teleportation area
  128538. */
  128539. teleportationFillColor?: string;
  128540. /**
  128541. * Border color for the teleportation area
  128542. */
  128543. teleportationBorderColor?: string;
  128544. /**
  128545. * Disable the mesh's animation sequence
  128546. */
  128547. disableAnimation?: boolean;
  128548. /**
  128549. * Disable lighting on the material or the ring and arrow
  128550. */
  128551. disableLighting?: boolean;
  128552. /**
  128553. * Override the default material of the torus and arrow
  128554. */
  128555. torusArrowMaterial?: Material;
  128556. };
  128557. /**
  128558. * A list of meshes to use as floor meshes.
  128559. * Meshes can be added and removed after initializing the feature using the
  128560. * addFloorMesh and removeFloorMesh functions
  128561. * If empty, rotation will still work
  128562. */
  128563. floorMeshes?: AbstractMesh[];
  128564. /**
  128565. * use this rendering group id for the meshes (optional)
  128566. */
  128567. renderingGroupId?: number;
  128568. /**
  128569. * Should teleportation move only to snap points
  128570. */
  128571. snapPointsOnly?: boolean;
  128572. /**
  128573. * An array of points to which the teleportation will snap to.
  128574. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  128575. */
  128576. snapPositions?: Vector3[];
  128577. /**
  128578. * How close should the teleportation ray be in order to snap to position.
  128579. * Default to 0.8 units (meters)
  128580. */
  128581. snapToPositionRadius?: number;
  128582. /**
  128583. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128584. * If you want to support rotation, make sure your mesh has a direction indicator.
  128585. *
  128586. * When left untouched, the default mesh will be initialized.
  128587. */
  128588. teleportationTargetMesh?: AbstractMesh;
  128589. /**
  128590. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128591. */
  128592. timeToTeleport?: number;
  128593. /**
  128594. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128595. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128596. */
  128597. useMainComponentOnly?: boolean;
  128598. /**
  128599. * Should meshes created here be added to a utility layer or the main scene
  128600. */
  128601. useUtilityLayer?: boolean;
  128602. /**
  128603. * Babylon XR Input class for controller
  128604. */
  128605. xrInput: WebXRInput;
  128606. }
  128607. /**
  128608. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128609. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128610. * the input of the attached controllers.
  128611. */
  128612. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128613. private _options;
  128614. private _controllers;
  128615. private _currentTeleportationControllerId;
  128616. private _floorMeshes;
  128617. private _quadraticBezierCurve;
  128618. private _selectionFeature;
  128619. private _snapToPositions;
  128620. private _snappedToPoint;
  128621. private _teleportationRingMaterial?;
  128622. private _tmpRay;
  128623. private _tmpVector;
  128624. /**
  128625. * The module's name
  128626. */
  128627. static readonly Name: string;
  128628. /**
  128629. * The (Babylon) version of this module.
  128630. * This is an integer representing the implementation version.
  128631. * This number does not correspond to the webxr specs version
  128632. */
  128633. static readonly Version: number;
  128634. /**
  128635. * Is movement backwards enabled
  128636. */
  128637. backwardsMovementEnabled: boolean;
  128638. /**
  128639. * Distance to travel when moving backwards
  128640. */
  128641. backwardsTeleportationDistance: number;
  128642. /**
  128643. * The distance from the user to the inspection point in the direction of the controller
  128644. * A higher number will allow the user to move further
  128645. * defaults to 5 (meters, in xr units)
  128646. */
  128647. parabolicCheckRadius: number;
  128648. /**
  128649. * Should the module support parabolic ray on top of direct ray
  128650. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128651. * Very helpful when moving between floors / different heights
  128652. */
  128653. parabolicRayEnabled: boolean;
  128654. /**
  128655. * How much rotation should be applied when rotating right and left
  128656. */
  128657. rotationAngle: number;
  128658. /**
  128659. * Is rotation enabled when moving forward?
  128660. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128661. */
  128662. rotationEnabled: boolean;
  128663. /**
  128664. * constructs a new anchor system
  128665. * @param _xrSessionManager an instance of WebXRSessionManager
  128666. * @param _options configuration object for this feature
  128667. */
  128668. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128669. /**
  128670. * Get the snapPointsOnly flag
  128671. */
  128672. get snapPointsOnly(): boolean;
  128673. /**
  128674. * Sets the snapPointsOnly flag
  128675. * @param snapToPoints should teleportation be exclusively to snap points
  128676. */
  128677. set snapPointsOnly(snapToPoints: boolean);
  128678. /**
  128679. * Add a new mesh to the floor meshes array
  128680. * @param mesh the mesh to use as floor mesh
  128681. */
  128682. addFloorMesh(mesh: AbstractMesh): void;
  128683. /**
  128684. * Add a new snap-to point to fix teleportation to this position
  128685. * @param newSnapPoint The new Snap-To point
  128686. */
  128687. addSnapPoint(newSnapPoint: Vector3): void;
  128688. attach(): boolean;
  128689. detach(): boolean;
  128690. dispose(): void;
  128691. /**
  128692. * Remove a mesh from the floor meshes array
  128693. * @param mesh the mesh to remove
  128694. */
  128695. removeFloorMesh(mesh: AbstractMesh): void;
  128696. /**
  128697. * Remove a mesh from the floor meshes array using its name
  128698. * @param name the mesh name to remove
  128699. */
  128700. removeFloorMeshByName(name: string): void;
  128701. /**
  128702. * 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
  128703. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128704. * @returns was the point found and removed or not
  128705. */
  128706. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128707. /**
  128708. * This function sets a selection feature that will be disabled when
  128709. * the forward ray is shown and will be reattached when hidden.
  128710. * This is used to remove the selection rays when moving.
  128711. * @param selectionFeature the feature to disable when forward movement is enabled
  128712. */
  128713. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128714. protected _onXRFrame(_xrFrame: XRFrame): void;
  128715. private _attachController;
  128716. private _createDefaultTargetMesh;
  128717. private _detachController;
  128718. private _findClosestSnapPointWithRadius;
  128719. private _setTargetMeshPosition;
  128720. private _setTargetMeshVisibility;
  128721. private _showParabolicPath;
  128722. private _teleportForward;
  128723. }
  128724. }
  128725. declare module BABYLON {
  128726. /**
  128727. * Options for the default xr helper
  128728. */
  128729. export class WebXRDefaultExperienceOptions {
  128730. /**
  128731. * Enable or disable default UI to enter XR
  128732. */
  128733. disableDefaultUI?: boolean;
  128734. /**
  128735. * Should teleportation not initialize. defaults to false.
  128736. */
  128737. disableTeleportation?: boolean;
  128738. /**
  128739. * Floor meshes that will be used for teleport
  128740. */
  128741. floorMeshes?: Array<AbstractMesh>;
  128742. /**
  128743. * If set to true, the first frame will not be used to reset position
  128744. * The first frame is mainly used when copying transformation from the old camera
  128745. * Mainly used in AR
  128746. */
  128747. ignoreNativeCameraTransformation?: boolean;
  128748. /**
  128749. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128750. */
  128751. inputOptions?: IWebXRInputOptions;
  128752. /**
  128753. * optional configuration for the output canvas
  128754. */
  128755. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128756. /**
  128757. * optional UI options. This can be used among other to change session mode and reference space type
  128758. */
  128759. uiOptions?: WebXREnterExitUIOptions;
  128760. /**
  128761. * When loading teleportation and pointer select, use stable versions instead of latest.
  128762. */
  128763. useStablePlugins?: boolean;
  128764. /**
  128765. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128766. */
  128767. renderingGroupId?: number;
  128768. /**
  128769. * A list of optional features to init the session with
  128770. * If set to true, all features we support will be added
  128771. */
  128772. optionalFeatures?: boolean | string[];
  128773. }
  128774. /**
  128775. * Default experience which provides a similar setup to the previous webVRExperience
  128776. */
  128777. export class WebXRDefaultExperience {
  128778. /**
  128779. * Base experience
  128780. */
  128781. baseExperience: WebXRExperienceHelper;
  128782. /**
  128783. * Enables ui for entering/exiting xr
  128784. */
  128785. enterExitUI: WebXREnterExitUI;
  128786. /**
  128787. * Input experience extension
  128788. */
  128789. input: WebXRInput;
  128790. /**
  128791. * Enables laser pointer and selection
  128792. */
  128793. pointerSelection: WebXRControllerPointerSelection;
  128794. /**
  128795. * Default target xr should render to
  128796. */
  128797. renderTarget: WebXRRenderTarget;
  128798. /**
  128799. * Enables teleportation
  128800. */
  128801. teleportation: WebXRMotionControllerTeleportation;
  128802. private constructor();
  128803. /**
  128804. * Creates the default xr experience
  128805. * @param scene scene
  128806. * @param options options for basic configuration
  128807. * @returns resulting WebXRDefaultExperience
  128808. */
  128809. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128810. /**
  128811. * DIsposes of the experience helper
  128812. */
  128813. dispose(): void;
  128814. }
  128815. }
  128816. declare module BABYLON {
  128817. /**
  128818. * Options to modify the vr teleportation behavior.
  128819. */
  128820. export interface VRTeleportationOptions {
  128821. /**
  128822. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128823. */
  128824. floorMeshName?: string;
  128825. /**
  128826. * A list of meshes to be used as the teleportation floor. (default: empty)
  128827. */
  128828. floorMeshes?: Mesh[];
  128829. /**
  128830. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128831. */
  128832. teleportationMode?: number;
  128833. /**
  128834. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128835. */
  128836. teleportationTime?: number;
  128837. /**
  128838. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128839. */
  128840. teleportationSpeed?: number;
  128841. /**
  128842. * The easing function used in the animation or null for Linear. (default CircleEase)
  128843. */
  128844. easingFunction?: EasingFunction;
  128845. }
  128846. /**
  128847. * Options to modify the vr experience helper's behavior.
  128848. */
  128849. export interface VRExperienceHelperOptions extends WebVROptions {
  128850. /**
  128851. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128852. */
  128853. createDeviceOrientationCamera?: boolean;
  128854. /**
  128855. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128856. */
  128857. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128858. /**
  128859. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128860. */
  128861. laserToggle?: boolean;
  128862. /**
  128863. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128864. */
  128865. floorMeshes?: Mesh[];
  128866. /**
  128867. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128868. */
  128869. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128870. /**
  128871. * Defines if WebXR should be used instead of WebVR (if available)
  128872. */
  128873. useXR?: boolean;
  128874. }
  128875. /**
  128876. * Event containing information after VR has been entered
  128877. */
  128878. export class OnAfterEnteringVRObservableEvent {
  128879. /**
  128880. * If entering vr was successful
  128881. */
  128882. success: boolean;
  128883. }
  128884. /**
  128885. * Helps to quickly add VR support to an existing scene.
  128886. * See https://doc.babylonjs.com/how_to/webvr_helper
  128887. */
  128888. export class VRExperienceHelper {
  128889. /** Options to modify the vr experience helper's behavior. */
  128890. webVROptions: VRExperienceHelperOptions;
  128891. private _scene;
  128892. private _position;
  128893. private _btnVR;
  128894. private _btnVRDisplayed;
  128895. private _webVRsupported;
  128896. private _webVRready;
  128897. private _webVRrequesting;
  128898. private _webVRpresenting;
  128899. private _hasEnteredVR;
  128900. private _fullscreenVRpresenting;
  128901. private _inputElement;
  128902. private _webVRCamera;
  128903. private _vrDeviceOrientationCamera;
  128904. private _deviceOrientationCamera;
  128905. private _existingCamera;
  128906. private _onKeyDown;
  128907. private _onVrDisplayPresentChange;
  128908. private _onVRDisplayChanged;
  128909. private _onVRRequestPresentStart;
  128910. private _onVRRequestPresentComplete;
  128911. /**
  128912. * 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)
  128913. */
  128914. enableGazeEvenWhenNoPointerLock: boolean;
  128915. /**
  128916. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128917. */
  128918. exitVROnDoubleTap: boolean;
  128919. /**
  128920. * Observable raised right before entering VR.
  128921. */
  128922. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128923. /**
  128924. * Observable raised when entering VR has completed.
  128925. */
  128926. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128927. /**
  128928. * Observable raised when exiting VR.
  128929. */
  128930. onExitingVRObservable: Observable<VRExperienceHelper>;
  128931. /**
  128932. * Observable raised when controller mesh is loaded.
  128933. */
  128934. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128935. /** Return this.onEnteringVRObservable
  128936. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128937. */
  128938. get onEnteringVR(): Observable<VRExperienceHelper>;
  128939. /** Return this.onExitingVRObservable
  128940. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128941. */
  128942. get onExitingVR(): Observable<VRExperienceHelper>;
  128943. /** Return this.onControllerMeshLoadedObservable
  128944. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128945. */
  128946. get onControllerMeshLoaded(): Observable<WebVRController>;
  128947. private _rayLength;
  128948. private _useCustomVRButton;
  128949. private _teleportationRequested;
  128950. private _teleportActive;
  128951. private _floorMeshName;
  128952. private _floorMeshesCollection;
  128953. private _teleportationMode;
  128954. private _teleportationTime;
  128955. private _teleportationSpeed;
  128956. private _teleportationEasing;
  128957. private _rotationAllowed;
  128958. private _teleportBackwardsVector;
  128959. private _teleportationTarget;
  128960. private _isDefaultTeleportationTarget;
  128961. private _postProcessMove;
  128962. private _teleportationFillColor;
  128963. private _teleportationBorderColor;
  128964. private _rotationAngle;
  128965. private _haloCenter;
  128966. private _cameraGazer;
  128967. private _padSensibilityUp;
  128968. private _padSensibilityDown;
  128969. private _leftController;
  128970. private _rightController;
  128971. private _gazeColor;
  128972. private _laserColor;
  128973. private _pickedLaserColor;
  128974. private _pickedGazeColor;
  128975. /**
  128976. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128977. */
  128978. onNewMeshSelected: Observable<AbstractMesh>;
  128979. /**
  128980. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128981. * This observable will provide the mesh and the controller used to select the mesh
  128982. */
  128983. onMeshSelectedWithController: Observable<{
  128984. mesh: AbstractMesh;
  128985. controller: WebVRController;
  128986. }>;
  128987. /**
  128988. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128989. */
  128990. onNewMeshPicked: Observable<PickingInfo>;
  128991. private _circleEase;
  128992. /**
  128993. * Observable raised before camera teleportation
  128994. */
  128995. onBeforeCameraTeleport: Observable<Vector3>;
  128996. /**
  128997. * Observable raised after camera teleportation
  128998. */
  128999. onAfterCameraTeleport: Observable<Vector3>;
  129000. /**
  129001. * Observable raised when current selected mesh gets unselected
  129002. */
  129003. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129004. private _raySelectionPredicate;
  129005. /**
  129006. * To be optionaly changed by user to define custom ray selection
  129007. */
  129008. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129009. /**
  129010. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129011. */
  129012. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129013. /**
  129014. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129015. */
  129016. teleportationEnabled: boolean;
  129017. private _defaultHeight;
  129018. private _teleportationInitialized;
  129019. private _interactionsEnabled;
  129020. private _interactionsRequested;
  129021. private _displayGaze;
  129022. private _displayLaserPointer;
  129023. /**
  129024. * The mesh used to display where the user is going to teleport.
  129025. */
  129026. get teleportationTarget(): Mesh;
  129027. /**
  129028. * Sets the mesh to be used to display where the user is going to teleport.
  129029. */
  129030. set teleportationTarget(value: Mesh);
  129031. /**
  129032. * 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
  129033. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129034. * See https://doc.babylonjs.com/resources/baking_transformations
  129035. */
  129036. get gazeTrackerMesh(): Mesh;
  129037. set gazeTrackerMesh(value: Mesh);
  129038. /**
  129039. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129040. */
  129041. updateGazeTrackerScale: boolean;
  129042. /**
  129043. * If the gaze trackers color should be updated when selecting meshes
  129044. */
  129045. updateGazeTrackerColor: boolean;
  129046. /**
  129047. * If the controller laser color should be updated when selecting meshes
  129048. */
  129049. updateControllerLaserColor: boolean;
  129050. /**
  129051. * The gaze tracking mesh corresponding to the left controller
  129052. */
  129053. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129054. /**
  129055. * The gaze tracking mesh corresponding to the right controller
  129056. */
  129057. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129058. /**
  129059. * If the ray of the gaze should be displayed.
  129060. */
  129061. get displayGaze(): boolean;
  129062. /**
  129063. * Sets if the ray of the gaze should be displayed.
  129064. */
  129065. set displayGaze(value: boolean);
  129066. /**
  129067. * If the ray of the LaserPointer should be displayed.
  129068. */
  129069. get displayLaserPointer(): boolean;
  129070. /**
  129071. * Sets if the ray of the LaserPointer should be displayed.
  129072. */
  129073. set displayLaserPointer(value: boolean);
  129074. /**
  129075. * The deviceOrientationCamera used as the camera when not in VR.
  129076. */
  129077. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129078. /**
  129079. * Based on the current WebVR support, returns the current VR camera used.
  129080. */
  129081. get currentVRCamera(): Nullable<Camera>;
  129082. /**
  129083. * The webVRCamera which is used when in VR.
  129084. */
  129085. get webVRCamera(): WebVRFreeCamera;
  129086. /**
  129087. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129088. */
  129089. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129090. /**
  129091. * The html button that is used to trigger entering into VR.
  129092. */
  129093. get vrButton(): Nullable<HTMLButtonElement>;
  129094. private get _teleportationRequestInitiated();
  129095. /**
  129096. * Defines whether or not Pointer lock should be requested when switching to
  129097. * full screen.
  129098. */
  129099. requestPointerLockOnFullScreen: boolean;
  129100. /**
  129101. * If asking to force XR, this will be populated with the default xr experience
  129102. */
  129103. xr: WebXRDefaultExperience;
  129104. /**
  129105. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129106. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129107. */
  129108. xrTestDone: boolean;
  129109. /**
  129110. * Instantiates a VRExperienceHelper.
  129111. * Helps to quickly add VR support to an existing scene.
  129112. * @param scene The scene the VRExperienceHelper belongs to.
  129113. * @param webVROptions Options to modify the vr experience helper's behavior.
  129114. */
  129115. constructor(scene: Scene,
  129116. /** Options to modify the vr experience helper's behavior. */
  129117. webVROptions?: VRExperienceHelperOptions);
  129118. private completeVRInit;
  129119. private _onDefaultMeshLoaded;
  129120. private _onResize;
  129121. private _onFullscreenChange;
  129122. /**
  129123. * Gets a value indicating if we are currently in VR mode.
  129124. */
  129125. get isInVRMode(): boolean;
  129126. private onVrDisplayPresentChange;
  129127. private onVRDisplayChanged;
  129128. private moveButtonToBottomRight;
  129129. private displayVRButton;
  129130. private updateButtonVisibility;
  129131. private _cachedAngularSensibility;
  129132. /**
  129133. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129134. * Otherwise, will use the fullscreen API.
  129135. */
  129136. enterVR(): void;
  129137. /**
  129138. * Attempt to exit VR, or fullscreen.
  129139. */
  129140. exitVR(): void;
  129141. /**
  129142. * The position of the vr experience helper.
  129143. */
  129144. get position(): Vector3;
  129145. /**
  129146. * Sets the position of the vr experience helper.
  129147. */
  129148. set position(value: Vector3);
  129149. /**
  129150. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  129151. */
  129152. enableInteractions(): void;
  129153. private get _noControllerIsActive();
  129154. private beforeRender;
  129155. private _isTeleportationFloor;
  129156. /**
  129157. * Adds a floor mesh to be used for teleportation.
  129158. * @param floorMesh the mesh to be used for teleportation.
  129159. */
  129160. addFloorMesh(floorMesh: Mesh): void;
  129161. /**
  129162. * Removes a floor mesh from being used for teleportation.
  129163. * @param floorMesh the mesh to be removed.
  129164. */
  129165. removeFloorMesh(floorMesh: Mesh): void;
  129166. /**
  129167. * Enables interactions and teleportation using the VR controllers and gaze.
  129168. * @param vrTeleportationOptions options to modify teleportation behavior.
  129169. */
  129170. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  129171. private _onNewGamepadConnected;
  129172. private _tryEnableInteractionOnController;
  129173. private _onNewGamepadDisconnected;
  129174. private _enableInteractionOnController;
  129175. private _checkTeleportWithRay;
  129176. private _checkRotate;
  129177. private _checkTeleportBackwards;
  129178. private _enableTeleportationOnController;
  129179. private _createTeleportationCircles;
  129180. private _displayTeleportationTarget;
  129181. private _hideTeleportationTarget;
  129182. private _rotateCamera;
  129183. private _moveTeleportationSelectorTo;
  129184. private _workingVector;
  129185. private _workingQuaternion;
  129186. private _workingMatrix;
  129187. /**
  129188. * Time Constant Teleportation Mode
  129189. */
  129190. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  129191. /**
  129192. * Speed Constant Teleportation Mode
  129193. */
  129194. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  129195. /**
  129196. * Teleports the users feet to the desired location
  129197. * @param location The location where the user's feet should be placed
  129198. */
  129199. teleportCamera(location: Vector3): void;
  129200. private _convertNormalToDirectionOfRay;
  129201. private _castRayAndSelectObject;
  129202. private _notifySelectedMeshUnselected;
  129203. /**
  129204. * Permanently set new colors for the laser pointer
  129205. * @param color the new laser color
  129206. * @param pickedColor the new laser color when picked mesh detected
  129207. */
  129208. setLaserColor(color: Color3, pickedColor?: Color3): void;
  129209. /**
  129210. * Set lighting enabled / disabled on the laser pointer of both controllers
  129211. * @param enabled should the lighting be enabled on the laser pointer
  129212. */
  129213. setLaserLightingState(enabled?: boolean): void;
  129214. /**
  129215. * Permanently set new colors for the gaze pointer
  129216. * @param color the new gaze color
  129217. * @param pickedColor the new gaze color when picked mesh detected
  129218. */
  129219. setGazeColor(color: Color3, pickedColor?: Color3): void;
  129220. /**
  129221. * Sets the color of the laser ray from the vr controllers.
  129222. * @param color new color for the ray.
  129223. */
  129224. changeLaserColor(color: Color3): void;
  129225. /**
  129226. * Sets the color of the ray from the vr headsets gaze.
  129227. * @param color new color for the ray.
  129228. */
  129229. changeGazeColor(color: Color3): void;
  129230. /**
  129231. * Exits VR and disposes of the vr experience helper
  129232. */
  129233. dispose(): void;
  129234. /**
  129235. * Gets the name of the VRExperienceHelper class
  129236. * @returns "VRExperienceHelper"
  129237. */
  129238. getClassName(): string;
  129239. }
  129240. }
  129241. declare module BABYLON {
  129242. /**
  129243. * Contains an array of blocks representing the octree
  129244. */
  129245. export interface IOctreeContainer<T> {
  129246. /**
  129247. * Blocks within the octree
  129248. */
  129249. blocks: Array<OctreeBlock<T>>;
  129250. }
  129251. /**
  129252. * Class used to store a cell in an octree
  129253. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129254. */
  129255. export class OctreeBlock<T> {
  129256. /**
  129257. * Gets the content of the current block
  129258. */
  129259. entries: T[];
  129260. /**
  129261. * Gets the list of block children
  129262. */
  129263. blocks: Array<OctreeBlock<T>>;
  129264. private _depth;
  129265. private _maxDepth;
  129266. private _capacity;
  129267. private _minPoint;
  129268. private _maxPoint;
  129269. private _boundingVectors;
  129270. private _creationFunc;
  129271. /**
  129272. * Creates a new block
  129273. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  129274. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  129275. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129276. * @param depth defines the current depth of this block in the octree
  129277. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  129278. * @param creationFunc defines a callback to call when an element is added to the block
  129279. */
  129280. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  129281. /**
  129282. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129283. */
  129284. get capacity(): number;
  129285. /**
  129286. * Gets the minimum vector (in world space) of the block's bounding box
  129287. */
  129288. get minPoint(): Vector3;
  129289. /**
  129290. * Gets the maximum vector (in world space) of the block's bounding box
  129291. */
  129292. get maxPoint(): Vector3;
  129293. /**
  129294. * Add a new element to this block
  129295. * @param entry defines the element to add
  129296. */
  129297. addEntry(entry: T): void;
  129298. /**
  129299. * Remove an element from this block
  129300. * @param entry defines the element to remove
  129301. */
  129302. removeEntry(entry: T): void;
  129303. /**
  129304. * Add an array of elements to this block
  129305. * @param entries defines the array of elements to add
  129306. */
  129307. addEntries(entries: T[]): void;
  129308. /**
  129309. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  129310. * @param frustumPlanes defines the frustum planes to test
  129311. * @param selection defines the array to store current content if selection is positive
  129312. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129313. */
  129314. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129315. /**
  129316. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  129317. * @param sphereCenter defines the bounding sphere center
  129318. * @param sphereRadius defines the bounding sphere radius
  129319. * @param selection defines the array to store current content if selection is positive
  129320. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129321. */
  129322. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129323. /**
  129324. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  129325. * @param ray defines the ray to test with
  129326. * @param selection defines the array to store current content if selection is positive
  129327. */
  129328. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  129329. /**
  129330. * Subdivide the content into child blocks (this block will then be empty)
  129331. */
  129332. createInnerBlocks(): void;
  129333. /**
  129334. * @hidden
  129335. */
  129336. 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;
  129337. }
  129338. }
  129339. declare module BABYLON {
  129340. /**
  129341. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  129342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129343. */
  129344. export class Octree<T> {
  129345. /** 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.) */
  129346. maxDepth: number;
  129347. /**
  129348. * Blocks within the octree containing objects
  129349. */
  129350. blocks: Array<OctreeBlock<T>>;
  129351. /**
  129352. * Content stored in the octree
  129353. */
  129354. dynamicContent: T[];
  129355. private _maxBlockCapacity;
  129356. private _selectionContent;
  129357. private _creationFunc;
  129358. /**
  129359. * Creates a octree
  129360. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129361. * @param creationFunc function to be used to instatiate the octree
  129362. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  129363. * @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.)
  129364. */
  129365. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  129366. /** 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.) */
  129367. maxDepth?: number);
  129368. /**
  129369. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129370. * @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);
  129371. * @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);
  129372. * @param entries meshes to be added to the octree blocks
  129373. */
  129374. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129375. /**
  129376. * Adds a mesh to the octree
  129377. * @param entry Mesh to add to the octree
  129378. */
  129379. addMesh(entry: T): void;
  129380. /**
  129381. * Remove an element from the octree
  129382. * @param entry defines the element to remove
  129383. */
  129384. removeMesh(entry: T): void;
  129385. /**
  129386. * Selects an array of meshes within the frustum
  129387. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129388. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129389. * @returns array of meshes within the frustum
  129390. */
  129391. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129392. /**
  129393. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129394. * @param sphereCenter defines the bounding sphere center
  129395. * @param sphereRadius defines the bounding sphere radius
  129396. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129397. * @returns an array of objects that intersect the sphere
  129398. */
  129399. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  129400. /**
  129401. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  129402. * @param ray defines the ray to test with
  129403. * @returns array of intersected objects
  129404. */
  129405. intersectsRay(ray: Ray): SmartArray<T>;
  129406. /**
  129407. * Adds a mesh into the octree block if it intersects the block
  129408. */
  129409. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  129410. /**
  129411. * Adds a submesh into the octree block if it intersects the block
  129412. */
  129413. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  129414. }
  129415. }
  129416. declare module BABYLON {
  129417. interface Scene {
  129418. /**
  129419. * @hidden
  129420. * Backing Filed
  129421. */
  129422. _selectionOctree: Octree<AbstractMesh>;
  129423. /**
  129424. * Gets the octree used to boost mesh selection (picking)
  129425. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129426. */
  129427. selectionOctree: Octree<AbstractMesh>;
  129428. /**
  129429. * Creates or updates the octree used to boost selection (picking)
  129430. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129431. * @param maxCapacity defines the maximum capacity per leaf
  129432. * @param maxDepth defines the maximum depth of the octree
  129433. * @returns an octree of AbstractMesh
  129434. */
  129435. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  129436. }
  129437. interface AbstractMesh {
  129438. /**
  129439. * @hidden
  129440. * Backing Field
  129441. */
  129442. _submeshesOctree: Octree<SubMesh>;
  129443. /**
  129444. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  129445. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  129446. * @param maxCapacity defines the maximum size of each block (64 by default)
  129447. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  129448. * @returns the new octree
  129449. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  129450. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129451. */
  129452. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  129453. }
  129454. /**
  129455. * Defines the octree scene component responsible to manage any octrees
  129456. * in a given scene.
  129457. */
  129458. export class OctreeSceneComponent {
  129459. /**
  129460. * The component name help to identify the component in the list of scene components.
  129461. */
  129462. readonly name: string;
  129463. /**
  129464. * The scene the component belongs to.
  129465. */
  129466. scene: Scene;
  129467. /**
  129468. * Indicates if the meshes have been checked to make sure they are isEnabled()
  129469. */
  129470. readonly checksIsEnabled: boolean;
  129471. /**
  129472. * Creates a new instance of the component for the given scene
  129473. * @param scene Defines the scene to register the component in
  129474. */
  129475. constructor(scene: Scene);
  129476. /**
  129477. * Registers the component in a given scene
  129478. */
  129479. register(): void;
  129480. /**
  129481. * Return the list of active meshes
  129482. * @returns the list of active meshes
  129483. */
  129484. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  129485. /**
  129486. * Return the list of active sub meshes
  129487. * @param mesh The mesh to get the candidates sub meshes from
  129488. * @returns the list of active sub meshes
  129489. */
  129490. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  129491. private _tempRay;
  129492. /**
  129493. * Return the list of sub meshes intersecting with a given local ray
  129494. * @param mesh defines the mesh to find the submesh for
  129495. * @param localRay defines the ray in local space
  129496. * @returns the list of intersecting sub meshes
  129497. */
  129498. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  129499. /**
  129500. * Return the list of sub meshes colliding with a collider
  129501. * @param mesh defines the mesh to find the submesh for
  129502. * @param collider defines the collider to evaluate the collision against
  129503. * @returns the list of colliding sub meshes
  129504. */
  129505. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  129506. /**
  129507. * Rebuilds the elements related to this component in case of
  129508. * context lost for instance.
  129509. */
  129510. rebuild(): void;
  129511. /**
  129512. * Disposes the component and the associated ressources.
  129513. */
  129514. dispose(): void;
  129515. }
  129516. }
  129517. declare module BABYLON {
  129518. /**
  129519. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  129520. */
  129521. export class Gizmo implements IDisposable {
  129522. /** The utility layer the gizmo will be added to */
  129523. gizmoLayer: UtilityLayerRenderer;
  129524. /**
  129525. * The root mesh of the gizmo
  129526. */
  129527. _rootMesh: Mesh;
  129528. private _attachedMesh;
  129529. private _attachedNode;
  129530. /**
  129531. * Ratio for the scale of the gizmo (Default: 1)
  129532. */
  129533. scaleRatio: number;
  129534. /**
  129535. * If a custom mesh has been set (Default: false)
  129536. */
  129537. protected _customMeshSet: boolean;
  129538. /**
  129539. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  129540. * * When set, interactions will be enabled
  129541. */
  129542. get attachedMesh(): Nullable<AbstractMesh>;
  129543. set attachedMesh(value: Nullable<AbstractMesh>);
  129544. /**
  129545. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  129546. * * When set, interactions will be enabled
  129547. */
  129548. get attachedNode(): Nullable<Node>;
  129549. set attachedNode(value: Nullable<Node>);
  129550. /**
  129551. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129552. * @param mesh The mesh to replace the default mesh of the gizmo
  129553. */
  129554. setCustomMesh(mesh: Mesh): void;
  129555. /**
  129556. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  129557. */
  129558. updateGizmoRotationToMatchAttachedMesh: boolean;
  129559. /**
  129560. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  129561. */
  129562. updateGizmoPositionToMatchAttachedMesh: boolean;
  129563. /**
  129564. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  129565. */
  129566. updateScale: boolean;
  129567. protected _interactionsEnabled: boolean;
  129568. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129569. private _beforeRenderObserver;
  129570. private _tempQuaternion;
  129571. private _tempVector;
  129572. private _tempVector2;
  129573. /**
  129574. * Creates a gizmo
  129575. * @param gizmoLayer The utility layer the gizmo will be added to
  129576. */
  129577. constructor(
  129578. /** The utility layer the gizmo will be added to */
  129579. gizmoLayer?: UtilityLayerRenderer);
  129580. /**
  129581. * Updates the gizmo to match the attached mesh's position/rotation
  129582. */
  129583. protected _update(): void;
  129584. /**
  129585. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129586. * @param value Node, TransformNode or mesh
  129587. */
  129588. protected _matrixChanged(): void;
  129589. /**
  129590. * Disposes of the gizmo
  129591. */
  129592. dispose(): void;
  129593. }
  129594. }
  129595. declare module BABYLON {
  129596. /**
  129597. * Single plane drag gizmo
  129598. */
  129599. export class PlaneDragGizmo extends Gizmo {
  129600. /**
  129601. * Drag behavior responsible for the gizmos dragging interactions
  129602. */
  129603. dragBehavior: PointerDragBehavior;
  129604. private _pointerObserver;
  129605. /**
  129606. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129607. */
  129608. snapDistance: number;
  129609. /**
  129610. * Event that fires each time the gizmo snaps to a new location.
  129611. * * snapDistance is the the change in distance
  129612. */
  129613. onSnapObservable: Observable<{
  129614. snapDistance: number;
  129615. }>;
  129616. private _plane;
  129617. private _coloredMaterial;
  129618. private _hoverMaterial;
  129619. private _isEnabled;
  129620. private _parent;
  129621. /** @hidden */
  129622. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129623. /** @hidden */
  129624. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129625. /**
  129626. * Creates a PlaneDragGizmo
  129627. * @param gizmoLayer The utility layer the gizmo will be added to
  129628. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129629. * @param color The color of the gizmo
  129630. */
  129631. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129632. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129633. /**
  129634. * If the gizmo is enabled
  129635. */
  129636. set isEnabled(value: boolean);
  129637. get isEnabled(): boolean;
  129638. /**
  129639. * Disposes of the gizmo
  129640. */
  129641. dispose(): void;
  129642. }
  129643. }
  129644. declare module BABYLON {
  129645. /**
  129646. * Gizmo that enables dragging a mesh along 3 axis
  129647. */
  129648. export class PositionGizmo extends Gizmo {
  129649. /**
  129650. * Internal gizmo used for interactions on the x axis
  129651. */
  129652. xGizmo: AxisDragGizmo;
  129653. /**
  129654. * Internal gizmo used for interactions on the y axis
  129655. */
  129656. yGizmo: AxisDragGizmo;
  129657. /**
  129658. * Internal gizmo used for interactions on the z axis
  129659. */
  129660. zGizmo: AxisDragGizmo;
  129661. /**
  129662. * Internal gizmo used for interactions on the yz plane
  129663. */
  129664. xPlaneGizmo: PlaneDragGizmo;
  129665. /**
  129666. * Internal gizmo used for interactions on the xz plane
  129667. */
  129668. yPlaneGizmo: PlaneDragGizmo;
  129669. /**
  129670. * Internal gizmo used for interactions on the xy plane
  129671. */
  129672. zPlaneGizmo: PlaneDragGizmo;
  129673. /**
  129674. * private variables
  129675. */
  129676. private _meshAttached;
  129677. private _nodeAttached;
  129678. private _updateGizmoRotationToMatchAttachedMesh;
  129679. private _snapDistance;
  129680. private _scaleRatio;
  129681. /** Fires an event when any of it's sub gizmos are dragged */
  129682. onDragStartObservable: Observable<unknown>;
  129683. /** Fires an event when any of it's sub gizmos are released from dragging */
  129684. onDragEndObservable: Observable<unknown>;
  129685. /**
  129686. * If set to true, planar drag is enabled
  129687. */
  129688. private _planarGizmoEnabled;
  129689. get attachedMesh(): Nullable<AbstractMesh>;
  129690. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129691. get attachedNode(): Nullable<Node>;
  129692. set attachedNode(node: Nullable<Node>);
  129693. /**
  129694. * Creates a PositionGizmo
  129695. * @param gizmoLayer The utility layer the gizmo will be added to
  129696. @param thickness display gizmo axis thickness
  129697. */
  129698. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129699. /**
  129700. * If the planar drag gizmo is enabled
  129701. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129702. */
  129703. set planarGizmoEnabled(value: boolean);
  129704. get planarGizmoEnabled(): boolean;
  129705. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129706. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129707. /**
  129708. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129709. */
  129710. set snapDistance(value: number);
  129711. get snapDistance(): number;
  129712. /**
  129713. * Ratio for the scale of the gizmo (Default: 1)
  129714. */
  129715. set scaleRatio(value: number);
  129716. get scaleRatio(): number;
  129717. /**
  129718. * Disposes of the gizmo
  129719. */
  129720. dispose(): void;
  129721. /**
  129722. * CustomMeshes are not supported by this gizmo
  129723. * @param mesh The mesh to replace the default mesh of the gizmo
  129724. */
  129725. setCustomMesh(mesh: Mesh): void;
  129726. }
  129727. }
  129728. declare module BABYLON {
  129729. /**
  129730. * Single axis drag gizmo
  129731. */
  129732. export class AxisDragGizmo extends Gizmo {
  129733. /**
  129734. * Drag behavior responsible for the gizmos dragging interactions
  129735. */
  129736. dragBehavior: PointerDragBehavior;
  129737. private _pointerObserver;
  129738. /**
  129739. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129740. */
  129741. snapDistance: number;
  129742. /**
  129743. * Event that fires each time the gizmo snaps to a new location.
  129744. * * snapDistance is the the change in distance
  129745. */
  129746. onSnapObservable: Observable<{
  129747. snapDistance: number;
  129748. }>;
  129749. private _isEnabled;
  129750. private _parent;
  129751. private _arrow;
  129752. private _coloredMaterial;
  129753. private _hoverMaterial;
  129754. /** @hidden */
  129755. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129756. /** @hidden */
  129757. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129758. /**
  129759. * Creates an AxisDragGizmo
  129760. * @param gizmoLayer The utility layer the gizmo will be added to
  129761. * @param dragAxis The axis which the gizmo will be able to drag on
  129762. * @param color The color of the gizmo
  129763. * @param thickness display gizmo axis thickness
  129764. */
  129765. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129766. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129767. /**
  129768. * If the gizmo is enabled
  129769. */
  129770. set isEnabled(value: boolean);
  129771. get isEnabled(): boolean;
  129772. /**
  129773. * Disposes of the gizmo
  129774. */
  129775. dispose(): void;
  129776. }
  129777. }
  129778. declare module BABYLON.Debug {
  129779. /**
  129780. * The Axes viewer will show 3 axes in a specific point in space
  129781. */
  129782. export class AxesViewer {
  129783. private _xAxis;
  129784. private _yAxis;
  129785. private _zAxis;
  129786. private _scaleLinesFactor;
  129787. private _instanced;
  129788. /**
  129789. * Gets the hosting scene
  129790. */
  129791. scene: Scene;
  129792. /**
  129793. * Gets or sets a number used to scale line length
  129794. */
  129795. scaleLines: number;
  129796. /** Gets the node hierarchy used to render x-axis */
  129797. get xAxis(): TransformNode;
  129798. /** Gets the node hierarchy used to render y-axis */
  129799. get yAxis(): TransformNode;
  129800. /** Gets the node hierarchy used to render z-axis */
  129801. get zAxis(): TransformNode;
  129802. /**
  129803. * Creates a new AxesViewer
  129804. * @param scene defines the hosting scene
  129805. * @param scaleLines defines a number used to scale line length (1 by default)
  129806. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129807. * @param xAxis defines the node hierarchy used to render the x-axis
  129808. * @param yAxis defines the node hierarchy used to render the y-axis
  129809. * @param zAxis defines the node hierarchy used to render the z-axis
  129810. */
  129811. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129812. /**
  129813. * Force the viewer to update
  129814. * @param position defines the position of the viewer
  129815. * @param xaxis defines the x axis of the viewer
  129816. * @param yaxis defines the y axis of the viewer
  129817. * @param zaxis defines the z axis of the viewer
  129818. */
  129819. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129820. /**
  129821. * Creates an instance of this axes viewer.
  129822. * @returns a new axes viewer with instanced meshes
  129823. */
  129824. createInstance(): AxesViewer;
  129825. /** Releases resources */
  129826. dispose(): void;
  129827. private static _SetRenderingGroupId;
  129828. }
  129829. }
  129830. declare module BABYLON.Debug {
  129831. /**
  129832. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129833. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129834. */
  129835. export class BoneAxesViewer extends AxesViewer {
  129836. /**
  129837. * Gets or sets the target mesh where to display the axes viewer
  129838. */
  129839. mesh: Nullable<Mesh>;
  129840. /**
  129841. * Gets or sets the target bone where to display the axes viewer
  129842. */
  129843. bone: Nullable<Bone>;
  129844. /** Gets current position */
  129845. pos: Vector3;
  129846. /** Gets direction of X axis */
  129847. xaxis: Vector3;
  129848. /** Gets direction of Y axis */
  129849. yaxis: Vector3;
  129850. /** Gets direction of Z axis */
  129851. zaxis: Vector3;
  129852. /**
  129853. * Creates a new BoneAxesViewer
  129854. * @param scene defines the hosting scene
  129855. * @param bone defines the target bone
  129856. * @param mesh defines the target mesh
  129857. * @param scaleLines defines a scaling factor for line length (1 by default)
  129858. */
  129859. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129860. /**
  129861. * Force the viewer to update
  129862. */
  129863. update(): void;
  129864. /** Releases resources */
  129865. dispose(): void;
  129866. }
  129867. }
  129868. declare module BABYLON {
  129869. /**
  129870. * Interface used to define scene explorer extensibility option
  129871. */
  129872. export interface IExplorerExtensibilityOption {
  129873. /**
  129874. * Define the option label
  129875. */
  129876. label: string;
  129877. /**
  129878. * Defines the action to execute on click
  129879. */
  129880. action: (entity: any) => void;
  129881. }
  129882. /**
  129883. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129884. */
  129885. export interface IExplorerExtensibilityGroup {
  129886. /**
  129887. * Defines a predicate to test if a given type mut be extended
  129888. */
  129889. predicate: (entity: any) => boolean;
  129890. /**
  129891. * Gets the list of options added to a type
  129892. */
  129893. entries: IExplorerExtensibilityOption[];
  129894. }
  129895. /**
  129896. * Interface used to define the options to use to create the Inspector
  129897. */
  129898. export interface IInspectorOptions {
  129899. /**
  129900. * Display in overlay mode (default: false)
  129901. */
  129902. overlay?: boolean;
  129903. /**
  129904. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129905. */
  129906. globalRoot?: HTMLElement;
  129907. /**
  129908. * Display the Scene explorer
  129909. */
  129910. showExplorer?: boolean;
  129911. /**
  129912. * Display the property inspector
  129913. */
  129914. showInspector?: boolean;
  129915. /**
  129916. * Display in embed mode (both panes on the right)
  129917. */
  129918. embedMode?: boolean;
  129919. /**
  129920. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129921. */
  129922. handleResize?: boolean;
  129923. /**
  129924. * Allow the panes to popup (default: true)
  129925. */
  129926. enablePopup?: boolean;
  129927. /**
  129928. * Allow the panes to be closed by users (default: true)
  129929. */
  129930. enableClose?: boolean;
  129931. /**
  129932. * Optional list of extensibility entries
  129933. */
  129934. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129935. /**
  129936. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129937. */
  129938. inspectorURL?: string;
  129939. /**
  129940. * Optional initial tab (default to DebugLayerTab.Properties)
  129941. */
  129942. initialTab?: DebugLayerTab;
  129943. }
  129944. interface Scene {
  129945. /**
  129946. * @hidden
  129947. * Backing field
  129948. */
  129949. _debugLayer: DebugLayer;
  129950. /**
  129951. * Gets the debug layer (aka Inspector) associated with the scene
  129952. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129953. */
  129954. debugLayer: DebugLayer;
  129955. }
  129956. /**
  129957. * Enum of inspector action tab
  129958. */
  129959. export enum DebugLayerTab {
  129960. /**
  129961. * Properties tag (default)
  129962. */
  129963. Properties = 0,
  129964. /**
  129965. * Debug tab
  129966. */
  129967. Debug = 1,
  129968. /**
  129969. * Statistics tab
  129970. */
  129971. Statistics = 2,
  129972. /**
  129973. * Tools tab
  129974. */
  129975. Tools = 3,
  129976. /**
  129977. * Settings tab
  129978. */
  129979. Settings = 4
  129980. }
  129981. /**
  129982. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129983. * what is happening in your scene
  129984. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129985. */
  129986. export class DebugLayer {
  129987. /**
  129988. * Define the url to get the inspector script from.
  129989. * By default it uses the babylonjs CDN.
  129990. * @ignoreNaming
  129991. */
  129992. static InspectorURL: string;
  129993. private _scene;
  129994. private BJSINSPECTOR;
  129995. private _onPropertyChangedObservable?;
  129996. /**
  129997. * Observable triggered when a property is changed through the inspector.
  129998. */
  129999. get onPropertyChangedObservable(): any;
  130000. /**
  130001. * Instantiates a new debug layer.
  130002. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130003. * what is happening in your scene
  130004. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130005. * @param scene Defines the scene to inspect
  130006. */
  130007. constructor(scene: Scene);
  130008. /** Creates the inspector window. */
  130009. private _createInspector;
  130010. /**
  130011. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130012. * @param entity defines the entity to select
  130013. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130014. */
  130015. select(entity: any, lineContainerTitles?: string | string[]): void;
  130016. /** Get the inspector from bundle or global */
  130017. private _getGlobalInspector;
  130018. /**
  130019. * Get if the inspector is visible or not.
  130020. * @returns true if visible otherwise, false
  130021. */
  130022. isVisible(): boolean;
  130023. /**
  130024. * Hide the inspector and close its window.
  130025. */
  130026. hide(): void;
  130027. /**
  130028. * Update the scene in the inspector
  130029. */
  130030. setAsActiveScene(): void;
  130031. /**
  130032. * Launch the debugLayer.
  130033. * @param config Define the configuration of the inspector
  130034. * @return a promise fulfilled when the debug layer is visible
  130035. */
  130036. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130037. }
  130038. }
  130039. declare module BABYLON {
  130040. /**
  130041. * Class containing static functions to help procedurally build meshes
  130042. */
  130043. export class BoxBuilder {
  130044. /**
  130045. * Creates a box mesh
  130046. * * The parameter `size` sets the size (float) of each box side (default 1)
  130047. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130048. * * 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)
  130049. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130053. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130054. * @param name defines the name of the mesh
  130055. * @param options defines the options used to create the mesh
  130056. * @param scene defines the hosting scene
  130057. * @returns the box mesh
  130058. */
  130059. static CreateBox(name: string, options: {
  130060. size?: number;
  130061. width?: number;
  130062. height?: number;
  130063. depth?: number;
  130064. faceUV?: Vector4[];
  130065. faceColors?: Color4[];
  130066. sideOrientation?: number;
  130067. frontUVs?: Vector4;
  130068. backUVs?: Vector4;
  130069. wrap?: boolean;
  130070. topBaseAt?: number;
  130071. bottomBaseAt?: number;
  130072. updatable?: boolean;
  130073. }, scene?: Nullable<Scene>): Mesh;
  130074. }
  130075. }
  130076. declare module BABYLON.Debug {
  130077. /**
  130078. * Used to show the physics impostor around the specific mesh
  130079. */
  130080. export class PhysicsViewer {
  130081. /** @hidden */
  130082. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130083. /** @hidden */
  130084. protected _meshes: Array<Nullable<AbstractMesh>>;
  130085. /** @hidden */
  130086. protected _scene: Nullable<Scene>;
  130087. /** @hidden */
  130088. protected _numMeshes: number;
  130089. /** @hidden */
  130090. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130091. private _renderFunction;
  130092. private _utilityLayer;
  130093. private _debugBoxMesh;
  130094. private _debugSphereMesh;
  130095. private _debugCylinderMesh;
  130096. private _debugMaterial;
  130097. private _debugMeshMeshes;
  130098. /**
  130099. * Creates a new PhysicsViewer
  130100. * @param scene defines the hosting scene
  130101. */
  130102. constructor(scene: Scene);
  130103. /** @hidden */
  130104. protected _updateDebugMeshes(): void;
  130105. /**
  130106. * Renders a specified physic impostor
  130107. * @param impostor defines the impostor to render
  130108. * @param targetMesh defines the mesh represented by the impostor
  130109. * @returns the new debug mesh used to render the impostor
  130110. */
  130111. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130112. /**
  130113. * Hides a specified physic impostor
  130114. * @param impostor defines the impostor to hide
  130115. */
  130116. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130117. private _getDebugMaterial;
  130118. private _getDebugBoxMesh;
  130119. private _getDebugSphereMesh;
  130120. private _getDebugCylinderMesh;
  130121. private _getDebugMeshMesh;
  130122. private _getDebugMesh;
  130123. /** Releases all resources */
  130124. dispose(): void;
  130125. }
  130126. }
  130127. declare module BABYLON {
  130128. /**
  130129. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130130. * in order to better appreciate the issue one might have.
  130131. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130132. */
  130133. export class RayHelper {
  130134. /**
  130135. * Defines the ray we are currently tryin to visualize.
  130136. */
  130137. ray: Nullable<Ray>;
  130138. private _renderPoints;
  130139. private _renderLine;
  130140. private _renderFunction;
  130141. private _scene;
  130142. private _onAfterRenderObserver;
  130143. private _onAfterStepObserver;
  130144. private _attachedToMesh;
  130145. private _meshSpaceDirection;
  130146. private _meshSpaceOrigin;
  130147. /**
  130148. * Helper function to create a colored helper in a scene in one line.
  130149. * @param ray Defines the ray we are currently tryin to visualize
  130150. * @param scene Defines the scene the ray is used in
  130151. * @param color Defines the color we want to see the ray in
  130152. * @returns The newly created ray helper.
  130153. */
  130154. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  130155. /**
  130156. * Instantiate a new ray helper.
  130157. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130158. * in order to better appreciate the issue one might have.
  130159. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130160. * @param ray Defines the ray we are currently tryin to visualize
  130161. */
  130162. constructor(ray: Ray);
  130163. /**
  130164. * Shows the ray we are willing to debug.
  130165. * @param scene Defines the scene the ray needs to be rendered in
  130166. * @param color Defines the color the ray needs to be rendered in
  130167. */
  130168. show(scene: Scene, color?: Color3): void;
  130169. /**
  130170. * Hides the ray we are debugging.
  130171. */
  130172. hide(): void;
  130173. private _render;
  130174. /**
  130175. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  130176. * @param mesh Defines the mesh we want the helper attached to
  130177. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  130178. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  130179. * @param length Defines the length of the ray
  130180. */
  130181. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  130182. /**
  130183. * Detach the ray helper from the mesh it has previously been attached to.
  130184. */
  130185. detachFromMesh(): void;
  130186. private _updateToMesh;
  130187. /**
  130188. * Dispose the helper and release its associated resources.
  130189. */
  130190. dispose(): void;
  130191. }
  130192. }
  130193. declare module BABYLON {
  130194. /**
  130195. * Defines the options associated with the creation of a SkeletonViewer.
  130196. */
  130197. export interface ISkeletonViewerOptions {
  130198. /** Should the system pause animations before building the Viewer? */
  130199. pauseAnimations: boolean;
  130200. /** Should the system return the skeleton to rest before building? */
  130201. returnToRest: boolean;
  130202. /** public Display Mode of the Viewer */
  130203. displayMode: number;
  130204. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130205. displayOptions: ISkeletonViewerDisplayOptions;
  130206. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130207. computeBonesUsingShaders: boolean;
  130208. }
  130209. /**
  130210. * Defines how to display the various bone meshes for the viewer.
  130211. */
  130212. export interface ISkeletonViewerDisplayOptions {
  130213. /** How far down to start tapering the bone spurs */
  130214. midStep?: number;
  130215. /** How big is the midStep? */
  130216. midStepFactor?: number;
  130217. /** Base for the Sphere Size */
  130218. sphereBaseSize?: number;
  130219. /** The ratio of the sphere to the longest bone in units */
  130220. sphereScaleUnit?: number;
  130221. /** Ratio for the Sphere Size */
  130222. sphereFactor?: number;
  130223. }
  130224. }
  130225. declare module BABYLON {
  130226. /**
  130227. * Class containing static functions to help procedurally build meshes
  130228. */
  130229. export class RibbonBuilder {
  130230. /**
  130231. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130232. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130233. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130234. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130235. * * 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
  130236. * * 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
  130237. * * 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
  130238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130241. * * 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
  130242. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130243. * * 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
  130244. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130246. * @param name defines the name of the mesh
  130247. * @param options defines the options used to create the mesh
  130248. * @param scene defines the hosting scene
  130249. * @returns the ribbon mesh
  130250. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130252. */
  130253. static CreateRibbon(name: string, options: {
  130254. pathArray: Vector3[][];
  130255. closeArray?: boolean;
  130256. closePath?: boolean;
  130257. offset?: number;
  130258. updatable?: boolean;
  130259. sideOrientation?: number;
  130260. frontUVs?: Vector4;
  130261. backUVs?: Vector4;
  130262. instance?: Mesh;
  130263. invertUV?: boolean;
  130264. uvs?: Vector2[];
  130265. colors?: Color4[];
  130266. }, scene?: Nullable<Scene>): Mesh;
  130267. }
  130268. }
  130269. declare module BABYLON {
  130270. /**
  130271. * Class containing static functions to help procedurally build meshes
  130272. */
  130273. export class ShapeBuilder {
  130274. /**
  130275. * 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.
  130276. * * 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.
  130277. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130278. * * 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.
  130279. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130280. * * 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
  130281. * * 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
  130282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130287. * @param name defines the name of the mesh
  130288. * @param options defines the options used to create the mesh
  130289. * @param scene defines the hosting scene
  130290. * @returns the extruded shape mesh
  130291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130293. */
  130294. static ExtrudeShape(name: string, options: {
  130295. shape: Vector3[];
  130296. path: Vector3[];
  130297. scale?: number;
  130298. rotation?: number;
  130299. cap?: number;
  130300. updatable?: boolean;
  130301. sideOrientation?: number;
  130302. frontUVs?: Vector4;
  130303. backUVs?: Vector4;
  130304. instance?: Mesh;
  130305. invertUV?: boolean;
  130306. }, scene?: Nullable<Scene>): Mesh;
  130307. /**
  130308. * Creates an custom extruded shape mesh.
  130309. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130310. * * 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.
  130311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130312. * * 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
  130313. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130314. * * 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
  130315. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130316. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130317. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130318. * * 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
  130319. * * 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
  130320. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130325. * @param name defines the name of the mesh
  130326. * @param options defines the options used to create the mesh
  130327. * @param scene defines the hosting scene
  130328. * @returns the custom extruded shape mesh
  130329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130332. */
  130333. static ExtrudeShapeCustom(name: string, options: {
  130334. shape: Vector3[];
  130335. path: Vector3[];
  130336. scaleFunction?: any;
  130337. rotationFunction?: any;
  130338. ribbonCloseArray?: boolean;
  130339. ribbonClosePath?: boolean;
  130340. cap?: number;
  130341. updatable?: boolean;
  130342. sideOrientation?: number;
  130343. frontUVs?: Vector4;
  130344. backUVs?: Vector4;
  130345. instance?: Mesh;
  130346. invertUV?: boolean;
  130347. }, scene?: Nullable<Scene>): Mesh;
  130348. private static _ExtrudeShapeGeneric;
  130349. }
  130350. }
  130351. declare module BABYLON.Debug {
  130352. /**
  130353. * Class used to render a debug view of a given skeleton
  130354. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  130355. */
  130356. export class SkeletonViewer {
  130357. /** defines the skeleton to render */
  130358. skeleton: Skeleton;
  130359. /** defines the mesh attached to the skeleton */
  130360. mesh: AbstractMesh;
  130361. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130362. autoUpdateBonesMatrices: boolean;
  130363. /** defines the rendering group id to use with the viewer */
  130364. renderingGroupId: number;
  130365. /** is the options for the viewer */
  130366. options: Partial<ISkeletonViewerOptions>;
  130367. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  130368. static readonly DISPLAY_LINES: number;
  130369. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  130370. static readonly DISPLAY_SPHERES: number;
  130371. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  130372. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  130373. /** If SkeletonViewer scene scope. */
  130374. private _scene;
  130375. /** Gets or sets the color used to render the skeleton */
  130376. color: Color3;
  130377. /** Array of the points of the skeleton fo the line view. */
  130378. private _debugLines;
  130379. /** The SkeletonViewers Mesh. */
  130380. private _debugMesh;
  130381. /** If SkeletonViewer is enabled. */
  130382. private _isEnabled;
  130383. /** If SkeletonViewer is ready. */
  130384. private _ready;
  130385. /** SkeletonViewer render observable. */
  130386. private _obs;
  130387. /** The Utility Layer to render the gizmos in. */
  130388. private _utilityLayer;
  130389. private _boneIndices;
  130390. /** Gets the Scene. */
  130391. get scene(): Scene;
  130392. /** Gets the utilityLayer. */
  130393. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  130394. /** Checks Ready Status. */
  130395. get isReady(): Boolean;
  130396. /** Sets Ready Status. */
  130397. set ready(value: boolean);
  130398. /** Gets the debugMesh */
  130399. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  130400. /** Sets the debugMesh */
  130401. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  130402. /** Gets the material */
  130403. get material(): StandardMaterial;
  130404. /** Sets the material */
  130405. set material(value: StandardMaterial);
  130406. /** Gets the material */
  130407. get displayMode(): number;
  130408. /** Sets the material */
  130409. set displayMode(value: number);
  130410. /**
  130411. * Creates a new SkeletonViewer
  130412. * @param skeleton defines the skeleton to render
  130413. * @param mesh defines the mesh attached to the skeleton
  130414. * @param scene defines the hosting scene
  130415. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  130416. * @param renderingGroupId defines the rendering group id to use with the viewer
  130417. * @param options All of the extra constructor options for the SkeletonViewer
  130418. */
  130419. constructor(
  130420. /** defines the skeleton to render */
  130421. skeleton: Skeleton,
  130422. /** defines the mesh attached to the skeleton */
  130423. mesh: AbstractMesh,
  130424. /** The Scene scope*/
  130425. scene: Scene,
  130426. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130427. autoUpdateBonesMatrices?: boolean,
  130428. /** defines the rendering group id to use with the viewer */
  130429. renderingGroupId?: number,
  130430. /** is the options for the viewer */
  130431. options?: Partial<ISkeletonViewerOptions>);
  130432. /** The Dynamic bindings for the update functions */
  130433. private _bindObs;
  130434. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  130435. update(): void;
  130436. /** Gets or sets a boolean indicating if the viewer is enabled */
  130437. set isEnabled(value: boolean);
  130438. get isEnabled(): boolean;
  130439. private _getBonePosition;
  130440. private _getLinesForBonesWithLength;
  130441. private _getLinesForBonesNoLength;
  130442. /** function to revert the mesh and scene back to the initial state. */
  130443. private _revert;
  130444. /** function to build and bind sphere joint points and spur bone representations. */
  130445. private _buildSpheresAndSpurs;
  130446. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  130447. private _displayLinesUpdate;
  130448. /** Changes the displayMode of the skeleton viewer
  130449. * @param mode The displayMode numerical value
  130450. */
  130451. changeDisplayMode(mode: number): void;
  130452. /** Changes the displayMode of the skeleton viewer
  130453. * @param option String of the option name
  130454. * @param value The numerical option value
  130455. */
  130456. changeDisplayOptions(option: string, value: number): void;
  130457. /** Release associated resources */
  130458. dispose(): void;
  130459. }
  130460. }
  130461. declare module BABYLON {
  130462. /**
  130463. * Enum for Device Types
  130464. */
  130465. export enum DeviceType {
  130466. /** Generic */
  130467. Generic = 0,
  130468. /** Keyboard */
  130469. Keyboard = 1,
  130470. /** Mouse */
  130471. Mouse = 2,
  130472. /** Touch Pointers */
  130473. Touch = 3,
  130474. /** PS4 Dual Shock */
  130475. DualShock = 4,
  130476. /** Xbox */
  130477. Xbox = 5,
  130478. /** Switch Controller */
  130479. Switch = 6
  130480. }
  130481. /**
  130482. * Enum for All Pointers (Touch/Mouse)
  130483. */
  130484. export enum PointerInput {
  130485. /** Horizontal Axis */
  130486. Horizontal = 0,
  130487. /** Vertical Axis */
  130488. Vertical = 1,
  130489. /** Left Click or Touch */
  130490. LeftClick = 2,
  130491. /** Middle Click */
  130492. MiddleClick = 3,
  130493. /** Right Click */
  130494. RightClick = 4,
  130495. /** Browser Back */
  130496. BrowserBack = 5,
  130497. /** Browser Forward */
  130498. BrowserForward = 6
  130499. }
  130500. /**
  130501. * Enum for Dual Shock Gamepad
  130502. */
  130503. export enum DualShockInput {
  130504. /** Cross */
  130505. Cross = 0,
  130506. /** Circle */
  130507. Circle = 1,
  130508. /** Square */
  130509. Square = 2,
  130510. /** Triangle */
  130511. Triangle = 3,
  130512. /** L1 */
  130513. L1 = 4,
  130514. /** R1 */
  130515. R1 = 5,
  130516. /** L2 */
  130517. L2 = 6,
  130518. /** R2 */
  130519. R2 = 7,
  130520. /** Share */
  130521. Share = 8,
  130522. /** Options */
  130523. Options = 9,
  130524. /** L3 */
  130525. L3 = 10,
  130526. /** R3 */
  130527. R3 = 11,
  130528. /** DPadUp */
  130529. DPadUp = 12,
  130530. /** DPadDown */
  130531. DPadDown = 13,
  130532. /** DPadLeft */
  130533. DPadLeft = 14,
  130534. /** DRight */
  130535. DPadRight = 15,
  130536. /** Home */
  130537. Home = 16,
  130538. /** TouchPad */
  130539. TouchPad = 17,
  130540. /** LStickXAxis */
  130541. LStickXAxis = 18,
  130542. /** LStickYAxis */
  130543. LStickYAxis = 19,
  130544. /** RStickXAxis */
  130545. RStickXAxis = 20,
  130546. /** RStickYAxis */
  130547. RStickYAxis = 21
  130548. }
  130549. /**
  130550. * Enum for Xbox Gamepad
  130551. */
  130552. export enum XboxInput {
  130553. /** A */
  130554. A = 0,
  130555. /** B */
  130556. B = 1,
  130557. /** X */
  130558. X = 2,
  130559. /** Y */
  130560. Y = 3,
  130561. /** LB */
  130562. LB = 4,
  130563. /** RB */
  130564. RB = 5,
  130565. /** LT */
  130566. LT = 6,
  130567. /** RT */
  130568. RT = 7,
  130569. /** Back */
  130570. Back = 8,
  130571. /** Start */
  130572. Start = 9,
  130573. /** LS */
  130574. LS = 10,
  130575. /** RS */
  130576. RS = 11,
  130577. /** DPadUp */
  130578. DPadUp = 12,
  130579. /** DPadDown */
  130580. DPadDown = 13,
  130581. /** DPadLeft */
  130582. DPadLeft = 14,
  130583. /** DRight */
  130584. DPadRight = 15,
  130585. /** Home */
  130586. Home = 16,
  130587. /** LStickXAxis */
  130588. LStickXAxis = 17,
  130589. /** LStickYAxis */
  130590. LStickYAxis = 18,
  130591. /** RStickXAxis */
  130592. RStickXAxis = 19,
  130593. /** RStickYAxis */
  130594. RStickYAxis = 20
  130595. }
  130596. /**
  130597. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130598. */
  130599. export enum SwitchInput {
  130600. /** B */
  130601. B = 0,
  130602. /** A */
  130603. A = 1,
  130604. /** Y */
  130605. Y = 2,
  130606. /** X */
  130607. X = 3,
  130608. /** L */
  130609. L = 4,
  130610. /** R */
  130611. R = 5,
  130612. /** ZL */
  130613. ZL = 6,
  130614. /** ZR */
  130615. ZR = 7,
  130616. /** Minus */
  130617. Minus = 8,
  130618. /** Plus */
  130619. Plus = 9,
  130620. /** LS */
  130621. LS = 10,
  130622. /** RS */
  130623. RS = 11,
  130624. /** DPadUp */
  130625. DPadUp = 12,
  130626. /** DPadDown */
  130627. DPadDown = 13,
  130628. /** DPadLeft */
  130629. DPadLeft = 14,
  130630. /** DRight */
  130631. DPadRight = 15,
  130632. /** Home */
  130633. Home = 16,
  130634. /** Capture */
  130635. Capture = 17,
  130636. /** LStickXAxis */
  130637. LStickXAxis = 18,
  130638. /** LStickYAxis */
  130639. LStickYAxis = 19,
  130640. /** RStickXAxis */
  130641. RStickXAxis = 20,
  130642. /** RStickYAxis */
  130643. RStickYAxis = 21
  130644. }
  130645. }
  130646. declare module BABYLON {
  130647. /**
  130648. * This class will take all inputs from Keyboard, Pointer, and
  130649. * any Gamepads and provide a polling system that all devices
  130650. * will use. This class assumes that there will only be one
  130651. * pointer device and one keyboard.
  130652. */
  130653. export class DeviceInputSystem implements IDisposable {
  130654. /**
  130655. * Callback to be triggered when a device is connected
  130656. */
  130657. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130658. /**
  130659. * Callback to be triggered when a device is disconnected
  130660. */
  130661. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130662. /**
  130663. * Callback to be triggered when event driven input is updated
  130664. */
  130665. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130666. private _inputs;
  130667. private _gamepads;
  130668. private _keyboardActive;
  130669. private _pointerActive;
  130670. private _elementToAttachTo;
  130671. private _keyboardDownEvent;
  130672. private _keyboardUpEvent;
  130673. private _pointerMoveEvent;
  130674. private _pointerDownEvent;
  130675. private _pointerUpEvent;
  130676. private _gamepadConnectedEvent;
  130677. private _gamepadDisconnectedEvent;
  130678. private static _MAX_KEYCODES;
  130679. private static _MAX_POINTER_INPUTS;
  130680. private constructor();
  130681. /**
  130682. * Creates a new DeviceInputSystem instance
  130683. * @param engine Engine to pull input element from
  130684. * @returns The new instance
  130685. */
  130686. static Create(engine: Engine): DeviceInputSystem;
  130687. /**
  130688. * Checks for current device input value, given an id and input index
  130689. * @param deviceName Id of connected device
  130690. * @param inputIndex Index of device input
  130691. * @returns Current value of input
  130692. */
  130693. /**
  130694. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  130695. * @param deviceType Enum specifiying device type
  130696. * @param deviceSlot "Slot" or index that device is referenced in
  130697. * @param inputIndex Id of input to be checked
  130698. * @returns Current value of input
  130699. */
  130700. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  130701. /**
  130702. * Dispose of all the eventlisteners
  130703. */
  130704. dispose(): void;
  130705. /**
  130706. * Add device and inputs to device array
  130707. * @param deviceType Enum specifiying device type
  130708. * @param deviceSlot "Slot" or index that device is referenced in
  130709. * @param numberOfInputs Number of input entries to create for given device
  130710. */
  130711. private _registerDevice;
  130712. /**
  130713. * Given a specific device name, remove that device from the device map
  130714. * @param deviceType Enum specifiying device type
  130715. * @param deviceSlot "Slot" or index that device is referenced in
  130716. */
  130717. private _unregisterDevice;
  130718. /**
  130719. * Handle all actions that come from keyboard interaction
  130720. */
  130721. private _handleKeyActions;
  130722. /**
  130723. * Handle all actions that come from pointer interaction
  130724. */
  130725. private _handlePointerActions;
  130726. /**
  130727. * Handle all actions that come from gamepad interaction
  130728. */
  130729. private _handleGamepadActions;
  130730. /**
  130731. * Update all non-event based devices with each frame
  130732. * @param deviceType Enum specifiying device type
  130733. * @param deviceSlot "Slot" or index that device is referenced in
  130734. * @param inputIndex Id of input to be checked
  130735. */
  130736. private _updateDevice;
  130737. /**
  130738. * Gets DeviceType from the device name
  130739. * @param deviceName Name of Device from DeviceInputSystem
  130740. * @returns DeviceType enum value
  130741. */
  130742. private _getGamepadDeviceType;
  130743. }
  130744. }
  130745. declare module BABYLON {
  130746. /**
  130747. * Type to handle enforcement of inputs
  130748. */
  130749. 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;
  130750. }
  130751. declare module BABYLON {
  130752. /**
  130753. * Class that handles all input for a specific device
  130754. */
  130755. export class DeviceSource<T extends DeviceType> {
  130756. /** Type of device */
  130757. readonly deviceType: DeviceType;
  130758. /** "Slot" or index that device is referenced in */
  130759. readonly deviceSlot: number;
  130760. /**
  130761. * Observable to handle device input changes per device
  130762. */
  130763. readonly onInputChangedObservable: Observable<{
  130764. inputIndex: DeviceInput<T>;
  130765. previousState: Nullable<number>;
  130766. currentState: Nullable<number>;
  130767. }>;
  130768. private readonly _deviceInputSystem;
  130769. /**
  130770. * Default Constructor
  130771. * @param deviceInputSystem Reference to DeviceInputSystem
  130772. * @param deviceType Type of device
  130773. * @param deviceSlot "Slot" or index that device is referenced in
  130774. */
  130775. constructor(deviceInputSystem: DeviceInputSystem,
  130776. /** Type of device */
  130777. deviceType: DeviceType,
  130778. /** "Slot" or index that device is referenced in */
  130779. deviceSlot?: number);
  130780. /**
  130781. * Get input for specific input
  130782. * @param inputIndex index of specific input on device
  130783. * @returns Input value from DeviceInputSystem
  130784. */
  130785. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130786. }
  130787. /**
  130788. * Class to keep track of devices
  130789. */
  130790. export class DeviceSourceManager implements IDisposable {
  130791. /**
  130792. * Observable to be triggered when before a device is connected
  130793. */
  130794. readonly onBeforeDeviceConnectedObservable: Observable<{
  130795. deviceType: DeviceType;
  130796. deviceSlot: number;
  130797. }>;
  130798. /**
  130799. * Observable to be triggered when before a device is disconnected
  130800. */
  130801. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130802. deviceType: DeviceType;
  130803. deviceSlot: number;
  130804. }>;
  130805. /**
  130806. * Observable to be triggered when after a device is connected
  130807. */
  130808. readonly onAfterDeviceConnectedObservable: Observable<{
  130809. deviceType: DeviceType;
  130810. deviceSlot: number;
  130811. }>;
  130812. /**
  130813. * Observable to be triggered when after a device is disconnected
  130814. */
  130815. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130816. deviceType: DeviceType;
  130817. deviceSlot: number;
  130818. }>;
  130819. private readonly _devices;
  130820. private readonly _firstDevice;
  130821. private readonly _deviceInputSystem;
  130822. /**
  130823. * Default Constructor
  130824. * @param engine engine to pull input element from
  130825. */
  130826. constructor(engine: Engine);
  130827. /**
  130828. * Gets a DeviceSource, given a type and slot
  130829. * @param deviceType Enum specifying device type
  130830. * @param deviceSlot "Slot" or index that device is referenced in
  130831. * @returns DeviceSource object
  130832. */
  130833. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130834. /**
  130835. * Gets an array of DeviceSource objects for a given device type
  130836. * @param deviceType Enum specifying device type
  130837. * @returns Array of DeviceSource objects
  130838. */
  130839. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130840. /**
  130841. * Dispose of DeviceInputSystem and other parts
  130842. */
  130843. dispose(): void;
  130844. /**
  130845. * Function to add device name to device list
  130846. * @param deviceType Enum specifying device type
  130847. * @param deviceSlot "Slot" or index that device is referenced in
  130848. */
  130849. private _addDevice;
  130850. /**
  130851. * Function to remove device name to device list
  130852. * @param deviceType Enum specifying device type
  130853. * @param deviceSlot "Slot" or index that device is referenced in
  130854. */
  130855. private _removeDevice;
  130856. /**
  130857. * Updates array storing first connected device of each type
  130858. * @param type Type of Device
  130859. */
  130860. private _updateFirstDevices;
  130861. }
  130862. }
  130863. declare module BABYLON {
  130864. /**
  130865. * Options to create the null engine
  130866. */
  130867. export class NullEngineOptions {
  130868. /**
  130869. * Render width (Default: 512)
  130870. */
  130871. renderWidth: number;
  130872. /**
  130873. * Render height (Default: 256)
  130874. */
  130875. renderHeight: number;
  130876. /**
  130877. * Texture size (Default: 512)
  130878. */
  130879. textureSize: number;
  130880. /**
  130881. * If delta time between frames should be constant
  130882. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130883. */
  130884. deterministicLockstep: boolean;
  130885. /**
  130886. * Maximum about of steps between frames (Default: 4)
  130887. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130888. */
  130889. lockstepMaxSteps: number;
  130890. /**
  130891. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130892. */
  130893. useHighPrecisionMatrix?: boolean;
  130894. }
  130895. /**
  130896. * The null engine class provides support for headless version of babylon.js.
  130897. * This can be used in server side scenario or for testing purposes
  130898. */
  130899. export class NullEngine extends Engine {
  130900. private _options;
  130901. /**
  130902. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130903. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130904. * @returns true if engine is in deterministic lock step mode
  130905. */
  130906. isDeterministicLockStep(): boolean;
  130907. /**
  130908. * Gets the max steps when engine is running in deterministic lock step
  130909. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130910. * @returns the max steps
  130911. */
  130912. getLockstepMaxSteps(): number;
  130913. /**
  130914. * Gets the current hardware scaling level.
  130915. * By default the hardware scaling level is computed from the window device ratio.
  130916. * 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.
  130917. * @returns a number indicating the current hardware scaling level
  130918. */
  130919. getHardwareScalingLevel(): number;
  130920. constructor(options?: NullEngineOptions);
  130921. /**
  130922. * Creates a vertex buffer
  130923. * @param vertices the data for the vertex buffer
  130924. * @returns the new WebGL static buffer
  130925. */
  130926. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130927. /**
  130928. * Creates a new index buffer
  130929. * @param indices defines the content of the index buffer
  130930. * @param updatable defines if the index buffer must be updatable
  130931. * @returns a new webGL buffer
  130932. */
  130933. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130934. /**
  130935. * Clear the current render buffer or the current render target (if any is set up)
  130936. * @param color defines the color to use
  130937. * @param backBuffer defines if the back buffer must be cleared
  130938. * @param depth defines if the depth buffer must be cleared
  130939. * @param stencil defines if the stencil buffer must be cleared
  130940. */
  130941. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130942. /**
  130943. * Gets the current render width
  130944. * @param useScreen defines if screen size must be used (or the current render target if any)
  130945. * @returns a number defining the current render width
  130946. */
  130947. getRenderWidth(useScreen?: boolean): number;
  130948. /**
  130949. * Gets the current render height
  130950. * @param useScreen defines if screen size must be used (or the current render target if any)
  130951. * @returns a number defining the current render height
  130952. */
  130953. getRenderHeight(useScreen?: boolean): number;
  130954. /**
  130955. * Set the WebGL's viewport
  130956. * @param viewport defines the viewport element to be used
  130957. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130958. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130959. */
  130960. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130961. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130962. /**
  130963. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130964. * @param pipelineContext defines the pipeline context to use
  130965. * @param uniformsNames defines the list of uniform names
  130966. * @returns an array of webGL uniform locations
  130967. */
  130968. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130969. /**
  130970. * Gets the lsit of active attributes for a given webGL program
  130971. * @param pipelineContext defines the pipeline context to use
  130972. * @param attributesNames defines the list of attribute names to get
  130973. * @returns an array of indices indicating the offset of each attribute
  130974. */
  130975. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130976. /**
  130977. * Binds an effect to the webGL context
  130978. * @param effect defines the effect to bind
  130979. */
  130980. bindSamplers(effect: Effect): void;
  130981. /**
  130982. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130983. * @param effect defines the effect to activate
  130984. */
  130985. enableEffect(effect: Effect): void;
  130986. /**
  130987. * Set various states to the webGL context
  130988. * @param culling defines backface culling state
  130989. * @param zOffset defines the value to apply to zOffset (0 by default)
  130990. * @param force defines if states must be applied even if cache is up to date
  130991. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130992. */
  130993. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130994. /**
  130995. * Set the value of an uniform to an array of int32
  130996. * @param uniform defines the webGL uniform location where to store the value
  130997. * @param array defines the array of int32 to store
  130998. */
  130999. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131000. /**
  131001. * Set the value of an uniform to an array of int32 (stored as vec2)
  131002. * @param uniform defines the webGL uniform location where to store the value
  131003. * @param array defines the array of int32 to store
  131004. */
  131005. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131006. /**
  131007. * Set the value of an uniform to an array of int32 (stored as vec3)
  131008. * @param uniform defines the webGL uniform location where to store the value
  131009. * @param array defines the array of int32 to store
  131010. */
  131011. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131012. /**
  131013. * Set the value of an uniform to an array of int32 (stored as vec4)
  131014. * @param uniform defines the webGL uniform location where to store the value
  131015. * @param array defines the array of int32 to store
  131016. */
  131017. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131018. /**
  131019. * Set the value of an uniform to an array of float32
  131020. * @param uniform defines the webGL uniform location where to store the value
  131021. * @param array defines the array of float32 to store
  131022. */
  131023. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131024. /**
  131025. * Set the value of an uniform to an array of float32 (stored as vec2)
  131026. * @param uniform defines the webGL uniform location where to store the value
  131027. * @param array defines the array of float32 to store
  131028. */
  131029. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131030. /**
  131031. * Set the value of an uniform to an array of float32 (stored as vec3)
  131032. * @param uniform defines the webGL uniform location where to store the value
  131033. * @param array defines the array of float32 to store
  131034. */
  131035. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131036. /**
  131037. * Set the value of an uniform to an array of float32 (stored as vec4)
  131038. * @param uniform defines the webGL uniform location where to store the value
  131039. * @param array defines the array of float32 to store
  131040. */
  131041. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131042. /**
  131043. * Set the value of an uniform to an array of number
  131044. * @param uniform defines the webGL uniform location where to store the value
  131045. * @param array defines the array of number to store
  131046. */
  131047. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131048. /**
  131049. * Set the value of an uniform to an array of number (stored as vec2)
  131050. * @param uniform defines the webGL uniform location where to store the value
  131051. * @param array defines the array of number to store
  131052. */
  131053. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131054. /**
  131055. * Set the value of an uniform to an array of number (stored as vec3)
  131056. * @param uniform defines the webGL uniform location where to store the value
  131057. * @param array defines the array of number to store
  131058. */
  131059. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131060. /**
  131061. * Set the value of an uniform to an array of number (stored as vec4)
  131062. * @param uniform defines the webGL uniform location where to store the value
  131063. * @param array defines the array of number to store
  131064. */
  131065. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131066. /**
  131067. * Set the value of an uniform to an array of float32 (stored as matrices)
  131068. * @param uniform defines the webGL uniform location where to store the value
  131069. * @param matrices defines the array of float32 to store
  131070. */
  131071. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131072. /**
  131073. * Set the value of an uniform to a matrix (3x3)
  131074. * @param uniform defines the webGL uniform location where to store the value
  131075. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131076. */
  131077. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131078. /**
  131079. * Set the value of an uniform to a matrix (2x2)
  131080. * @param uniform defines the webGL uniform location where to store the value
  131081. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131082. */
  131083. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131084. /**
  131085. * Set the value of an uniform to a number (float)
  131086. * @param uniform defines the webGL uniform location where to store the value
  131087. * @param value defines the float number to store
  131088. */
  131089. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131090. /**
  131091. * Set the value of an uniform to a vec2
  131092. * @param uniform defines the webGL uniform location where to store the value
  131093. * @param x defines the 1st component of the value
  131094. * @param y defines the 2nd component of the value
  131095. */
  131096. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131097. /**
  131098. * Set the value of an uniform to a vec3
  131099. * @param uniform defines the webGL uniform location where to store the value
  131100. * @param x defines the 1st component of the value
  131101. * @param y defines the 2nd component of the value
  131102. * @param z defines the 3rd component of the value
  131103. */
  131104. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131105. /**
  131106. * Set the value of an uniform to a boolean
  131107. * @param uniform defines the webGL uniform location where to store the value
  131108. * @param bool defines the boolean to store
  131109. */
  131110. setBool(uniform: WebGLUniformLocation, bool: number): void;
  131111. /**
  131112. * Set the value of an uniform to a vec4
  131113. * @param uniform defines the webGL uniform location where to store the value
  131114. * @param x defines the 1st component of the value
  131115. * @param y defines the 2nd component of the value
  131116. * @param z defines the 3rd component of the value
  131117. * @param w defines the 4th component of the value
  131118. */
  131119. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131120. /**
  131121. * Sets the current alpha mode
  131122. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131123. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131124. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131125. */
  131126. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131127. /**
  131128. * Bind webGl buffers directly to the webGL context
  131129. * @param vertexBuffers defines the vertex buffer to bind
  131130. * @param indexBuffer defines the index buffer to bind
  131131. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  131132. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  131133. * @param effect defines the effect associated with the vertex buffer
  131134. */
  131135. bindBuffers(vertexBuffers: {
  131136. [key: string]: VertexBuffer;
  131137. }, indexBuffer: DataBuffer, effect: Effect): void;
  131138. /**
  131139. * Force the entire cache to be cleared
  131140. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  131141. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  131142. */
  131143. wipeCaches(bruteForce?: boolean): void;
  131144. /**
  131145. * Send a draw order
  131146. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  131147. * @param indexStart defines the starting index
  131148. * @param indexCount defines the number of index to draw
  131149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131150. */
  131151. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  131152. /**
  131153. * Draw a list of indexed primitives
  131154. * @param fillMode defines the primitive to use
  131155. * @param indexStart defines the starting index
  131156. * @param indexCount defines the number of index to draw
  131157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131158. */
  131159. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131160. /**
  131161. * Draw a list of unindexed primitives
  131162. * @param fillMode defines the primitive to use
  131163. * @param verticesStart defines the index of first vertex to draw
  131164. * @param verticesCount defines the count of vertices to draw
  131165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131166. */
  131167. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131168. /** @hidden */
  131169. _createTexture(): WebGLTexture;
  131170. /** @hidden */
  131171. _releaseTexture(texture: InternalTexture): void;
  131172. /**
  131173. * Usually called from Texture.ts.
  131174. * Passed information to create a WebGLTexture
  131175. * @param urlArg defines a value which contains one of the following:
  131176. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131177. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131178. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131179. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131180. * @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)
  131181. * @param scene needed for loading to the correct scene
  131182. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131183. * @param onLoad optional callback to be called upon successful completion
  131184. * @param onError optional callback to be called upon failure
  131185. * @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
  131186. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131187. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131188. * @param forcedExtension defines the extension to use to pick the right loader
  131189. * @param mimeType defines an optional mime type
  131190. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131191. */
  131192. 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;
  131193. /**
  131194. * Creates a new render target texture
  131195. * @param size defines the size of the texture
  131196. * @param options defines the options used to create the texture
  131197. * @returns a new render target texture stored in an InternalTexture
  131198. */
  131199. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131200. /**
  131201. * Update the sampling mode of a given texture
  131202. * @param samplingMode defines the required sampling mode
  131203. * @param texture defines the texture to update
  131204. */
  131205. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131206. /**
  131207. * Binds the frame buffer to the specified texture.
  131208. * @param texture The texture to render to or null for the default canvas
  131209. * @param faceIndex The face of the texture to render to in case of cube texture
  131210. * @param requiredWidth The width of the target to render to
  131211. * @param requiredHeight The height of the target to render to
  131212. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  131213. * @param lodLevel defines le lod level to bind to the frame buffer
  131214. */
  131215. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131216. /**
  131217. * Unbind the current render target texture from the webGL context
  131218. * @param texture defines the render target texture to unbind
  131219. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131220. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131221. */
  131222. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131223. /**
  131224. * Creates a dynamic vertex buffer
  131225. * @param vertices the data for the dynamic vertex buffer
  131226. * @returns the new WebGL dynamic buffer
  131227. */
  131228. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  131229. /**
  131230. * Update the content of a dynamic texture
  131231. * @param texture defines the texture to update
  131232. * @param canvas defines the canvas containing the source
  131233. * @param invertY defines if data must be stored with Y axis inverted
  131234. * @param premulAlpha defines if alpha is stored as premultiplied
  131235. * @param format defines the format of the data
  131236. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  131237. */
  131238. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  131239. /**
  131240. * Gets a boolean indicating if all created effects are ready
  131241. * @returns true if all effects are ready
  131242. */
  131243. areAllEffectsReady(): boolean;
  131244. /**
  131245. * @hidden
  131246. * Get the current error code of the webGL context
  131247. * @returns the error code
  131248. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  131249. */
  131250. getError(): number;
  131251. /** @hidden */
  131252. _getUnpackAlignement(): number;
  131253. /** @hidden */
  131254. _unpackFlipY(value: boolean): void;
  131255. /**
  131256. * Update a dynamic index buffer
  131257. * @param indexBuffer defines the target index buffer
  131258. * @param indices defines the data to update
  131259. * @param offset defines the offset in the target index buffer where update should start
  131260. */
  131261. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  131262. /**
  131263. * Updates a dynamic vertex buffer.
  131264. * @param vertexBuffer the vertex buffer to update
  131265. * @param vertices the data used to update the vertex buffer
  131266. * @param byteOffset the byte offset of the data (optional)
  131267. * @param byteLength the byte length of the data (optional)
  131268. */
  131269. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  131270. /** @hidden */
  131271. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  131272. /** @hidden */
  131273. _bindTexture(channel: number, texture: InternalTexture): void;
  131274. protected _deleteBuffer(buffer: WebGLBuffer): void;
  131275. /**
  131276. * 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
  131277. */
  131278. releaseEffects(): void;
  131279. displayLoadingUI(): void;
  131280. hideLoadingUI(): void;
  131281. /** @hidden */
  131282. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131283. /** @hidden */
  131284. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131285. /** @hidden */
  131286. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131287. /** @hidden */
  131288. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131289. }
  131290. }
  131291. declare module BABYLON {
  131292. /**
  131293. * @hidden
  131294. **/
  131295. export class _TimeToken {
  131296. _startTimeQuery: Nullable<WebGLQuery>;
  131297. _endTimeQuery: Nullable<WebGLQuery>;
  131298. _timeElapsedQuery: Nullable<WebGLQuery>;
  131299. _timeElapsedQueryEnded: boolean;
  131300. }
  131301. }
  131302. declare module BABYLON {
  131303. /** @hidden */
  131304. export class _OcclusionDataStorage {
  131305. /** @hidden */
  131306. occlusionInternalRetryCounter: number;
  131307. /** @hidden */
  131308. isOcclusionQueryInProgress: boolean;
  131309. /** @hidden */
  131310. isOccluded: boolean;
  131311. /** @hidden */
  131312. occlusionRetryCount: number;
  131313. /** @hidden */
  131314. occlusionType: number;
  131315. /** @hidden */
  131316. occlusionQueryAlgorithmType: number;
  131317. }
  131318. interface Engine {
  131319. /**
  131320. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  131321. * @return the new query
  131322. */
  131323. createQuery(): WebGLQuery;
  131324. /**
  131325. * Delete and release a webGL query
  131326. * @param query defines the query to delete
  131327. * @return the current engine
  131328. */
  131329. deleteQuery(query: WebGLQuery): Engine;
  131330. /**
  131331. * Check if a given query has resolved and got its value
  131332. * @param query defines the query to check
  131333. * @returns true if the query got its value
  131334. */
  131335. isQueryResultAvailable(query: WebGLQuery): boolean;
  131336. /**
  131337. * Gets the value of a given query
  131338. * @param query defines the query to check
  131339. * @returns the value of the query
  131340. */
  131341. getQueryResult(query: WebGLQuery): number;
  131342. /**
  131343. * Initiates an occlusion query
  131344. * @param algorithmType defines the algorithm to use
  131345. * @param query defines the query to use
  131346. * @returns the current engine
  131347. * @see https://doc.babylonjs.com/features/occlusionquery
  131348. */
  131349. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  131350. /**
  131351. * Ends an occlusion query
  131352. * @see https://doc.babylonjs.com/features/occlusionquery
  131353. * @param algorithmType defines the algorithm to use
  131354. * @returns the current engine
  131355. */
  131356. endOcclusionQuery(algorithmType: number): Engine;
  131357. /**
  131358. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  131359. * Please note that only one query can be issued at a time
  131360. * @returns a time token used to track the time span
  131361. */
  131362. startTimeQuery(): Nullable<_TimeToken>;
  131363. /**
  131364. * Ends a time query
  131365. * @param token defines the token used to measure the time span
  131366. * @returns the time spent (in ns)
  131367. */
  131368. endTimeQuery(token: _TimeToken): int;
  131369. /** @hidden */
  131370. _currentNonTimestampToken: Nullable<_TimeToken>;
  131371. /** @hidden */
  131372. _createTimeQuery(): WebGLQuery;
  131373. /** @hidden */
  131374. _deleteTimeQuery(query: WebGLQuery): void;
  131375. /** @hidden */
  131376. _getGlAlgorithmType(algorithmType: number): number;
  131377. /** @hidden */
  131378. _getTimeQueryResult(query: WebGLQuery): any;
  131379. /** @hidden */
  131380. _getTimeQueryAvailability(query: WebGLQuery): any;
  131381. }
  131382. interface AbstractMesh {
  131383. /**
  131384. * Backing filed
  131385. * @hidden
  131386. */
  131387. __occlusionDataStorage: _OcclusionDataStorage;
  131388. /**
  131389. * Access property
  131390. * @hidden
  131391. */
  131392. _occlusionDataStorage: _OcclusionDataStorage;
  131393. /**
  131394. * 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.
  131395. * The default value is -1 which means don't break the query and wait till the result
  131396. * @see https://doc.babylonjs.com/features/occlusionquery
  131397. */
  131398. occlusionRetryCount: number;
  131399. /**
  131400. * 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:
  131401. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  131402. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  131403. * * 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.
  131404. * @see https://doc.babylonjs.com/features/occlusionquery
  131405. */
  131406. occlusionType: number;
  131407. /**
  131408. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  131409. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  131410. * * 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.
  131411. * @see https://doc.babylonjs.com/features/occlusionquery
  131412. */
  131413. occlusionQueryAlgorithmType: number;
  131414. /**
  131415. * 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
  131416. * @see https://doc.babylonjs.com/features/occlusionquery
  131417. */
  131418. isOccluded: boolean;
  131419. /**
  131420. * Flag to check the progress status of the query
  131421. * @see https://doc.babylonjs.com/features/occlusionquery
  131422. */
  131423. isOcclusionQueryInProgress: boolean;
  131424. }
  131425. }
  131426. declare module BABYLON {
  131427. /** @hidden */
  131428. export var _forceTransformFeedbackToBundle: boolean;
  131429. interface Engine {
  131430. /**
  131431. * Creates a webGL transform feedback object
  131432. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  131433. * @returns the webGL transform feedback object
  131434. */
  131435. createTransformFeedback(): WebGLTransformFeedback;
  131436. /**
  131437. * Delete a webGL transform feedback object
  131438. * @param value defines the webGL transform feedback object to delete
  131439. */
  131440. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  131441. /**
  131442. * Bind a webGL transform feedback object to the webgl context
  131443. * @param value defines the webGL transform feedback object to bind
  131444. */
  131445. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  131446. /**
  131447. * Begins a transform feedback operation
  131448. * @param usePoints defines if points or triangles must be used
  131449. */
  131450. beginTransformFeedback(usePoints: boolean): void;
  131451. /**
  131452. * Ends a transform feedback operation
  131453. */
  131454. endTransformFeedback(): void;
  131455. /**
  131456. * Specify the varyings to use with transform feedback
  131457. * @param program defines the associated webGL program
  131458. * @param value defines the list of strings representing the varying names
  131459. */
  131460. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  131461. /**
  131462. * Bind a webGL buffer for a transform feedback operation
  131463. * @param value defines the webGL buffer to bind
  131464. */
  131465. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  131466. }
  131467. }
  131468. declare module BABYLON {
  131469. /**
  131470. * Class used to define an additional view for the engine
  131471. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131472. */
  131473. export class EngineView {
  131474. /** Defines the canvas where to render the view */
  131475. target: HTMLCanvasElement;
  131476. /** Defines an optional camera used to render the view (will use active camera else) */
  131477. camera?: Camera;
  131478. }
  131479. interface Engine {
  131480. /**
  131481. * Gets or sets the HTML element to use for attaching events
  131482. */
  131483. inputElement: Nullable<HTMLElement>;
  131484. /**
  131485. * Gets the current engine view
  131486. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131487. */
  131488. activeView: Nullable<EngineView>;
  131489. /** Gets or sets the list of views */
  131490. views: EngineView[];
  131491. /**
  131492. * Register a new child canvas
  131493. * @param canvas defines the canvas to register
  131494. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  131495. * @returns the associated view
  131496. */
  131497. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  131498. /**
  131499. * Remove a registered child canvas
  131500. * @param canvas defines the canvas to remove
  131501. * @returns the current engine
  131502. */
  131503. unRegisterView(canvas: HTMLCanvasElement): Engine;
  131504. }
  131505. }
  131506. declare module BABYLON {
  131507. interface Engine {
  131508. /** @hidden */
  131509. _excludedCompressedTextures: string[];
  131510. /** @hidden */
  131511. _textureFormatInUse: string;
  131512. /**
  131513. * Gets the list of texture formats supported
  131514. */
  131515. readonly texturesSupported: Array<string>;
  131516. /**
  131517. * Gets the texture format in use
  131518. */
  131519. readonly textureFormatInUse: Nullable<string>;
  131520. /**
  131521. * Set the compressed texture extensions or file names to skip.
  131522. *
  131523. * @param skippedFiles defines the list of those texture files you want to skip
  131524. * Example: [".dds", ".env", "myfile.png"]
  131525. */
  131526. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  131527. /**
  131528. * Set the compressed texture format to use, based on the formats you have, and the formats
  131529. * supported by the hardware / browser.
  131530. *
  131531. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  131532. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  131533. * to API arguments needed to compressed textures. This puts the burden on the container
  131534. * generator to house the arcane code for determining these for current & future formats.
  131535. *
  131536. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  131537. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  131538. *
  131539. * Note: The result of this call is not taken into account when a texture is base64.
  131540. *
  131541. * @param formatsAvailable defines the list of those format families you have created
  131542. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  131543. *
  131544. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  131545. * @returns The extension selected.
  131546. */
  131547. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  131548. }
  131549. }
  131550. declare module BABYLON {
  131551. /**
  131552. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  131553. */
  131554. export interface CubeMapInfo {
  131555. /**
  131556. * The pixel array for the front face.
  131557. * This is stored in format, left to right, up to down format.
  131558. */
  131559. front: Nullable<ArrayBufferView>;
  131560. /**
  131561. * The pixel array for the back face.
  131562. * This is stored in format, left to right, up to down format.
  131563. */
  131564. back: Nullable<ArrayBufferView>;
  131565. /**
  131566. * The pixel array for the left face.
  131567. * This is stored in format, left to right, up to down format.
  131568. */
  131569. left: Nullable<ArrayBufferView>;
  131570. /**
  131571. * The pixel array for the right face.
  131572. * This is stored in format, left to right, up to down format.
  131573. */
  131574. right: Nullable<ArrayBufferView>;
  131575. /**
  131576. * The pixel array for the up face.
  131577. * This is stored in format, left to right, up to down format.
  131578. */
  131579. up: Nullable<ArrayBufferView>;
  131580. /**
  131581. * The pixel array for the down face.
  131582. * This is stored in format, left to right, up to down format.
  131583. */
  131584. down: Nullable<ArrayBufferView>;
  131585. /**
  131586. * The size of the cubemap stored.
  131587. *
  131588. * Each faces will be size * size pixels.
  131589. */
  131590. size: number;
  131591. /**
  131592. * The format of the texture.
  131593. *
  131594. * RGBA, RGB.
  131595. */
  131596. format: number;
  131597. /**
  131598. * The type of the texture data.
  131599. *
  131600. * UNSIGNED_INT, FLOAT.
  131601. */
  131602. type: number;
  131603. /**
  131604. * Specifies whether the texture is in gamma space.
  131605. */
  131606. gammaSpace: boolean;
  131607. }
  131608. /**
  131609. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131610. */
  131611. export class PanoramaToCubeMapTools {
  131612. private static FACE_LEFT;
  131613. private static FACE_RIGHT;
  131614. private static FACE_FRONT;
  131615. private static FACE_BACK;
  131616. private static FACE_DOWN;
  131617. private static FACE_UP;
  131618. /**
  131619. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131620. *
  131621. * @param float32Array The source data.
  131622. * @param inputWidth The width of the input panorama.
  131623. * @param inputHeight The height of the input panorama.
  131624. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131625. * @return The cubemap data
  131626. */
  131627. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131628. private static CreateCubemapTexture;
  131629. private static CalcProjectionSpherical;
  131630. }
  131631. }
  131632. declare module BABYLON {
  131633. /**
  131634. * Helper class dealing with the extraction of spherical polynomial dataArray
  131635. * from a cube map.
  131636. */
  131637. export class CubeMapToSphericalPolynomialTools {
  131638. private static FileFaces;
  131639. /**
  131640. * Converts a texture to the according Spherical Polynomial data.
  131641. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131642. *
  131643. * @param texture The texture to extract the information from.
  131644. * @return The Spherical Polynomial data.
  131645. */
  131646. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131647. /**
  131648. * Converts a cubemap to the according Spherical Polynomial data.
  131649. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131650. *
  131651. * @param cubeInfo The Cube map to extract the information from.
  131652. * @return The Spherical Polynomial data.
  131653. */
  131654. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131655. }
  131656. }
  131657. declare module BABYLON {
  131658. interface BaseTexture {
  131659. /**
  131660. * Get the polynomial representation of the texture data.
  131661. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131662. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131663. */
  131664. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131665. }
  131666. }
  131667. declare module BABYLON {
  131668. /** @hidden */
  131669. export var rgbdEncodePixelShader: {
  131670. name: string;
  131671. shader: string;
  131672. };
  131673. }
  131674. declare module BABYLON {
  131675. /** @hidden */
  131676. export var rgbdDecodePixelShader: {
  131677. name: string;
  131678. shader: string;
  131679. };
  131680. }
  131681. declare module BABYLON {
  131682. /**
  131683. * Raw texture data and descriptor sufficient for WebGL texture upload
  131684. */
  131685. export interface EnvironmentTextureInfo {
  131686. /**
  131687. * Version of the environment map
  131688. */
  131689. version: number;
  131690. /**
  131691. * Width of image
  131692. */
  131693. width: number;
  131694. /**
  131695. * Irradiance information stored in the file.
  131696. */
  131697. irradiance: any;
  131698. /**
  131699. * Specular information stored in the file.
  131700. */
  131701. specular: any;
  131702. }
  131703. /**
  131704. * Defines One Image in the file. It requires only the position in the file
  131705. * as well as the length.
  131706. */
  131707. interface BufferImageData {
  131708. /**
  131709. * Length of the image data.
  131710. */
  131711. length: number;
  131712. /**
  131713. * Position of the data from the null terminator delimiting the end of the JSON.
  131714. */
  131715. position: number;
  131716. }
  131717. /**
  131718. * Defines the specular data enclosed in the file.
  131719. * This corresponds to the version 1 of the data.
  131720. */
  131721. export interface EnvironmentTextureSpecularInfoV1 {
  131722. /**
  131723. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131724. */
  131725. specularDataPosition?: number;
  131726. /**
  131727. * This contains all the images data needed to reconstruct the cubemap.
  131728. */
  131729. mipmaps: Array<BufferImageData>;
  131730. /**
  131731. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131732. */
  131733. lodGenerationScale: number;
  131734. }
  131735. /**
  131736. * Sets of helpers addressing the serialization and deserialization of environment texture
  131737. * stored in a BabylonJS env file.
  131738. * Those files are usually stored as .env files.
  131739. */
  131740. export class EnvironmentTextureTools {
  131741. /**
  131742. * Magic number identifying the env file.
  131743. */
  131744. private static _MagicBytes;
  131745. /**
  131746. * Gets the environment info from an env file.
  131747. * @param data The array buffer containing the .env bytes.
  131748. * @returns the environment file info (the json header) if successfully parsed.
  131749. */
  131750. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131751. /**
  131752. * Creates an environment texture from a loaded cube texture.
  131753. * @param texture defines the cube texture to convert in env file
  131754. * @return a promise containing the environment data if succesfull.
  131755. */
  131756. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131757. /**
  131758. * Creates a JSON representation of the spherical data.
  131759. * @param texture defines the texture containing the polynomials
  131760. * @return the JSON representation of the spherical info
  131761. */
  131762. private static _CreateEnvTextureIrradiance;
  131763. /**
  131764. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131765. * @param data the image data
  131766. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131767. * @return the views described by info providing access to the underlying buffer
  131768. */
  131769. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131770. /**
  131771. * Uploads the texture info contained in the env file to the GPU.
  131772. * @param texture defines the internal texture to upload to
  131773. * @param data defines the data to load
  131774. * @param info defines the texture info retrieved through the GetEnvInfo method
  131775. * @returns a promise
  131776. */
  131777. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131778. private static _OnImageReadyAsync;
  131779. /**
  131780. * Uploads the levels of image data to the GPU.
  131781. * @param texture defines the internal texture to upload to
  131782. * @param imageData defines the array buffer views of image data [mipmap][face]
  131783. * @returns a promise
  131784. */
  131785. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131786. /**
  131787. * Uploads spherical polynomials information to the texture.
  131788. * @param texture defines the texture we are trying to upload the information to
  131789. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131790. */
  131791. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131792. /** @hidden */
  131793. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131794. }
  131795. }
  131796. declare module BABYLON {
  131797. /**
  131798. * Class used to inline functions in shader code
  131799. */
  131800. export class ShaderCodeInliner {
  131801. private static readonly _RegexpFindFunctionNameAndType;
  131802. private _sourceCode;
  131803. private _functionDescr;
  131804. private _numMaxIterations;
  131805. /** Gets or sets the token used to mark the functions to inline */
  131806. inlineToken: string;
  131807. /** Gets or sets the debug mode */
  131808. debug: boolean;
  131809. /** Gets the code after the inlining process */
  131810. get code(): string;
  131811. /**
  131812. * Initializes the inliner
  131813. * @param sourceCode shader code source to inline
  131814. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131815. */
  131816. constructor(sourceCode: string, numMaxIterations?: number);
  131817. /**
  131818. * Start the processing of the shader code
  131819. */
  131820. processCode(): void;
  131821. private _collectFunctions;
  131822. private _processInlining;
  131823. private _extractBetweenMarkers;
  131824. private _skipWhitespaces;
  131825. private _removeComments;
  131826. private _replaceFunctionCallsByCode;
  131827. private _findBackward;
  131828. private _escapeRegExp;
  131829. private _replaceNames;
  131830. }
  131831. }
  131832. declare module BABYLON {
  131833. /**
  131834. * Container for accessors for natively-stored mesh data buffers.
  131835. */
  131836. class NativeDataBuffer extends DataBuffer {
  131837. /**
  131838. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131839. */
  131840. nativeIndexBuffer?: any;
  131841. /**
  131842. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131843. */
  131844. nativeVertexBuffer?: any;
  131845. }
  131846. /** @hidden */
  131847. class NativeTexture extends InternalTexture {
  131848. getInternalTexture(): InternalTexture;
  131849. getViewCount(): number;
  131850. }
  131851. /** @hidden */
  131852. export class NativeEngine extends Engine {
  131853. private readonly _native;
  131854. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131855. private readonly INVALID_HANDLE;
  131856. private _boundBuffersVertexArray;
  131857. getHardwareScalingLevel(): number;
  131858. constructor();
  131859. dispose(): void;
  131860. /**
  131861. * Can be used to override the current requestAnimationFrame requester.
  131862. * @hidden
  131863. */
  131864. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131865. /**
  131866. * Override default engine behavior.
  131867. * @param color
  131868. * @param backBuffer
  131869. * @param depth
  131870. * @param stencil
  131871. */
  131872. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131873. /**
  131874. * Gets host document
  131875. * @returns the host document object
  131876. */
  131877. getHostDocument(): Nullable<Document>;
  131878. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131879. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131880. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131881. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  131882. [key: string]: VertexBuffer;
  131883. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131884. bindBuffers(vertexBuffers: {
  131885. [key: string]: VertexBuffer;
  131886. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131887. recordVertexArrayObject(vertexBuffers: {
  131888. [key: string]: VertexBuffer;
  131889. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131890. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131891. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131892. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131893. /**
  131894. * Draw a list of indexed primitives
  131895. * @param fillMode defines the primitive to use
  131896. * @param indexStart defines the starting index
  131897. * @param indexCount defines the number of index to draw
  131898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131899. */
  131900. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131901. /**
  131902. * Draw a list of unindexed primitives
  131903. * @param fillMode defines the primitive to use
  131904. * @param verticesStart defines the index of first vertex to draw
  131905. * @param verticesCount defines the count of vertices to draw
  131906. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131907. */
  131908. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131909. createPipelineContext(): IPipelineContext;
  131910. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131911. /** @hidden */
  131912. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131913. /** @hidden */
  131914. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131915. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131916. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131917. protected _setProgram(program: WebGLProgram): void;
  131918. _releaseEffect(effect: Effect): void;
  131919. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131920. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131921. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131922. bindSamplers(effect: Effect): void;
  131923. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131924. getRenderWidth(useScreen?: boolean): number;
  131925. getRenderHeight(useScreen?: boolean): number;
  131926. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131927. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131928. /**
  131929. * Set the z offset to apply to current rendering
  131930. * @param value defines the offset to apply
  131931. */
  131932. setZOffset(value: number): void;
  131933. /**
  131934. * Gets the current value of the zOffset
  131935. * @returns the current zOffset state
  131936. */
  131937. getZOffset(): number;
  131938. /**
  131939. * Enable or disable depth buffering
  131940. * @param enable defines the state to set
  131941. */
  131942. setDepthBuffer(enable: boolean): void;
  131943. /**
  131944. * Gets a boolean indicating if depth writing is enabled
  131945. * @returns the current depth writing state
  131946. */
  131947. getDepthWrite(): boolean;
  131948. /**
  131949. * Enable or disable depth writing
  131950. * @param enable defines the state to set
  131951. */
  131952. setDepthWrite(enable: boolean): void;
  131953. /**
  131954. * Enable or disable color writing
  131955. * @param enable defines the state to set
  131956. */
  131957. setColorWrite(enable: boolean): void;
  131958. /**
  131959. * Gets a boolean indicating if color writing is enabled
  131960. * @returns the current color writing state
  131961. */
  131962. getColorWrite(): boolean;
  131963. /**
  131964. * Sets alpha constants used by some alpha blending modes
  131965. * @param r defines the red component
  131966. * @param g defines the green component
  131967. * @param b defines the blue component
  131968. * @param a defines the alpha component
  131969. */
  131970. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131971. /**
  131972. * Sets the current alpha mode
  131973. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131974. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131975. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131976. */
  131977. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131978. /**
  131979. * Gets the current alpha mode
  131980. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131981. * @returns the current alpha mode
  131982. */
  131983. getAlphaMode(): number;
  131984. setInt(uniform: WebGLUniformLocation, int: number): void;
  131985. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131986. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131987. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131988. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131989. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131990. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131991. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131992. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131993. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131994. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131995. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131996. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131997. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131998. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131999. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132000. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132001. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132002. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132003. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132004. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132005. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132006. wipeCaches(bruteForce?: boolean): void;
  132007. _createTexture(): WebGLTexture;
  132008. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132009. /**
  132010. * Usually called from Texture.ts.
  132011. * Passed information to create a WebGLTexture
  132012. * @param url defines a value which contains one of the following:
  132013. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132014. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132015. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132016. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132017. * @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)
  132018. * @param scene needed for loading to the correct scene
  132019. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132020. * @param onLoad optional callback to be called upon successful completion
  132021. * @param onError optional callback to be called upon failure
  132022. * @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
  132023. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132024. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132025. * @param forcedExtension defines the extension to use to pick the right loader
  132026. * @param mimeType defines an optional mime type
  132027. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132028. */
  132029. 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;
  132030. /**
  132031. * Creates a cube texture
  132032. * @param rootUrl defines the url where the files to load is located
  132033. * @param scene defines the current scene
  132034. * @param files defines the list of files to load (1 per face)
  132035. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132036. * @param onLoad defines an optional callback raised when the texture is loaded
  132037. * @param onError defines an optional callback raised if there is an issue to load the texture
  132038. * @param format defines the format of the data
  132039. * @param forcedExtension defines the extension to use to pick the right loader
  132040. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132041. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132042. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132043. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132044. * @returns the cube texture as an InternalTexture
  132045. */
  132046. 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;
  132047. private _getSamplingFilter;
  132048. private static _GetNativeTextureFormat;
  132049. createRenderTargetTexture(size: number | {
  132050. width: number;
  132051. height: number;
  132052. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132053. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132054. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132055. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132056. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132057. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132058. /**
  132059. * Updates a dynamic vertex buffer.
  132060. * @param vertexBuffer the vertex buffer to update
  132061. * @param data the data used to update the vertex buffer
  132062. * @param byteOffset the byte offset of the data (optional)
  132063. * @param byteLength the byte length of the data (optional)
  132064. */
  132065. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132066. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132067. private _updateAnisotropicLevel;
  132068. private _getAddressMode;
  132069. /** @hidden */
  132070. _bindTexture(channel: number, texture: InternalTexture): void;
  132071. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132072. releaseEffects(): void;
  132073. /** @hidden */
  132074. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132075. /** @hidden */
  132076. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132077. /** @hidden */
  132078. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132079. /** @hidden */
  132080. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132081. }
  132082. }
  132083. declare module BABYLON {
  132084. /**
  132085. * Gather the list of clipboard event types as constants.
  132086. */
  132087. export class ClipboardEventTypes {
  132088. /**
  132089. * The clipboard event is fired when a copy command is active (pressed).
  132090. */
  132091. static readonly COPY: number;
  132092. /**
  132093. * The clipboard event is fired when a cut command is active (pressed).
  132094. */
  132095. static readonly CUT: number;
  132096. /**
  132097. * The clipboard event is fired when a paste command is active (pressed).
  132098. */
  132099. static readonly PASTE: number;
  132100. }
  132101. /**
  132102. * This class is used to store clipboard related info for the onClipboardObservable event.
  132103. */
  132104. export class ClipboardInfo {
  132105. /**
  132106. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132107. */
  132108. type: number;
  132109. /**
  132110. * Defines the related dom event
  132111. */
  132112. event: ClipboardEvent;
  132113. /**
  132114. *Creates an instance of ClipboardInfo.
  132115. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  132116. * @param event Defines the related dom event
  132117. */
  132118. constructor(
  132119. /**
  132120. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132121. */
  132122. type: number,
  132123. /**
  132124. * Defines the related dom event
  132125. */
  132126. event: ClipboardEvent);
  132127. /**
  132128. * Get the clipboard event's type from the keycode.
  132129. * @param keyCode Defines the keyCode for the current keyboard event.
  132130. * @return {number}
  132131. */
  132132. static GetTypeFromCharacter(keyCode: number): number;
  132133. }
  132134. }
  132135. declare module BABYLON {
  132136. /**
  132137. * Google Daydream controller
  132138. */
  132139. export class DaydreamController extends WebVRController {
  132140. /**
  132141. * Base Url for the controller model.
  132142. */
  132143. static MODEL_BASE_URL: string;
  132144. /**
  132145. * File name for the controller model.
  132146. */
  132147. static MODEL_FILENAME: string;
  132148. /**
  132149. * Gamepad Id prefix used to identify Daydream Controller.
  132150. */
  132151. static readonly GAMEPAD_ID_PREFIX: string;
  132152. /**
  132153. * Creates a new DaydreamController from a gamepad
  132154. * @param vrGamepad the gamepad that the controller should be created from
  132155. */
  132156. constructor(vrGamepad: any);
  132157. /**
  132158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132159. * @param scene scene in which to add meshes
  132160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132161. */
  132162. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132163. /**
  132164. * Called once for each button that changed state since the last frame
  132165. * @param buttonIdx Which button index changed
  132166. * @param state New state of the button
  132167. * @param changes Which properties on the state changed since last frame
  132168. */
  132169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132170. }
  132171. }
  132172. declare module BABYLON {
  132173. /**
  132174. * Gear VR Controller
  132175. */
  132176. export class GearVRController extends WebVRController {
  132177. /**
  132178. * Base Url for the controller model.
  132179. */
  132180. static MODEL_BASE_URL: string;
  132181. /**
  132182. * File name for the controller model.
  132183. */
  132184. static MODEL_FILENAME: string;
  132185. /**
  132186. * Gamepad Id prefix used to identify this controller.
  132187. */
  132188. static readonly GAMEPAD_ID_PREFIX: string;
  132189. private readonly _buttonIndexToObservableNameMap;
  132190. /**
  132191. * Creates a new GearVRController from a gamepad
  132192. * @param vrGamepad the gamepad that the controller should be created from
  132193. */
  132194. constructor(vrGamepad: any);
  132195. /**
  132196. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132197. * @param scene scene in which to add meshes
  132198. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132199. */
  132200. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132201. /**
  132202. * Called once for each button that changed state since the last frame
  132203. * @param buttonIdx Which button index changed
  132204. * @param state New state of the button
  132205. * @param changes Which properties on the state changed since last frame
  132206. */
  132207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132208. }
  132209. }
  132210. declare module BABYLON {
  132211. /**
  132212. * Generic Controller
  132213. */
  132214. export class GenericController extends WebVRController {
  132215. /**
  132216. * Base Url for the controller model.
  132217. */
  132218. static readonly MODEL_BASE_URL: string;
  132219. /**
  132220. * File name for the controller model.
  132221. */
  132222. static readonly MODEL_FILENAME: string;
  132223. /**
  132224. * Creates a new GenericController from a gamepad
  132225. * @param vrGamepad the gamepad that the controller should be created from
  132226. */
  132227. constructor(vrGamepad: any);
  132228. /**
  132229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132230. * @param scene scene in which to add meshes
  132231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132232. */
  132233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132234. /**
  132235. * Called once for each button that changed state since the last frame
  132236. * @param buttonIdx Which button index changed
  132237. * @param state New state of the button
  132238. * @param changes Which properties on the state changed since last frame
  132239. */
  132240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132241. }
  132242. }
  132243. declare module BABYLON {
  132244. /**
  132245. * Oculus Touch Controller
  132246. */
  132247. export class OculusTouchController extends WebVRController {
  132248. /**
  132249. * Base Url for the controller model.
  132250. */
  132251. static MODEL_BASE_URL: string;
  132252. /**
  132253. * File name for the left controller model.
  132254. */
  132255. static MODEL_LEFT_FILENAME: string;
  132256. /**
  132257. * File name for the right controller model.
  132258. */
  132259. static MODEL_RIGHT_FILENAME: string;
  132260. /**
  132261. * Base Url for the Quest controller model.
  132262. */
  132263. static QUEST_MODEL_BASE_URL: string;
  132264. /**
  132265. * @hidden
  132266. * If the controllers are running on a device that needs the updated Quest controller models
  132267. */
  132268. static _IsQuest: boolean;
  132269. /**
  132270. * Fired when the secondary trigger on this controller is modified
  132271. */
  132272. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  132273. /**
  132274. * Fired when the thumb rest on this controller is modified
  132275. */
  132276. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  132277. /**
  132278. * Creates a new OculusTouchController from a gamepad
  132279. * @param vrGamepad the gamepad that the controller should be created from
  132280. */
  132281. constructor(vrGamepad: any);
  132282. /**
  132283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132284. * @param scene scene in which to add meshes
  132285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132286. */
  132287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132288. /**
  132289. * Fired when the A button on this controller is modified
  132290. */
  132291. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132292. /**
  132293. * Fired when the B button on this controller is modified
  132294. */
  132295. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132296. /**
  132297. * Fired when the X button on this controller is modified
  132298. */
  132299. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132300. /**
  132301. * Fired when the Y button on this controller is modified
  132302. */
  132303. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132304. /**
  132305. * Called once for each button that changed state since the last frame
  132306. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  132307. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  132308. * 2) secondary trigger (same)
  132309. * 3) A (right) X (left), touch, pressed = value
  132310. * 4) B / Y
  132311. * 5) thumb rest
  132312. * @param buttonIdx Which button index changed
  132313. * @param state New state of the button
  132314. * @param changes Which properties on the state changed since last frame
  132315. */
  132316. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132317. }
  132318. }
  132319. declare module BABYLON {
  132320. /**
  132321. * Vive Controller
  132322. */
  132323. export class ViveController extends WebVRController {
  132324. /**
  132325. * Base Url for the controller model.
  132326. */
  132327. static MODEL_BASE_URL: string;
  132328. /**
  132329. * File name for the controller model.
  132330. */
  132331. static MODEL_FILENAME: string;
  132332. /**
  132333. * Creates a new ViveController from a gamepad
  132334. * @param vrGamepad the gamepad that the controller should be created from
  132335. */
  132336. constructor(vrGamepad: any);
  132337. /**
  132338. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132339. * @param scene scene in which to add meshes
  132340. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132341. */
  132342. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132343. /**
  132344. * Fired when the left button on this controller is modified
  132345. */
  132346. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132347. /**
  132348. * Fired when the right button on this controller is modified
  132349. */
  132350. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132351. /**
  132352. * Fired when the menu button on this controller is modified
  132353. */
  132354. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132355. /**
  132356. * Called once for each button that changed state since the last frame
  132357. * Vive mapping:
  132358. * 0: touchpad
  132359. * 1: trigger
  132360. * 2: left AND right buttons
  132361. * 3: menu button
  132362. * @param buttonIdx Which button index changed
  132363. * @param state New state of the button
  132364. * @param changes Which properties on the state changed since last frame
  132365. */
  132366. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132367. }
  132368. }
  132369. declare module BABYLON {
  132370. /**
  132371. * Defines the WindowsMotionController object that the state of the windows motion controller
  132372. */
  132373. export class WindowsMotionController extends WebVRController {
  132374. /**
  132375. * The base url used to load the left and right controller models
  132376. */
  132377. static MODEL_BASE_URL: string;
  132378. /**
  132379. * The name of the left controller model file
  132380. */
  132381. static MODEL_LEFT_FILENAME: string;
  132382. /**
  132383. * The name of the right controller model file
  132384. */
  132385. static MODEL_RIGHT_FILENAME: string;
  132386. /**
  132387. * The controller name prefix for this controller type
  132388. */
  132389. static readonly GAMEPAD_ID_PREFIX: string;
  132390. /**
  132391. * The controller id pattern for this controller type
  132392. */
  132393. private static readonly GAMEPAD_ID_PATTERN;
  132394. private _loadedMeshInfo;
  132395. protected readonly _mapping: {
  132396. buttons: string[];
  132397. buttonMeshNames: {
  132398. trigger: string;
  132399. menu: string;
  132400. grip: string;
  132401. thumbstick: string;
  132402. trackpad: string;
  132403. };
  132404. buttonObservableNames: {
  132405. trigger: string;
  132406. menu: string;
  132407. grip: string;
  132408. thumbstick: string;
  132409. trackpad: string;
  132410. };
  132411. axisMeshNames: string[];
  132412. pointingPoseMeshName: string;
  132413. };
  132414. /**
  132415. * Fired when the trackpad on this controller is clicked
  132416. */
  132417. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132418. /**
  132419. * Fired when the trackpad on this controller is modified
  132420. */
  132421. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132422. /**
  132423. * The current x and y values of this controller's trackpad
  132424. */
  132425. trackpad: StickValues;
  132426. /**
  132427. * Creates a new WindowsMotionController from a gamepad
  132428. * @param vrGamepad the gamepad that the controller should be created from
  132429. */
  132430. constructor(vrGamepad: any);
  132431. /**
  132432. * Fired when the trigger on this controller is modified
  132433. */
  132434. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132435. /**
  132436. * Fired when the menu button on this controller is modified
  132437. */
  132438. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132439. /**
  132440. * Fired when the grip button on this controller is modified
  132441. */
  132442. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132443. /**
  132444. * Fired when the thumbstick button on this controller is modified
  132445. */
  132446. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132447. /**
  132448. * Fired when the touchpad button on this controller is modified
  132449. */
  132450. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132451. /**
  132452. * Fired when the touchpad values on this controller are modified
  132453. */
  132454. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  132455. protected _updateTrackpad(): void;
  132456. /**
  132457. * Called once per frame by the engine.
  132458. */
  132459. update(): void;
  132460. /**
  132461. * Called once for each button that changed state since the last frame
  132462. * @param buttonIdx Which button index changed
  132463. * @param state New state of the button
  132464. * @param changes Which properties on the state changed since last frame
  132465. */
  132466. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132467. /**
  132468. * Moves the buttons on the controller mesh based on their current state
  132469. * @param buttonName the name of the button to move
  132470. * @param buttonValue the value of the button which determines the buttons new position
  132471. */
  132472. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  132473. /**
  132474. * Moves the axis on the controller mesh based on its current state
  132475. * @param axis the index of the axis
  132476. * @param axisValue the value of the axis which determines the meshes new position
  132477. * @hidden
  132478. */
  132479. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  132480. /**
  132481. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132482. * @param scene scene in which to add meshes
  132483. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132484. */
  132485. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  132486. /**
  132487. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  132488. * can be transformed by button presses and axes values, based on this._mapping.
  132489. *
  132490. * @param scene scene in which the meshes exist
  132491. * @param meshes list of meshes that make up the controller model to process
  132492. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  132493. */
  132494. private processModel;
  132495. private createMeshInfo;
  132496. /**
  132497. * Gets the ray of the controller in the direction the controller is pointing
  132498. * @param length the length the resulting ray should be
  132499. * @returns a ray in the direction the controller is pointing
  132500. */
  132501. getForwardRay(length?: number): Ray;
  132502. /**
  132503. * Disposes of the controller
  132504. */
  132505. dispose(): void;
  132506. }
  132507. /**
  132508. * This class represents a new windows motion controller in XR.
  132509. */
  132510. export class XRWindowsMotionController extends WindowsMotionController {
  132511. /**
  132512. * Changing the original WIndowsMotionController mapping to fir the new mapping
  132513. */
  132514. protected readonly _mapping: {
  132515. buttons: string[];
  132516. buttonMeshNames: {
  132517. trigger: string;
  132518. menu: string;
  132519. grip: string;
  132520. thumbstick: string;
  132521. trackpad: string;
  132522. };
  132523. buttonObservableNames: {
  132524. trigger: string;
  132525. menu: string;
  132526. grip: string;
  132527. thumbstick: string;
  132528. trackpad: string;
  132529. };
  132530. axisMeshNames: string[];
  132531. pointingPoseMeshName: string;
  132532. };
  132533. /**
  132534. * Construct a new XR-Based windows motion controller
  132535. *
  132536. * @param gamepadInfo the gamepad object from the browser
  132537. */
  132538. constructor(gamepadInfo: any);
  132539. /**
  132540. * holds the thumbstick values (X,Y)
  132541. */
  132542. thumbstickValues: StickValues;
  132543. /**
  132544. * Fired when the thumbstick on this controller is clicked
  132545. */
  132546. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  132547. /**
  132548. * Fired when the thumbstick on this controller is modified
  132549. */
  132550. onThumbstickValuesChangedObservable: Observable<StickValues>;
  132551. /**
  132552. * Fired when the touchpad button on this controller is modified
  132553. */
  132554. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132555. /**
  132556. * Fired when the touchpad values on this controller are modified
  132557. */
  132558. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132559. /**
  132560. * Fired when the thumbstick button on this controller is modified
  132561. * here to prevent breaking changes
  132562. */
  132563. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132564. /**
  132565. * updating the thumbstick(!) and not the trackpad.
  132566. * This is named this way due to the difference between WebVR and XR and to avoid
  132567. * changing the parent class.
  132568. */
  132569. protected _updateTrackpad(): void;
  132570. /**
  132571. * Disposes the class with joy
  132572. */
  132573. dispose(): void;
  132574. }
  132575. }
  132576. declare module BABYLON {
  132577. /**
  132578. * Class containing static functions to help procedurally build meshes
  132579. */
  132580. export class PolyhedronBuilder {
  132581. /**
  132582. * Creates a polyhedron mesh
  132583. * * 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
  132584. * * The parameter `size` (positive float, default 1) sets the polygon size
  132585. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132586. * * 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`
  132587. * * 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
  132588. * * 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)`)
  132589. * * 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
  132590. * * 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
  132591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132594. * @param name defines the name of the mesh
  132595. * @param options defines the options used to create the mesh
  132596. * @param scene defines the hosting scene
  132597. * @returns the polyhedron mesh
  132598. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132599. */
  132600. static CreatePolyhedron(name: string, options: {
  132601. type?: number;
  132602. size?: number;
  132603. sizeX?: number;
  132604. sizeY?: number;
  132605. sizeZ?: number;
  132606. custom?: any;
  132607. faceUV?: Vector4[];
  132608. faceColors?: Color4[];
  132609. flat?: boolean;
  132610. updatable?: boolean;
  132611. sideOrientation?: number;
  132612. frontUVs?: Vector4;
  132613. backUVs?: Vector4;
  132614. }, scene?: Nullable<Scene>): Mesh;
  132615. }
  132616. }
  132617. declare module BABYLON {
  132618. /**
  132619. * Gizmo that enables scaling a mesh along 3 axis
  132620. */
  132621. export class ScaleGizmo extends Gizmo {
  132622. /**
  132623. * Internal gizmo used for interactions on the x axis
  132624. */
  132625. xGizmo: AxisScaleGizmo;
  132626. /**
  132627. * Internal gizmo used for interactions on the y axis
  132628. */
  132629. yGizmo: AxisScaleGizmo;
  132630. /**
  132631. * Internal gizmo used for interactions on the z axis
  132632. */
  132633. zGizmo: AxisScaleGizmo;
  132634. /**
  132635. * Internal gizmo used to scale all axis equally
  132636. */
  132637. uniformScaleGizmo: AxisScaleGizmo;
  132638. private _meshAttached;
  132639. private _nodeAttached;
  132640. private _updateGizmoRotationToMatchAttachedMesh;
  132641. private _snapDistance;
  132642. private _scaleRatio;
  132643. private _uniformScalingMesh;
  132644. private _octahedron;
  132645. private _sensitivity;
  132646. /** Fires an event when any of it's sub gizmos are dragged */
  132647. onDragStartObservable: Observable<unknown>;
  132648. /** Fires an event when any of it's sub gizmos are released from dragging */
  132649. onDragEndObservable: Observable<unknown>;
  132650. get attachedMesh(): Nullable<AbstractMesh>;
  132651. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132652. get attachedNode(): Nullable<Node>;
  132653. set attachedNode(node: Nullable<Node>);
  132654. /**
  132655. * Creates a ScaleGizmo
  132656. * @param gizmoLayer The utility layer the gizmo will be added to
  132657. * @param thickness display gizmo axis thickness
  132658. */
  132659. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132660. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132661. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132662. /**
  132663. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132664. */
  132665. set snapDistance(value: number);
  132666. get snapDistance(): number;
  132667. /**
  132668. * Ratio for the scale of the gizmo (Default: 1)
  132669. */
  132670. set scaleRatio(value: number);
  132671. get scaleRatio(): number;
  132672. /**
  132673. * Sensitivity factor for dragging (Default: 1)
  132674. */
  132675. set sensitivity(value: number);
  132676. get sensitivity(): number;
  132677. /**
  132678. * Disposes of the gizmo
  132679. */
  132680. dispose(): void;
  132681. }
  132682. }
  132683. declare module BABYLON {
  132684. /**
  132685. * Single axis scale gizmo
  132686. */
  132687. export class AxisScaleGizmo extends Gizmo {
  132688. /**
  132689. * Drag behavior responsible for the gizmos dragging interactions
  132690. */
  132691. dragBehavior: PointerDragBehavior;
  132692. private _pointerObserver;
  132693. /**
  132694. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132695. */
  132696. snapDistance: number;
  132697. /**
  132698. * Event that fires each time the gizmo snaps to a new location.
  132699. * * snapDistance is the the change in distance
  132700. */
  132701. onSnapObservable: Observable<{
  132702. snapDistance: number;
  132703. }>;
  132704. /**
  132705. * If the scaling operation should be done on all axis (default: false)
  132706. */
  132707. uniformScaling: boolean;
  132708. /**
  132709. * Custom sensitivity value for the drag strength
  132710. */
  132711. sensitivity: number;
  132712. private _isEnabled;
  132713. private _parent;
  132714. private _arrow;
  132715. private _coloredMaterial;
  132716. private _hoverMaterial;
  132717. /**
  132718. * Creates an AxisScaleGizmo
  132719. * @param gizmoLayer The utility layer the gizmo will be added to
  132720. * @param dragAxis The axis which the gizmo will be able to scale on
  132721. * @param color The color of the gizmo
  132722. * @param thickness display gizmo axis thickness
  132723. */
  132724. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132725. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132726. /**
  132727. * If the gizmo is enabled
  132728. */
  132729. set isEnabled(value: boolean);
  132730. get isEnabled(): boolean;
  132731. /**
  132732. * Disposes of the gizmo
  132733. */
  132734. dispose(): void;
  132735. /**
  132736. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132737. * @param mesh The mesh to replace the default mesh of the gizmo
  132738. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132739. */
  132740. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132741. }
  132742. }
  132743. declare module BABYLON {
  132744. /**
  132745. * Bounding box gizmo
  132746. */
  132747. export class BoundingBoxGizmo extends Gizmo {
  132748. private _lineBoundingBox;
  132749. private _rotateSpheresParent;
  132750. private _scaleBoxesParent;
  132751. private _boundingDimensions;
  132752. private _renderObserver;
  132753. private _pointerObserver;
  132754. private _scaleDragSpeed;
  132755. private _tmpQuaternion;
  132756. private _tmpVector;
  132757. private _tmpRotationMatrix;
  132758. /**
  132759. * 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)
  132760. */
  132761. ignoreChildren: boolean;
  132762. /**
  132763. * 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)
  132764. */
  132765. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132766. /**
  132767. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132768. */
  132769. rotationSphereSize: number;
  132770. /**
  132771. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132772. */
  132773. scaleBoxSize: number;
  132774. /**
  132775. * 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)
  132776. */
  132777. fixedDragMeshScreenSize: boolean;
  132778. /**
  132779. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132780. */
  132781. fixedDragMeshScreenSizeDistanceFactor: number;
  132782. /**
  132783. * Fired when a rotation sphere or scale box is dragged
  132784. */
  132785. onDragStartObservable: Observable<{}>;
  132786. /**
  132787. * Fired when a scale box is dragged
  132788. */
  132789. onScaleBoxDragObservable: Observable<{}>;
  132790. /**
  132791. * Fired when a scale box drag is ended
  132792. */
  132793. onScaleBoxDragEndObservable: Observable<{}>;
  132794. /**
  132795. * Fired when a rotation sphere is dragged
  132796. */
  132797. onRotationSphereDragObservable: Observable<{}>;
  132798. /**
  132799. * Fired when a rotation sphere drag is ended
  132800. */
  132801. onRotationSphereDragEndObservable: Observable<{}>;
  132802. /**
  132803. * 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)
  132804. */
  132805. scalePivot: Nullable<Vector3>;
  132806. /**
  132807. * Mesh used as a pivot to rotate the attached node
  132808. */
  132809. private _anchorMesh;
  132810. private _existingMeshScale;
  132811. private _dragMesh;
  132812. private pointerDragBehavior;
  132813. private coloredMaterial;
  132814. private hoverColoredMaterial;
  132815. /**
  132816. * Sets the color of the bounding box gizmo
  132817. * @param color the color to set
  132818. */
  132819. setColor(color: Color3): void;
  132820. /**
  132821. * Creates an BoundingBoxGizmo
  132822. * @param gizmoLayer The utility layer the gizmo will be added to
  132823. * @param color The color of the gizmo
  132824. */
  132825. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132826. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132827. private _selectNode;
  132828. /**
  132829. * Updates the bounding box information for the Gizmo
  132830. */
  132831. updateBoundingBox(): void;
  132832. private _updateRotationSpheres;
  132833. private _updateScaleBoxes;
  132834. /**
  132835. * Enables rotation on the specified axis and disables rotation on the others
  132836. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132837. */
  132838. setEnabledRotationAxis(axis: string): void;
  132839. /**
  132840. * Enables/disables scaling
  132841. * @param enable if scaling should be enabled
  132842. * @param homogeneousScaling defines if scaling should only be homogeneous
  132843. */
  132844. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132845. private _updateDummy;
  132846. /**
  132847. * Enables a pointer drag behavior on the bounding box of the gizmo
  132848. */
  132849. enableDragBehavior(): void;
  132850. /**
  132851. * Disposes of the gizmo
  132852. */
  132853. dispose(): void;
  132854. /**
  132855. * 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)
  132856. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132857. * @returns the bounding box mesh with the passed in mesh as a child
  132858. */
  132859. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132860. /**
  132861. * CustomMeshes are not supported by this gizmo
  132862. * @param mesh The mesh to replace the default mesh of the gizmo
  132863. */
  132864. setCustomMesh(mesh: Mesh): void;
  132865. }
  132866. }
  132867. declare module BABYLON {
  132868. /**
  132869. * Single plane rotation gizmo
  132870. */
  132871. export class PlaneRotationGizmo extends Gizmo {
  132872. /**
  132873. * Drag behavior responsible for the gizmos dragging interactions
  132874. */
  132875. dragBehavior: PointerDragBehavior;
  132876. private _pointerObserver;
  132877. /**
  132878. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132879. */
  132880. snapDistance: number;
  132881. /**
  132882. * Event that fires each time the gizmo snaps to a new location.
  132883. * * snapDistance is the the change in distance
  132884. */
  132885. onSnapObservable: Observable<{
  132886. snapDistance: number;
  132887. }>;
  132888. private _isEnabled;
  132889. private _parent;
  132890. /**
  132891. * Creates a PlaneRotationGizmo
  132892. * @param gizmoLayer The utility layer the gizmo will be added to
  132893. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132894. * @param color The color of the gizmo
  132895. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132896. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132897. * @param thickness display gizmo axis thickness
  132898. */
  132899. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132900. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132901. /**
  132902. * If the gizmo is enabled
  132903. */
  132904. set isEnabled(value: boolean);
  132905. get isEnabled(): boolean;
  132906. /**
  132907. * Disposes of the gizmo
  132908. */
  132909. dispose(): void;
  132910. }
  132911. }
  132912. declare module BABYLON {
  132913. /**
  132914. * Gizmo that enables rotating a mesh along 3 axis
  132915. */
  132916. export class RotationGizmo extends Gizmo {
  132917. /**
  132918. * Internal gizmo used for interactions on the x axis
  132919. */
  132920. xGizmo: PlaneRotationGizmo;
  132921. /**
  132922. * Internal gizmo used for interactions on the y axis
  132923. */
  132924. yGizmo: PlaneRotationGizmo;
  132925. /**
  132926. * Internal gizmo used for interactions on the z axis
  132927. */
  132928. zGizmo: PlaneRotationGizmo;
  132929. /** Fires an event when any of it's sub gizmos are dragged */
  132930. onDragStartObservable: Observable<unknown>;
  132931. /** Fires an event when any of it's sub gizmos are released from dragging */
  132932. onDragEndObservable: Observable<unknown>;
  132933. private _meshAttached;
  132934. private _nodeAttached;
  132935. get attachedMesh(): Nullable<AbstractMesh>;
  132936. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132937. get attachedNode(): Nullable<Node>;
  132938. set attachedNode(node: Nullable<Node>);
  132939. /**
  132940. * Creates a RotationGizmo
  132941. * @param gizmoLayer The utility layer the gizmo will be added to
  132942. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132943. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132944. * @param thickness display gizmo axis thickness
  132945. */
  132946. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132947. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132948. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132949. /**
  132950. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132951. */
  132952. set snapDistance(value: number);
  132953. get snapDistance(): number;
  132954. /**
  132955. * Ratio for the scale of the gizmo (Default: 1)
  132956. */
  132957. set scaleRatio(value: number);
  132958. get scaleRatio(): number;
  132959. /**
  132960. * Disposes of the gizmo
  132961. */
  132962. dispose(): void;
  132963. /**
  132964. * CustomMeshes are not supported by this gizmo
  132965. * @param mesh The mesh to replace the default mesh of the gizmo
  132966. */
  132967. setCustomMesh(mesh: Mesh): void;
  132968. }
  132969. }
  132970. declare module BABYLON {
  132971. /**
  132972. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  132973. */
  132974. export class GizmoManager implements IDisposable {
  132975. private scene;
  132976. /**
  132977. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132978. */
  132979. gizmos: {
  132980. positionGizmo: Nullable<PositionGizmo>;
  132981. rotationGizmo: Nullable<RotationGizmo>;
  132982. scaleGizmo: Nullable<ScaleGizmo>;
  132983. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132984. };
  132985. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132986. clearGizmoOnEmptyPointerEvent: boolean;
  132987. /** Fires an event when the manager is attached to a mesh */
  132988. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132989. /** Fires an event when the manager is attached to a node */
  132990. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  132991. private _gizmosEnabled;
  132992. private _pointerObserver;
  132993. private _attachedMesh;
  132994. private _attachedNode;
  132995. private _boundingBoxColor;
  132996. private _defaultUtilityLayer;
  132997. private _defaultKeepDepthUtilityLayer;
  132998. private _thickness;
  132999. /**
  133000. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133001. */
  133002. boundingBoxDragBehavior: SixDofDragBehavior;
  133003. /**
  133004. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133005. */
  133006. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133007. /**
  133008. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133009. */
  133010. attachableNodes: Nullable<Array<Node>>;
  133011. /**
  133012. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133013. */
  133014. usePointerToAttachGizmos: boolean;
  133015. /**
  133016. * Utility layer that the bounding box gizmo belongs to
  133017. */
  133018. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133019. /**
  133020. * Utility layer that all gizmos besides bounding box belong to
  133021. */
  133022. get utilityLayer(): UtilityLayerRenderer;
  133023. /**
  133024. * Instatiates a gizmo manager
  133025. * @param scene the scene to overlay the gizmos on top of
  133026. * @param thickness display gizmo axis thickness
  133027. */
  133028. constructor(scene: Scene, thickness?: number);
  133029. /**
  133030. * Attaches a set of gizmos to the specified mesh
  133031. * @param mesh The mesh the gizmo's should be attached to
  133032. */
  133033. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133034. /**
  133035. * Attaches a set of gizmos to the specified node
  133036. * @param node The node the gizmo's should be attached to
  133037. */
  133038. attachToNode(node: Nullable<Node>): void;
  133039. /**
  133040. * If the position gizmo is enabled
  133041. */
  133042. set positionGizmoEnabled(value: boolean);
  133043. get positionGizmoEnabled(): boolean;
  133044. /**
  133045. * If the rotation gizmo is enabled
  133046. */
  133047. set rotationGizmoEnabled(value: boolean);
  133048. get rotationGizmoEnabled(): boolean;
  133049. /**
  133050. * If the scale gizmo is enabled
  133051. */
  133052. set scaleGizmoEnabled(value: boolean);
  133053. get scaleGizmoEnabled(): boolean;
  133054. /**
  133055. * If the boundingBox gizmo is enabled
  133056. */
  133057. set boundingBoxGizmoEnabled(value: boolean);
  133058. get boundingBoxGizmoEnabled(): boolean;
  133059. /**
  133060. * Disposes of the gizmo manager
  133061. */
  133062. dispose(): void;
  133063. }
  133064. }
  133065. declare module BABYLON {
  133066. /**
  133067. * A directional light is defined by a direction (what a surprise!).
  133068. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133069. * 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.
  133070. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133071. */
  133072. export class DirectionalLight extends ShadowLight {
  133073. private _shadowFrustumSize;
  133074. /**
  133075. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133076. */
  133077. get shadowFrustumSize(): number;
  133078. /**
  133079. * Specifies a fix frustum size for the shadow generation.
  133080. */
  133081. set shadowFrustumSize(value: number);
  133082. private _shadowOrthoScale;
  133083. /**
  133084. * Gets the shadow projection scale against the optimal computed one.
  133085. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133086. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133087. */
  133088. get shadowOrthoScale(): number;
  133089. /**
  133090. * Sets the shadow projection scale against the optimal computed one.
  133091. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133092. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133093. */
  133094. set shadowOrthoScale(value: number);
  133095. /**
  133096. * Automatically compute the projection matrix to best fit (including all the casters)
  133097. * on each frame.
  133098. */
  133099. autoUpdateExtends: boolean;
  133100. /**
  133101. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  133102. * on each frame. autoUpdateExtends must be set to true for this to work
  133103. */
  133104. autoCalcShadowZBounds: boolean;
  133105. private _orthoLeft;
  133106. private _orthoRight;
  133107. private _orthoTop;
  133108. private _orthoBottom;
  133109. /**
  133110. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  133111. * The directional light is emitted from everywhere in the given direction.
  133112. * It can cast shadows.
  133113. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133114. * @param name The friendly name of the light
  133115. * @param direction The direction of the light
  133116. * @param scene The scene the light belongs to
  133117. */
  133118. constructor(name: string, direction: Vector3, scene: Scene);
  133119. /**
  133120. * Returns the string "DirectionalLight".
  133121. * @return The class name
  133122. */
  133123. getClassName(): string;
  133124. /**
  133125. * Returns the integer 1.
  133126. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133127. */
  133128. getTypeID(): number;
  133129. /**
  133130. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  133131. * Returns the DirectionalLight Shadow projection matrix.
  133132. */
  133133. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133134. /**
  133135. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  133136. * Returns the DirectionalLight Shadow projection matrix.
  133137. */
  133138. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  133139. /**
  133140. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  133141. * Returns the DirectionalLight Shadow projection matrix.
  133142. */
  133143. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133144. protected _buildUniformLayout(): void;
  133145. /**
  133146. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  133147. * @param effect The effect to update
  133148. * @param lightIndex The index of the light in the effect to update
  133149. * @returns The directional light
  133150. */
  133151. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  133152. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  133153. /**
  133154. * Gets the minZ used for shadow according to both the scene and the light.
  133155. *
  133156. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133157. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133158. * @param activeCamera The camera we are returning the min for
  133159. * @returns the depth min z
  133160. */
  133161. getDepthMinZ(activeCamera: Camera): number;
  133162. /**
  133163. * Gets the maxZ used for shadow according to both the scene and the light.
  133164. *
  133165. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133166. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133167. * @param activeCamera The camera we are returning the max for
  133168. * @returns the depth max z
  133169. */
  133170. getDepthMaxZ(activeCamera: Camera): number;
  133171. /**
  133172. * Prepares the list of defines specific to the light type.
  133173. * @param defines the list of defines
  133174. * @param lightIndex defines the index of the light for the effect
  133175. */
  133176. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133177. }
  133178. }
  133179. declare module BABYLON {
  133180. /**
  133181. * Class containing static functions to help procedurally build meshes
  133182. */
  133183. export class HemisphereBuilder {
  133184. /**
  133185. * Creates a hemisphere mesh
  133186. * @param name defines the name of the mesh
  133187. * @param options defines the options used to create the mesh
  133188. * @param scene defines the hosting scene
  133189. * @returns the hemisphere mesh
  133190. */
  133191. static CreateHemisphere(name: string, options: {
  133192. segments?: number;
  133193. diameter?: number;
  133194. sideOrientation?: number;
  133195. }, scene: any): Mesh;
  133196. }
  133197. }
  133198. declare module BABYLON {
  133199. /**
  133200. * A spot light is defined by a position, a direction, an angle, and an exponent.
  133201. * These values define a cone of light starting from the position, emitting toward the direction.
  133202. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  133203. * and the exponent defines the speed of the decay of the light with distance (reach).
  133204. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133205. */
  133206. export class SpotLight extends ShadowLight {
  133207. private _angle;
  133208. private _innerAngle;
  133209. private _cosHalfAngle;
  133210. private _lightAngleScale;
  133211. private _lightAngleOffset;
  133212. /**
  133213. * Gets the cone angle of the spot light in Radians.
  133214. */
  133215. get angle(): number;
  133216. /**
  133217. * Sets the cone angle of the spot light in Radians.
  133218. */
  133219. set angle(value: number);
  133220. /**
  133221. * Only used in gltf falloff mode, this defines the angle where
  133222. * the directional falloff will start before cutting at angle which could be seen
  133223. * as outer angle.
  133224. */
  133225. get innerAngle(): number;
  133226. /**
  133227. * Only used in gltf falloff mode, this defines the angle where
  133228. * the directional falloff will start before cutting at angle which could be seen
  133229. * as outer angle.
  133230. */
  133231. set innerAngle(value: number);
  133232. private _shadowAngleScale;
  133233. /**
  133234. * Allows scaling the angle of the light for shadow generation only.
  133235. */
  133236. get shadowAngleScale(): number;
  133237. /**
  133238. * Allows scaling the angle of the light for shadow generation only.
  133239. */
  133240. set shadowAngleScale(value: number);
  133241. /**
  133242. * The light decay speed with the distance from the emission spot.
  133243. */
  133244. exponent: number;
  133245. private _projectionTextureMatrix;
  133246. /**
  133247. * Allows reading the projecton texture
  133248. */
  133249. get projectionTextureMatrix(): Matrix;
  133250. protected _projectionTextureLightNear: number;
  133251. /**
  133252. * Gets the near clip of the Spotlight for texture projection.
  133253. */
  133254. get projectionTextureLightNear(): number;
  133255. /**
  133256. * Sets the near clip of the Spotlight for texture projection.
  133257. */
  133258. set projectionTextureLightNear(value: number);
  133259. protected _projectionTextureLightFar: number;
  133260. /**
  133261. * Gets the far clip of the Spotlight for texture projection.
  133262. */
  133263. get projectionTextureLightFar(): number;
  133264. /**
  133265. * Sets the far clip of the Spotlight for texture projection.
  133266. */
  133267. set projectionTextureLightFar(value: number);
  133268. protected _projectionTextureUpDirection: Vector3;
  133269. /**
  133270. * Gets the Up vector of the Spotlight for texture projection.
  133271. */
  133272. get projectionTextureUpDirection(): Vector3;
  133273. /**
  133274. * Sets the Up vector of the Spotlight for texture projection.
  133275. */
  133276. set projectionTextureUpDirection(value: Vector3);
  133277. private _projectionTexture;
  133278. /**
  133279. * Gets the projection texture of the light.
  133280. */
  133281. get projectionTexture(): Nullable<BaseTexture>;
  133282. /**
  133283. * Sets the projection texture of the light.
  133284. */
  133285. set projectionTexture(value: Nullable<BaseTexture>);
  133286. private _projectionTextureViewLightDirty;
  133287. private _projectionTextureProjectionLightDirty;
  133288. private _projectionTextureDirty;
  133289. private _projectionTextureViewTargetVector;
  133290. private _projectionTextureViewLightMatrix;
  133291. private _projectionTextureProjectionLightMatrix;
  133292. private _projectionTextureScalingMatrix;
  133293. /**
  133294. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  133295. * It can cast shadows.
  133296. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133297. * @param name The light friendly name
  133298. * @param position The position of the spot light in the scene
  133299. * @param direction The direction of the light in the scene
  133300. * @param angle The cone angle of the light in Radians
  133301. * @param exponent The light decay speed with the distance from the emission spot
  133302. * @param scene The scene the lights belongs to
  133303. */
  133304. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  133305. /**
  133306. * Returns the string "SpotLight".
  133307. * @returns the class name
  133308. */
  133309. getClassName(): string;
  133310. /**
  133311. * Returns the integer 2.
  133312. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133313. */
  133314. getTypeID(): number;
  133315. /**
  133316. * Overrides the direction setter to recompute the projection texture view light Matrix.
  133317. */
  133318. protected _setDirection(value: Vector3): void;
  133319. /**
  133320. * Overrides the position setter to recompute the projection texture view light Matrix.
  133321. */
  133322. protected _setPosition(value: Vector3): void;
  133323. /**
  133324. * 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.
  133325. * Returns the SpotLight.
  133326. */
  133327. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133328. protected _computeProjectionTextureViewLightMatrix(): void;
  133329. protected _computeProjectionTextureProjectionLightMatrix(): void;
  133330. /**
  133331. * Main function for light texture projection matrix computing.
  133332. */
  133333. protected _computeProjectionTextureMatrix(): void;
  133334. protected _buildUniformLayout(): void;
  133335. private _computeAngleValues;
  133336. /**
  133337. * Sets the passed Effect "effect" with the Light textures.
  133338. * @param effect The effect to update
  133339. * @param lightIndex The index of the light in the effect to update
  133340. * @returns The light
  133341. */
  133342. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  133343. /**
  133344. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  133345. * @param effect The effect to update
  133346. * @param lightIndex The index of the light in the effect to update
  133347. * @returns The spot light
  133348. */
  133349. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  133350. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  133351. /**
  133352. * Disposes the light and the associated resources.
  133353. */
  133354. dispose(): void;
  133355. /**
  133356. * Prepares the list of defines specific to the light type.
  133357. * @param defines the list of defines
  133358. * @param lightIndex defines the index of the light for the effect
  133359. */
  133360. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133361. }
  133362. }
  133363. declare module BABYLON {
  133364. /**
  133365. * Gizmo that enables viewing a light
  133366. */
  133367. export class LightGizmo extends Gizmo {
  133368. private _lightMesh;
  133369. private _material;
  133370. private _cachedPosition;
  133371. private _cachedForward;
  133372. private _attachedMeshParent;
  133373. /**
  133374. * Creates a LightGizmo
  133375. * @param gizmoLayer The utility layer the gizmo will be added to
  133376. */
  133377. constructor(gizmoLayer?: UtilityLayerRenderer);
  133378. private _light;
  133379. /**
  133380. * The light that the gizmo is attached to
  133381. */
  133382. set light(light: Nullable<Light>);
  133383. get light(): Nullable<Light>;
  133384. /**
  133385. * Gets the material used to render the light gizmo
  133386. */
  133387. get material(): StandardMaterial;
  133388. /**
  133389. * @hidden
  133390. * Updates the gizmo to match the attached mesh's position/rotation
  133391. */
  133392. protected _update(): void;
  133393. private static _Scale;
  133394. /**
  133395. * Creates the lines for a light mesh
  133396. */
  133397. private static _CreateLightLines;
  133398. /**
  133399. * Disposes of the light gizmo
  133400. */
  133401. dispose(): void;
  133402. private static _CreateHemisphericLightMesh;
  133403. private static _CreatePointLightMesh;
  133404. private static _CreateSpotLightMesh;
  133405. private static _CreateDirectionalLightMesh;
  133406. }
  133407. }
  133408. declare module BABYLON {
  133409. /**
  133410. * Gizmo that enables viewing a camera
  133411. */
  133412. export class CameraGizmo extends Gizmo {
  133413. private _cameraMesh;
  133414. private _cameraLinesMesh;
  133415. private _material;
  133416. /**
  133417. * Creates a CameraGizmo
  133418. * @param gizmoLayer The utility layer the gizmo will be added to
  133419. */
  133420. constructor(gizmoLayer?: UtilityLayerRenderer);
  133421. private _camera;
  133422. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  133423. get displayFrustum(): boolean;
  133424. set displayFrustum(value: boolean);
  133425. /**
  133426. * The camera that the gizmo is attached to
  133427. */
  133428. set camera(camera: Nullable<Camera>);
  133429. get camera(): Nullable<Camera>;
  133430. /**
  133431. * Gets the material used to render the camera gizmo
  133432. */
  133433. get material(): StandardMaterial;
  133434. /**
  133435. * @hidden
  133436. * Updates the gizmo to match the attached mesh's position/rotation
  133437. */
  133438. protected _update(): void;
  133439. private static _Scale;
  133440. private _invProjection;
  133441. /**
  133442. * Disposes of the camera gizmo
  133443. */
  133444. dispose(): void;
  133445. private static _CreateCameraMesh;
  133446. private static _CreateCameraFrustum;
  133447. }
  133448. }
  133449. declare module BABYLON {
  133450. /** @hidden */
  133451. export var backgroundFragmentDeclaration: {
  133452. name: string;
  133453. shader: string;
  133454. };
  133455. }
  133456. declare module BABYLON {
  133457. /** @hidden */
  133458. export var backgroundUboDeclaration: {
  133459. name: string;
  133460. shader: string;
  133461. };
  133462. }
  133463. declare module BABYLON {
  133464. /** @hidden */
  133465. export var backgroundPixelShader: {
  133466. name: string;
  133467. shader: string;
  133468. };
  133469. }
  133470. declare module BABYLON {
  133471. /** @hidden */
  133472. export var backgroundVertexDeclaration: {
  133473. name: string;
  133474. shader: string;
  133475. };
  133476. }
  133477. declare module BABYLON {
  133478. /** @hidden */
  133479. export var backgroundVertexShader: {
  133480. name: string;
  133481. shader: string;
  133482. };
  133483. }
  133484. declare module BABYLON {
  133485. /**
  133486. * Background material used to create an efficient environement around your scene.
  133487. */
  133488. export class BackgroundMaterial extends PushMaterial {
  133489. /**
  133490. * Standard reflectance value at parallel view angle.
  133491. */
  133492. static StandardReflectance0: number;
  133493. /**
  133494. * Standard reflectance value at grazing angle.
  133495. */
  133496. static StandardReflectance90: number;
  133497. protected _primaryColor: Color3;
  133498. /**
  133499. * Key light Color (multiply against the environement texture)
  133500. */
  133501. primaryColor: Color3;
  133502. protected __perceptualColor: Nullable<Color3>;
  133503. /**
  133504. * Experimental Internal Use Only.
  133505. *
  133506. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  133507. * This acts as a helper to set the primary color to a more "human friendly" value.
  133508. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  133509. * output color as close as possible from the chosen value.
  133510. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  133511. * part of lighting setup.)
  133512. */
  133513. get _perceptualColor(): Nullable<Color3>;
  133514. set _perceptualColor(value: Nullable<Color3>);
  133515. protected _primaryColorShadowLevel: float;
  133516. /**
  133517. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  133518. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  133519. */
  133520. get primaryColorShadowLevel(): float;
  133521. set primaryColorShadowLevel(value: float);
  133522. protected _primaryColorHighlightLevel: float;
  133523. /**
  133524. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  133525. * The primary color is used at the level chosen to define what the white area would look.
  133526. */
  133527. get primaryColorHighlightLevel(): float;
  133528. set primaryColorHighlightLevel(value: float);
  133529. protected _reflectionTexture: Nullable<BaseTexture>;
  133530. /**
  133531. * Reflection Texture used in the material.
  133532. * Should be author in a specific way for the best result (refer to the documentation).
  133533. */
  133534. reflectionTexture: Nullable<BaseTexture>;
  133535. protected _reflectionBlur: float;
  133536. /**
  133537. * Reflection Texture level of blur.
  133538. *
  133539. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  133540. * texture twice.
  133541. */
  133542. reflectionBlur: float;
  133543. protected _diffuseTexture: Nullable<BaseTexture>;
  133544. /**
  133545. * Diffuse Texture used in the material.
  133546. * Should be author in a specific way for the best result (refer to the documentation).
  133547. */
  133548. diffuseTexture: Nullable<BaseTexture>;
  133549. protected _shadowLights: Nullable<IShadowLight[]>;
  133550. /**
  133551. * Specify the list of lights casting shadow on the material.
  133552. * All scene shadow lights will be included if null.
  133553. */
  133554. shadowLights: Nullable<IShadowLight[]>;
  133555. protected _shadowLevel: float;
  133556. /**
  133557. * Helps adjusting the shadow to a softer level if required.
  133558. * 0 means black shadows and 1 means no shadows.
  133559. */
  133560. shadowLevel: float;
  133561. protected _sceneCenter: Vector3;
  133562. /**
  133563. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  133564. * It is usually zero but might be interesting to modify according to your setup.
  133565. */
  133566. sceneCenter: Vector3;
  133567. protected _opacityFresnel: boolean;
  133568. /**
  133569. * This helps specifying that the material is falling off to the sky box at grazing angle.
  133570. * This helps ensuring a nice transition when the camera goes under the ground.
  133571. */
  133572. opacityFresnel: boolean;
  133573. protected _reflectionFresnel: boolean;
  133574. /**
  133575. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  133576. * This helps adding a mirror texture on the ground.
  133577. */
  133578. reflectionFresnel: boolean;
  133579. protected _reflectionFalloffDistance: number;
  133580. /**
  133581. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  133582. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  133583. */
  133584. reflectionFalloffDistance: number;
  133585. protected _reflectionAmount: number;
  133586. /**
  133587. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  133588. */
  133589. reflectionAmount: number;
  133590. protected _reflectionReflectance0: number;
  133591. /**
  133592. * This specifies the weight of the reflection at grazing angle.
  133593. */
  133594. reflectionReflectance0: number;
  133595. protected _reflectionReflectance90: number;
  133596. /**
  133597. * This specifies the weight of the reflection at a perpendicular point of view.
  133598. */
  133599. reflectionReflectance90: number;
  133600. /**
  133601. * Sets the reflection reflectance fresnel values according to the default standard
  133602. * empirically know to work well :-)
  133603. */
  133604. set reflectionStandardFresnelWeight(value: number);
  133605. protected _useRGBColor: boolean;
  133606. /**
  133607. * Helps to directly use the maps channels instead of their level.
  133608. */
  133609. useRGBColor: boolean;
  133610. protected _enableNoise: boolean;
  133611. /**
  133612. * This helps reducing the banding effect that could occur on the background.
  133613. */
  133614. enableNoise: boolean;
  133615. /**
  133616. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133617. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  133618. * Recommended to be keep at 1.0 except for special cases.
  133619. */
  133620. get fovMultiplier(): number;
  133621. set fovMultiplier(value: number);
  133622. private _fovMultiplier;
  133623. /**
  133624. * Enable the FOV adjustment feature controlled by fovMultiplier.
  133625. */
  133626. useEquirectangularFOV: boolean;
  133627. private _maxSimultaneousLights;
  133628. /**
  133629. * Number of Simultaneous lights allowed on the material.
  133630. */
  133631. maxSimultaneousLights: int;
  133632. private _shadowOnly;
  133633. /**
  133634. * Make the material only render shadows
  133635. */
  133636. shadowOnly: boolean;
  133637. /**
  133638. * Default configuration related to image processing available in the Background Material.
  133639. */
  133640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133641. /**
  133642. * Keep track of the image processing observer to allow dispose and replace.
  133643. */
  133644. private _imageProcessingObserver;
  133645. /**
  133646. * Attaches a new image processing configuration to the PBR Material.
  133647. * @param configuration (if null the scene configuration will be use)
  133648. */
  133649. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133650. /**
  133651. * Gets the image processing configuration used either in this material.
  133652. */
  133653. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  133654. /**
  133655. * Sets the Default image processing configuration used either in the this material.
  133656. *
  133657. * If sets to null, the scene one is in use.
  133658. */
  133659. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  133660. /**
  133661. * Gets wether the color curves effect is enabled.
  133662. */
  133663. get cameraColorCurvesEnabled(): boolean;
  133664. /**
  133665. * Sets wether the color curves effect is enabled.
  133666. */
  133667. set cameraColorCurvesEnabled(value: boolean);
  133668. /**
  133669. * Gets wether the color grading effect is enabled.
  133670. */
  133671. get cameraColorGradingEnabled(): boolean;
  133672. /**
  133673. * Gets wether the color grading effect is enabled.
  133674. */
  133675. set cameraColorGradingEnabled(value: boolean);
  133676. /**
  133677. * Gets wether tonemapping is enabled or not.
  133678. */
  133679. get cameraToneMappingEnabled(): boolean;
  133680. /**
  133681. * Sets wether tonemapping is enabled or not
  133682. */
  133683. set cameraToneMappingEnabled(value: boolean);
  133684. /**
  133685. * The camera exposure used on this material.
  133686. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133687. * This corresponds to a photographic exposure.
  133688. */
  133689. get cameraExposure(): float;
  133690. /**
  133691. * The camera exposure used on this material.
  133692. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133693. * This corresponds to a photographic exposure.
  133694. */
  133695. set cameraExposure(value: float);
  133696. /**
  133697. * Gets The camera contrast used on this material.
  133698. */
  133699. get cameraContrast(): float;
  133700. /**
  133701. * Sets The camera contrast used on this material.
  133702. */
  133703. set cameraContrast(value: float);
  133704. /**
  133705. * Gets the Color Grading 2D Lookup Texture.
  133706. */
  133707. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133708. /**
  133709. * Sets the Color Grading 2D Lookup Texture.
  133710. */
  133711. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133712. /**
  133713. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133714. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133715. * 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;
  133716. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133717. */
  133718. get cameraColorCurves(): Nullable<ColorCurves>;
  133719. /**
  133720. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133721. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133722. * 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;
  133723. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133724. */
  133725. set cameraColorCurves(value: Nullable<ColorCurves>);
  133726. /**
  133727. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133728. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133729. */
  133730. switchToBGR: boolean;
  133731. private _renderTargets;
  133732. private _reflectionControls;
  133733. private _white;
  133734. private _primaryShadowColor;
  133735. private _primaryHighlightColor;
  133736. /**
  133737. * Instantiates a Background Material in the given scene
  133738. * @param name The friendly name of the material
  133739. * @param scene The scene to add the material to
  133740. */
  133741. constructor(name: string, scene: Scene);
  133742. /**
  133743. * Gets a boolean indicating that current material needs to register RTT
  133744. */
  133745. get hasRenderTargetTextures(): boolean;
  133746. /**
  133747. * The entire material has been created in order to prevent overdraw.
  133748. * @returns false
  133749. */
  133750. needAlphaTesting(): boolean;
  133751. /**
  133752. * The entire material has been created in order to prevent overdraw.
  133753. * @returns true if blending is enable
  133754. */
  133755. needAlphaBlending(): boolean;
  133756. /**
  133757. * Checks wether the material is ready to be rendered for a given mesh.
  133758. * @param mesh The mesh to render
  133759. * @param subMesh The submesh to check against
  133760. * @param useInstances Specify wether or not the material is used with instances
  133761. * @returns true if all the dependencies are ready (Textures, Effects...)
  133762. */
  133763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133764. /**
  133765. * Compute the primary color according to the chosen perceptual color.
  133766. */
  133767. private _computePrimaryColorFromPerceptualColor;
  133768. /**
  133769. * Compute the highlights and shadow colors according to their chosen levels.
  133770. */
  133771. private _computePrimaryColors;
  133772. /**
  133773. * Build the uniform buffer used in the material.
  133774. */
  133775. buildUniformLayout(): void;
  133776. /**
  133777. * Unbind the material.
  133778. */
  133779. unbind(): void;
  133780. /**
  133781. * Bind only the world matrix to the material.
  133782. * @param world The world matrix to bind.
  133783. */
  133784. bindOnlyWorldMatrix(world: Matrix): void;
  133785. /**
  133786. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133787. * @param world The world matrix to bind.
  133788. * @param subMesh The submesh to bind for.
  133789. */
  133790. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133791. /**
  133792. * Checks to see if a texture is used in the material.
  133793. * @param texture - Base texture to use.
  133794. * @returns - Boolean specifying if a texture is used in the material.
  133795. */
  133796. hasTexture(texture: BaseTexture): boolean;
  133797. /**
  133798. * Dispose the material.
  133799. * @param forceDisposeEffect Force disposal of the associated effect.
  133800. * @param forceDisposeTextures Force disposal of the associated textures.
  133801. */
  133802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133803. /**
  133804. * Clones the material.
  133805. * @param name The cloned name.
  133806. * @returns The cloned material.
  133807. */
  133808. clone(name: string): BackgroundMaterial;
  133809. /**
  133810. * Serializes the current material to its JSON representation.
  133811. * @returns The JSON representation.
  133812. */
  133813. serialize(): any;
  133814. /**
  133815. * Gets the class name of the material
  133816. * @returns "BackgroundMaterial"
  133817. */
  133818. getClassName(): string;
  133819. /**
  133820. * Parse a JSON input to create back a background material.
  133821. * @param source The JSON data to parse
  133822. * @param scene The scene to create the parsed material in
  133823. * @param rootUrl The root url of the assets the material depends upon
  133824. * @returns the instantiated BackgroundMaterial.
  133825. */
  133826. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133827. }
  133828. }
  133829. declare module BABYLON {
  133830. /**
  133831. * Represents the different options available during the creation of
  133832. * a Environment helper.
  133833. *
  133834. * This can control the default ground, skybox and image processing setup of your scene.
  133835. */
  133836. export interface IEnvironmentHelperOptions {
  133837. /**
  133838. * Specifies whether or not to create a ground.
  133839. * True by default.
  133840. */
  133841. createGround: boolean;
  133842. /**
  133843. * Specifies the ground size.
  133844. * 15 by default.
  133845. */
  133846. groundSize: number;
  133847. /**
  133848. * The texture used on the ground for the main color.
  133849. * Comes from the BabylonJS CDN by default.
  133850. *
  133851. * Remarks: Can be either a texture or a url.
  133852. */
  133853. groundTexture: string | BaseTexture;
  133854. /**
  133855. * The color mixed in the ground texture by default.
  133856. * BabylonJS clearColor by default.
  133857. */
  133858. groundColor: Color3;
  133859. /**
  133860. * Specifies the ground opacity.
  133861. * 1 by default.
  133862. */
  133863. groundOpacity: number;
  133864. /**
  133865. * Enables the ground to receive shadows.
  133866. * True by default.
  133867. */
  133868. enableGroundShadow: boolean;
  133869. /**
  133870. * Helps preventing the shadow to be fully black on the ground.
  133871. * 0.5 by default.
  133872. */
  133873. groundShadowLevel: number;
  133874. /**
  133875. * Creates a mirror texture attach to the ground.
  133876. * false by default.
  133877. */
  133878. enableGroundMirror: boolean;
  133879. /**
  133880. * Specifies the ground mirror size ratio.
  133881. * 0.3 by default as the default kernel is 64.
  133882. */
  133883. groundMirrorSizeRatio: number;
  133884. /**
  133885. * Specifies the ground mirror blur kernel size.
  133886. * 64 by default.
  133887. */
  133888. groundMirrorBlurKernel: number;
  133889. /**
  133890. * Specifies the ground mirror visibility amount.
  133891. * 1 by default
  133892. */
  133893. groundMirrorAmount: number;
  133894. /**
  133895. * Specifies the ground mirror reflectance weight.
  133896. * This uses the standard weight of the background material to setup the fresnel effect
  133897. * of the mirror.
  133898. * 1 by default.
  133899. */
  133900. groundMirrorFresnelWeight: number;
  133901. /**
  133902. * Specifies the ground mirror Falloff distance.
  133903. * This can helps reducing the size of the reflection.
  133904. * 0 by Default.
  133905. */
  133906. groundMirrorFallOffDistance: number;
  133907. /**
  133908. * Specifies the ground mirror texture type.
  133909. * Unsigned Int by Default.
  133910. */
  133911. groundMirrorTextureType: number;
  133912. /**
  133913. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133914. * the shown objects.
  133915. */
  133916. groundYBias: number;
  133917. /**
  133918. * Specifies whether or not to create a skybox.
  133919. * True by default.
  133920. */
  133921. createSkybox: boolean;
  133922. /**
  133923. * Specifies the skybox size.
  133924. * 20 by default.
  133925. */
  133926. skyboxSize: number;
  133927. /**
  133928. * The texture used on the skybox for the main color.
  133929. * Comes from the BabylonJS CDN by default.
  133930. *
  133931. * Remarks: Can be either a texture or a url.
  133932. */
  133933. skyboxTexture: string | BaseTexture;
  133934. /**
  133935. * The color mixed in the skybox texture by default.
  133936. * BabylonJS clearColor by default.
  133937. */
  133938. skyboxColor: Color3;
  133939. /**
  133940. * The background rotation around the Y axis of the scene.
  133941. * This helps aligning the key lights of your scene with the background.
  133942. * 0 by default.
  133943. */
  133944. backgroundYRotation: number;
  133945. /**
  133946. * Compute automatically the size of the elements to best fit with the scene.
  133947. */
  133948. sizeAuto: boolean;
  133949. /**
  133950. * Default position of the rootMesh if autoSize is not true.
  133951. */
  133952. rootPosition: Vector3;
  133953. /**
  133954. * Sets up the image processing in the scene.
  133955. * true by default.
  133956. */
  133957. setupImageProcessing: boolean;
  133958. /**
  133959. * The texture used as your environment texture in the scene.
  133960. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133961. *
  133962. * Remarks: Can be either a texture or a url.
  133963. */
  133964. environmentTexture: string | BaseTexture;
  133965. /**
  133966. * The value of the exposure to apply to the scene.
  133967. * 0.6 by default if setupImageProcessing is true.
  133968. */
  133969. cameraExposure: number;
  133970. /**
  133971. * The value of the contrast to apply to the scene.
  133972. * 1.6 by default if setupImageProcessing is true.
  133973. */
  133974. cameraContrast: number;
  133975. /**
  133976. * Specifies whether or not tonemapping should be enabled in the scene.
  133977. * true by default if setupImageProcessing is true.
  133978. */
  133979. toneMappingEnabled: boolean;
  133980. }
  133981. /**
  133982. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133983. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133984. * It also helps with the default setup of your imageProcessing configuration.
  133985. */
  133986. export class EnvironmentHelper {
  133987. /**
  133988. * Default ground texture URL.
  133989. */
  133990. private static _groundTextureCDNUrl;
  133991. /**
  133992. * Default skybox texture URL.
  133993. */
  133994. private static _skyboxTextureCDNUrl;
  133995. /**
  133996. * Default environment texture URL.
  133997. */
  133998. private static _environmentTextureCDNUrl;
  133999. /**
  134000. * Creates the default options for the helper.
  134001. */
  134002. private static _getDefaultOptions;
  134003. private _rootMesh;
  134004. /**
  134005. * Gets the root mesh created by the helper.
  134006. */
  134007. get rootMesh(): Mesh;
  134008. private _skybox;
  134009. /**
  134010. * Gets the skybox created by the helper.
  134011. */
  134012. get skybox(): Nullable<Mesh>;
  134013. private _skyboxTexture;
  134014. /**
  134015. * Gets the skybox texture created by the helper.
  134016. */
  134017. get skyboxTexture(): Nullable<BaseTexture>;
  134018. private _skyboxMaterial;
  134019. /**
  134020. * Gets the skybox material created by the helper.
  134021. */
  134022. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134023. private _ground;
  134024. /**
  134025. * Gets the ground mesh created by the helper.
  134026. */
  134027. get ground(): Nullable<Mesh>;
  134028. private _groundTexture;
  134029. /**
  134030. * Gets the ground texture created by the helper.
  134031. */
  134032. get groundTexture(): Nullable<BaseTexture>;
  134033. private _groundMirror;
  134034. /**
  134035. * Gets the ground mirror created by the helper.
  134036. */
  134037. get groundMirror(): Nullable<MirrorTexture>;
  134038. /**
  134039. * Gets the ground mirror render list to helps pushing the meshes
  134040. * you wish in the ground reflection.
  134041. */
  134042. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134043. private _groundMaterial;
  134044. /**
  134045. * Gets the ground material created by the helper.
  134046. */
  134047. get groundMaterial(): Nullable<BackgroundMaterial>;
  134048. /**
  134049. * Stores the creation options.
  134050. */
  134051. private readonly _scene;
  134052. private _options;
  134053. /**
  134054. * This observable will be notified with any error during the creation of the environment,
  134055. * mainly texture creation errors.
  134056. */
  134057. onErrorObservable: Observable<{
  134058. message?: string;
  134059. exception?: any;
  134060. }>;
  134061. /**
  134062. * constructor
  134063. * @param options Defines the options we want to customize the helper
  134064. * @param scene The scene to add the material to
  134065. */
  134066. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134067. /**
  134068. * Updates the background according to the new options
  134069. * @param options
  134070. */
  134071. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134072. /**
  134073. * Sets the primary color of all the available elements.
  134074. * @param color the main color to affect to the ground and the background
  134075. */
  134076. setMainColor(color: Color3): void;
  134077. /**
  134078. * Setup the image processing according to the specified options.
  134079. */
  134080. private _setupImageProcessing;
  134081. /**
  134082. * Setup the environment texture according to the specified options.
  134083. */
  134084. private _setupEnvironmentTexture;
  134085. /**
  134086. * Setup the background according to the specified options.
  134087. */
  134088. private _setupBackground;
  134089. /**
  134090. * Get the scene sizes according to the setup.
  134091. */
  134092. private _getSceneSize;
  134093. /**
  134094. * Setup the ground according to the specified options.
  134095. */
  134096. private _setupGround;
  134097. /**
  134098. * Setup the ground material according to the specified options.
  134099. */
  134100. private _setupGroundMaterial;
  134101. /**
  134102. * Setup the ground diffuse texture according to the specified options.
  134103. */
  134104. private _setupGroundDiffuseTexture;
  134105. /**
  134106. * Setup the ground mirror texture according to the specified options.
  134107. */
  134108. private _setupGroundMirrorTexture;
  134109. /**
  134110. * Setup the ground to receive the mirror texture.
  134111. */
  134112. private _setupMirrorInGroundMaterial;
  134113. /**
  134114. * Setup the skybox according to the specified options.
  134115. */
  134116. private _setupSkybox;
  134117. /**
  134118. * Setup the skybox material according to the specified options.
  134119. */
  134120. private _setupSkyboxMaterial;
  134121. /**
  134122. * Setup the skybox reflection texture according to the specified options.
  134123. */
  134124. private _setupSkyboxReflectionTexture;
  134125. private _errorHandler;
  134126. /**
  134127. * Dispose all the elements created by the Helper.
  134128. */
  134129. dispose(): void;
  134130. }
  134131. }
  134132. declare module BABYLON {
  134133. /**
  134134. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  134135. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  134136. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134137. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134138. */
  134139. export class PhotoDome extends TransformNode {
  134140. /**
  134141. * Define the image as a Monoscopic panoramic 360 image.
  134142. */
  134143. static readonly MODE_MONOSCOPIC: number;
  134144. /**
  134145. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134146. */
  134147. static readonly MODE_TOPBOTTOM: number;
  134148. /**
  134149. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134150. */
  134151. static readonly MODE_SIDEBYSIDE: number;
  134152. private _useDirectMapping;
  134153. /**
  134154. * The texture being displayed on the sphere
  134155. */
  134156. protected _photoTexture: Texture;
  134157. /**
  134158. * Gets or sets the texture being displayed on the sphere
  134159. */
  134160. get photoTexture(): Texture;
  134161. set photoTexture(value: Texture);
  134162. /**
  134163. * Observable raised when an error occured while loading the 360 image
  134164. */
  134165. onLoadErrorObservable: Observable<string>;
  134166. /**
  134167. * The skybox material
  134168. */
  134169. protected _material: BackgroundMaterial;
  134170. /**
  134171. * The surface used for the skybox
  134172. */
  134173. protected _mesh: Mesh;
  134174. /**
  134175. * Gets the mesh used for the skybox.
  134176. */
  134177. get mesh(): Mesh;
  134178. /**
  134179. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134180. * Also see the options.resolution property.
  134181. */
  134182. get fovMultiplier(): number;
  134183. set fovMultiplier(value: number);
  134184. private _imageMode;
  134185. /**
  134186. * Gets or set the current video mode for the video. It can be:
  134187. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  134188. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134189. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134190. */
  134191. get imageMode(): number;
  134192. set imageMode(value: number);
  134193. /**
  134194. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  134195. * @param name Element's name, child elements will append suffixes for their own names.
  134196. * @param urlsOfPhoto defines the url of the photo to display
  134197. * @param options defines an object containing optional or exposed sub element properties
  134198. * @param onError defines a callback called when an error occured while loading the texture
  134199. */
  134200. constructor(name: string, urlOfPhoto: string, options: {
  134201. resolution?: number;
  134202. size?: number;
  134203. useDirectMapping?: boolean;
  134204. faceForward?: boolean;
  134205. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  134206. private _onBeforeCameraRenderObserver;
  134207. private _changeImageMode;
  134208. /**
  134209. * Releases resources associated with this node.
  134210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134212. */
  134213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134214. }
  134215. }
  134216. declare module BABYLON {
  134217. /**
  134218. * Class used to host RGBD texture specific utilities
  134219. */
  134220. export class RGBDTextureTools {
  134221. /**
  134222. * Expand the RGBD Texture from RGBD to Half Float if possible.
  134223. * @param texture the texture to expand.
  134224. */
  134225. static ExpandRGBDTexture(texture: Texture): void;
  134226. }
  134227. }
  134228. declare module BABYLON {
  134229. /**
  134230. * Class used to host texture specific utilities
  134231. */
  134232. export class BRDFTextureTools {
  134233. /**
  134234. * Prevents texture cache collision
  134235. */
  134236. private static _instanceNumber;
  134237. /**
  134238. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  134239. * @param scene defines the hosting scene
  134240. * @returns the environment BRDF texture
  134241. */
  134242. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  134243. private static _environmentBRDFBase64Texture;
  134244. }
  134245. }
  134246. declare module BABYLON {
  134247. /**
  134248. * @hidden
  134249. */
  134250. export interface IMaterialClearCoatDefines {
  134251. CLEARCOAT: boolean;
  134252. CLEARCOAT_DEFAULTIOR: boolean;
  134253. CLEARCOAT_TEXTURE: boolean;
  134254. CLEARCOAT_TEXTUREDIRECTUV: number;
  134255. CLEARCOAT_BUMP: boolean;
  134256. CLEARCOAT_BUMPDIRECTUV: number;
  134257. CLEARCOAT_TINT: boolean;
  134258. CLEARCOAT_TINT_TEXTURE: boolean;
  134259. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134260. /** @hidden */
  134261. _areTexturesDirty: boolean;
  134262. }
  134263. /**
  134264. * Define the code related to the clear coat parameters of the pbr material.
  134265. */
  134266. export class PBRClearCoatConfiguration {
  134267. /**
  134268. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134269. * The default fits with a polyurethane material.
  134270. */
  134271. private static readonly _DefaultIndexOfRefraction;
  134272. private _isEnabled;
  134273. /**
  134274. * Defines if the clear coat is enabled in the material.
  134275. */
  134276. isEnabled: boolean;
  134277. /**
  134278. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  134279. */
  134280. intensity: number;
  134281. /**
  134282. * Defines the clear coat layer roughness.
  134283. */
  134284. roughness: number;
  134285. private _indexOfRefraction;
  134286. /**
  134287. * Defines the index of refraction of the clear coat.
  134288. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  134289. * The default fits with a polyurethane material.
  134290. * Changing the default value is more performance intensive.
  134291. */
  134292. indexOfRefraction: number;
  134293. private _texture;
  134294. /**
  134295. * Stores the clear coat values in a texture.
  134296. */
  134297. texture: Nullable<BaseTexture>;
  134298. private _bumpTexture;
  134299. /**
  134300. * Define the clear coat specific bump texture.
  134301. */
  134302. bumpTexture: Nullable<BaseTexture>;
  134303. private _isTintEnabled;
  134304. /**
  134305. * Defines if the clear coat tint is enabled in the material.
  134306. */
  134307. isTintEnabled: boolean;
  134308. /**
  134309. * Defines the clear coat tint of the material.
  134310. * This is only use if tint is enabled
  134311. */
  134312. tintColor: Color3;
  134313. /**
  134314. * Defines the distance at which the tint color should be found in the
  134315. * clear coat media.
  134316. * This is only use if tint is enabled
  134317. */
  134318. tintColorAtDistance: number;
  134319. /**
  134320. * Defines the clear coat layer thickness.
  134321. * This is only use if tint is enabled
  134322. */
  134323. tintThickness: number;
  134324. private _tintTexture;
  134325. /**
  134326. * Stores the clear tint values in a texture.
  134327. * rgb is tint
  134328. * a is a thickness factor
  134329. */
  134330. tintTexture: Nullable<BaseTexture>;
  134331. /** @hidden */
  134332. private _internalMarkAllSubMeshesAsTexturesDirty;
  134333. /** @hidden */
  134334. _markAllSubMeshesAsTexturesDirty(): void;
  134335. /**
  134336. * Instantiate a new istance of clear coat configuration.
  134337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134338. */
  134339. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134340. /**
  134341. * Gets wehter the submesh is ready to be used or not.
  134342. * @param defines the list of "defines" to update.
  134343. * @param scene defines the scene the material belongs to.
  134344. * @param engine defines the engine the material belongs to.
  134345. * @param disableBumpMap defines wether the material disables bump or not.
  134346. * @returns - boolean indicating that the submesh is ready or not.
  134347. */
  134348. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  134349. /**
  134350. * Checks to see if a texture is used in the material.
  134351. * @param defines the list of "defines" to update.
  134352. * @param scene defines the scene to the material belongs to.
  134353. */
  134354. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  134355. /**
  134356. * Binds the material data.
  134357. * @param uniformBuffer defines the Uniform buffer to fill in.
  134358. * @param scene defines the scene the material belongs to.
  134359. * @param engine defines the engine the material belongs to.
  134360. * @param disableBumpMap defines wether the material disables bump or not.
  134361. * @param isFrozen defines wether the material is frozen or not.
  134362. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134363. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134364. */
  134365. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  134366. /**
  134367. * Checks to see if a texture is used in the material.
  134368. * @param texture - Base texture to use.
  134369. * @returns - Boolean specifying if a texture is used in the material.
  134370. */
  134371. hasTexture(texture: BaseTexture): boolean;
  134372. /**
  134373. * Returns an array of the actively used textures.
  134374. * @param activeTextures Array of BaseTextures
  134375. */
  134376. getActiveTextures(activeTextures: BaseTexture[]): void;
  134377. /**
  134378. * Returns the animatable textures.
  134379. * @param animatables Array of animatable textures.
  134380. */
  134381. getAnimatables(animatables: IAnimatable[]): void;
  134382. /**
  134383. * Disposes the resources of the material.
  134384. * @param forceDisposeTextures - Forces the disposal of all textures.
  134385. */
  134386. dispose(forceDisposeTextures?: boolean): void;
  134387. /**
  134388. * Get the current class name of the texture useful for serialization or dynamic coding.
  134389. * @returns "PBRClearCoatConfiguration"
  134390. */
  134391. getClassName(): string;
  134392. /**
  134393. * Add fallbacks to the effect fallbacks list.
  134394. * @param defines defines the Base texture to use.
  134395. * @param fallbacks defines the current fallback list.
  134396. * @param currentRank defines the current fallback rank.
  134397. * @returns the new fallback rank.
  134398. */
  134399. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134400. /**
  134401. * Add the required uniforms to the current list.
  134402. * @param uniforms defines the current uniform list.
  134403. */
  134404. static AddUniforms(uniforms: string[]): void;
  134405. /**
  134406. * Add the required samplers to the current list.
  134407. * @param samplers defines the current sampler list.
  134408. */
  134409. static AddSamplers(samplers: string[]): void;
  134410. /**
  134411. * Add the required uniforms to the current buffer.
  134412. * @param uniformBuffer defines the current uniform buffer.
  134413. */
  134414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134415. /**
  134416. * Makes a duplicate of the current configuration into another one.
  134417. * @param clearCoatConfiguration define the config where to copy the info
  134418. */
  134419. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  134420. /**
  134421. * Serializes this clear coat configuration.
  134422. * @returns - An object with the serialized config.
  134423. */
  134424. serialize(): any;
  134425. /**
  134426. * Parses a anisotropy Configuration from a serialized object.
  134427. * @param source - Serialized object.
  134428. * @param scene Defines the scene we are parsing for
  134429. * @param rootUrl Defines the rootUrl to load from
  134430. */
  134431. parse(source: any, scene: Scene, rootUrl: string): void;
  134432. }
  134433. }
  134434. declare module BABYLON {
  134435. /**
  134436. * @hidden
  134437. */
  134438. export interface IMaterialAnisotropicDefines {
  134439. ANISOTROPIC: boolean;
  134440. ANISOTROPIC_TEXTURE: boolean;
  134441. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134442. MAINUV1: boolean;
  134443. _areTexturesDirty: boolean;
  134444. _needUVs: boolean;
  134445. }
  134446. /**
  134447. * Define the code related to the anisotropic parameters of the pbr material.
  134448. */
  134449. export class PBRAnisotropicConfiguration {
  134450. private _isEnabled;
  134451. /**
  134452. * Defines if the anisotropy is enabled in the material.
  134453. */
  134454. isEnabled: boolean;
  134455. /**
  134456. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  134457. */
  134458. intensity: number;
  134459. /**
  134460. * Defines if the effect is along the tangents, bitangents or in between.
  134461. * By default, the effect is "strectching" the highlights along the tangents.
  134462. */
  134463. direction: Vector2;
  134464. private _texture;
  134465. /**
  134466. * Stores the anisotropy values in a texture.
  134467. * rg is direction (like normal from -1 to 1)
  134468. * b is a intensity
  134469. */
  134470. texture: Nullable<BaseTexture>;
  134471. /** @hidden */
  134472. private _internalMarkAllSubMeshesAsTexturesDirty;
  134473. /** @hidden */
  134474. _markAllSubMeshesAsTexturesDirty(): void;
  134475. /**
  134476. * Instantiate a new istance of anisotropy configuration.
  134477. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134478. */
  134479. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134480. /**
  134481. * Specifies that the submesh is ready to be used.
  134482. * @param defines the list of "defines" to update.
  134483. * @param scene defines the scene the material belongs to.
  134484. * @returns - boolean indicating that the submesh is ready or not.
  134485. */
  134486. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  134487. /**
  134488. * Checks to see if a texture is used in the material.
  134489. * @param defines the list of "defines" to update.
  134490. * @param mesh the mesh we are preparing the defines for.
  134491. * @param scene defines the scene the material belongs to.
  134492. */
  134493. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  134494. /**
  134495. * Binds the material data.
  134496. * @param uniformBuffer defines the Uniform buffer to fill in.
  134497. * @param scene defines the scene the material belongs to.
  134498. * @param isFrozen defines wether the material is frozen or not.
  134499. */
  134500. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134501. /**
  134502. * Checks to see if a texture is used in the material.
  134503. * @param texture - Base texture to use.
  134504. * @returns - Boolean specifying if a texture is used in the material.
  134505. */
  134506. hasTexture(texture: BaseTexture): boolean;
  134507. /**
  134508. * Returns an array of the actively used textures.
  134509. * @param activeTextures Array of BaseTextures
  134510. */
  134511. getActiveTextures(activeTextures: BaseTexture[]): void;
  134512. /**
  134513. * Returns the animatable textures.
  134514. * @param animatables Array of animatable textures.
  134515. */
  134516. getAnimatables(animatables: IAnimatable[]): void;
  134517. /**
  134518. * Disposes the resources of the material.
  134519. * @param forceDisposeTextures - Forces the disposal of all textures.
  134520. */
  134521. dispose(forceDisposeTextures?: boolean): void;
  134522. /**
  134523. * Get the current class name of the texture useful for serialization or dynamic coding.
  134524. * @returns "PBRAnisotropicConfiguration"
  134525. */
  134526. getClassName(): string;
  134527. /**
  134528. * Add fallbacks to the effect fallbacks list.
  134529. * @param defines defines the Base texture to use.
  134530. * @param fallbacks defines the current fallback list.
  134531. * @param currentRank defines the current fallback rank.
  134532. * @returns the new fallback rank.
  134533. */
  134534. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134535. /**
  134536. * Add the required uniforms to the current list.
  134537. * @param uniforms defines the current uniform list.
  134538. */
  134539. static AddUniforms(uniforms: string[]): void;
  134540. /**
  134541. * Add the required uniforms to the current buffer.
  134542. * @param uniformBuffer defines the current uniform buffer.
  134543. */
  134544. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134545. /**
  134546. * Add the required samplers to the current list.
  134547. * @param samplers defines the current sampler list.
  134548. */
  134549. static AddSamplers(samplers: string[]): void;
  134550. /**
  134551. * Makes a duplicate of the current configuration into another one.
  134552. * @param anisotropicConfiguration define the config where to copy the info
  134553. */
  134554. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  134555. /**
  134556. * Serializes this anisotropy configuration.
  134557. * @returns - An object with the serialized config.
  134558. */
  134559. serialize(): any;
  134560. /**
  134561. * Parses a anisotropy Configuration from a serialized object.
  134562. * @param source - Serialized object.
  134563. * @param scene Defines the scene we are parsing for
  134564. * @param rootUrl Defines the rootUrl to load from
  134565. */
  134566. parse(source: any, scene: Scene, rootUrl: string): void;
  134567. }
  134568. }
  134569. declare module BABYLON {
  134570. /**
  134571. * @hidden
  134572. */
  134573. export interface IMaterialBRDFDefines {
  134574. BRDF_V_HEIGHT_CORRELATED: boolean;
  134575. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134576. SPHERICAL_HARMONICS: boolean;
  134577. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134578. /** @hidden */
  134579. _areMiscDirty: boolean;
  134580. }
  134581. /**
  134582. * Define the code related to the BRDF parameters of the pbr material.
  134583. */
  134584. export class PBRBRDFConfiguration {
  134585. /**
  134586. * Default value used for the energy conservation.
  134587. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134588. */
  134589. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  134590. /**
  134591. * Default value used for the Smith Visibility Height Correlated mode.
  134592. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134593. */
  134594. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  134595. /**
  134596. * Default value used for the IBL diffuse part.
  134597. * This can help switching back to the polynomials mode globally which is a tiny bit
  134598. * less GPU intensive at the drawback of a lower quality.
  134599. */
  134600. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  134601. /**
  134602. * Default value used for activating energy conservation for the specular workflow.
  134603. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134604. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134605. */
  134606. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  134607. private _useEnergyConservation;
  134608. /**
  134609. * Defines if the material uses energy conservation.
  134610. */
  134611. useEnergyConservation: boolean;
  134612. private _useSmithVisibilityHeightCorrelated;
  134613. /**
  134614. * LEGACY Mode set to false
  134615. * Defines if the material uses height smith correlated visibility term.
  134616. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  134617. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  134618. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  134619. * Not relying on height correlated will also disable energy conservation.
  134620. */
  134621. useSmithVisibilityHeightCorrelated: boolean;
  134622. private _useSphericalHarmonics;
  134623. /**
  134624. * LEGACY Mode set to false
  134625. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  134626. * diffuse part of the IBL.
  134627. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  134628. * to the ground truth.
  134629. */
  134630. useSphericalHarmonics: boolean;
  134631. private _useSpecularGlossinessInputEnergyConservation;
  134632. /**
  134633. * Defines if the material uses energy conservation, when the specular workflow is active.
  134634. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134635. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134636. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  134637. */
  134638. useSpecularGlossinessInputEnergyConservation: boolean;
  134639. /** @hidden */
  134640. private _internalMarkAllSubMeshesAsMiscDirty;
  134641. /** @hidden */
  134642. _markAllSubMeshesAsMiscDirty(): void;
  134643. /**
  134644. * Instantiate a new istance of clear coat configuration.
  134645. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  134646. */
  134647. constructor(markAllSubMeshesAsMiscDirty: () => void);
  134648. /**
  134649. * Checks to see if a texture is used in the material.
  134650. * @param defines the list of "defines" to update.
  134651. */
  134652. prepareDefines(defines: IMaterialBRDFDefines): void;
  134653. /**
  134654. * Get the current class name of the texture useful for serialization or dynamic coding.
  134655. * @returns "PBRClearCoatConfiguration"
  134656. */
  134657. getClassName(): string;
  134658. /**
  134659. * Makes a duplicate of the current configuration into another one.
  134660. * @param brdfConfiguration define the config where to copy the info
  134661. */
  134662. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  134663. /**
  134664. * Serializes this BRDF configuration.
  134665. * @returns - An object with the serialized config.
  134666. */
  134667. serialize(): any;
  134668. /**
  134669. * Parses a anisotropy Configuration from a serialized object.
  134670. * @param source - Serialized object.
  134671. * @param scene Defines the scene we are parsing for
  134672. * @param rootUrl Defines the rootUrl to load from
  134673. */
  134674. parse(source: any, scene: Scene, rootUrl: string): void;
  134675. }
  134676. }
  134677. declare module BABYLON {
  134678. /**
  134679. * @hidden
  134680. */
  134681. export interface IMaterialSheenDefines {
  134682. SHEEN: boolean;
  134683. SHEEN_TEXTURE: boolean;
  134684. SHEEN_TEXTUREDIRECTUV: number;
  134685. SHEEN_LINKWITHALBEDO: boolean;
  134686. SHEEN_ROUGHNESS: boolean;
  134687. SHEEN_ALBEDOSCALING: boolean;
  134688. /** @hidden */
  134689. _areTexturesDirty: boolean;
  134690. }
  134691. /**
  134692. * Define the code related to the Sheen parameters of the pbr material.
  134693. */
  134694. export class PBRSheenConfiguration {
  134695. private _isEnabled;
  134696. /**
  134697. * Defines if the material uses sheen.
  134698. */
  134699. isEnabled: boolean;
  134700. private _linkSheenWithAlbedo;
  134701. /**
  134702. * Defines if the sheen is linked to the sheen color.
  134703. */
  134704. linkSheenWithAlbedo: boolean;
  134705. /**
  134706. * Defines the sheen intensity.
  134707. */
  134708. intensity: number;
  134709. /**
  134710. * Defines the sheen color.
  134711. */
  134712. color: Color3;
  134713. private _texture;
  134714. /**
  134715. * Stores the sheen tint values in a texture.
  134716. * rgb is tint
  134717. * a is a intensity or roughness if roughness has been defined
  134718. */
  134719. texture: Nullable<BaseTexture>;
  134720. private _roughness;
  134721. /**
  134722. * Defines the sheen roughness.
  134723. * It is not taken into account if linkSheenWithAlbedo is true.
  134724. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134725. */
  134726. roughness: Nullable<number>;
  134727. private _albedoScaling;
  134728. /**
  134729. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134730. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134731. * making it easier to setup and tweak the effect
  134732. */
  134733. albedoScaling: boolean;
  134734. /** @hidden */
  134735. private _internalMarkAllSubMeshesAsTexturesDirty;
  134736. /** @hidden */
  134737. _markAllSubMeshesAsTexturesDirty(): void;
  134738. /**
  134739. * Instantiate a new istance of clear coat configuration.
  134740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134741. */
  134742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134743. /**
  134744. * Specifies that the submesh is ready to be used.
  134745. * @param defines the list of "defines" to update.
  134746. * @param scene defines the scene the material belongs to.
  134747. * @returns - boolean indicating that the submesh is ready or not.
  134748. */
  134749. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134750. /**
  134751. * Checks to see if a texture is used in the material.
  134752. * @param defines the list of "defines" to update.
  134753. * @param scene defines the scene the material belongs to.
  134754. */
  134755. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134756. /**
  134757. * Binds the material data.
  134758. * @param uniformBuffer defines the Uniform buffer to fill in.
  134759. * @param scene defines the scene the material belongs to.
  134760. * @param isFrozen defines wether the material is frozen or not.
  134761. */
  134762. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134763. /**
  134764. * Checks to see if a texture is used in the material.
  134765. * @param texture - Base texture to use.
  134766. * @returns - Boolean specifying if a texture is used in the material.
  134767. */
  134768. hasTexture(texture: BaseTexture): boolean;
  134769. /**
  134770. * Returns an array of the actively used textures.
  134771. * @param activeTextures Array of BaseTextures
  134772. */
  134773. getActiveTextures(activeTextures: BaseTexture[]): void;
  134774. /**
  134775. * Returns the animatable textures.
  134776. * @param animatables Array of animatable textures.
  134777. */
  134778. getAnimatables(animatables: IAnimatable[]): void;
  134779. /**
  134780. * Disposes the resources of the material.
  134781. * @param forceDisposeTextures - Forces the disposal of all textures.
  134782. */
  134783. dispose(forceDisposeTextures?: boolean): void;
  134784. /**
  134785. * Get the current class name of the texture useful for serialization or dynamic coding.
  134786. * @returns "PBRSheenConfiguration"
  134787. */
  134788. getClassName(): string;
  134789. /**
  134790. * Add fallbacks to the effect fallbacks list.
  134791. * @param defines defines the Base texture to use.
  134792. * @param fallbacks defines the current fallback list.
  134793. * @param currentRank defines the current fallback rank.
  134794. * @returns the new fallback rank.
  134795. */
  134796. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134797. /**
  134798. * Add the required uniforms to the current list.
  134799. * @param uniforms defines the current uniform list.
  134800. */
  134801. static AddUniforms(uniforms: string[]): void;
  134802. /**
  134803. * Add the required uniforms to the current buffer.
  134804. * @param uniformBuffer defines the current uniform buffer.
  134805. */
  134806. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134807. /**
  134808. * Add the required samplers to the current list.
  134809. * @param samplers defines the current sampler list.
  134810. */
  134811. static AddSamplers(samplers: string[]): void;
  134812. /**
  134813. * Makes a duplicate of the current configuration into another one.
  134814. * @param sheenConfiguration define the config where to copy the info
  134815. */
  134816. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134817. /**
  134818. * Serializes this BRDF configuration.
  134819. * @returns - An object with the serialized config.
  134820. */
  134821. serialize(): any;
  134822. /**
  134823. * Parses a anisotropy Configuration from a serialized object.
  134824. * @param source - Serialized object.
  134825. * @param scene Defines the scene we are parsing for
  134826. * @param rootUrl Defines the rootUrl to load from
  134827. */
  134828. parse(source: any, scene: Scene, rootUrl: string): void;
  134829. }
  134830. }
  134831. declare module BABYLON {
  134832. /**
  134833. * @hidden
  134834. */
  134835. export interface IMaterialSubSurfaceDefines {
  134836. SUBSURFACE: boolean;
  134837. SS_REFRACTION: boolean;
  134838. SS_TRANSLUCENCY: boolean;
  134839. SS_SCATTERING: boolean;
  134840. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134841. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134842. SS_REFRACTIONMAP_3D: boolean;
  134843. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134844. SS_LODINREFRACTIONALPHA: boolean;
  134845. SS_GAMMAREFRACTION: boolean;
  134846. SS_RGBDREFRACTION: boolean;
  134847. SS_LINEARSPECULARREFRACTION: boolean;
  134848. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134849. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134850. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134851. /** @hidden */
  134852. _areTexturesDirty: boolean;
  134853. }
  134854. /**
  134855. * Define the code related to the sub surface parameters of the pbr material.
  134856. */
  134857. export class PBRSubSurfaceConfiguration {
  134858. private _isRefractionEnabled;
  134859. /**
  134860. * Defines if the refraction is enabled in the material.
  134861. */
  134862. isRefractionEnabled: boolean;
  134863. private _isTranslucencyEnabled;
  134864. /**
  134865. * Defines if the translucency is enabled in the material.
  134866. */
  134867. isTranslucencyEnabled: boolean;
  134868. private _isScatteringEnabled;
  134869. /**
  134870. * Defines if the sub surface scattering is enabled in the material.
  134871. */
  134872. isScatteringEnabled: boolean;
  134873. private _scatteringDiffusionProfileIndex;
  134874. /**
  134875. * Diffusion profile for subsurface scattering.
  134876. * Useful for better scattering in the skins or foliages.
  134877. */
  134878. get scatteringDiffusionProfile(): Nullable<Color3>;
  134879. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134880. /**
  134881. * Defines the refraction intensity of the material.
  134882. * The refraction when enabled replaces the Diffuse part of the material.
  134883. * The intensity helps transitionning between diffuse and refraction.
  134884. */
  134885. refractionIntensity: number;
  134886. /**
  134887. * Defines the translucency intensity of the material.
  134888. * When translucency has been enabled, this defines how much of the "translucency"
  134889. * is addded to the diffuse part of the material.
  134890. */
  134891. translucencyIntensity: number;
  134892. /**
  134893. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134894. */
  134895. useAlbedoToTintRefraction: boolean;
  134896. private _thicknessTexture;
  134897. /**
  134898. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134899. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134900. * 0 would mean minimumThickness
  134901. * 1 would mean maximumThickness
  134902. * The other channels might be use as a mask to vary the different effects intensity.
  134903. */
  134904. thicknessTexture: Nullable<BaseTexture>;
  134905. private _refractionTexture;
  134906. /**
  134907. * Defines the texture to use for refraction.
  134908. */
  134909. refractionTexture: Nullable<BaseTexture>;
  134910. private _indexOfRefraction;
  134911. /**
  134912. * Index of refraction of the material base layer.
  134913. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134914. *
  134915. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134916. *
  134917. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134918. */
  134919. indexOfRefraction: number;
  134920. private _volumeIndexOfRefraction;
  134921. /**
  134922. * Index of refraction of the material's volume.
  134923. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134924. *
  134925. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134926. * the volume will use the same IOR as the surface.
  134927. */
  134928. get volumeIndexOfRefraction(): number;
  134929. set volumeIndexOfRefraction(value: number);
  134930. private _invertRefractionY;
  134931. /**
  134932. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134933. */
  134934. invertRefractionY: boolean;
  134935. private _linkRefractionWithTransparency;
  134936. /**
  134937. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134938. * Materials half opaque for instance using refraction could benefit from this control.
  134939. */
  134940. linkRefractionWithTransparency: boolean;
  134941. /**
  134942. * Defines the minimum thickness stored in the thickness map.
  134943. * If no thickness map is defined, this value will be used to simulate thickness.
  134944. */
  134945. minimumThickness: number;
  134946. /**
  134947. * Defines the maximum thickness stored in the thickness map.
  134948. */
  134949. maximumThickness: number;
  134950. /**
  134951. * Defines the volume tint of the material.
  134952. * This is used for both translucency and scattering.
  134953. */
  134954. tintColor: Color3;
  134955. /**
  134956. * Defines the distance at which the tint color should be found in the media.
  134957. * This is used for refraction only.
  134958. */
  134959. tintColorAtDistance: number;
  134960. /**
  134961. * Defines how far each channel transmit through the media.
  134962. * It is defined as a color to simplify it selection.
  134963. */
  134964. diffusionDistance: Color3;
  134965. private _useMaskFromThicknessTexture;
  134966. /**
  134967. * Stores the intensity of the different subsurface effects in the thickness texture.
  134968. * * the green channel is the translucency intensity.
  134969. * * the blue channel is the scattering intensity.
  134970. * * the alpha channel is the refraction intensity.
  134971. */
  134972. useMaskFromThicknessTexture: boolean;
  134973. private _scene;
  134974. /** @hidden */
  134975. private _internalMarkAllSubMeshesAsTexturesDirty;
  134976. private _internalMarkScenePrePassDirty;
  134977. /** @hidden */
  134978. _markAllSubMeshesAsTexturesDirty(): void;
  134979. /** @hidden */
  134980. _markScenePrePassDirty(): void;
  134981. /**
  134982. * Instantiate a new istance of sub surface configuration.
  134983. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134984. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134985. * @param scene The scene
  134986. */
  134987. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134988. /**
  134989. * Gets wehter the submesh is ready to be used or not.
  134990. * @param defines the list of "defines" to update.
  134991. * @param scene defines the scene the material belongs to.
  134992. * @returns - boolean indicating that the submesh is ready or not.
  134993. */
  134994. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134995. /**
  134996. * Checks to see if a texture is used in the material.
  134997. * @param defines the list of "defines" to update.
  134998. * @param scene defines the scene to the material belongs to.
  134999. */
  135000. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  135001. /**
  135002. * Binds the material data.
  135003. * @param uniformBuffer defines the Uniform buffer to fill in.
  135004. * @param scene defines the scene the material belongs to.
  135005. * @param engine defines the engine the material belongs to.
  135006. * @param isFrozen defines whether the material is frozen or not.
  135007. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  135008. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  135009. */
  135010. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  135011. /**
  135012. * Unbinds the material from the mesh.
  135013. * @param activeEffect defines the effect that should be unbound from.
  135014. * @returns true if unbound, otherwise false
  135015. */
  135016. unbind(activeEffect: Effect): boolean;
  135017. /**
  135018. * Returns the texture used for refraction or null if none is used.
  135019. * @param scene defines the scene the material belongs to.
  135020. * @returns - Refraction texture if present. If no refraction texture and refraction
  135021. * is linked with transparency, returns environment texture. Otherwise, returns null.
  135022. */
  135023. private _getRefractionTexture;
  135024. /**
  135025. * Returns true if alpha blending should be disabled.
  135026. */
  135027. get disableAlphaBlending(): boolean;
  135028. /**
  135029. * Fills the list of render target textures.
  135030. * @param renderTargets the list of render targets to update
  135031. */
  135032. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  135033. /**
  135034. * Checks to see if a texture is used in the material.
  135035. * @param texture - Base texture to use.
  135036. * @returns - Boolean specifying if a texture is used in the material.
  135037. */
  135038. hasTexture(texture: BaseTexture): boolean;
  135039. /**
  135040. * Gets a boolean indicating that current material needs to register RTT
  135041. * @returns true if this uses a render target otherwise false.
  135042. */
  135043. hasRenderTargetTextures(): boolean;
  135044. /**
  135045. * Returns an array of the actively used textures.
  135046. * @param activeTextures Array of BaseTextures
  135047. */
  135048. getActiveTextures(activeTextures: BaseTexture[]): void;
  135049. /**
  135050. * Returns the animatable textures.
  135051. * @param animatables Array of animatable textures.
  135052. */
  135053. getAnimatables(animatables: IAnimatable[]): void;
  135054. /**
  135055. * Disposes the resources of the material.
  135056. * @param forceDisposeTextures - Forces the disposal of all textures.
  135057. */
  135058. dispose(forceDisposeTextures?: boolean): void;
  135059. /**
  135060. * Get the current class name of the texture useful for serialization or dynamic coding.
  135061. * @returns "PBRSubSurfaceConfiguration"
  135062. */
  135063. getClassName(): string;
  135064. /**
  135065. * Add fallbacks to the effect fallbacks list.
  135066. * @param defines defines the Base texture to use.
  135067. * @param fallbacks defines the current fallback list.
  135068. * @param currentRank defines the current fallback rank.
  135069. * @returns the new fallback rank.
  135070. */
  135071. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135072. /**
  135073. * Add the required uniforms to the current list.
  135074. * @param uniforms defines the current uniform list.
  135075. */
  135076. static AddUniforms(uniforms: string[]): void;
  135077. /**
  135078. * Add the required samplers to the current list.
  135079. * @param samplers defines the current sampler list.
  135080. */
  135081. static AddSamplers(samplers: string[]): void;
  135082. /**
  135083. * Add the required uniforms to the current buffer.
  135084. * @param uniformBuffer defines the current uniform buffer.
  135085. */
  135086. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135087. /**
  135088. * Makes a duplicate of the current configuration into another one.
  135089. * @param configuration define the config where to copy the info
  135090. */
  135091. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  135092. /**
  135093. * Serializes this Sub Surface configuration.
  135094. * @returns - An object with the serialized config.
  135095. */
  135096. serialize(): any;
  135097. /**
  135098. * Parses a anisotropy Configuration from a serialized object.
  135099. * @param source - Serialized object.
  135100. * @param scene Defines the scene we are parsing for
  135101. * @param rootUrl Defines the rootUrl to load from
  135102. */
  135103. parse(source: any, scene: Scene, rootUrl: string): void;
  135104. }
  135105. }
  135106. declare module BABYLON {
  135107. /** @hidden */
  135108. export var pbrFragmentDeclaration: {
  135109. name: string;
  135110. shader: string;
  135111. };
  135112. }
  135113. declare module BABYLON {
  135114. /** @hidden */
  135115. export var pbrUboDeclaration: {
  135116. name: string;
  135117. shader: string;
  135118. };
  135119. }
  135120. declare module BABYLON {
  135121. /** @hidden */
  135122. export var pbrFragmentExtraDeclaration: {
  135123. name: string;
  135124. shader: string;
  135125. };
  135126. }
  135127. declare module BABYLON {
  135128. /** @hidden */
  135129. export var pbrFragmentSamplersDeclaration: {
  135130. name: string;
  135131. shader: string;
  135132. };
  135133. }
  135134. declare module BABYLON {
  135135. /** @hidden */
  135136. export var importanceSampling: {
  135137. name: string;
  135138. shader: string;
  135139. };
  135140. }
  135141. declare module BABYLON {
  135142. /** @hidden */
  135143. export var pbrHelperFunctions: {
  135144. name: string;
  135145. shader: string;
  135146. };
  135147. }
  135148. declare module BABYLON {
  135149. /** @hidden */
  135150. export var harmonicsFunctions: {
  135151. name: string;
  135152. shader: string;
  135153. };
  135154. }
  135155. declare module BABYLON {
  135156. /** @hidden */
  135157. export var pbrDirectLightingSetupFunctions: {
  135158. name: string;
  135159. shader: string;
  135160. };
  135161. }
  135162. declare module BABYLON {
  135163. /** @hidden */
  135164. export var pbrDirectLightingFalloffFunctions: {
  135165. name: string;
  135166. shader: string;
  135167. };
  135168. }
  135169. declare module BABYLON {
  135170. /** @hidden */
  135171. export var pbrBRDFFunctions: {
  135172. name: string;
  135173. shader: string;
  135174. };
  135175. }
  135176. declare module BABYLON {
  135177. /** @hidden */
  135178. export var hdrFilteringFunctions: {
  135179. name: string;
  135180. shader: string;
  135181. };
  135182. }
  135183. declare module BABYLON {
  135184. /** @hidden */
  135185. export var pbrDirectLightingFunctions: {
  135186. name: string;
  135187. shader: string;
  135188. };
  135189. }
  135190. declare module BABYLON {
  135191. /** @hidden */
  135192. export var pbrIBLFunctions: {
  135193. name: string;
  135194. shader: string;
  135195. };
  135196. }
  135197. declare module BABYLON {
  135198. /** @hidden */
  135199. export var pbrBlockAlbedoOpacity: {
  135200. name: string;
  135201. shader: string;
  135202. };
  135203. }
  135204. declare module BABYLON {
  135205. /** @hidden */
  135206. export var pbrBlockReflectivity: {
  135207. name: string;
  135208. shader: string;
  135209. };
  135210. }
  135211. declare module BABYLON {
  135212. /** @hidden */
  135213. export var pbrBlockAmbientOcclusion: {
  135214. name: string;
  135215. shader: string;
  135216. };
  135217. }
  135218. declare module BABYLON {
  135219. /** @hidden */
  135220. export var pbrBlockAlphaFresnel: {
  135221. name: string;
  135222. shader: string;
  135223. };
  135224. }
  135225. declare module BABYLON {
  135226. /** @hidden */
  135227. export var pbrBlockAnisotropic: {
  135228. name: string;
  135229. shader: string;
  135230. };
  135231. }
  135232. declare module BABYLON {
  135233. /** @hidden */
  135234. export var pbrBlockReflection: {
  135235. name: string;
  135236. shader: string;
  135237. };
  135238. }
  135239. declare module BABYLON {
  135240. /** @hidden */
  135241. export var pbrBlockSheen: {
  135242. name: string;
  135243. shader: string;
  135244. };
  135245. }
  135246. declare module BABYLON {
  135247. /** @hidden */
  135248. export var pbrBlockClearcoat: {
  135249. name: string;
  135250. shader: string;
  135251. };
  135252. }
  135253. declare module BABYLON {
  135254. /** @hidden */
  135255. export var pbrBlockSubSurface: {
  135256. name: string;
  135257. shader: string;
  135258. };
  135259. }
  135260. declare module BABYLON {
  135261. /** @hidden */
  135262. export var pbrBlockNormalGeometric: {
  135263. name: string;
  135264. shader: string;
  135265. };
  135266. }
  135267. declare module BABYLON {
  135268. /** @hidden */
  135269. export var pbrBlockNormalFinal: {
  135270. name: string;
  135271. shader: string;
  135272. };
  135273. }
  135274. declare module BABYLON {
  135275. /** @hidden */
  135276. export var pbrBlockLightmapInit: {
  135277. name: string;
  135278. shader: string;
  135279. };
  135280. }
  135281. declare module BABYLON {
  135282. /** @hidden */
  135283. export var pbrBlockGeometryInfo: {
  135284. name: string;
  135285. shader: string;
  135286. };
  135287. }
  135288. declare module BABYLON {
  135289. /** @hidden */
  135290. export var pbrBlockReflectance0: {
  135291. name: string;
  135292. shader: string;
  135293. };
  135294. }
  135295. declare module BABYLON {
  135296. /** @hidden */
  135297. export var pbrBlockReflectance: {
  135298. name: string;
  135299. shader: string;
  135300. };
  135301. }
  135302. declare module BABYLON {
  135303. /** @hidden */
  135304. export var pbrBlockDirectLighting: {
  135305. name: string;
  135306. shader: string;
  135307. };
  135308. }
  135309. declare module BABYLON {
  135310. /** @hidden */
  135311. export var pbrBlockFinalLitComponents: {
  135312. name: string;
  135313. shader: string;
  135314. };
  135315. }
  135316. declare module BABYLON {
  135317. /** @hidden */
  135318. export var pbrBlockFinalUnlitComponents: {
  135319. name: string;
  135320. shader: string;
  135321. };
  135322. }
  135323. declare module BABYLON {
  135324. /** @hidden */
  135325. export var pbrBlockFinalColorComposition: {
  135326. name: string;
  135327. shader: string;
  135328. };
  135329. }
  135330. declare module BABYLON {
  135331. /** @hidden */
  135332. export var pbrBlockImageProcessing: {
  135333. name: string;
  135334. shader: string;
  135335. };
  135336. }
  135337. declare module BABYLON {
  135338. /** @hidden */
  135339. export var pbrDebug: {
  135340. name: string;
  135341. shader: string;
  135342. };
  135343. }
  135344. declare module BABYLON {
  135345. /** @hidden */
  135346. export var pbrPixelShader: {
  135347. name: string;
  135348. shader: string;
  135349. };
  135350. }
  135351. declare module BABYLON {
  135352. /** @hidden */
  135353. export var pbrVertexDeclaration: {
  135354. name: string;
  135355. shader: string;
  135356. };
  135357. }
  135358. declare module BABYLON {
  135359. /** @hidden */
  135360. export var pbrVertexShader: {
  135361. name: string;
  135362. shader: string;
  135363. };
  135364. }
  135365. declare module BABYLON {
  135366. /**
  135367. * Manages the defines for the PBR Material.
  135368. * @hidden
  135369. */
  135370. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  135371. PBR: boolean;
  135372. NUM_SAMPLES: string;
  135373. REALTIME_FILTERING: boolean;
  135374. MAINUV1: boolean;
  135375. MAINUV2: boolean;
  135376. UV1: boolean;
  135377. UV2: boolean;
  135378. ALBEDO: boolean;
  135379. GAMMAALBEDO: boolean;
  135380. ALBEDODIRECTUV: number;
  135381. VERTEXCOLOR: boolean;
  135382. DETAIL: boolean;
  135383. DETAILDIRECTUV: number;
  135384. DETAIL_NORMALBLENDMETHOD: number;
  135385. AMBIENT: boolean;
  135386. AMBIENTDIRECTUV: number;
  135387. AMBIENTINGRAYSCALE: boolean;
  135388. OPACITY: boolean;
  135389. VERTEXALPHA: boolean;
  135390. OPACITYDIRECTUV: number;
  135391. OPACITYRGB: boolean;
  135392. ALPHATEST: boolean;
  135393. DEPTHPREPASS: boolean;
  135394. ALPHABLEND: boolean;
  135395. ALPHAFROMALBEDO: boolean;
  135396. ALPHATESTVALUE: string;
  135397. SPECULAROVERALPHA: boolean;
  135398. RADIANCEOVERALPHA: boolean;
  135399. ALPHAFRESNEL: boolean;
  135400. LINEARALPHAFRESNEL: boolean;
  135401. PREMULTIPLYALPHA: boolean;
  135402. EMISSIVE: boolean;
  135403. EMISSIVEDIRECTUV: number;
  135404. REFLECTIVITY: boolean;
  135405. REFLECTIVITYDIRECTUV: number;
  135406. SPECULARTERM: boolean;
  135407. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  135408. MICROSURFACEAUTOMATIC: boolean;
  135409. LODBASEDMICROSFURACE: boolean;
  135410. MICROSURFACEMAP: boolean;
  135411. MICROSURFACEMAPDIRECTUV: number;
  135412. METALLICWORKFLOW: boolean;
  135413. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  135414. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  135415. METALLNESSSTOREINMETALMAPBLUE: boolean;
  135416. AOSTOREINMETALMAPRED: boolean;
  135417. METALLIC_REFLECTANCE: boolean;
  135418. METALLIC_REFLECTANCEDIRECTUV: number;
  135419. ENVIRONMENTBRDF: boolean;
  135420. ENVIRONMENTBRDF_RGBD: boolean;
  135421. NORMAL: boolean;
  135422. TANGENT: boolean;
  135423. BUMP: boolean;
  135424. BUMPDIRECTUV: number;
  135425. OBJECTSPACE_NORMALMAP: boolean;
  135426. PARALLAX: boolean;
  135427. PARALLAXOCCLUSION: boolean;
  135428. NORMALXYSCALE: boolean;
  135429. LIGHTMAP: boolean;
  135430. LIGHTMAPDIRECTUV: number;
  135431. USELIGHTMAPASSHADOWMAP: boolean;
  135432. GAMMALIGHTMAP: boolean;
  135433. RGBDLIGHTMAP: boolean;
  135434. REFLECTION: boolean;
  135435. REFLECTIONMAP_3D: boolean;
  135436. REFLECTIONMAP_SPHERICAL: boolean;
  135437. REFLECTIONMAP_PLANAR: boolean;
  135438. REFLECTIONMAP_CUBIC: boolean;
  135439. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  135440. REFLECTIONMAP_PROJECTION: boolean;
  135441. REFLECTIONMAP_SKYBOX: boolean;
  135442. REFLECTIONMAP_EXPLICIT: boolean;
  135443. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  135444. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  135445. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  135446. INVERTCUBICMAP: boolean;
  135447. USESPHERICALFROMREFLECTIONMAP: boolean;
  135448. USEIRRADIANCEMAP: boolean;
  135449. SPHERICAL_HARMONICS: boolean;
  135450. USESPHERICALINVERTEX: boolean;
  135451. REFLECTIONMAP_OPPOSITEZ: boolean;
  135452. LODINREFLECTIONALPHA: boolean;
  135453. GAMMAREFLECTION: boolean;
  135454. RGBDREFLECTION: boolean;
  135455. LINEARSPECULARREFLECTION: boolean;
  135456. RADIANCEOCCLUSION: boolean;
  135457. HORIZONOCCLUSION: boolean;
  135458. INSTANCES: boolean;
  135459. THIN_INSTANCES: boolean;
  135460. PREPASS: boolean;
  135461. SCENE_MRT_COUNT: number;
  135462. NUM_BONE_INFLUENCERS: number;
  135463. BonesPerMesh: number;
  135464. BONETEXTURE: boolean;
  135465. NONUNIFORMSCALING: boolean;
  135466. MORPHTARGETS: boolean;
  135467. MORPHTARGETS_NORMAL: boolean;
  135468. MORPHTARGETS_TANGENT: boolean;
  135469. MORPHTARGETS_UV: boolean;
  135470. NUM_MORPH_INFLUENCERS: number;
  135471. IMAGEPROCESSING: boolean;
  135472. VIGNETTE: boolean;
  135473. VIGNETTEBLENDMODEMULTIPLY: boolean;
  135474. VIGNETTEBLENDMODEOPAQUE: boolean;
  135475. TONEMAPPING: boolean;
  135476. TONEMAPPING_ACES: boolean;
  135477. CONTRAST: boolean;
  135478. COLORCURVES: boolean;
  135479. COLORGRADING: boolean;
  135480. COLORGRADING3D: boolean;
  135481. SAMPLER3DGREENDEPTH: boolean;
  135482. SAMPLER3DBGRMAP: boolean;
  135483. IMAGEPROCESSINGPOSTPROCESS: boolean;
  135484. EXPOSURE: boolean;
  135485. MULTIVIEW: boolean;
  135486. USEPHYSICALLIGHTFALLOFF: boolean;
  135487. USEGLTFLIGHTFALLOFF: boolean;
  135488. TWOSIDEDLIGHTING: boolean;
  135489. SHADOWFLOAT: boolean;
  135490. CLIPPLANE: boolean;
  135491. CLIPPLANE2: boolean;
  135492. CLIPPLANE3: boolean;
  135493. CLIPPLANE4: boolean;
  135494. CLIPPLANE5: boolean;
  135495. CLIPPLANE6: boolean;
  135496. POINTSIZE: boolean;
  135497. FOG: boolean;
  135498. LOGARITHMICDEPTH: boolean;
  135499. FORCENORMALFORWARD: boolean;
  135500. SPECULARAA: boolean;
  135501. CLEARCOAT: boolean;
  135502. CLEARCOAT_DEFAULTIOR: boolean;
  135503. CLEARCOAT_TEXTURE: boolean;
  135504. CLEARCOAT_TEXTUREDIRECTUV: number;
  135505. CLEARCOAT_BUMP: boolean;
  135506. CLEARCOAT_BUMPDIRECTUV: number;
  135507. CLEARCOAT_TINT: boolean;
  135508. CLEARCOAT_TINT_TEXTURE: boolean;
  135509. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135510. ANISOTROPIC: boolean;
  135511. ANISOTROPIC_TEXTURE: boolean;
  135512. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135513. BRDF_V_HEIGHT_CORRELATED: boolean;
  135514. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135515. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135516. SHEEN: boolean;
  135517. SHEEN_TEXTURE: boolean;
  135518. SHEEN_TEXTUREDIRECTUV: number;
  135519. SHEEN_LINKWITHALBEDO: boolean;
  135520. SHEEN_ROUGHNESS: boolean;
  135521. SHEEN_ALBEDOSCALING: boolean;
  135522. SUBSURFACE: boolean;
  135523. SS_REFRACTION: boolean;
  135524. SS_TRANSLUCENCY: boolean;
  135525. SS_SCATTERING: boolean;
  135526. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135527. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135528. SS_REFRACTIONMAP_3D: boolean;
  135529. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135530. SS_LODINREFRACTIONALPHA: boolean;
  135531. SS_GAMMAREFRACTION: boolean;
  135532. SS_RGBDREFRACTION: boolean;
  135533. SS_LINEARSPECULARREFRACTION: boolean;
  135534. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135535. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135536. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135537. UNLIT: boolean;
  135538. DEBUGMODE: number;
  135539. /**
  135540. * Initializes the PBR Material defines.
  135541. */
  135542. constructor();
  135543. /**
  135544. * Resets the PBR Material defines.
  135545. */
  135546. reset(): void;
  135547. }
  135548. /**
  135549. * The Physically based material base class of BJS.
  135550. *
  135551. * This offers the main features of a standard PBR material.
  135552. * For more information, please refer to the documentation :
  135553. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135554. */
  135555. export abstract class PBRBaseMaterial extends PushMaterial {
  135556. /**
  135557. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135558. */
  135559. static readonly PBRMATERIAL_OPAQUE: number;
  135560. /**
  135561. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135562. */
  135563. static readonly PBRMATERIAL_ALPHATEST: number;
  135564. /**
  135565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135566. */
  135567. static readonly PBRMATERIAL_ALPHABLEND: number;
  135568. /**
  135569. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135570. * They are also discarded below the alpha cutoff threshold to improve performances.
  135571. */
  135572. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135573. /**
  135574. * Defines the default value of how much AO map is occluding the analytical lights
  135575. * (point spot...).
  135576. */
  135577. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135578. /**
  135579. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  135580. */
  135581. static readonly LIGHTFALLOFF_PHYSICAL: number;
  135582. /**
  135583. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  135584. * to enhance interoperability with other engines.
  135585. */
  135586. static readonly LIGHTFALLOFF_GLTF: number;
  135587. /**
  135588. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  135589. * to enhance interoperability with other materials.
  135590. */
  135591. static readonly LIGHTFALLOFF_STANDARD: number;
  135592. /**
  135593. * Intensity of the direct lights e.g. the four lights available in your scene.
  135594. * This impacts both the direct diffuse and specular highlights.
  135595. */
  135596. protected _directIntensity: number;
  135597. /**
  135598. * Intensity of the emissive part of the material.
  135599. * This helps controlling the emissive effect without modifying the emissive color.
  135600. */
  135601. protected _emissiveIntensity: number;
  135602. /**
  135603. * Intensity of the environment e.g. how much the environment will light the object
  135604. * either through harmonics for rough material or through the refelction for shiny ones.
  135605. */
  135606. protected _environmentIntensity: number;
  135607. /**
  135608. * This is a special control allowing the reduction of the specular highlights coming from the
  135609. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135610. */
  135611. protected _specularIntensity: number;
  135612. /**
  135613. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  135614. */
  135615. private _lightingInfos;
  135616. /**
  135617. * Debug Control allowing disabling the bump map on this material.
  135618. */
  135619. protected _disableBumpMap: boolean;
  135620. /**
  135621. * AKA Diffuse Texture in standard nomenclature.
  135622. */
  135623. protected _albedoTexture: Nullable<BaseTexture>;
  135624. /**
  135625. * AKA Occlusion Texture in other nomenclature.
  135626. */
  135627. protected _ambientTexture: Nullable<BaseTexture>;
  135628. /**
  135629. * AKA Occlusion Texture Intensity in other nomenclature.
  135630. */
  135631. protected _ambientTextureStrength: number;
  135632. /**
  135633. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135634. * 1 means it completely occludes it
  135635. * 0 mean it has no impact
  135636. */
  135637. protected _ambientTextureImpactOnAnalyticalLights: number;
  135638. /**
  135639. * Stores the alpha values in a texture.
  135640. */
  135641. protected _opacityTexture: Nullable<BaseTexture>;
  135642. /**
  135643. * Stores the reflection values in a texture.
  135644. */
  135645. protected _reflectionTexture: Nullable<BaseTexture>;
  135646. /**
  135647. * Stores the emissive values in a texture.
  135648. */
  135649. protected _emissiveTexture: Nullable<BaseTexture>;
  135650. /**
  135651. * AKA Specular texture in other nomenclature.
  135652. */
  135653. protected _reflectivityTexture: Nullable<BaseTexture>;
  135654. /**
  135655. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135656. */
  135657. protected _metallicTexture: Nullable<BaseTexture>;
  135658. /**
  135659. * Specifies the metallic scalar of the metallic/roughness workflow.
  135660. * Can also be used to scale the metalness values of the metallic texture.
  135661. */
  135662. protected _metallic: Nullable<number>;
  135663. /**
  135664. * Specifies the roughness scalar of the metallic/roughness workflow.
  135665. * Can also be used to scale the roughness values of the metallic texture.
  135666. */
  135667. protected _roughness: Nullable<number>;
  135668. /**
  135669. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135670. * By default the indexOfrefraction is used to compute F0;
  135671. *
  135672. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135673. *
  135674. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135675. * F90 = metallicReflectanceColor;
  135676. */
  135677. protected _metallicF0Factor: number;
  135678. /**
  135679. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135680. * By default the F90 is always 1;
  135681. *
  135682. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135683. *
  135684. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135685. * F90 = metallicReflectanceColor;
  135686. */
  135687. protected _metallicReflectanceColor: Color3;
  135688. /**
  135689. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135690. * This is multiply against the scalar values defined in the material.
  135691. */
  135692. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135693. /**
  135694. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135695. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135696. */
  135697. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135698. /**
  135699. * Stores surface normal data used to displace a mesh in a texture.
  135700. */
  135701. protected _bumpTexture: Nullable<BaseTexture>;
  135702. /**
  135703. * Stores the pre-calculated light information of a mesh in a texture.
  135704. */
  135705. protected _lightmapTexture: Nullable<BaseTexture>;
  135706. /**
  135707. * The color of a material in ambient lighting.
  135708. */
  135709. protected _ambientColor: Color3;
  135710. /**
  135711. * AKA Diffuse Color in other nomenclature.
  135712. */
  135713. protected _albedoColor: Color3;
  135714. /**
  135715. * AKA Specular Color in other nomenclature.
  135716. */
  135717. protected _reflectivityColor: Color3;
  135718. /**
  135719. * The color applied when light is reflected from a material.
  135720. */
  135721. protected _reflectionColor: Color3;
  135722. /**
  135723. * The color applied when light is emitted from a material.
  135724. */
  135725. protected _emissiveColor: Color3;
  135726. /**
  135727. * AKA Glossiness in other nomenclature.
  135728. */
  135729. protected _microSurface: number;
  135730. /**
  135731. * Specifies that the material will use the light map as a show map.
  135732. */
  135733. protected _useLightmapAsShadowmap: boolean;
  135734. /**
  135735. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135736. * makes the reflect vector face the model (under horizon).
  135737. */
  135738. protected _useHorizonOcclusion: boolean;
  135739. /**
  135740. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135741. * too much the area relying on ambient texture to define their ambient occlusion.
  135742. */
  135743. protected _useRadianceOcclusion: boolean;
  135744. /**
  135745. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135746. */
  135747. protected _useAlphaFromAlbedoTexture: boolean;
  135748. /**
  135749. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135750. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135751. */
  135752. protected _useSpecularOverAlpha: boolean;
  135753. /**
  135754. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135755. */
  135756. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135757. /**
  135758. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135759. */
  135760. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135761. /**
  135762. * Specifies if the metallic texture contains the roughness information in its green channel.
  135763. */
  135764. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135765. /**
  135766. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135767. */
  135768. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135769. /**
  135770. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135771. */
  135772. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135773. /**
  135774. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135775. */
  135776. protected _useAmbientInGrayScale: boolean;
  135777. /**
  135778. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135779. * The material will try to infer what glossiness each pixel should be.
  135780. */
  135781. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135782. /**
  135783. * Defines the falloff type used in this material.
  135784. * It by default is Physical.
  135785. */
  135786. protected _lightFalloff: number;
  135787. /**
  135788. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135789. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135790. */
  135791. protected _useRadianceOverAlpha: boolean;
  135792. /**
  135793. * Allows using an object space normal map (instead of tangent space).
  135794. */
  135795. protected _useObjectSpaceNormalMap: boolean;
  135796. /**
  135797. * Allows using the bump map in parallax mode.
  135798. */
  135799. protected _useParallax: boolean;
  135800. /**
  135801. * Allows using the bump map in parallax occlusion mode.
  135802. */
  135803. protected _useParallaxOcclusion: boolean;
  135804. /**
  135805. * Controls the scale bias of the parallax mode.
  135806. */
  135807. protected _parallaxScaleBias: number;
  135808. /**
  135809. * If sets to true, disables all the lights affecting the material.
  135810. */
  135811. protected _disableLighting: boolean;
  135812. /**
  135813. * Number of Simultaneous lights allowed on the material.
  135814. */
  135815. protected _maxSimultaneousLights: number;
  135816. /**
  135817. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135818. */
  135819. protected _invertNormalMapX: boolean;
  135820. /**
  135821. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135822. */
  135823. protected _invertNormalMapY: boolean;
  135824. /**
  135825. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135826. */
  135827. protected _twoSidedLighting: boolean;
  135828. /**
  135829. * Defines the alpha limits in alpha test mode.
  135830. */
  135831. protected _alphaCutOff: number;
  135832. /**
  135833. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135834. */
  135835. protected _forceAlphaTest: boolean;
  135836. /**
  135837. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135838. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135839. */
  135840. protected _useAlphaFresnel: boolean;
  135841. /**
  135842. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135843. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135844. */
  135845. protected _useLinearAlphaFresnel: boolean;
  135846. /**
  135847. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135848. * from cos thetav and roughness:
  135849. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135850. */
  135851. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135852. /**
  135853. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135854. */
  135855. protected _forceIrradianceInFragment: boolean;
  135856. private _realTimeFiltering;
  135857. /**
  135858. * Enables realtime filtering on the texture.
  135859. */
  135860. get realTimeFiltering(): boolean;
  135861. set realTimeFiltering(b: boolean);
  135862. private _realTimeFilteringQuality;
  135863. /**
  135864. * Quality switch for realtime filtering
  135865. */
  135866. get realTimeFilteringQuality(): number;
  135867. set realTimeFilteringQuality(n: number);
  135868. /**
  135869. * Can this material render to several textures at once
  135870. */
  135871. get canRenderToMRT(): boolean;
  135872. /**
  135873. * Force normal to face away from face.
  135874. */
  135875. protected _forceNormalForward: boolean;
  135876. /**
  135877. * Enables specular anti aliasing in the PBR shader.
  135878. * It will both interacts on the Geometry for analytical and IBL lighting.
  135879. * It also prefilter the roughness map based on the bump values.
  135880. */
  135881. protected _enableSpecularAntiAliasing: boolean;
  135882. /**
  135883. * Default configuration related to image processing available in the PBR Material.
  135884. */
  135885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135886. /**
  135887. * Keep track of the image processing observer to allow dispose and replace.
  135888. */
  135889. private _imageProcessingObserver;
  135890. /**
  135891. * Attaches a new image processing configuration to the PBR Material.
  135892. * @param configuration
  135893. */
  135894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135895. /**
  135896. * Stores the available render targets.
  135897. */
  135898. private _renderTargets;
  135899. /**
  135900. * Sets the global ambient color for the material used in lighting calculations.
  135901. */
  135902. private _globalAmbientColor;
  135903. /**
  135904. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135905. */
  135906. private _useLogarithmicDepth;
  135907. /**
  135908. * If set to true, no lighting calculations will be applied.
  135909. */
  135910. private _unlit;
  135911. private _debugMode;
  135912. /**
  135913. * @hidden
  135914. * This is reserved for the inspector.
  135915. * Defines the material debug mode.
  135916. * It helps seeing only some components of the material while troubleshooting.
  135917. */
  135918. debugMode: number;
  135919. /**
  135920. * @hidden
  135921. * This is reserved for the inspector.
  135922. * Specify from where on screen the debug mode should start.
  135923. * The value goes from -1 (full screen) to 1 (not visible)
  135924. * It helps with side by side comparison against the final render
  135925. * This defaults to -1
  135926. */
  135927. private debugLimit;
  135928. /**
  135929. * @hidden
  135930. * This is reserved for the inspector.
  135931. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135932. * You can use the factor to better multiply the final value.
  135933. */
  135934. private debugFactor;
  135935. /**
  135936. * Defines the clear coat layer parameters for the material.
  135937. */
  135938. readonly clearCoat: PBRClearCoatConfiguration;
  135939. /**
  135940. * Defines the anisotropic parameters for the material.
  135941. */
  135942. readonly anisotropy: PBRAnisotropicConfiguration;
  135943. /**
  135944. * Defines the BRDF parameters for the material.
  135945. */
  135946. readonly brdf: PBRBRDFConfiguration;
  135947. /**
  135948. * Defines the Sheen parameters for the material.
  135949. */
  135950. readonly sheen: PBRSheenConfiguration;
  135951. /**
  135952. * Defines the SubSurface parameters for the material.
  135953. */
  135954. readonly subSurface: PBRSubSurfaceConfiguration;
  135955. /**
  135956. * Defines the detail map parameters for the material.
  135957. */
  135958. readonly detailMap: DetailMapConfiguration;
  135959. protected _rebuildInParallel: boolean;
  135960. /**
  135961. * Instantiates a new PBRMaterial instance.
  135962. *
  135963. * @param name The material name
  135964. * @param scene The scene the material will be use in.
  135965. */
  135966. constructor(name: string, scene: Scene);
  135967. /**
  135968. * Gets a boolean indicating that current material needs to register RTT
  135969. */
  135970. get hasRenderTargetTextures(): boolean;
  135971. /**
  135972. * Gets the name of the material class.
  135973. */
  135974. getClassName(): string;
  135975. /**
  135976. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135977. */
  135978. get useLogarithmicDepth(): boolean;
  135979. /**
  135980. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135981. */
  135982. set useLogarithmicDepth(value: boolean);
  135983. /**
  135984. * Returns true if alpha blending should be disabled.
  135985. */
  135986. protected get _disableAlphaBlending(): boolean;
  135987. /**
  135988. * Specifies whether or not this material should be rendered in alpha blend mode.
  135989. */
  135990. needAlphaBlending(): boolean;
  135991. /**
  135992. * Specifies whether or not this material should be rendered in alpha test mode.
  135993. */
  135994. needAlphaTesting(): boolean;
  135995. /**
  135996. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135997. */
  135998. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135999. /**
  136000. * Gets the texture used for the alpha test.
  136001. */
  136002. getAlphaTestTexture(): Nullable<BaseTexture>;
  136003. /**
  136004. * Specifies that the submesh is ready to be used.
  136005. * @param mesh - BJS mesh.
  136006. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  136007. * @param useInstances - Specifies that instances should be used.
  136008. * @returns - boolean indicating that the submesh is ready or not.
  136009. */
  136010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  136011. /**
  136012. * Specifies if the material uses metallic roughness workflow.
  136013. * @returns boolean specifiying if the material uses metallic roughness workflow.
  136014. */
  136015. isMetallicWorkflow(): boolean;
  136016. private _prepareEffect;
  136017. private _prepareDefines;
  136018. /**
  136019. * Force shader compilation
  136020. */
  136021. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  136022. /**
  136023. * Initializes the uniform buffer layout for the shader.
  136024. */
  136025. buildUniformLayout(): void;
  136026. /**
  136027. * Unbinds the material from the mesh
  136028. */
  136029. unbind(): void;
  136030. /**
  136031. * Binds the submesh data.
  136032. * @param world - The world matrix.
  136033. * @param mesh - The BJS mesh.
  136034. * @param subMesh - A submesh of the BJS mesh.
  136035. */
  136036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  136037. /**
  136038. * Returns the animatable textures.
  136039. * @returns - Array of animatable textures.
  136040. */
  136041. getAnimatables(): IAnimatable[];
  136042. /**
  136043. * Returns the texture used for reflections.
  136044. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  136045. */
  136046. private _getReflectionTexture;
  136047. /**
  136048. * Returns an array of the actively used textures.
  136049. * @returns - Array of BaseTextures
  136050. */
  136051. getActiveTextures(): BaseTexture[];
  136052. /**
  136053. * Checks to see if a texture is used in the material.
  136054. * @param texture - Base texture to use.
  136055. * @returns - Boolean specifying if a texture is used in the material.
  136056. */
  136057. hasTexture(texture: BaseTexture): boolean;
  136058. /**
  136059. * Sets the required values to the prepass renderer.
  136060. * @param prePassRenderer defines the prepass renderer to setup
  136061. */
  136062. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  136063. /**
  136064. * Disposes the resources of the material.
  136065. * @param forceDisposeEffect - Forces the disposal of effects.
  136066. * @param forceDisposeTextures - Forces the disposal of all textures.
  136067. */
  136068. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  136069. }
  136070. }
  136071. declare module BABYLON {
  136072. /**
  136073. * The Physically based material of BJS.
  136074. *
  136075. * This offers the main features of a standard PBR material.
  136076. * For more information, please refer to the documentation :
  136077. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136078. */
  136079. export class PBRMaterial extends PBRBaseMaterial {
  136080. /**
  136081. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136082. */
  136083. static readonly PBRMATERIAL_OPAQUE: number;
  136084. /**
  136085. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136086. */
  136087. static readonly PBRMATERIAL_ALPHATEST: number;
  136088. /**
  136089. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136090. */
  136091. static readonly PBRMATERIAL_ALPHABLEND: number;
  136092. /**
  136093. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136094. * They are also discarded below the alpha cutoff threshold to improve performances.
  136095. */
  136096. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136097. /**
  136098. * Defines the default value of how much AO map is occluding the analytical lights
  136099. * (point spot...).
  136100. */
  136101. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136102. /**
  136103. * Intensity of the direct lights e.g. the four lights available in your scene.
  136104. * This impacts both the direct diffuse and specular highlights.
  136105. */
  136106. directIntensity: number;
  136107. /**
  136108. * Intensity of the emissive part of the material.
  136109. * This helps controlling the emissive effect without modifying the emissive color.
  136110. */
  136111. emissiveIntensity: number;
  136112. /**
  136113. * Intensity of the environment e.g. how much the environment will light the object
  136114. * either through harmonics for rough material or through the refelction for shiny ones.
  136115. */
  136116. environmentIntensity: number;
  136117. /**
  136118. * This is a special control allowing the reduction of the specular highlights coming from the
  136119. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136120. */
  136121. specularIntensity: number;
  136122. /**
  136123. * Debug Control allowing disabling the bump map on this material.
  136124. */
  136125. disableBumpMap: boolean;
  136126. /**
  136127. * AKA Diffuse Texture in standard nomenclature.
  136128. */
  136129. albedoTexture: BaseTexture;
  136130. /**
  136131. * AKA Occlusion Texture in other nomenclature.
  136132. */
  136133. ambientTexture: BaseTexture;
  136134. /**
  136135. * AKA Occlusion Texture Intensity in other nomenclature.
  136136. */
  136137. ambientTextureStrength: number;
  136138. /**
  136139. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136140. * 1 means it completely occludes it
  136141. * 0 mean it has no impact
  136142. */
  136143. ambientTextureImpactOnAnalyticalLights: number;
  136144. /**
  136145. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  136146. */
  136147. opacityTexture: BaseTexture;
  136148. /**
  136149. * Stores the reflection values in a texture.
  136150. */
  136151. reflectionTexture: Nullable<BaseTexture>;
  136152. /**
  136153. * Stores the emissive values in a texture.
  136154. */
  136155. emissiveTexture: BaseTexture;
  136156. /**
  136157. * AKA Specular texture in other nomenclature.
  136158. */
  136159. reflectivityTexture: BaseTexture;
  136160. /**
  136161. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136162. */
  136163. metallicTexture: BaseTexture;
  136164. /**
  136165. * Specifies the metallic scalar of the metallic/roughness workflow.
  136166. * Can also be used to scale the metalness values of the metallic texture.
  136167. */
  136168. metallic: Nullable<number>;
  136169. /**
  136170. * Specifies the roughness scalar of the metallic/roughness workflow.
  136171. * Can also be used to scale the roughness values of the metallic texture.
  136172. */
  136173. roughness: Nullable<number>;
  136174. /**
  136175. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136176. * By default the indexOfrefraction is used to compute F0;
  136177. *
  136178. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136179. *
  136180. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136181. * F90 = metallicReflectanceColor;
  136182. */
  136183. metallicF0Factor: number;
  136184. /**
  136185. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136186. * By default the F90 is always 1;
  136187. *
  136188. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136189. *
  136190. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136191. * F90 = metallicReflectanceColor;
  136192. */
  136193. metallicReflectanceColor: Color3;
  136194. /**
  136195. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136196. * This is multiply against the scalar values defined in the material.
  136197. */
  136198. metallicReflectanceTexture: Nullable<BaseTexture>;
  136199. /**
  136200. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136201. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136202. */
  136203. microSurfaceTexture: BaseTexture;
  136204. /**
  136205. * Stores surface normal data used to displace a mesh in a texture.
  136206. */
  136207. bumpTexture: BaseTexture;
  136208. /**
  136209. * Stores the pre-calculated light information of a mesh in a texture.
  136210. */
  136211. lightmapTexture: BaseTexture;
  136212. /**
  136213. * Stores the refracted light information in a texture.
  136214. */
  136215. get refractionTexture(): Nullable<BaseTexture>;
  136216. set refractionTexture(value: Nullable<BaseTexture>);
  136217. /**
  136218. * The color of a material in ambient lighting.
  136219. */
  136220. ambientColor: Color3;
  136221. /**
  136222. * AKA Diffuse Color in other nomenclature.
  136223. */
  136224. albedoColor: Color3;
  136225. /**
  136226. * AKA Specular Color in other nomenclature.
  136227. */
  136228. reflectivityColor: Color3;
  136229. /**
  136230. * The color reflected from the material.
  136231. */
  136232. reflectionColor: Color3;
  136233. /**
  136234. * The color emitted from the material.
  136235. */
  136236. emissiveColor: Color3;
  136237. /**
  136238. * AKA Glossiness in other nomenclature.
  136239. */
  136240. microSurface: number;
  136241. /**
  136242. * Index of refraction of the material base layer.
  136243. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136244. *
  136245. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136246. *
  136247. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136248. */
  136249. get indexOfRefraction(): number;
  136250. set indexOfRefraction(value: number);
  136251. /**
  136252. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136253. */
  136254. get invertRefractionY(): boolean;
  136255. set invertRefractionY(value: boolean);
  136256. /**
  136257. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136258. * Materials half opaque for instance using refraction could benefit from this control.
  136259. */
  136260. get linkRefractionWithTransparency(): boolean;
  136261. set linkRefractionWithTransparency(value: boolean);
  136262. /**
  136263. * If true, the light map contains occlusion information instead of lighting info.
  136264. */
  136265. useLightmapAsShadowmap: boolean;
  136266. /**
  136267. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136268. */
  136269. useAlphaFromAlbedoTexture: boolean;
  136270. /**
  136271. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136272. */
  136273. forceAlphaTest: boolean;
  136274. /**
  136275. * Defines the alpha limits in alpha test mode.
  136276. */
  136277. alphaCutOff: number;
  136278. /**
  136279. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  136280. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136281. */
  136282. useSpecularOverAlpha: boolean;
  136283. /**
  136284. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136285. */
  136286. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136287. /**
  136288. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136289. */
  136290. useRoughnessFromMetallicTextureAlpha: boolean;
  136291. /**
  136292. * Specifies if the metallic texture contains the roughness information in its green channel.
  136293. */
  136294. useRoughnessFromMetallicTextureGreen: boolean;
  136295. /**
  136296. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136297. */
  136298. useMetallnessFromMetallicTextureBlue: boolean;
  136299. /**
  136300. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136301. */
  136302. useAmbientOcclusionFromMetallicTextureRed: boolean;
  136303. /**
  136304. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136305. */
  136306. useAmbientInGrayScale: boolean;
  136307. /**
  136308. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136309. * The material will try to infer what glossiness each pixel should be.
  136310. */
  136311. useAutoMicroSurfaceFromReflectivityMap: boolean;
  136312. /**
  136313. * BJS is using an harcoded light falloff based on a manually sets up range.
  136314. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136315. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136316. */
  136317. get usePhysicalLightFalloff(): boolean;
  136318. /**
  136319. * BJS is using an harcoded light falloff based on a manually sets up range.
  136320. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136321. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136322. */
  136323. set usePhysicalLightFalloff(value: boolean);
  136324. /**
  136325. * In order to support the falloff compatibility with gltf, a special mode has been added
  136326. * to reproduce the gltf light falloff.
  136327. */
  136328. get useGLTFLightFalloff(): boolean;
  136329. /**
  136330. * In order to support the falloff compatibility with gltf, a special mode has been added
  136331. * to reproduce the gltf light falloff.
  136332. */
  136333. set useGLTFLightFalloff(value: boolean);
  136334. /**
  136335. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136336. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136337. */
  136338. useRadianceOverAlpha: boolean;
  136339. /**
  136340. * Allows using an object space normal map (instead of tangent space).
  136341. */
  136342. useObjectSpaceNormalMap: boolean;
  136343. /**
  136344. * Allows using the bump map in parallax mode.
  136345. */
  136346. useParallax: boolean;
  136347. /**
  136348. * Allows using the bump map in parallax occlusion mode.
  136349. */
  136350. useParallaxOcclusion: boolean;
  136351. /**
  136352. * Controls the scale bias of the parallax mode.
  136353. */
  136354. parallaxScaleBias: number;
  136355. /**
  136356. * If sets to true, disables all the lights affecting the material.
  136357. */
  136358. disableLighting: boolean;
  136359. /**
  136360. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136361. */
  136362. forceIrradianceInFragment: boolean;
  136363. /**
  136364. * Number of Simultaneous lights allowed on the material.
  136365. */
  136366. maxSimultaneousLights: number;
  136367. /**
  136368. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136369. */
  136370. invertNormalMapX: boolean;
  136371. /**
  136372. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136373. */
  136374. invertNormalMapY: boolean;
  136375. /**
  136376. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136377. */
  136378. twoSidedLighting: boolean;
  136379. /**
  136380. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136381. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136382. */
  136383. useAlphaFresnel: boolean;
  136384. /**
  136385. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136386. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136387. */
  136388. useLinearAlphaFresnel: boolean;
  136389. /**
  136390. * Let user defines the brdf lookup texture used for IBL.
  136391. * A default 8bit version is embedded but you could point at :
  136392. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  136393. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  136394. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  136395. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  136396. */
  136397. environmentBRDFTexture: Nullable<BaseTexture>;
  136398. /**
  136399. * Force normal to face away from face.
  136400. */
  136401. forceNormalForward: boolean;
  136402. /**
  136403. * Enables specular anti aliasing in the PBR shader.
  136404. * It will both interacts on the Geometry for analytical and IBL lighting.
  136405. * It also prefilter the roughness map based on the bump values.
  136406. */
  136407. enableSpecularAntiAliasing: boolean;
  136408. /**
  136409. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136410. * makes the reflect vector face the model (under horizon).
  136411. */
  136412. useHorizonOcclusion: boolean;
  136413. /**
  136414. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136415. * too much the area relying on ambient texture to define their ambient occlusion.
  136416. */
  136417. useRadianceOcclusion: boolean;
  136418. /**
  136419. * If set to true, no lighting calculations will be applied.
  136420. */
  136421. unlit: boolean;
  136422. /**
  136423. * Gets the image processing configuration used either in this material.
  136424. */
  136425. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  136426. /**
  136427. * Sets the Default image processing configuration used either in the this material.
  136428. *
  136429. * If sets to null, the scene one is in use.
  136430. */
  136431. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  136432. /**
  136433. * Gets wether the color curves effect is enabled.
  136434. */
  136435. get cameraColorCurvesEnabled(): boolean;
  136436. /**
  136437. * Sets wether the color curves effect is enabled.
  136438. */
  136439. set cameraColorCurvesEnabled(value: boolean);
  136440. /**
  136441. * Gets wether the color grading effect is enabled.
  136442. */
  136443. get cameraColorGradingEnabled(): boolean;
  136444. /**
  136445. * Gets wether the color grading effect is enabled.
  136446. */
  136447. set cameraColorGradingEnabled(value: boolean);
  136448. /**
  136449. * Gets wether tonemapping is enabled or not.
  136450. */
  136451. get cameraToneMappingEnabled(): boolean;
  136452. /**
  136453. * Sets wether tonemapping is enabled or not
  136454. */
  136455. set cameraToneMappingEnabled(value: boolean);
  136456. /**
  136457. * The camera exposure used on this material.
  136458. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136459. * This corresponds to a photographic exposure.
  136460. */
  136461. get cameraExposure(): number;
  136462. /**
  136463. * The camera exposure used on this material.
  136464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136465. * This corresponds to a photographic exposure.
  136466. */
  136467. set cameraExposure(value: number);
  136468. /**
  136469. * Gets The camera contrast used on this material.
  136470. */
  136471. get cameraContrast(): number;
  136472. /**
  136473. * Sets The camera contrast used on this material.
  136474. */
  136475. set cameraContrast(value: number);
  136476. /**
  136477. * Gets the Color Grading 2D Lookup Texture.
  136478. */
  136479. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  136480. /**
  136481. * Sets the Color Grading 2D Lookup Texture.
  136482. */
  136483. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  136484. /**
  136485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136487. * 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;
  136488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136489. */
  136490. get cameraColorCurves(): Nullable<ColorCurves>;
  136491. /**
  136492. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136493. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136494. * 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;
  136495. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136496. */
  136497. set cameraColorCurves(value: Nullable<ColorCurves>);
  136498. /**
  136499. * Instantiates a new PBRMaterial instance.
  136500. *
  136501. * @param name The material name
  136502. * @param scene The scene the material will be use in.
  136503. */
  136504. constructor(name: string, scene: Scene);
  136505. /**
  136506. * Returns the name of this material class.
  136507. */
  136508. getClassName(): string;
  136509. /**
  136510. * Makes a duplicate of the current material.
  136511. * @param name - name to use for the new material.
  136512. */
  136513. clone(name: string): PBRMaterial;
  136514. /**
  136515. * Serializes this PBR Material.
  136516. * @returns - An object with the serialized material.
  136517. */
  136518. serialize(): any;
  136519. /**
  136520. * Parses a PBR Material from a serialized object.
  136521. * @param source - Serialized object.
  136522. * @param scene - BJS scene instance.
  136523. * @param rootUrl - url for the scene object
  136524. * @returns - PBRMaterial
  136525. */
  136526. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  136527. }
  136528. }
  136529. declare module BABYLON {
  136530. /**
  136531. * Direct draw surface info
  136532. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  136533. */
  136534. export interface DDSInfo {
  136535. /**
  136536. * Width of the texture
  136537. */
  136538. width: number;
  136539. /**
  136540. * Width of the texture
  136541. */
  136542. height: number;
  136543. /**
  136544. * Number of Mipmaps for the texture
  136545. * @see https://en.wikipedia.org/wiki/Mipmap
  136546. */
  136547. mipmapCount: number;
  136548. /**
  136549. * If the textures format is a known fourCC format
  136550. * @see https://www.fourcc.org/
  136551. */
  136552. isFourCC: boolean;
  136553. /**
  136554. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  136555. */
  136556. isRGB: boolean;
  136557. /**
  136558. * If the texture is a lumincance format
  136559. */
  136560. isLuminance: boolean;
  136561. /**
  136562. * If this is a cube texture
  136563. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  136564. */
  136565. isCube: boolean;
  136566. /**
  136567. * If the texture is a compressed format eg. FOURCC_DXT1
  136568. */
  136569. isCompressed: boolean;
  136570. /**
  136571. * The dxgiFormat of the texture
  136572. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  136573. */
  136574. dxgiFormat: number;
  136575. /**
  136576. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  136577. */
  136578. textureType: number;
  136579. /**
  136580. * Sphericle polynomial created for the dds texture
  136581. */
  136582. sphericalPolynomial?: SphericalPolynomial;
  136583. }
  136584. /**
  136585. * Class used to provide DDS decompression tools
  136586. */
  136587. export class DDSTools {
  136588. /**
  136589. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  136590. */
  136591. static StoreLODInAlphaChannel: boolean;
  136592. /**
  136593. * Gets DDS information from an array buffer
  136594. * @param data defines the array buffer view to read data from
  136595. * @returns the DDS information
  136596. */
  136597. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  136598. private static _FloatView;
  136599. private static _Int32View;
  136600. private static _ToHalfFloat;
  136601. private static _FromHalfFloat;
  136602. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  136603. private static _GetHalfFloatRGBAArrayBuffer;
  136604. private static _GetFloatRGBAArrayBuffer;
  136605. private static _GetFloatAsUIntRGBAArrayBuffer;
  136606. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  136607. private static _GetRGBAArrayBuffer;
  136608. private static _ExtractLongWordOrder;
  136609. private static _GetRGBArrayBuffer;
  136610. private static _GetLuminanceArrayBuffer;
  136611. /**
  136612. * Uploads DDS Levels to a Babylon Texture
  136613. * @hidden
  136614. */
  136615. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  136616. }
  136617. interface ThinEngine {
  136618. /**
  136619. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  136620. * @param rootUrl defines the url where the file to load is located
  136621. * @param scene defines the current scene
  136622. * @param lodScale defines scale to apply to the mip map selection
  136623. * @param lodOffset defines offset to apply to the mip map selection
  136624. * @param onLoad defines an optional callback raised when the texture is loaded
  136625. * @param onError defines an optional callback raised if there is an issue to load the texture
  136626. * @param format defines the format of the data
  136627. * @param forcedExtension defines the extension to use to pick the right loader
  136628. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  136629. * @returns the cube texture as an InternalTexture
  136630. */
  136631. 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;
  136632. }
  136633. }
  136634. declare module BABYLON {
  136635. /**
  136636. * Implementation of the DDS Texture Loader.
  136637. * @hidden
  136638. */
  136639. export class _DDSTextureLoader implements IInternalTextureLoader {
  136640. /**
  136641. * Defines wether the loader supports cascade loading the different faces.
  136642. */
  136643. readonly supportCascades: boolean;
  136644. /**
  136645. * This returns if the loader support the current file information.
  136646. * @param extension defines the file extension of the file being loaded
  136647. * @returns true if the loader can load the specified file
  136648. */
  136649. canLoad(extension: string): boolean;
  136650. /**
  136651. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136652. * @param data contains the texture data
  136653. * @param texture defines the BabylonJS internal texture
  136654. * @param createPolynomials will be true if polynomials have been requested
  136655. * @param onLoad defines the callback to trigger once the texture is ready
  136656. * @param onError defines the callback to trigger in case of error
  136657. */
  136658. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136659. /**
  136660. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136661. * @param data contains the texture data
  136662. * @param texture defines the BabylonJS internal texture
  136663. * @param callback defines the method to call once ready to upload
  136664. */
  136665. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136666. }
  136667. }
  136668. declare module BABYLON {
  136669. /**
  136670. * Implementation of the ENV Texture Loader.
  136671. * @hidden
  136672. */
  136673. export class _ENVTextureLoader implements IInternalTextureLoader {
  136674. /**
  136675. * Defines wether the loader supports cascade loading the different faces.
  136676. */
  136677. readonly supportCascades: boolean;
  136678. /**
  136679. * This returns if the loader support the current file information.
  136680. * @param extension defines the file extension of the file being loaded
  136681. * @returns true if the loader can load the specified file
  136682. */
  136683. canLoad(extension: string): boolean;
  136684. /**
  136685. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136686. * @param data contains the texture data
  136687. * @param texture defines the BabylonJS internal texture
  136688. * @param createPolynomials will be true if polynomials have been requested
  136689. * @param onLoad defines the callback to trigger once the texture is ready
  136690. * @param onError defines the callback to trigger in case of error
  136691. */
  136692. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136693. /**
  136694. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136695. * @param data contains the texture data
  136696. * @param texture defines the BabylonJS internal texture
  136697. * @param callback defines the method to call once ready to upload
  136698. */
  136699. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136700. }
  136701. }
  136702. declare module BABYLON {
  136703. /**
  136704. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136705. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136706. */
  136707. export class KhronosTextureContainer {
  136708. /** contents of the KTX container file */
  136709. data: ArrayBufferView;
  136710. private static HEADER_LEN;
  136711. private static COMPRESSED_2D;
  136712. private static COMPRESSED_3D;
  136713. private static TEX_2D;
  136714. private static TEX_3D;
  136715. /**
  136716. * Gets the openGL type
  136717. */
  136718. glType: number;
  136719. /**
  136720. * Gets the openGL type size
  136721. */
  136722. glTypeSize: number;
  136723. /**
  136724. * Gets the openGL format
  136725. */
  136726. glFormat: number;
  136727. /**
  136728. * Gets the openGL internal format
  136729. */
  136730. glInternalFormat: number;
  136731. /**
  136732. * Gets the base internal format
  136733. */
  136734. glBaseInternalFormat: number;
  136735. /**
  136736. * Gets image width in pixel
  136737. */
  136738. pixelWidth: number;
  136739. /**
  136740. * Gets image height in pixel
  136741. */
  136742. pixelHeight: number;
  136743. /**
  136744. * Gets image depth in pixels
  136745. */
  136746. pixelDepth: number;
  136747. /**
  136748. * Gets the number of array elements
  136749. */
  136750. numberOfArrayElements: number;
  136751. /**
  136752. * Gets the number of faces
  136753. */
  136754. numberOfFaces: number;
  136755. /**
  136756. * Gets the number of mipmap levels
  136757. */
  136758. numberOfMipmapLevels: number;
  136759. /**
  136760. * Gets the bytes of key value data
  136761. */
  136762. bytesOfKeyValueData: number;
  136763. /**
  136764. * Gets the load type
  136765. */
  136766. loadType: number;
  136767. /**
  136768. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136769. */
  136770. isInvalid: boolean;
  136771. /**
  136772. * Creates a new KhronosTextureContainer
  136773. * @param data contents of the KTX container file
  136774. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136775. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136776. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136777. */
  136778. constructor(
  136779. /** contents of the KTX container file */
  136780. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136781. /**
  136782. * Uploads KTX content to a Babylon Texture.
  136783. * It is assumed that the texture has already been created & is currently bound
  136784. * @hidden
  136785. */
  136786. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136787. private _upload2DCompressedLevels;
  136788. /**
  136789. * Checks if the given data starts with a KTX file identifier.
  136790. * @param data the data to check
  136791. * @returns true if the data is a KTX file or false otherwise
  136792. */
  136793. static IsValid(data: ArrayBufferView): boolean;
  136794. }
  136795. }
  136796. declare module BABYLON {
  136797. /**
  136798. * Class for loading KTX2 files
  136799. * !!! Experimental Extension Subject to Changes !!!
  136800. * @hidden
  136801. */
  136802. export class KhronosTextureContainer2 {
  136803. private static _ModulePromise;
  136804. private static _TranscodeFormat;
  136805. constructor(engine: ThinEngine);
  136806. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136807. private _determineTranscodeFormat;
  136808. /**
  136809. * Checks if the given data starts with a KTX2 file identifier.
  136810. * @param data the data to check
  136811. * @returns true if the data is a KTX2 file or false otherwise
  136812. */
  136813. static IsValid(data: ArrayBufferView): boolean;
  136814. }
  136815. }
  136816. declare module BABYLON {
  136817. /**
  136818. * Implementation of the KTX Texture Loader.
  136819. * @hidden
  136820. */
  136821. export class _KTXTextureLoader implements IInternalTextureLoader {
  136822. /**
  136823. * Defines wether the loader supports cascade loading the different faces.
  136824. */
  136825. readonly supportCascades: boolean;
  136826. /**
  136827. * This returns if the loader support the current file information.
  136828. * @param extension defines the file extension of the file being loaded
  136829. * @param mimeType defines the optional mime type of the file being loaded
  136830. * @returns true if the loader can load the specified file
  136831. */
  136832. canLoad(extension: string, mimeType?: string): boolean;
  136833. /**
  136834. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136835. * @param data contains the texture data
  136836. * @param texture defines the BabylonJS internal texture
  136837. * @param createPolynomials will be true if polynomials have been requested
  136838. * @param onLoad defines the callback to trigger once the texture is ready
  136839. * @param onError defines the callback to trigger in case of error
  136840. */
  136841. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136842. /**
  136843. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136844. * @param data contains the texture data
  136845. * @param texture defines the BabylonJS internal texture
  136846. * @param callback defines the method to call once ready to upload
  136847. */
  136848. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136849. }
  136850. }
  136851. declare module BABYLON {
  136852. /** @hidden */
  136853. export var _forceSceneHelpersToBundle: boolean;
  136854. interface Scene {
  136855. /**
  136856. * Creates a default light for the scene.
  136857. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136858. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136859. */
  136860. createDefaultLight(replace?: boolean): void;
  136861. /**
  136862. * Creates a default camera for the scene.
  136863. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136864. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136865. * @param replace has default false, when true replaces the active camera in the scene
  136866. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136867. */
  136868. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136869. /**
  136870. * Creates a default camera and a default light.
  136871. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136872. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136873. * @param replace has the default false, when true replaces the active camera/light in the scene
  136874. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136875. */
  136876. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136877. /**
  136878. * Creates a new sky box
  136879. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136880. * @param environmentTexture defines the texture to use as environment texture
  136881. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136882. * @param scale defines the overall scale of the skybox
  136883. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136884. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136885. * @returns a new mesh holding the sky box
  136886. */
  136887. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136888. /**
  136889. * Creates a new environment
  136890. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136891. * @param options defines the options you can use to configure the environment
  136892. * @returns the new EnvironmentHelper
  136893. */
  136894. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136895. /**
  136896. * Creates a new VREXperienceHelper
  136897. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136898. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136899. * @returns a new VREXperienceHelper
  136900. */
  136901. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136902. /**
  136903. * Creates a new WebXRDefaultExperience
  136904. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136905. * @param options experience options
  136906. * @returns a promise for a new WebXRDefaultExperience
  136907. */
  136908. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136909. }
  136910. }
  136911. declare module BABYLON {
  136912. /**
  136913. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136914. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136915. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136916. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136917. */
  136918. export class VideoDome extends TransformNode {
  136919. /**
  136920. * Define the video source as a Monoscopic panoramic 360 video.
  136921. */
  136922. static readonly MODE_MONOSCOPIC: number;
  136923. /**
  136924. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136925. */
  136926. static readonly MODE_TOPBOTTOM: number;
  136927. /**
  136928. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136929. */
  136930. static readonly MODE_SIDEBYSIDE: number;
  136931. private _halfDome;
  136932. private _useDirectMapping;
  136933. /**
  136934. * The video texture being displayed on the sphere
  136935. */
  136936. protected _videoTexture: VideoTexture;
  136937. /**
  136938. * Gets the video texture being displayed on the sphere
  136939. */
  136940. get videoTexture(): VideoTexture;
  136941. /**
  136942. * The skybox material
  136943. */
  136944. protected _material: BackgroundMaterial;
  136945. /**
  136946. * The surface used for the video dome
  136947. */
  136948. protected _mesh: Mesh;
  136949. /**
  136950. * Gets the mesh used for the video dome.
  136951. */
  136952. get mesh(): Mesh;
  136953. /**
  136954. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136955. */
  136956. private _halfDomeMask;
  136957. /**
  136958. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136959. * Also see the options.resolution property.
  136960. */
  136961. get fovMultiplier(): number;
  136962. set fovMultiplier(value: number);
  136963. private _videoMode;
  136964. /**
  136965. * Gets or set the current video mode for the video. It can be:
  136966. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136967. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136968. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136969. */
  136970. get videoMode(): number;
  136971. set videoMode(value: number);
  136972. /**
  136973. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136974. *
  136975. */
  136976. get halfDome(): boolean;
  136977. /**
  136978. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136979. */
  136980. set halfDome(enabled: boolean);
  136981. /**
  136982. * Oberserver used in Stereoscopic VR Mode.
  136983. */
  136984. private _onBeforeCameraRenderObserver;
  136985. /**
  136986. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136987. * @param name Element's name, child elements will append suffixes for their own names.
  136988. * @param urlsOrVideo defines the url(s) or the video element to use
  136989. * @param options An object containing optional or exposed sub element properties
  136990. */
  136991. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136992. resolution?: number;
  136993. clickToPlay?: boolean;
  136994. autoPlay?: boolean;
  136995. loop?: boolean;
  136996. size?: number;
  136997. poster?: string;
  136998. faceForward?: boolean;
  136999. useDirectMapping?: boolean;
  137000. halfDomeMode?: boolean;
  137001. }, scene: Scene);
  137002. private _changeVideoMode;
  137003. /**
  137004. * Releases resources associated with this node.
  137005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  137006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  137007. */
  137008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  137009. }
  137010. }
  137011. declare module BABYLON {
  137012. /**
  137013. * This class can be used to get instrumentation data from a Babylon engine
  137014. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137015. */
  137016. export class EngineInstrumentation implements IDisposable {
  137017. /**
  137018. * Define the instrumented engine.
  137019. */
  137020. engine: Engine;
  137021. private _captureGPUFrameTime;
  137022. private _gpuFrameTimeToken;
  137023. private _gpuFrameTime;
  137024. private _captureShaderCompilationTime;
  137025. private _shaderCompilationTime;
  137026. private _onBeginFrameObserver;
  137027. private _onEndFrameObserver;
  137028. private _onBeforeShaderCompilationObserver;
  137029. private _onAfterShaderCompilationObserver;
  137030. /**
  137031. * Gets the perf counter used for GPU frame time
  137032. */
  137033. get gpuFrameTimeCounter(): PerfCounter;
  137034. /**
  137035. * Gets the GPU frame time capture status
  137036. */
  137037. get captureGPUFrameTime(): boolean;
  137038. /**
  137039. * Enable or disable the GPU frame time capture
  137040. */
  137041. set captureGPUFrameTime(value: boolean);
  137042. /**
  137043. * Gets the perf counter used for shader compilation time
  137044. */
  137045. get shaderCompilationTimeCounter(): PerfCounter;
  137046. /**
  137047. * Gets the shader compilation time capture status
  137048. */
  137049. get captureShaderCompilationTime(): boolean;
  137050. /**
  137051. * Enable or disable the shader compilation time capture
  137052. */
  137053. set captureShaderCompilationTime(value: boolean);
  137054. /**
  137055. * Instantiates a new engine instrumentation.
  137056. * This class can be used to get instrumentation data from a Babylon engine
  137057. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137058. * @param engine Defines the engine to instrument
  137059. */
  137060. constructor(
  137061. /**
  137062. * Define the instrumented engine.
  137063. */
  137064. engine: Engine);
  137065. /**
  137066. * Dispose and release associated resources.
  137067. */
  137068. dispose(): void;
  137069. }
  137070. }
  137071. declare module BABYLON {
  137072. /**
  137073. * This class can be used to get instrumentation data from a Babylon engine
  137074. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137075. */
  137076. export class SceneInstrumentation implements IDisposable {
  137077. /**
  137078. * Defines the scene to instrument
  137079. */
  137080. scene: Scene;
  137081. private _captureActiveMeshesEvaluationTime;
  137082. private _activeMeshesEvaluationTime;
  137083. private _captureRenderTargetsRenderTime;
  137084. private _renderTargetsRenderTime;
  137085. private _captureFrameTime;
  137086. private _frameTime;
  137087. private _captureRenderTime;
  137088. private _renderTime;
  137089. private _captureInterFrameTime;
  137090. private _interFrameTime;
  137091. private _captureParticlesRenderTime;
  137092. private _particlesRenderTime;
  137093. private _captureSpritesRenderTime;
  137094. private _spritesRenderTime;
  137095. private _capturePhysicsTime;
  137096. private _physicsTime;
  137097. private _captureAnimationsTime;
  137098. private _animationsTime;
  137099. private _captureCameraRenderTime;
  137100. private _cameraRenderTime;
  137101. private _onBeforeActiveMeshesEvaluationObserver;
  137102. private _onAfterActiveMeshesEvaluationObserver;
  137103. private _onBeforeRenderTargetsRenderObserver;
  137104. private _onAfterRenderTargetsRenderObserver;
  137105. private _onAfterRenderObserver;
  137106. private _onBeforeDrawPhaseObserver;
  137107. private _onAfterDrawPhaseObserver;
  137108. private _onBeforeAnimationsObserver;
  137109. private _onBeforeParticlesRenderingObserver;
  137110. private _onAfterParticlesRenderingObserver;
  137111. private _onBeforeSpritesRenderingObserver;
  137112. private _onAfterSpritesRenderingObserver;
  137113. private _onBeforePhysicsObserver;
  137114. private _onAfterPhysicsObserver;
  137115. private _onAfterAnimationsObserver;
  137116. private _onBeforeCameraRenderObserver;
  137117. private _onAfterCameraRenderObserver;
  137118. /**
  137119. * Gets the perf counter used for active meshes evaluation time
  137120. */
  137121. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  137122. /**
  137123. * Gets the active meshes evaluation time capture status
  137124. */
  137125. get captureActiveMeshesEvaluationTime(): boolean;
  137126. /**
  137127. * Enable or disable the active meshes evaluation time capture
  137128. */
  137129. set captureActiveMeshesEvaluationTime(value: boolean);
  137130. /**
  137131. * Gets the perf counter used for render targets render time
  137132. */
  137133. get renderTargetsRenderTimeCounter(): PerfCounter;
  137134. /**
  137135. * Gets the render targets render time capture status
  137136. */
  137137. get captureRenderTargetsRenderTime(): boolean;
  137138. /**
  137139. * Enable or disable the render targets render time capture
  137140. */
  137141. set captureRenderTargetsRenderTime(value: boolean);
  137142. /**
  137143. * Gets the perf counter used for particles render time
  137144. */
  137145. get particlesRenderTimeCounter(): PerfCounter;
  137146. /**
  137147. * Gets the particles render time capture status
  137148. */
  137149. get captureParticlesRenderTime(): boolean;
  137150. /**
  137151. * Enable or disable the particles render time capture
  137152. */
  137153. set captureParticlesRenderTime(value: boolean);
  137154. /**
  137155. * Gets the perf counter used for sprites render time
  137156. */
  137157. get spritesRenderTimeCounter(): PerfCounter;
  137158. /**
  137159. * Gets the sprites render time capture status
  137160. */
  137161. get captureSpritesRenderTime(): boolean;
  137162. /**
  137163. * Enable or disable the sprites render time capture
  137164. */
  137165. set captureSpritesRenderTime(value: boolean);
  137166. /**
  137167. * Gets the perf counter used for physics time
  137168. */
  137169. get physicsTimeCounter(): PerfCounter;
  137170. /**
  137171. * Gets the physics time capture status
  137172. */
  137173. get capturePhysicsTime(): boolean;
  137174. /**
  137175. * Enable or disable the physics time capture
  137176. */
  137177. set capturePhysicsTime(value: boolean);
  137178. /**
  137179. * Gets the perf counter used for animations time
  137180. */
  137181. get animationsTimeCounter(): PerfCounter;
  137182. /**
  137183. * Gets the animations time capture status
  137184. */
  137185. get captureAnimationsTime(): boolean;
  137186. /**
  137187. * Enable or disable the animations time capture
  137188. */
  137189. set captureAnimationsTime(value: boolean);
  137190. /**
  137191. * Gets the perf counter used for frame time capture
  137192. */
  137193. get frameTimeCounter(): PerfCounter;
  137194. /**
  137195. * Gets the frame time capture status
  137196. */
  137197. get captureFrameTime(): boolean;
  137198. /**
  137199. * Enable or disable the frame time capture
  137200. */
  137201. set captureFrameTime(value: boolean);
  137202. /**
  137203. * Gets the perf counter used for inter-frames time capture
  137204. */
  137205. get interFrameTimeCounter(): PerfCounter;
  137206. /**
  137207. * Gets the inter-frames time capture status
  137208. */
  137209. get captureInterFrameTime(): boolean;
  137210. /**
  137211. * Enable or disable the inter-frames time capture
  137212. */
  137213. set captureInterFrameTime(value: boolean);
  137214. /**
  137215. * Gets the perf counter used for render time capture
  137216. */
  137217. get renderTimeCounter(): PerfCounter;
  137218. /**
  137219. * Gets the render time capture status
  137220. */
  137221. get captureRenderTime(): boolean;
  137222. /**
  137223. * Enable or disable the render time capture
  137224. */
  137225. set captureRenderTime(value: boolean);
  137226. /**
  137227. * Gets the perf counter used for camera render time capture
  137228. */
  137229. get cameraRenderTimeCounter(): PerfCounter;
  137230. /**
  137231. * Gets the camera render time capture status
  137232. */
  137233. get captureCameraRenderTime(): boolean;
  137234. /**
  137235. * Enable or disable the camera render time capture
  137236. */
  137237. set captureCameraRenderTime(value: boolean);
  137238. /**
  137239. * Gets the perf counter used for draw calls
  137240. */
  137241. get drawCallsCounter(): PerfCounter;
  137242. /**
  137243. * Instantiates a new scene instrumentation.
  137244. * This class can be used to get instrumentation data from a Babylon engine
  137245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137246. * @param scene Defines the scene to instrument
  137247. */
  137248. constructor(
  137249. /**
  137250. * Defines the scene to instrument
  137251. */
  137252. scene: Scene);
  137253. /**
  137254. * Dispose and release associated resources.
  137255. */
  137256. dispose(): void;
  137257. }
  137258. }
  137259. declare module BABYLON {
  137260. /** @hidden */
  137261. export var glowMapGenerationPixelShader: {
  137262. name: string;
  137263. shader: string;
  137264. };
  137265. }
  137266. declare module BABYLON {
  137267. /** @hidden */
  137268. export var glowMapGenerationVertexShader: {
  137269. name: string;
  137270. shader: string;
  137271. };
  137272. }
  137273. declare module BABYLON {
  137274. /**
  137275. * Effect layer options. This helps customizing the behaviour
  137276. * of the effect layer.
  137277. */
  137278. export interface IEffectLayerOptions {
  137279. /**
  137280. * Multiplication factor apply to the canvas size to compute the render target size
  137281. * used to generated the objects (the smaller the faster).
  137282. */
  137283. mainTextureRatio: number;
  137284. /**
  137285. * Enforces a fixed size texture to ensure effect stability across devices.
  137286. */
  137287. mainTextureFixedSize?: number;
  137288. /**
  137289. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  137290. */
  137291. alphaBlendingMode: number;
  137292. /**
  137293. * The camera attached to the layer.
  137294. */
  137295. camera: Nullable<Camera>;
  137296. /**
  137297. * The rendering group to draw the layer in.
  137298. */
  137299. renderingGroupId: number;
  137300. }
  137301. /**
  137302. * The effect layer Helps adding post process effect blended with the main pass.
  137303. *
  137304. * This can be for instance use to generate glow or higlight effects on the scene.
  137305. *
  137306. * The effect layer class can not be used directly and is intented to inherited from to be
  137307. * customized per effects.
  137308. */
  137309. export abstract class EffectLayer {
  137310. private _vertexBuffers;
  137311. private _indexBuffer;
  137312. private _cachedDefines;
  137313. private _effectLayerMapGenerationEffect;
  137314. private _effectLayerOptions;
  137315. private _mergeEffect;
  137316. protected _scene: Scene;
  137317. protected _engine: Engine;
  137318. protected _maxSize: number;
  137319. protected _mainTextureDesiredSize: ISize;
  137320. protected _mainTexture: RenderTargetTexture;
  137321. protected _shouldRender: boolean;
  137322. protected _postProcesses: PostProcess[];
  137323. protected _textures: BaseTexture[];
  137324. protected _emissiveTextureAndColor: {
  137325. texture: Nullable<BaseTexture>;
  137326. color: Color4;
  137327. };
  137328. /**
  137329. * The name of the layer
  137330. */
  137331. name: string;
  137332. /**
  137333. * The clear color of the texture used to generate the glow map.
  137334. */
  137335. neutralColor: Color4;
  137336. /**
  137337. * Specifies whether the highlight layer is enabled or not.
  137338. */
  137339. isEnabled: boolean;
  137340. /**
  137341. * Gets the camera attached to the layer.
  137342. */
  137343. get camera(): Nullable<Camera>;
  137344. /**
  137345. * Gets the rendering group id the layer should render in.
  137346. */
  137347. get renderingGroupId(): number;
  137348. set renderingGroupId(renderingGroupId: number);
  137349. /**
  137350. * An event triggered when the effect layer has been disposed.
  137351. */
  137352. onDisposeObservable: Observable<EffectLayer>;
  137353. /**
  137354. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  137355. */
  137356. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  137357. /**
  137358. * An event triggered when the generated texture is being merged in the scene.
  137359. */
  137360. onBeforeComposeObservable: Observable<EffectLayer>;
  137361. /**
  137362. * An event triggered when the mesh is rendered into the effect render target.
  137363. */
  137364. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  137365. /**
  137366. * An event triggered after the mesh has been rendered into the effect render target.
  137367. */
  137368. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  137369. /**
  137370. * An event triggered when the generated texture has been merged in the scene.
  137371. */
  137372. onAfterComposeObservable: Observable<EffectLayer>;
  137373. /**
  137374. * An event triggered when the efffect layer changes its size.
  137375. */
  137376. onSizeChangedObservable: Observable<EffectLayer>;
  137377. /** @hidden */
  137378. static _SceneComponentInitialization: (scene: Scene) => void;
  137379. /**
  137380. * Instantiates a new effect Layer and references it in the scene.
  137381. * @param name The name of the layer
  137382. * @param scene The scene to use the layer in
  137383. */
  137384. constructor(
  137385. /** The Friendly of the effect in the scene */
  137386. name: string, scene: Scene);
  137387. /**
  137388. * Get the effect name of the layer.
  137389. * @return The effect name
  137390. */
  137391. abstract getEffectName(): string;
  137392. /**
  137393. * Checks for the readiness of the element composing the layer.
  137394. * @param subMesh the mesh to check for
  137395. * @param useInstances specify whether or not to use instances to render the mesh
  137396. * @return true if ready otherwise, false
  137397. */
  137398. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137399. /**
  137400. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137401. * @returns true if the effect requires stencil during the main canvas render pass.
  137402. */
  137403. abstract needStencil(): boolean;
  137404. /**
  137405. * Create the merge effect. This is the shader use to blit the information back
  137406. * to the main canvas at the end of the scene rendering.
  137407. * @returns The effect containing the shader used to merge the effect on the main canvas
  137408. */
  137409. protected abstract _createMergeEffect(): Effect;
  137410. /**
  137411. * Creates the render target textures and post processes used in the effect layer.
  137412. */
  137413. protected abstract _createTextureAndPostProcesses(): void;
  137414. /**
  137415. * Implementation specific of rendering the generating effect on the main canvas.
  137416. * @param effect The effect used to render through
  137417. */
  137418. protected abstract _internalRender(effect: Effect): void;
  137419. /**
  137420. * Sets the required values for both the emissive texture and and the main color.
  137421. */
  137422. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137423. /**
  137424. * Free any resources and references associated to a mesh.
  137425. * Internal use
  137426. * @param mesh The mesh to free.
  137427. */
  137428. abstract _disposeMesh(mesh: Mesh): void;
  137429. /**
  137430. * Serializes this layer (Glow or Highlight for example)
  137431. * @returns a serialized layer object
  137432. */
  137433. abstract serialize?(): any;
  137434. /**
  137435. * Initializes the effect layer with the required options.
  137436. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  137437. */
  137438. protected _init(options: Partial<IEffectLayerOptions>): void;
  137439. /**
  137440. * Generates the index buffer of the full screen quad blending to the main canvas.
  137441. */
  137442. private _generateIndexBuffer;
  137443. /**
  137444. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  137445. */
  137446. private _generateVertexBuffer;
  137447. /**
  137448. * Sets the main texture desired size which is the closest power of two
  137449. * of the engine canvas size.
  137450. */
  137451. private _setMainTextureSize;
  137452. /**
  137453. * Creates the main texture for the effect layer.
  137454. */
  137455. protected _createMainTexture(): void;
  137456. /**
  137457. * Adds specific effects defines.
  137458. * @param defines The defines to add specifics to.
  137459. */
  137460. protected _addCustomEffectDefines(defines: string[]): void;
  137461. /**
  137462. * Checks for the readiness of the element composing the layer.
  137463. * @param subMesh the mesh to check for
  137464. * @param useInstances specify whether or not to use instances to render the mesh
  137465. * @param emissiveTexture the associated emissive texture used to generate the glow
  137466. * @return true if ready otherwise, false
  137467. */
  137468. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  137469. /**
  137470. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  137471. */
  137472. render(): void;
  137473. /**
  137474. * Determine if a given mesh will be used in the current effect.
  137475. * @param mesh mesh to test
  137476. * @returns true if the mesh will be used
  137477. */
  137478. hasMesh(mesh: AbstractMesh): boolean;
  137479. /**
  137480. * Returns true if the layer contains information to display, otherwise false.
  137481. * @returns true if the glow layer should be rendered
  137482. */
  137483. shouldRender(): boolean;
  137484. /**
  137485. * Returns true if the mesh should render, otherwise false.
  137486. * @param mesh The mesh to render
  137487. * @returns true if it should render otherwise false
  137488. */
  137489. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  137490. /**
  137491. * Returns true if the mesh can be rendered, otherwise false.
  137492. * @param mesh The mesh to render
  137493. * @param material The material used on the mesh
  137494. * @returns true if it can be rendered otherwise false
  137495. */
  137496. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137497. /**
  137498. * Returns true if the mesh should render, otherwise false.
  137499. * @param mesh The mesh to render
  137500. * @returns true if it should render otherwise false
  137501. */
  137502. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  137503. /**
  137504. * Renders the submesh passed in parameter to the generation map.
  137505. */
  137506. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  137507. /**
  137508. * Defines whether the current material of the mesh should be use to render the effect.
  137509. * @param mesh defines the current mesh to render
  137510. */
  137511. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137512. /**
  137513. * Rebuild the required buffers.
  137514. * @hidden Internal use only.
  137515. */
  137516. _rebuild(): void;
  137517. /**
  137518. * Dispose only the render target textures and post process.
  137519. */
  137520. private _disposeTextureAndPostProcesses;
  137521. /**
  137522. * Dispose the highlight layer and free resources.
  137523. */
  137524. dispose(): void;
  137525. /**
  137526. * Gets the class name of the effect layer
  137527. * @returns the string with the class name of the effect layer
  137528. */
  137529. getClassName(): string;
  137530. /**
  137531. * Creates an effect layer from parsed effect layer data
  137532. * @param parsedEffectLayer defines effect layer data
  137533. * @param scene defines the current scene
  137534. * @param rootUrl defines the root URL containing the effect layer information
  137535. * @returns a parsed effect Layer
  137536. */
  137537. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  137538. }
  137539. }
  137540. declare module BABYLON {
  137541. interface AbstractScene {
  137542. /**
  137543. * The list of effect layers (highlights/glow) added to the scene
  137544. * @see https://doc.babylonjs.com/how_to/highlight_layer
  137545. * @see https://doc.babylonjs.com/how_to/glow_layer
  137546. */
  137547. effectLayers: Array<EffectLayer>;
  137548. /**
  137549. * Removes the given effect layer from this scene.
  137550. * @param toRemove defines the effect layer to remove
  137551. * @returns the index of the removed effect layer
  137552. */
  137553. removeEffectLayer(toRemove: EffectLayer): number;
  137554. /**
  137555. * Adds the given effect layer to this scene
  137556. * @param newEffectLayer defines the effect layer to add
  137557. */
  137558. addEffectLayer(newEffectLayer: EffectLayer): void;
  137559. }
  137560. /**
  137561. * Defines the layer scene component responsible to manage any effect layers
  137562. * in a given scene.
  137563. */
  137564. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  137565. /**
  137566. * The component name helpfull to identify the component in the list of scene components.
  137567. */
  137568. readonly name: string;
  137569. /**
  137570. * The scene the component belongs to.
  137571. */
  137572. scene: Scene;
  137573. private _engine;
  137574. private _renderEffects;
  137575. private _needStencil;
  137576. private _previousStencilState;
  137577. /**
  137578. * Creates a new instance of the component for the given scene
  137579. * @param scene Defines the scene to register the component in
  137580. */
  137581. constructor(scene: Scene);
  137582. /**
  137583. * Registers the component in a given scene
  137584. */
  137585. register(): void;
  137586. /**
  137587. * Rebuilds the elements related to this component in case of
  137588. * context lost for instance.
  137589. */
  137590. rebuild(): void;
  137591. /**
  137592. * Serializes the component data to the specified json object
  137593. * @param serializationObject The object to serialize to
  137594. */
  137595. serialize(serializationObject: any): void;
  137596. /**
  137597. * Adds all the elements from the container to the scene
  137598. * @param container the container holding the elements
  137599. */
  137600. addFromContainer(container: AbstractScene): void;
  137601. /**
  137602. * Removes all the elements in the container from the scene
  137603. * @param container contains the elements to remove
  137604. * @param dispose if the removed element should be disposed (default: false)
  137605. */
  137606. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137607. /**
  137608. * Disposes the component and the associated ressources.
  137609. */
  137610. dispose(): void;
  137611. private _isReadyForMesh;
  137612. private _renderMainTexture;
  137613. private _setStencil;
  137614. private _setStencilBack;
  137615. private _draw;
  137616. private _drawCamera;
  137617. private _drawRenderingGroup;
  137618. }
  137619. }
  137620. declare module BABYLON {
  137621. /** @hidden */
  137622. export var glowMapMergePixelShader: {
  137623. name: string;
  137624. shader: string;
  137625. };
  137626. }
  137627. declare module BABYLON {
  137628. /** @hidden */
  137629. export var glowMapMergeVertexShader: {
  137630. name: string;
  137631. shader: string;
  137632. };
  137633. }
  137634. declare module BABYLON {
  137635. interface AbstractScene {
  137636. /**
  137637. * Return a the first highlight layer of the scene with a given name.
  137638. * @param name The name of the highlight layer to look for.
  137639. * @return The highlight layer if found otherwise null.
  137640. */
  137641. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  137642. }
  137643. /**
  137644. * Glow layer options. This helps customizing the behaviour
  137645. * of the glow layer.
  137646. */
  137647. export interface IGlowLayerOptions {
  137648. /**
  137649. * Multiplication factor apply to the canvas size to compute the render target size
  137650. * used to generated the glowing objects (the smaller the faster).
  137651. */
  137652. mainTextureRatio: number;
  137653. /**
  137654. * Enforces a fixed size texture to ensure resize independant blur.
  137655. */
  137656. mainTextureFixedSize?: number;
  137657. /**
  137658. * How big is the kernel of the blur texture.
  137659. */
  137660. blurKernelSize: number;
  137661. /**
  137662. * The camera attached to the layer.
  137663. */
  137664. camera: Nullable<Camera>;
  137665. /**
  137666. * Enable MSAA by chosing the number of samples.
  137667. */
  137668. mainTextureSamples?: number;
  137669. /**
  137670. * The rendering group to draw the layer in.
  137671. */
  137672. renderingGroupId: number;
  137673. }
  137674. /**
  137675. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  137676. *
  137677. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137678. *
  137679. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137680. */
  137681. export class GlowLayer extends EffectLayer {
  137682. /**
  137683. * Effect Name of the layer.
  137684. */
  137685. static readonly EffectName: string;
  137686. /**
  137687. * The default blur kernel size used for the glow.
  137688. */
  137689. static DefaultBlurKernelSize: number;
  137690. /**
  137691. * The default texture size ratio used for the glow.
  137692. */
  137693. static DefaultTextureRatio: number;
  137694. /**
  137695. * Sets the kernel size of the blur.
  137696. */
  137697. set blurKernelSize(value: number);
  137698. /**
  137699. * Gets the kernel size of the blur.
  137700. */
  137701. get blurKernelSize(): number;
  137702. /**
  137703. * Sets the glow intensity.
  137704. */
  137705. set intensity(value: number);
  137706. /**
  137707. * Gets the glow intensity.
  137708. */
  137709. get intensity(): number;
  137710. private _options;
  137711. private _intensity;
  137712. private _horizontalBlurPostprocess1;
  137713. private _verticalBlurPostprocess1;
  137714. private _horizontalBlurPostprocess2;
  137715. private _verticalBlurPostprocess2;
  137716. private _blurTexture1;
  137717. private _blurTexture2;
  137718. private _postProcesses1;
  137719. private _postProcesses2;
  137720. private _includedOnlyMeshes;
  137721. private _excludedMeshes;
  137722. private _meshesUsingTheirOwnMaterials;
  137723. /**
  137724. * Callback used to let the user override the color selection on a per mesh basis
  137725. */
  137726. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137727. /**
  137728. * Callback used to let the user override the texture selection on a per mesh basis
  137729. */
  137730. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137731. /**
  137732. * Instantiates a new glow Layer and references it to the scene.
  137733. * @param name The name of the layer
  137734. * @param scene The scene to use the layer in
  137735. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137736. */
  137737. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137738. /**
  137739. * Get the effect name of the layer.
  137740. * @return The effect name
  137741. */
  137742. getEffectName(): string;
  137743. /**
  137744. * Create the merge effect. This is the shader use to blit the information back
  137745. * to the main canvas at the end of the scene rendering.
  137746. */
  137747. protected _createMergeEffect(): Effect;
  137748. /**
  137749. * Creates the render target textures and post processes used in the glow layer.
  137750. */
  137751. protected _createTextureAndPostProcesses(): void;
  137752. /**
  137753. * Checks for the readiness of the element composing the layer.
  137754. * @param subMesh the mesh to check for
  137755. * @param useInstances specify wether or not to use instances to render the mesh
  137756. * @param emissiveTexture the associated emissive texture used to generate the glow
  137757. * @return true if ready otherwise, false
  137758. */
  137759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137760. /**
  137761. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137762. */
  137763. needStencil(): boolean;
  137764. /**
  137765. * Returns true if the mesh can be rendered, otherwise false.
  137766. * @param mesh The mesh to render
  137767. * @param material The material used on the mesh
  137768. * @returns true if it can be rendered otherwise false
  137769. */
  137770. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137771. /**
  137772. * Implementation specific of rendering the generating effect on the main canvas.
  137773. * @param effect The effect used to render through
  137774. */
  137775. protected _internalRender(effect: Effect): void;
  137776. /**
  137777. * Sets the required values for both the emissive texture and and the main color.
  137778. */
  137779. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137780. /**
  137781. * Returns true if the mesh should render, otherwise false.
  137782. * @param mesh The mesh to render
  137783. * @returns true if it should render otherwise false
  137784. */
  137785. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137786. /**
  137787. * Adds specific effects defines.
  137788. * @param defines The defines to add specifics to.
  137789. */
  137790. protected _addCustomEffectDefines(defines: string[]): void;
  137791. /**
  137792. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137793. * @param mesh The mesh to exclude from the glow layer
  137794. */
  137795. addExcludedMesh(mesh: Mesh): void;
  137796. /**
  137797. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137798. * @param mesh The mesh to remove
  137799. */
  137800. removeExcludedMesh(mesh: Mesh): void;
  137801. /**
  137802. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137803. * @param mesh The mesh to include in the glow layer
  137804. */
  137805. addIncludedOnlyMesh(mesh: Mesh): void;
  137806. /**
  137807. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137808. * @param mesh The mesh to remove
  137809. */
  137810. removeIncludedOnlyMesh(mesh: Mesh): void;
  137811. /**
  137812. * Determine if a given mesh will be used in the glow layer
  137813. * @param mesh The mesh to test
  137814. * @returns true if the mesh will be highlighted by the current glow layer
  137815. */
  137816. hasMesh(mesh: AbstractMesh): boolean;
  137817. /**
  137818. * Defines whether the current material of the mesh should be use to render the effect.
  137819. * @param mesh defines the current mesh to render
  137820. */
  137821. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137822. /**
  137823. * Add a mesh to be rendered through its own material and not with emissive only.
  137824. * @param mesh The mesh for which we need to use its material
  137825. */
  137826. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137827. /**
  137828. * Remove a mesh from being rendered through its own material and not with emissive only.
  137829. * @param mesh The mesh for which we need to not use its material
  137830. */
  137831. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137832. /**
  137833. * Free any resources and references associated to a mesh.
  137834. * Internal use
  137835. * @param mesh The mesh to free.
  137836. * @hidden
  137837. */
  137838. _disposeMesh(mesh: Mesh): void;
  137839. /**
  137840. * Gets the class name of the effect layer
  137841. * @returns the string with the class name of the effect layer
  137842. */
  137843. getClassName(): string;
  137844. /**
  137845. * Serializes this glow layer
  137846. * @returns a serialized glow layer object
  137847. */
  137848. serialize(): any;
  137849. /**
  137850. * Creates a Glow Layer from parsed glow layer data
  137851. * @param parsedGlowLayer defines glow layer data
  137852. * @param scene defines the current scene
  137853. * @param rootUrl defines the root URL containing the glow layer information
  137854. * @returns a parsed Glow Layer
  137855. */
  137856. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137857. }
  137858. }
  137859. declare module BABYLON {
  137860. /** @hidden */
  137861. export var glowBlurPostProcessPixelShader: {
  137862. name: string;
  137863. shader: string;
  137864. };
  137865. }
  137866. declare module BABYLON {
  137867. interface AbstractScene {
  137868. /**
  137869. * Return a the first highlight layer of the scene with a given name.
  137870. * @param name The name of the highlight layer to look for.
  137871. * @return The highlight layer if found otherwise null.
  137872. */
  137873. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137874. }
  137875. /**
  137876. * Highlight layer options. This helps customizing the behaviour
  137877. * of the highlight layer.
  137878. */
  137879. export interface IHighlightLayerOptions {
  137880. /**
  137881. * Multiplication factor apply to the canvas size to compute the render target size
  137882. * used to generated the glowing objects (the smaller the faster).
  137883. */
  137884. mainTextureRatio: number;
  137885. /**
  137886. * Enforces a fixed size texture to ensure resize independant blur.
  137887. */
  137888. mainTextureFixedSize?: number;
  137889. /**
  137890. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137891. * of the picture to blur (the smaller the faster).
  137892. */
  137893. blurTextureSizeRatio: number;
  137894. /**
  137895. * How big in texel of the blur texture is the vertical blur.
  137896. */
  137897. blurVerticalSize: number;
  137898. /**
  137899. * How big in texel of the blur texture is the horizontal blur.
  137900. */
  137901. blurHorizontalSize: number;
  137902. /**
  137903. * Alpha blending mode used to apply the blur. Default is combine.
  137904. */
  137905. alphaBlendingMode: number;
  137906. /**
  137907. * The camera attached to the layer.
  137908. */
  137909. camera: Nullable<Camera>;
  137910. /**
  137911. * Should we display highlight as a solid stroke?
  137912. */
  137913. isStroke?: boolean;
  137914. /**
  137915. * The rendering group to draw the layer in.
  137916. */
  137917. renderingGroupId: number;
  137918. }
  137919. /**
  137920. * The highlight layer Helps adding a glow effect around a mesh.
  137921. *
  137922. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137923. * glowy meshes to your scene.
  137924. *
  137925. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137926. */
  137927. export class HighlightLayer extends EffectLayer {
  137928. name: string;
  137929. /**
  137930. * Effect Name of the highlight layer.
  137931. */
  137932. static readonly EffectName: string;
  137933. /**
  137934. * The neutral color used during the preparation of the glow effect.
  137935. * This is black by default as the blend operation is a blend operation.
  137936. */
  137937. static NeutralColor: Color4;
  137938. /**
  137939. * Stencil value used for glowing meshes.
  137940. */
  137941. static GlowingMeshStencilReference: number;
  137942. /**
  137943. * Stencil value used for the other meshes in the scene.
  137944. */
  137945. static NormalMeshStencilReference: number;
  137946. /**
  137947. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137948. */
  137949. innerGlow: boolean;
  137950. /**
  137951. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137952. */
  137953. outerGlow: boolean;
  137954. /**
  137955. * Specifies the horizontal size of the blur.
  137956. */
  137957. set blurHorizontalSize(value: number);
  137958. /**
  137959. * Specifies the vertical size of the blur.
  137960. */
  137961. set blurVerticalSize(value: number);
  137962. /**
  137963. * Gets the horizontal size of the blur.
  137964. */
  137965. get blurHorizontalSize(): number;
  137966. /**
  137967. * Gets the vertical size of the blur.
  137968. */
  137969. get blurVerticalSize(): number;
  137970. /**
  137971. * An event triggered when the highlight layer is being blurred.
  137972. */
  137973. onBeforeBlurObservable: Observable<HighlightLayer>;
  137974. /**
  137975. * An event triggered when the highlight layer has been blurred.
  137976. */
  137977. onAfterBlurObservable: Observable<HighlightLayer>;
  137978. private _instanceGlowingMeshStencilReference;
  137979. private _options;
  137980. private _downSamplePostprocess;
  137981. private _horizontalBlurPostprocess;
  137982. private _verticalBlurPostprocess;
  137983. private _blurTexture;
  137984. private _meshes;
  137985. private _excludedMeshes;
  137986. /**
  137987. * Instantiates a new highlight Layer and references it to the scene..
  137988. * @param name The name of the layer
  137989. * @param scene The scene to use the layer in
  137990. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137991. */
  137992. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137993. /**
  137994. * Get the effect name of the layer.
  137995. * @return The effect name
  137996. */
  137997. getEffectName(): string;
  137998. /**
  137999. * Create the merge effect. This is the shader use to blit the information back
  138000. * to the main canvas at the end of the scene rendering.
  138001. */
  138002. protected _createMergeEffect(): Effect;
  138003. /**
  138004. * Creates the render target textures and post processes used in the highlight layer.
  138005. */
  138006. protected _createTextureAndPostProcesses(): void;
  138007. /**
  138008. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  138009. */
  138010. needStencil(): boolean;
  138011. /**
  138012. * Checks for the readiness of the element composing the layer.
  138013. * @param subMesh the mesh to check for
  138014. * @param useInstances specify wether or not to use instances to render the mesh
  138015. * @param emissiveTexture the associated emissive texture used to generate the glow
  138016. * @return true if ready otherwise, false
  138017. */
  138018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138019. /**
  138020. * Implementation specific of rendering the generating effect on the main canvas.
  138021. * @param effect The effect used to render through
  138022. */
  138023. protected _internalRender(effect: Effect): void;
  138024. /**
  138025. * Returns true if the layer contains information to display, otherwise false.
  138026. */
  138027. shouldRender(): boolean;
  138028. /**
  138029. * Returns true if the mesh should render, otherwise false.
  138030. * @param mesh The mesh to render
  138031. * @returns true if it should render otherwise false
  138032. */
  138033. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138034. /**
  138035. * Returns true if the mesh can be rendered, otherwise false.
  138036. * @param mesh The mesh to render
  138037. * @param material The material used on the mesh
  138038. * @returns true if it can be rendered otherwise false
  138039. */
  138040. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138041. /**
  138042. * Adds specific effects defines.
  138043. * @param defines The defines to add specifics to.
  138044. */
  138045. protected _addCustomEffectDefines(defines: string[]): void;
  138046. /**
  138047. * Sets the required values for both the emissive texture and and the main color.
  138048. */
  138049. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138050. /**
  138051. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  138052. * @param mesh The mesh to exclude from the highlight layer
  138053. */
  138054. addExcludedMesh(mesh: Mesh): void;
  138055. /**
  138056. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  138057. * @param mesh The mesh to highlight
  138058. */
  138059. removeExcludedMesh(mesh: Mesh): void;
  138060. /**
  138061. * Determine if a given mesh will be highlighted by the current HighlightLayer
  138062. * @param mesh mesh to test
  138063. * @returns true if the mesh will be highlighted by the current HighlightLayer
  138064. */
  138065. hasMesh(mesh: AbstractMesh): boolean;
  138066. /**
  138067. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  138068. * @param mesh The mesh to highlight
  138069. * @param color The color of the highlight
  138070. * @param glowEmissiveOnly Extract the glow from the emissive texture
  138071. */
  138072. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  138073. /**
  138074. * Remove a mesh from the highlight layer in order to make it stop glowing.
  138075. * @param mesh The mesh to highlight
  138076. */
  138077. removeMesh(mesh: Mesh): void;
  138078. /**
  138079. * Remove all the meshes currently referenced in the highlight layer
  138080. */
  138081. removeAllMeshes(): void;
  138082. /**
  138083. * Force the stencil to the normal expected value for none glowing parts
  138084. */
  138085. private _defaultStencilReference;
  138086. /**
  138087. * Free any resources and references associated to a mesh.
  138088. * Internal use
  138089. * @param mesh The mesh to free.
  138090. * @hidden
  138091. */
  138092. _disposeMesh(mesh: Mesh): void;
  138093. /**
  138094. * Dispose the highlight layer and free resources.
  138095. */
  138096. dispose(): void;
  138097. /**
  138098. * Gets the class name of the effect layer
  138099. * @returns the string with the class name of the effect layer
  138100. */
  138101. getClassName(): string;
  138102. /**
  138103. * Serializes this Highlight layer
  138104. * @returns a serialized Highlight layer object
  138105. */
  138106. serialize(): any;
  138107. /**
  138108. * Creates a Highlight layer from parsed Highlight layer data
  138109. * @param parsedHightlightLayer defines the Highlight layer data
  138110. * @param scene defines the current scene
  138111. * @param rootUrl defines the root URL containing the Highlight layer information
  138112. * @returns a parsed Highlight layer
  138113. */
  138114. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  138115. }
  138116. }
  138117. declare module BABYLON {
  138118. interface AbstractScene {
  138119. /**
  138120. * The list of layers (background and foreground) of the scene
  138121. */
  138122. layers: Array<Layer>;
  138123. }
  138124. /**
  138125. * Defines the layer scene component responsible to manage any layers
  138126. * in a given scene.
  138127. */
  138128. export class LayerSceneComponent implements ISceneComponent {
  138129. /**
  138130. * The component name helpfull to identify the component in the list of scene components.
  138131. */
  138132. readonly name: string;
  138133. /**
  138134. * The scene the component belongs to.
  138135. */
  138136. scene: Scene;
  138137. private _engine;
  138138. /**
  138139. * Creates a new instance of the component for the given scene
  138140. * @param scene Defines the scene to register the component in
  138141. */
  138142. constructor(scene: Scene);
  138143. /**
  138144. * Registers the component in a given scene
  138145. */
  138146. register(): void;
  138147. /**
  138148. * Rebuilds the elements related to this component in case of
  138149. * context lost for instance.
  138150. */
  138151. rebuild(): void;
  138152. /**
  138153. * Disposes the component and the associated ressources.
  138154. */
  138155. dispose(): void;
  138156. private _draw;
  138157. private _drawCameraPredicate;
  138158. private _drawCameraBackground;
  138159. private _drawCameraForeground;
  138160. private _drawRenderTargetPredicate;
  138161. private _drawRenderTargetBackground;
  138162. private _drawRenderTargetForeground;
  138163. /**
  138164. * Adds all the elements from the container to the scene
  138165. * @param container the container holding the elements
  138166. */
  138167. addFromContainer(container: AbstractScene): void;
  138168. /**
  138169. * Removes all the elements in the container from the scene
  138170. * @param container contains the elements to remove
  138171. * @param dispose if the removed element should be disposed (default: false)
  138172. */
  138173. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138174. }
  138175. }
  138176. declare module BABYLON {
  138177. /** @hidden */
  138178. export var layerPixelShader: {
  138179. name: string;
  138180. shader: string;
  138181. };
  138182. }
  138183. declare module BABYLON {
  138184. /** @hidden */
  138185. export var layerVertexShader: {
  138186. name: string;
  138187. shader: string;
  138188. };
  138189. }
  138190. declare module BABYLON {
  138191. /**
  138192. * This represents a full screen 2d layer.
  138193. * This can be useful to display a picture in the background of your scene for instance.
  138194. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138195. */
  138196. export class Layer {
  138197. /**
  138198. * Define the name of the layer.
  138199. */
  138200. name: string;
  138201. /**
  138202. * Define the texture the layer should display.
  138203. */
  138204. texture: Nullable<Texture>;
  138205. /**
  138206. * Is the layer in background or foreground.
  138207. */
  138208. isBackground: boolean;
  138209. /**
  138210. * Define the color of the layer (instead of texture).
  138211. */
  138212. color: Color4;
  138213. /**
  138214. * Define the scale of the layer in order to zoom in out of the texture.
  138215. */
  138216. scale: Vector2;
  138217. /**
  138218. * Define an offset for the layer in order to shift the texture.
  138219. */
  138220. offset: Vector2;
  138221. /**
  138222. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  138223. */
  138224. alphaBlendingMode: number;
  138225. /**
  138226. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  138227. * Alpha test will not mix with the background color in case of transparency.
  138228. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  138229. */
  138230. alphaTest: boolean;
  138231. /**
  138232. * Define a mask to restrict the layer to only some of the scene cameras.
  138233. */
  138234. layerMask: number;
  138235. /**
  138236. * Define the list of render target the layer is visible into.
  138237. */
  138238. renderTargetTextures: RenderTargetTexture[];
  138239. /**
  138240. * Define if the layer is only used in renderTarget or if it also
  138241. * renders in the main frame buffer of the canvas.
  138242. */
  138243. renderOnlyInRenderTargetTextures: boolean;
  138244. private _scene;
  138245. private _vertexBuffers;
  138246. private _indexBuffer;
  138247. private _effect;
  138248. private _previousDefines;
  138249. /**
  138250. * An event triggered when the layer is disposed.
  138251. */
  138252. onDisposeObservable: Observable<Layer>;
  138253. private _onDisposeObserver;
  138254. /**
  138255. * Back compatibility with callback before the onDisposeObservable existed.
  138256. * The set callback will be triggered when the layer has been disposed.
  138257. */
  138258. set onDispose(callback: () => void);
  138259. /**
  138260. * An event triggered before rendering the scene
  138261. */
  138262. onBeforeRenderObservable: Observable<Layer>;
  138263. private _onBeforeRenderObserver;
  138264. /**
  138265. * Back compatibility with callback before the onBeforeRenderObservable existed.
  138266. * The set callback will be triggered just before rendering the layer.
  138267. */
  138268. set onBeforeRender(callback: () => void);
  138269. /**
  138270. * An event triggered after rendering the scene
  138271. */
  138272. onAfterRenderObservable: Observable<Layer>;
  138273. private _onAfterRenderObserver;
  138274. /**
  138275. * Back compatibility with callback before the onAfterRenderObservable existed.
  138276. * The set callback will be triggered just after rendering the layer.
  138277. */
  138278. set onAfterRender(callback: () => void);
  138279. /**
  138280. * Instantiates a new layer.
  138281. * This represents a full screen 2d layer.
  138282. * This can be useful to display a picture in the background of your scene for instance.
  138283. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138284. * @param name Define the name of the layer in the scene
  138285. * @param imgUrl Define the url of the texture to display in the layer
  138286. * @param scene Define the scene the layer belongs to
  138287. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  138288. * @param color Defines a color for the layer
  138289. */
  138290. constructor(
  138291. /**
  138292. * Define the name of the layer.
  138293. */
  138294. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  138295. private _createIndexBuffer;
  138296. /** @hidden */
  138297. _rebuild(): void;
  138298. /**
  138299. * Renders the layer in the scene.
  138300. */
  138301. render(): void;
  138302. /**
  138303. * Disposes and releases the associated ressources.
  138304. */
  138305. dispose(): void;
  138306. }
  138307. }
  138308. declare module BABYLON {
  138309. /** @hidden */
  138310. export var lensFlarePixelShader: {
  138311. name: string;
  138312. shader: string;
  138313. };
  138314. }
  138315. declare module BABYLON {
  138316. /** @hidden */
  138317. export var lensFlareVertexShader: {
  138318. name: string;
  138319. shader: string;
  138320. };
  138321. }
  138322. declare module BABYLON {
  138323. /**
  138324. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138325. * It is usually composed of several `lensFlare`.
  138326. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138327. */
  138328. export class LensFlareSystem {
  138329. /**
  138330. * Define the name of the lens flare system
  138331. */
  138332. name: string;
  138333. /**
  138334. * List of lens flares used in this system.
  138335. */
  138336. lensFlares: LensFlare[];
  138337. /**
  138338. * Define a limit from the border the lens flare can be visible.
  138339. */
  138340. borderLimit: number;
  138341. /**
  138342. * Define a viewport border we do not want to see the lens flare in.
  138343. */
  138344. viewportBorder: number;
  138345. /**
  138346. * Define a predicate which could limit the list of meshes able to occlude the effect.
  138347. */
  138348. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  138349. /**
  138350. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  138351. */
  138352. layerMask: number;
  138353. /**
  138354. * Define the id of the lens flare system in the scene.
  138355. * (equal to name by default)
  138356. */
  138357. id: string;
  138358. private _scene;
  138359. private _emitter;
  138360. private _vertexBuffers;
  138361. private _indexBuffer;
  138362. private _effect;
  138363. private _positionX;
  138364. private _positionY;
  138365. private _isEnabled;
  138366. /** @hidden */
  138367. static _SceneComponentInitialization: (scene: Scene) => void;
  138368. /**
  138369. * Instantiates a lens flare system.
  138370. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138371. * It is usually composed of several `lensFlare`.
  138372. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138373. * @param name Define the name of the lens flare system in the scene
  138374. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  138375. * @param scene Define the scene the lens flare system belongs to
  138376. */
  138377. constructor(
  138378. /**
  138379. * Define the name of the lens flare system
  138380. */
  138381. name: string, emitter: any, scene: Scene);
  138382. /**
  138383. * Define if the lens flare system is enabled.
  138384. */
  138385. get isEnabled(): boolean;
  138386. set isEnabled(value: boolean);
  138387. /**
  138388. * Get the scene the effects belongs to.
  138389. * @returns the scene holding the lens flare system
  138390. */
  138391. getScene(): Scene;
  138392. /**
  138393. * Get the emitter of the lens flare system.
  138394. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138395. * @returns the emitter of the lens flare system
  138396. */
  138397. getEmitter(): any;
  138398. /**
  138399. * Set the emitter of the lens flare system.
  138400. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138401. * @param newEmitter Define the new emitter of the system
  138402. */
  138403. setEmitter(newEmitter: any): void;
  138404. /**
  138405. * Get the lens flare system emitter position.
  138406. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  138407. * @returns the position
  138408. */
  138409. getEmitterPosition(): Vector3;
  138410. /**
  138411. * @hidden
  138412. */
  138413. computeEffectivePosition(globalViewport: Viewport): boolean;
  138414. /** @hidden */
  138415. _isVisible(): boolean;
  138416. /**
  138417. * @hidden
  138418. */
  138419. render(): boolean;
  138420. /**
  138421. * Dispose and release the lens flare with its associated resources.
  138422. */
  138423. dispose(): void;
  138424. /**
  138425. * Parse a lens flare system from a JSON repressentation
  138426. * @param parsedLensFlareSystem Define the JSON to parse
  138427. * @param scene Define the scene the parsed system should be instantiated in
  138428. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  138429. * @returns the parsed system
  138430. */
  138431. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  138432. /**
  138433. * Serialize the current Lens Flare System into a JSON representation.
  138434. * @returns the serialized JSON
  138435. */
  138436. serialize(): any;
  138437. }
  138438. }
  138439. declare module BABYLON {
  138440. /**
  138441. * This represents one of the lens effect in a `lensFlareSystem`.
  138442. * It controls one of the indiviual texture used in the effect.
  138443. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138444. */
  138445. export class LensFlare {
  138446. /**
  138447. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138448. */
  138449. size: number;
  138450. /**
  138451. * 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.
  138452. */
  138453. position: number;
  138454. /**
  138455. * Define the lens color.
  138456. */
  138457. color: Color3;
  138458. /**
  138459. * Define the lens texture.
  138460. */
  138461. texture: Nullable<Texture>;
  138462. /**
  138463. * Define the alpha mode to render this particular lens.
  138464. */
  138465. alphaMode: number;
  138466. private _system;
  138467. /**
  138468. * Creates a new Lens Flare.
  138469. * This represents one of the lens effect in a `lensFlareSystem`.
  138470. * It controls one of the indiviual texture used in the effect.
  138471. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138472. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  138473. * @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.
  138474. * @param color Define the lens color
  138475. * @param imgUrl Define the lens texture url
  138476. * @param system Define the `lensFlareSystem` this flare is part of
  138477. * @returns The newly created Lens Flare
  138478. */
  138479. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  138480. /**
  138481. * Instantiates a new Lens Flare.
  138482. * This represents one of the lens effect in a `lensFlareSystem`.
  138483. * It controls one of the indiviual texture used in the effect.
  138484. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138485. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  138486. * @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.
  138487. * @param color Define the lens color
  138488. * @param imgUrl Define the lens texture url
  138489. * @param system Define the `lensFlareSystem` this flare is part of
  138490. */
  138491. constructor(
  138492. /**
  138493. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138494. */
  138495. size: number,
  138496. /**
  138497. * 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.
  138498. */
  138499. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  138500. /**
  138501. * Dispose and release the lens flare with its associated resources.
  138502. */
  138503. dispose(): void;
  138504. }
  138505. }
  138506. declare module BABYLON {
  138507. interface AbstractScene {
  138508. /**
  138509. * The list of lens flare system added to the scene
  138510. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138511. */
  138512. lensFlareSystems: Array<LensFlareSystem>;
  138513. /**
  138514. * Removes the given lens flare system from this scene.
  138515. * @param toRemove The lens flare system to remove
  138516. * @returns The index of the removed lens flare system
  138517. */
  138518. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  138519. /**
  138520. * Adds the given lens flare system to this scene
  138521. * @param newLensFlareSystem The lens flare system to add
  138522. */
  138523. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  138524. /**
  138525. * Gets a lens flare system using its name
  138526. * @param name defines the name to look for
  138527. * @returns the lens flare system or null if not found
  138528. */
  138529. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  138530. /**
  138531. * Gets a lens flare system using its id
  138532. * @param id defines the id to look for
  138533. * @returns the lens flare system or null if not found
  138534. */
  138535. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  138536. }
  138537. /**
  138538. * Defines the lens flare scene component responsible to manage any lens flares
  138539. * in a given scene.
  138540. */
  138541. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  138542. /**
  138543. * The component name helpfull to identify the component in the list of scene components.
  138544. */
  138545. readonly name: string;
  138546. /**
  138547. * The scene the component belongs to.
  138548. */
  138549. scene: Scene;
  138550. /**
  138551. * Creates a new instance of the component for the given scene
  138552. * @param scene Defines the scene to register the component in
  138553. */
  138554. constructor(scene: Scene);
  138555. /**
  138556. * Registers the component in a given scene
  138557. */
  138558. register(): void;
  138559. /**
  138560. * Rebuilds the elements related to this component in case of
  138561. * context lost for instance.
  138562. */
  138563. rebuild(): void;
  138564. /**
  138565. * Adds all the elements from the container to the scene
  138566. * @param container the container holding the elements
  138567. */
  138568. addFromContainer(container: AbstractScene): void;
  138569. /**
  138570. * Removes all the elements in the container from the scene
  138571. * @param container contains the elements to remove
  138572. * @param dispose if the removed element should be disposed (default: false)
  138573. */
  138574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138575. /**
  138576. * Serializes the component data to the specified json object
  138577. * @param serializationObject The object to serialize to
  138578. */
  138579. serialize(serializationObject: any): void;
  138580. /**
  138581. * Disposes the component and the associated ressources.
  138582. */
  138583. dispose(): void;
  138584. private _draw;
  138585. }
  138586. }
  138587. declare module BABYLON {
  138588. /** @hidden */
  138589. export var depthPixelShader: {
  138590. name: string;
  138591. shader: string;
  138592. };
  138593. }
  138594. declare module BABYLON {
  138595. /** @hidden */
  138596. export var depthVertexShader: {
  138597. name: string;
  138598. shader: string;
  138599. };
  138600. }
  138601. declare module BABYLON {
  138602. /**
  138603. * This represents a depth renderer in Babylon.
  138604. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  138605. */
  138606. export class DepthRenderer {
  138607. private _scene;
  138608. private _depthMap;
  138609. private _effect;
  138610. private readonly _storeNonLinearDepth;
  138611. private readonly _clearColor;
  138612. /** Get if the depth renderer is using packed depth or not */
  138613. readonly isPacked: boolean;
  138614. private _cachedDefines;
  138615. private _camera;
  138616. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  138617. enabled: boolean;
  138618. /**
  138619. * Specifiess that the depth renderer will only be used within
  138620. * the camera it is created for.
  138621. * This can help forcing its rendering during the camera processing.
  138622. */
  138623. useOnlyInActiveCamera: boolean;
  138624. /** @hidden */
  138625. static _SceneComponentInitialization: (scene: Scene) => void;
  138626. /**
  138627. * Instantiates a depth renderer
  138628. * @param scene The scene the renderer belongs to
  138629. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  138630. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  138631. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138632. */
  138633. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  138634. /**
  138635. * Creates the depth rendering effect and checks if the effect is ready.
  138636. * @param subMesh The submesh to be used to render the depth map of
  138637. * @param useInstances If multiple world instances should be used
  138638. * @returns if the depth renderer is ready to render the depth map
  138639. */
  138640. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138641. /**
  138642. * Gets the texture which the depth map will be written to.
  138643. * @returns The depth map texture
  138644. */
  138645. getDepthMap(): RenderTargetTexture;
  138646. /**
  138647. * Disposes of the depth renderer.
  138648. */
  138649. dispose(): void;
  138650. }
  138651. }
  138652. declare module BABYLON {
  138653. /** @hidden */
  138654. export var minmaxReduxPixelShader: {
  138655. name: string;
  138656. shader: string;
  138657. };
  138658. }
  138659. declare module BABYLON {
  138660. /**
  138661. * This class computes a min/max reduction from a texture: it means it computes the minimum
  138662. * and maximum values from all values of the texture.
  138663. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  138664. * The source values are read from the red channel of the texture.
  138665. */
  138666. export class MinMaxReducer {
  138667. /**
  138668. * Observable triggered when the computation has been performed
  138669. */
  138670. onAfterReductionPerformed: Observable<{
  138671. min: number;
  138672. max: number;
  138673. }>;
  138674. protected _camera: Camera;
  138675. protected _sourceTexture: Nullable<RenderTargetTexture>;
  138676. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138677. protected _postProcessManager: PostProcessManager;
  138678. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138679. protected _forceFullscreenViewport: boolean;
  138680. /**
  138681. * Creates a min/max reducer
  138682. * @param camera The camera to use for the post processes
  138683. */
  138684. constructor(camera: Camera);
  138685. /**
  138686. * Gets the texture used to read the values from.
  138687. */
  138688. get sourceTexture(): Nullable<RenderTargetTexture>;
  138689. /**
  138690. * Sets the source texture to read the values from.
  138691. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138692. * because in such textures '1' value must not be taken into account to compute the maximum
  138693. * as this value is used to clear the texture.
  138694. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138695. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138696. * @param depthRedux Indicates if the texture is a depth texture or not
  138697. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138698. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138699. */
  138700. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138701. /**
  138702. * Defines the refresh rate of the computation.
  138703. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138704. */
  138705. get refreshRate(): number;
  138706. set refreshRate(value: number);
  138707. protected _activated: boolean;
  138708. /**
  138709. * Gets the activation status of the reducer
  138710. */
  138711. get activated(): boolean;
  138712. /**
  138713. * Activates the reduction computation.
  138714. * When activated, the observers registered in onAfterReductionPerformed are
  138715. * called after the compuation is performed
  138716. */
  138717. activate(): void;
  138718. /**
  138719. * Deactivates the reduction computation.
  138720. */
  138721. deactivate(): void;
  138722. /**
  138723. * Disposes the min/max reducer
  138724. * @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.
  138725. */
  138726. dispose(disposeAll?: boolean): void;
  138727. }
  138728. }
  138729. declare module BABYLON {
  138730. /**
  138731. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138732. */
  138733. export class DepthReducer extends MinMaxReducer {
  138734. private _depthRenderer;
  138735. private _depthRendererId;
  138736. /**
  138737. * Gets the depth renderer used for the computation.
  138738. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138739. */
  138740. get depthRenderer(): Nullable<DepthRenderer>;
  138741. /**
  138742. * Creates a depth reducer
  138743. * @param camera The camera used to render the depth texture
  138744. */
  138745. constructor(camera: Camera);
  138746. /**
  138747. * Sets the depth renderer to use to generate the depth map
  138748. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138749. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138750. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138751. */
  138752. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138753. /** @hidden */
  138754. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138755. /**
  138756. * Activates the reduction computation.
  138757. * When activated, the observers registered in onAfterReductionPerformed are
  138758. * called after the compuation is performed
  138759. */
  138760. activate(): void;
  138761. /**
  138762. * Deactivates the reduction computation.
  138763. */
  138764. deactivate(): void;
  138765. /**
  138766. * Disposes the depth reducer
  138767. * @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.
  138768. */
  138769. dispose(disposeAll?: boolean): void;
  138770. }
  138771. }
  138772. declare module BABYLON {
  138773. /**
  138774. * A CSM implementation allowing casting shadows on large scenes.
  138775. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138776. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138777. */
  138778. export class CascadedShadowGenerator extends ShadowGenerator {
  138779. private static readonly frustumCornersNDCSpace;
  138780. /**
  138781. * Name of the CSM class
  138782. */
  138783. static CLASSNAME: string;
  138784. /**
  138785. * Defines the default number of cascades used by the CSM.
  138786. */
  138787. static readonly DEFAULT_CASCADES_COUNT: number;
  138788. /**
  138789. * Defines the minimum number of cascades used by the CSM.
  138790. */
  138791. static readonly MIN_CASCADES_COUNT: number;
  138792. /**
  138793. * Defines the maximum number of cascades used by the CSM.
  138794. */
  138795. static readonly MAX_CASCADES_COUNT: number;
  138796. protected _validateFilter(filter: number): number;
  138797. /**
  138798. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138799. */
  138800. penumbraDarkness: number;
  138801. private _numCascades;
  138802. /**
  138803. * Gets or set the number of cascades used by the CSM.
  138804. */
  138805. get numCascades(): number;
  138806. set numCascades(value: number);
  138807. /**
  138808. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138809. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138810. */
  138811. stabilizeCascades: boolean;
  138812. private _freezeShadowCastersBoundingInfo;
  138813. private _freezeShadowCastersBoundingInfoObservable;
  138814. /**
  138815. * Enables or disables the shadow casters bounding info computation.
  138816. * If your shadow casters don't move, you can disable this feature.
  138817. * If it is enabled, the bounding box computation is done every frame.
  138818. */
  138819. get freezeShadowCastersBoundingInfo(): boolean;
  138820. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138821. private _scbiMin;
  138822. private _scbiMax;
  138823. protected _computeShadowCastersBoundingInfo(): void;
  138824. protected _shadowCastersBoundingInfo: BoundingInfo;
  138825. /**
  138826. * Gets or sets the shadow casters bounding info.
  138827. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138828. * so that the system won't overwrite the bounds you provide
  138829. */
  138830. get shadowCastersBoundingInfo(): BoundingInfo;
  138831. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138832. protected _breaksAreDirty: boolean;
  138833. protected _minDistance: number;
  138834. protected _maxDistance: number;
  138835. /**
  138836. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138837. *
  138838. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138839. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138840. * @param min minimal distance for the breaks (default to 0.)
  138841. * @param max maximal distance for the breaks (default to 1.)
  138842. */
  138843. setMinMaxDistance(min: number, max: number): void;
  138844. /** Gets the minimal distance used in the cascade break computation */
  138845. get minDistance(): number;
  138846. /** Gets the maximal distance used in the cascade break computation */
  138847. get maxDistance(): number;
  138848. /**
  138849. * Gets the class name of that object
  138850. * @returns "CascadedShadowGenerator"
  138851. */
  138852. getClassName(): string;
  138853. private _cascadeMinExtents;
  138854. private _cascadeMaxExtents;
  138855. /**
  138856. * Gets a cascade minimum extents
  138857. * @param cascadeIndex index of the cascade
  138858. * @returns the minimum cascade extents
  138859. */
  138860. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138861. /**
  138862. * Gets a cascade maximum extents
  138863. * @param cascadeIndex index of the cascade
  138864. * @returns the maximum cascade extents
  138865. */
  138866. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138867. private _cascades;
  138868. private _currentLayer;
  138869. private _viewSpaceFrustumsZ;
  138870. private _viewMatrices;
  138871. private _projectionMatrices;
  138872. private _transformMatrices;
  138873. private _transformMatricesAsArray;
  138874. private _frustumLengths;
  138875. private _lightSizeUVCorrection;
  138876. private _depthCorrection;
  138877. private _frustumCornersWorldSpace;
  138878. private _frustumCenter;
  138879. private _shadowCameraPos;
  138880. private _shadowMaxZ;
  138881. /**
  138882. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138883. * It defaults to camera.maxZ
  138884. */
  138885. get shadowMaxZ(): number;
  138886. /**
  138887. * Sets the shadow max z distance.
  138888. */
  138889. set shadowMaxZ(value: number);
  138890. protected _debug: boolean;
  138891. /**
  138892. * Gets or sets the debug flag.
  138893. * When enabled, the cascades are materialized by different colors on the screen.
  138894. */
  138895. get debug(): boolean;
  138896. set debug(dbg: boolean);
  138897. private _depthClamp;
  138898. /**
  138899. * Gets or sets the depth clamping value.
  138900. *
  138901. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138902. * to account for the shadow casters far away.
  138903. *
  138904. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138905. */
  138906. get depthClamp(): boolean;
  138907. set depthClamp(value: boolean);
  138908. private _cascadeBlendPercentage;
  138909. /**
  138910. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138911. * It defaults to 0.1 (10% blending).
  138912. */
  138913. get cascadeBlendPercentage(): number;
  138914. set cascadeBlendPercentage(value: number);
  138915. private _lambda;
  138916. /**
  138917. * Gets or set the lambda parameter.
  138918. * This parameter is used to split the camera frustum and create the cascades.
  138919. * 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.
  138920. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138921. */
  138922. get lambda(): number;
  138923. set lambda(value: number);
  138924. /**
  138925. * Gets the view matrix corresponding to a given cascade
  138926. * @param cascadeNum cascade to retrieve the view matrix from
  138927. * @returns the cascade view matrix
  138928. */
  138929. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138930. /**
  138931. * Gets the projection matrix corresponding to a given cascade
  138932. * @param cascadeNum cascade to retrieve the projection matrix from
  138933. * @returns the cascade projection matrix
  138934. */
  138935. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138936. /**
  138937. * Gets the transformation matrix corresponding to a given cascade
  138938. * @param cascadeNum cascade to retrieve the transformation matrix from
  138939. * @returns the cascade transformation matrix
  138940. */
  138941. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138942. private _depthRenderer;
  138943. /**
  138944. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138945. *
  138946. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138947. *
  138948. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138949. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138950. * @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
  138951. */
  138952. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138953. private _depthReducer;
  138954. private _autoCalcDepthBounds;
  138955. /**
  138956. * Gets or sets the autoCalcDepthBounds property.
  138957. *
  138958. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138959. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138960. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138961. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138962. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138963. */
  138964. get autoCalcDepthBounds(): boolean;
  138965. set autoCalcDepthBounds(value: boolean);
  138966. /**
  138967. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138968. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138969. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138970. * for setting the refresh rate on the renderer yourself!
  138971. */
  138972. get autoCalcDepthBoundsRefreshRate(): number;
  138973. set autoCalcDepthBoundsRefreshRate(value: number);
  138974. /**
  138975. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138976. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138977. * you change the camera near/far planes!
  138978. */
  138979. splitFrustum(): void;
  138980. private _splitFrustum;
  138981. private _computeMatrices;
  138982. private _computeFrustumInWorldSpace;
  138983. private _computeCascadeFrustum;
  138984. /**
  138985. * Support test.
  138986. */
  138987. static get IsSupported(): boolean;
  138988. /** @hidden */
  138989. static _SceneComponentInitialization: (scene: Scene) => void;
  138990. /**
  138991. * Creates a Cascaded Shadow Generator object.
  138992. * A ShadowGenerator is the required tool to use the shadows.
  138993. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138994. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138995. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138996. * @param light The directional light object generating the shadows.
  138997. * @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.
  138998. */
  138999. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139000. protected _initializeGenerator(): void;
  139001. protected _createTargetRenderTexture(): void;
  139002. protected _initializeShadowMap(): void;
  139003. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139004. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139005. /**
  139006. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  139007. * @param defines Defines of the material we want to update
  139008. * @param lightIndex Index of the light in the enabled light list of the material
  139009. */
  139010. prepareDefines(defines: any, lightIndex: number): void;
  139011. /**
  139012. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  139013. * defined in the generator but impacting the effect).
  139014. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  139015. * @param effect The effect we are binfing the information for
  139016. */
  139017. bindShadowLight(lightIndex: string, effect: Effect): void;
  139018. /**
  139019. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  139020. * (eq to view projection * shadow projection matrices)
  139021. * @returns The transform matrix used to create the shadow map
  139022. */
  139023. getTransformMatrix(): Matrix;
  139024. /**
  139025. * Disposes the ShadowGenerator.
  139026. * Returns nothing.
  139027. */
  139028. dispose(): void;
  139029. /**
  139030. * Serializes the shadow generator setup to a json object.
  139031. * @returns The serialized JSON object
  139032. */
  139033. serialize(): any;
  139034. /**
  139035. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  139036. * @param parsedShadowGenerator The JSON object to parse
  139037. * @param scene The scene to create the shadow map for
  139038. * @returns The parsed shadow generator
  139039. */
  139040. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  139041. }
  139042. }
  139043. declare module BABYLON {
  139044. /**
  139045. * Defines the shadow generator component responsible to manage any shadow generators
  139046. * in a given scene.
  139047. */
  139048. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  139049. /**
  139050. * The component name helpfull to identify the component in the list of scene components.
  139051. */
  139052. readonly name: string;
  139053. /**
  139054. * The scene the component belongs to.
  139055. */
  139056. scene: Scene;
  139057. /**
  139058. * Creates a new instance of the component for the given scene
  139059. * @param scene Defines the scene to register the component in
  139060. */
  139061. constructor(scene: Scene);
  139062. /**
  139063. * Registers the component in a given scene
  139064. */
  139065. register(): void;
  139066. /**
  139067. * Rebuilds the elements related to this component in case of
  139068. * context lost for instance.
  139069. */
  139070. rebuild(): void;
  139071. /**
  139072. * Serializes the component data to the specified json object
  139073. * @param serializationObject The object to serialize to
  139074. */
  139075. serialize(serializationObject: any): void;
  139076. /**
  139077. * Adds all the elements from the container to the scene
  139078. * @param container the container holding the elements
  139079. */
  139080. addFromContainer(container: AbstractScene): void;
  139081. /**
  139082. * Removes all the elements in the container from the scene
  139083. * @param container contains the elements to remove
  139084. * @param dispose if the removed element should be disposed (default: false)
  139085. */
  139086. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139087. /**
  139088. * Rebuilds the elements related to this component in case of
  139089. * context lost for instance.
  139090. */
  139091. dispose(): void;
  139092. private _gatherRenderTargets;
  139093. }
  139094. }
  139095. declare module BABYLON {
  139096. /**
  139097. * A point light is a light defined by an unique point in world space.
  139098. * The light is emitted in every direction from this point.
  139099. * A good example of a point light is a standard light bulb.
  139100. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139101. */
  139102. export class PointLight extends ShadowLight {
  139103. private _shadowAngle;
  139104. /**
  139105. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139106. * This specifies what angle the shadow will use to be created.
  139107. *
  139108. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139109. */
  139110. get shadowAngle(): number;
  139111. /**
  139112. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139113. * This specifies what angle the shadow will use to be created.
  139114. *
  139115. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139116. */
  139117. set shadowAngle(value: number);
  139118. /**
  139119. * Gets the direction if it has been set.
  139120. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139121. */
  139122. get direction(): Vector3;
  139123. /**
  139124. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139125. */
  139126. set direction(value: Vector3);
  139127. /**
  139128. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  139129. * A PointLight emits the light in every direction.
  139130. * It can cast shadows.
  139131. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  139132. * ```javascript
  139133. * var pointLight = new PointLight("pl", camera.position, scene);
  139134. * ```
  139135. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139136. * @param name The light friendly name
  139137. * @param position The position of the point light in the scene
  139138. * @param scene The scene the lights belongs to
  139139. */
  139140. constructor(name: string, position: Vector3, scene: Scene);
  139141. /**
  139142. * Returns the string "PointLight"
  139143. * @returns the class name
  139144. */
  139145. getClassName(): string;
  139146. /**
  139147. * Returns the integer 0.
  139148. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139149. */
  139150. getTypeID(): number;
  139151. /**
  139152. * Specifies wether or not the shadowmap should be a cube texture.
  139153. * @returns true if the shadowmap needs to be a cube texture.
  139154. */
  139155. needCube(): boolean;
  139156. /**
  139157. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  139158. * @param faceIndex The index of the face we are computed the direction to generate shadow
  139159. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  139160. */
  139161. getShadowDirection(faceIndex?: number): Vector3;
  139162. /**
  139163. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  139164. * - fov = PI / 2
  139165. * - aspect ratio : 1.0
  139166. * - z-near and far equal to the active camera minZ and maxZ.
  139167. * Returns the PointLight.
  139168. */
  139169. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139170. protected _buildUniformLayout(): void;
  139171. /**
  139172. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  139173. * @param effect The effect to update
  139174. * @param lightIndex The index of the light in the effect to update
  139175. * @returns The point light
  139176. */
  139177. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  139178. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139179. /**
  139180. * Prepares the list of defines specific to the light type.
  139181. * @param defines the list of defines
  139182. * @param lightIndex defines the index of the light for the effect
  139183. */
  139184. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139185. }
  139186. }
  139187. declare module BABYLON {
  139188. /**
  139189. * Header information of HDR texture files.
  139190. */
  139191. export interface HDRInfo {
  139192. /**
  139193. * The height of the texture in pixels.
  139194. */
  139195. height: number;
  139196. /**
  139197. * The width of the texture in pixels.
  139198. */
  139199. width: number;
  139200. /**
  139201. * The index of the beginning of the data in the binary file.
  139202. */
  139203. dataPosition: number;
  139204. }
  139205. /**
  139206. * This groups tools to convert HDR texture to native colors array.
  139207. */
  139208. export class HDRTools {
  139209. private static Ldexp;
  139210. private static Rgbe2float;
  139211. private static readStringLine;
  139212. /**
  139213. * Reads header information from an RGBE texture stored in a native array.
  139214. * More information on this format are available here:
  139215. * https://en.wikipedia.org/wiki/RGBE_image_format
  139216. *
  139217. * @param uint8array The binary file stored in native array.
  139218. * @return The header information.
  139219. */
  139220. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  139221. /**
  139222. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  139223. * This RGBE texture needs to store the information as a panorama.
  139224. *
  139225. * More information on this format are available here:
  139226. * https://en.wikipedia.org/wiki/RGBE_image_format
  139227. *
  139228. * @param buffer The binary file stored in an array buffer.
  139229. * @param size The expected size of the extracted cubemap.
  139230. * @return The Cube Map information.
  139231. */
  139232. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  139233. /**
  139234. * Returns the pixels data extracted from an RGBE texture.
  139235. * This pixels will be stored left to right up to down in the R G B order in one array.
  139236. *
  139237. * More information on this format are available here:
  139238. * https://en.wikipedia.org/wiki/RGBE_image_format
  139239. *
  139240. * @param uint8array The binary file stored in an array buffer.
  139241. * @param hdrInfo The header information of the file.
  139242. * @return The pixels data in RGB right to left up to down order.
  139243. */
  139244. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  139245. private static RGBE_ReadPixels_RLE;
  139246. private static RGBE_ReadPixels_NOT_RLE;
  139247. }
  139248. }
  139249. declare module BABYLON {
  139250. /**
  139251. * Effect Render Options
  139252. */
  139253. export interface IEffectRendererOptions {
  139254. /**
  139255. * Defines the vertices positions.
  139256. */
  139257. positions?: number[];
  139258. /**
  139259. * Defines the indices.
  139260. */
  139261. indices?: number[];
  139262. }
  139263. /**
  139264. * Helper class to render one or more effects.
  139265. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  139266. */
  139267. export class EffectRenderer {
  139268. private engine;
  139269. private static _DefaultOptions;
  139270. private _vertexBuffers;
  139271. private _indexBuffer;
  139272. private _fullscreenViewport;
  139273. /**
  139274. * Creates an effect renderer
  139275. * @param engine the engine to use for rendering
  139276. * @param options defines the options of the effect renderer
  139277. */
  139278. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  139279. /**
  139280. * Sets the current viewport in normalized coordinates 0-1
  139281. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  139282. */
  139283. setViewport(viewport?: Viewport): void;
  139284. /**
  139285. * Binds the embedded attributes buffer to the effect.
  139286. * @param effect Defines the effect to bind the attributes for
  139287. */
  139288. bindBuffers(effect: Effect): void;
  139289. /**
  139290. * Sets the current effect wrapper to use during draw.
  139291. * The effect needs to be ready before calling this api.
  139292. * This also sets the default full screen position attribute.
  139293. * @param effectWrapper Defines the effect to draw with
  139294. */
  139295. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  139296. /**
  139297. * Restores engine states
  139298. */
  139299. restoreStates(): void;
  139300. /**
  139301. * Draws a full screen quad.
  139302. */
  139303. draw(): void;
  139304. private isRenderTargetTexture;
  139305. /**
  139306. * renders one or more effects to a specified texture
  139307. * @param effectWrapper the effect to renderer
  139308. * @param outputTexture texture to draw to, if null it will render to the screen.
  139309. */
  139310. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  139311. /**
  139312. * Disposes of the effect renderer
  139313. */
  139314. dispose(): void;
  139315. }
  139316. /**
  139317. * Options to create an EffectWrapper
  139318. */
  139319. interface EffectWrapperCreationOptions {
  139320. /**
  139321. * Engine to use to create the effect
  139322. */
  139323. engine: ThinEngine;
  139324. /**
  139325. * Fragment shader for the effect
  139326. */
  139327. fragmentShader: string;
  139328. /**
  139329. * Use the shader store instead of direct source code
  139330. */
  139331. useShaderStore?: boolean;
  139332. /**
  139333. * Vertex shader for the effect
  139334. */
  139335. vertexShader?: string;
  139336. /**
  139337. * Attributes to use in the shader
  139338. */
  139339. attributeNames?: Array<string>;
  139340. /**
  139341. * Uniforms to use in the shader
  139342. */
  139343. uniformNames?: Array<string>;
  139344. /**
  139345. * Texture sampler names to use in the shader
  139346. */
  139347. samplerNames?: Array<string>;
  139348. /**
  139349. * Defines to use in the shader
  139350. */
  139351. defines?: Array<string>;
  139352. /**
  139353. * Callback when effect is compiled
  139354. */
  139355. onCompiled?: Nullable<(effect: Effect) => void>;
  139356. /**
  139357. * The friendly name of the effect displayed in Spector.
  139358. */
  139359. name?: string;
  139360. }
  139361. /**
  139362. * Wraps an effect to be used for rendering
  139363. */
  139364. export class EffectWrapper {
  139365. /**
  139366. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  139367. */
  139368. onApplyObservable: Observable<{}>;
  139369. /**
  139370. * The underlying effect
  139371. */
  139372. effect: Effect;
  139373. /**
  139374. * Creates an effect to be renderer
  139375. * @param creationOptions options to create the effect
  139376. */
  139377. constructor(creationOptions: EffectWrapperCreationOptions);
  139378. /**
  139379. * Disposes of the effect wrapper
  139380. */
  139381. dispose(): void;
  139382. }
  139383. }
  139384. declare module BABYLON {
  139385. /** @hidden */
  139386. export var hdrFilteringVertexShader: {
  139387. name: string;
  139388. shader: string;
  139389. };
  139390. }
  139391. declare module BABYLON {
  139392. /** @hidden */
  139393. export var hdrFilteringPixelShader: {
  139394. name: string;
  139395. shader: string;
  139396. };
  139397. }
  139398. declare module BABYLON {
  139399. /**
  139400. * Options for texture filtering
  139401. */
  139402. interface IHDRFilteringOptions {
  139403. /**
  139404. * Scales pixel intensity for the input HDR map.
  139405. */
  139406. hdrScale?: number;
  139407. /**
  139408. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  139409. */
  139410. quality?: number;
  139411. }
  139412. /**
  139413. * Filters HDR maps to get correct renderings of PBR reflections
  139414. */
  139415. export class HDRFiltering {
  139416. private _engine;
  139417. private _effectRenderer;
  139418. private _effectWrapper;
  139419. private _lodGenerationOffset;
  139420. private _lodGenerationScale;
  139421. /**
  139422. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  139423. * you care about baking speed.
  139424. */
  139425. quality: number;
  139426. /**
  139427. * Scales pixel intensity for the input HDR map.
  139428. */
  139429. hdrScale: number;
  139430. /**
  139431. * Instantiates HDR filter for reflection maps
  139432. *
  139433. * @param engine Thin engine
  139434. * @param options Options
  139435. */
  139436. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  139437. private _createRenderTarget;
  139438. private _prefilterInternal;
  139439. private _createEffect;
  139440. /**
  139441. * Get a value indicating if the filter is ready to be used
  139442. * @param texture Texture to filter
  139443. * @returns true if the filter is ready
  139444. */
  139445. isReady(texture: BaseTexture): boolean;
  139446. /**
  139447. * Prefilters a cube texture to have mipmap levels representing roughness values.
  139448. * Prefiltering will be invoked at the end of next rendering pass.
  139449. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  139450. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  139451. * @param texture Texture to filter
  139452. * @param onFinished Callback when filtering is done
  139453. * @return Promise called when prefiltering is done
  139454. */
  139455. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  139456. }
  139457. }
  139458. declare module BABYLON {
  139459. /**
  139460. * This represents a texture coming from an HDR input.
  139461. *
  139462. * The only supported format is currently panorama picture stored in RGBE format.
  139463. * Example of such files can be found on HDRLib: http://hdrlib.com/
  139464. */
  139465. export class HDRCubeTexture extends BaseTexture {
  139466. private static _facesMapping;
  139467. private _generateHarmonics;
  139468. private _noMipmap;
  139469. private _prefilterOnLoad;
  139470. private _textureMatrix;
  139471. private _size;
  139472. private _onLoad;
  139473. private _onError;
  139474. /**
  139475. * The texture URL.
  139476. */
  139477. url: string;
  139478. /**
  139479. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  139480. */
  139481. coordinatesMode: number;
  139482. protected _isBlocking: boolean;
  139483. /**
  139484. * Sets wether or not the texture is blocking during loading.
  139485. */
  139486. set isBlocking(value: boolean);
  139487. /**
  139488. * Gets wether or not the texture is blocking during loading.
  139489. */
  139490. get isBlocking(): boolean;
  139491. protected _rotationY: number;
  139492. /**
  139493. * Sets texture matrix rotation angle around Y axis in radians.
  139494. */
  139495. set rotationY(value: number);
  139496. /**
  139497. * Gets texture matrix rotation angle around Y axis radians.
  139498. */
  139499. get rotationY(): number;
  139500. /**
  139501. * Gets or sets the center of the bounding box associated with the cube texture
  139502. * It must define where the camera used to render the texture was set
  139503. */
  139504. boundingBoxPosition: Vector3;
  139505. private _boundingBoxSize;
  139506. /**
  139507. * Gets or sets the size of the bounding box associated with the cube texture
  139508. * When defined, the cubemap will switch to local mode
  139509. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  139510. * @example https://www.babylonjs-playground.com/#RNASML
  139511. */
  139512. set boundingBoxSize(value: Vector3);
  139513. get boundingBoxSize(): Vector3;
  139514. /**
  139515. * Instantiates an HDRTexture from the following parameters.
  139516. *
  139517. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  139518. * @param sceneOrEngine The scene or engine the texture will be used in
  139519. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139520. * @param noMipmap Forces to not generate the mipmap if true
  139521. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  139522. * @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)
  139523. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  139524. */
  139525. 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>);
  139526. /**
  139527. * Get the current class name of the texture useful for serialization or dynamic coding.
  139528. * @returns "HDRCubeTexture"
  139529. */
  139530. getClassName(): string;
  139531. /**
  139532. * Occurs when the file is raw .hdr file.
  139533. */
  139534. private loadTexture;
  139535. clone(): HDRCubeTexture;
  139536. delayLoad(): void;
  139537. /**
  139538. * Get the texture reflection matrix used to rotate/transform the reflection.
  139539. * @returns the reflection matrix
  139540. */
  139541. getReflectionTextureMatrix(): Matrix;
  139542. /**
  139543. * Set the texture reflection matrix used to rotate/transform the reflection.
  139544. * @param value Define the reflection matrix to set
  139545. */
  139546. setReflectionTextureMatrix(value: Matrix): void;
  139547. /**
  139548. * Parses a JSON representation of an HDR Texture in order to create the texture
  139549. * @param parsedTexture Define the JSON representation
  139550. * @param scene Define the scene the texture should be created in
  139551. * @param rootUrl Define the root url in case we need to load relative dependencies
  139552. * @returns the newly created texture after parsing
  139553. */
  139554. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  139555. serialize(): any;
  139556. }
  139557. }
  139558. declare module BABYLON {
  139559. /**
  139560. * Class used to control physics engine
  139561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139562. */
  139563. export class PhysicsEngine implements IPhysicsEngine {
  139564. private _physicsPlugin;
  139565. /**
  139566. * Global value used to control the smallest number supported by the simulation
  139567. */
  139568. static Epsilon: number;
  139569. private _impostors;
  139570. private _joints;
  139571. private _subTimeStep;
  139572. /**
  139573. * Gets the gravity vector used by the simulation
  139574. */
  139575. gravity: Vector3;
  139576. /**
  139577. * Factory used to create the default physics plugin.
  139578. * @returns The default physics plugin
  139579. */
  139580. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  139581. /**
  139582. * Creates a new Physics Engine
  139583. * @param gravity defines the gravity vector used by the simulation
  139584. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  139585. */
  139586. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  139587. /**
  139588. * Sets the gravity vector used by the simulation
  139589. * @param gravity defines the gravity vector to use
  139590. */
  139591. setGravity(gravity: Vector3): void;
  139592. /**
  139593. * Set the time step of the physics engine.
  139594. * Default is 1/60.
  139595. * To slow it down, enter 1/600 for example.
  139596. * To speed it up, 1/30
  139597. * @param newTimeStep defines the new timestep to apply to this world.
  139598. */
  139599. setTimeStep(newTimeStep?: number): void;
  139600. /**
  139601. * Get the time step of the physics engine.
  139602. * @returns the current time step
  139603. */
  139604. getTimeStep(): number;
  139605. /**
  139606. * Set the sub time step of the physics engine.
  139607. * Default is 0 meaning there is no sub steps
  139608. * To increase physics resolution precision, set a small value (like 1 ms)
  139609. * @param subTimeStep defines the new sub timestep used for physics resolution.
  139610. */
  139611. setSubTimeStep(subTimeStep?: number): void;
  139612. /**
  139613. * Get the sub time step of the physics engine.
  139614. * @returns the current sub time step
  139615. */
  139616. getSubTimeStep(): number;
  139617. /**
  139618. * Release all resources
  139619. */
  139620. dispose(): void;
  139621. /**
  139622. * Gets the name of the current physics plugin
  139623. * @returns the name of the plugin
  139624. */
  139625. getPhysicsPluginName(): string;
  139626. /**
  139627. * Adding a new impostor for the impostor tracking.
  139628. * This will be done by the impostor itself.
  139629. * @param impostor the impostor to add
  139630. */
  139631. addImpostor(impostor: PhysicsImpostor): void;
  139632. /**
  139633. * Remove an impostor from the engine.
  139634. * This impostor and its mesh will not longer be updated by the physics engine.
  139635. * @param impostor the impostor to remove
  139636. */
  139637. removeImpostor(impostor: PhysicsImpostor): void;
  139638. /**
  139639. * Add a joint to the physics engine
  139640. * @param mainImpostor defines the main impostor to which the joint is added.
  139641. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  139642. * @param joint defines the joint that will connect both impostors.
  139643. */
  139644. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139645. /**
  139646. * Removes a joint from the simulation
  139647. * @param mainImpostor defines the impostor used with the joint
  139648. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  139649. * @param joint defines the joint to remove
  139650. */
  139651. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139652. /**
  139653. * Called by the scene. No need to call it.
  139654. * @param delta defines the timespam between frames
  139655. */
  139656. _step(delta: number): void;
  139657. /**
  139658. * Gets the current plugin used to run the simulation
  139659. * @returns current plugin
  139660. */
  139661. getPhysicsPlugin(): IPhysicsEnginePlugin;
  139662. /**
  139663. * Gets the list of physic impostors
  139664. * @returns an array of PhysicsImpostor
  139665. */
  139666. getImpostors(): Array<PhysicsImpostor>;
  139667. /**
  139668. * Gets the impostor for a physics enabled object
  139669. * @param object defines the object impersonated by the impostor
  139670. * @returns the PhysicsImpostor or null if not found
  139671. */
  139672. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  139673. /**
  139674. * Gets the impostor for a physics body object
  139675. * @param body defines physics body used by the impostor
  139676. * @returns the PhysicsImpostor or null if not found
  139677. */
  139678. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139679. /**
  139680. * Does a raycast in the physics world
  139681. * @param from when should the ray start?
  139682. * @param to when should the ray end?
  139683. * @returns PhysicsRaycastResult
  139684. */
  139685. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139686. }
  139687. }
  139688. declare module BABYLON {
  139689. /** @hidden */
  139690. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139691. private _useDeltaForWorldStep;
  139692. world: any;
  139693. name: string;
  139694. private _physicsMaterials;
  139695. private _fixedTimeStep;
  139696. private _cannonRaycastResult;
  139697. private _raycastResult;
  139698. private _physicsBodysToRemoveAfterStep;
  139699. private _firstFrame;
  139700. BJSCANNON: any;
  139701. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139702. setGravity(gravity: Vector3): void;
  139703. setTimeStep(timeStep: number): void;
  139704. getTimeStep(): number;
  139705. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139706. private _removeMarkedPhysicsBodiesFromWorld;
  139707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139710. private _processChildMeshes;
  139711. removePhysicsBody(impostor: PhysicsImpostor): void;
  139712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139714. private _addMaterial;
  139715. private _checkWithEpsilon;
  139716. private _createShape;
  139717. private _createHeightmap;
  139718. private _minus90X;
  139719. private _plus90X;
  139720. private _tmpPosition;
  139721. private _tmpDeltaPosition;
  139722. private _tmpUnityRotation;
  139723. private _updatePhysicsBodyTransformation;
  139724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139725. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139726. isSupported(): boolean;
  139727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139732. getBodyMass(impostor: PhysicsImpostor): number;
  139733. getBodyFriction(impostor: PhysicsImpostor): number;
  139734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139735. getBodyRestitution(impostor: PhysicsImpostor): number;
  139736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139737. sleepBody(impostor: PhysicsImpostor): void;
  139738. wakeUpBody(impostor: PhysicsImpostor): void;
  139739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139740. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139743. getRadius(impostor: PhysicsImpostor): number;
  139744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139745. dispose(): void;
  139746. private _extendNamespace;
  139747. /**
  139748. * Does a raycast in the physics world
  139749. * @param from when should the ray start?
  139750. * @param to when should the ray end?
  139751. * @returns PhysicsRaycastResult
  139752. */
  139753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139754. }
  139755. }
  139756. declare module BABYLON {
  139757. /** @hidden */
  139758. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139759. private _useDeltaForWorldStep;
  139760. world: any;
  139761. name: string;
  139762. BJSOIMO: any;
  139763. private _raycastResult;
  139764. private _fixedTimeStep;
  139765. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139766. setGravity(gravity: Vector3): void;
  139767. setTimeStep(timeStep: number): void;
  139768. getTimeStep(): number;
  139769. private _tmpImpostorsArray;
  139770. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139771. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139772. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139773. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139774. private _tmpPositionVector;
  139775. removePhysicsBody(impostor: PhysicsImpostor): void;
  139776. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139777. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139778. isSupported(): boolean;
  139779. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139780. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139781. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139782. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139783. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139784. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139785. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139786. getBodyMass(impostor: PhysicsImpostor): number;
  139787. getBodyFriction(impostor: PhysicsImpostor): number;
  139788. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139789. getBodyRestitution(impostor: PhysicsImpostor): number;
  139790. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139791. sleepBody(impostor: PhysicsImpostor): void;
  139792. wakeUpBody(impostor: PhysicsImpostor): void;
  139793. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139794. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139795. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139796. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139797. getRadius(impostor: PhysicsImpostor): number;
  139798. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139799. dispose(): void;
  139800. /**
  139801. * Does a raycast in the physics world
  139802. * @param from when should the ray start?
  139803. * @param to when should the ray end?
  139804. * @returns PhysicsRaycastResult
  139805. */
  139806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139807. }
  139808. }
  139809. declare module BABYLON {
  139810. /**
  139811. * AmmoJS Physics plugin
  139812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139813. * @see https://github.com/kripken/ammo.js/
  139814. */
  139815. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139816. private _useDeltaForWorldStep;
  139817. /**
  139818. * Reference to the Ammo library
  139819. */
  139820. bjsAMMO: any;
  139821. /**
  139822. * Created ammoJS world which physics bodies are added to
  139823. */
  139824. world: any;
  139825. /**
  139826. * Name of the plugin
  139827. */
  139828. name: string;
  139829. private _timeStep;
  139830. private _fixedTimeStep;
  139831. private _maxSteps;
  139832. private _tmpQuaternion;
  139833. private _tmpAmmoTransform;
  139834. private _tmpAmmoQuaternion;
  139835. private _tmpAmmoConcreteContactResultCallback;
  139836. private _collisionConfiguration;
  139837. private _dispatcher;
  139838. private _overlappingPairCache;
  139839. private _solver;
  139840. private _softBodySolver;
  139841. private _tmpAmmoVectorA;
  139842. private _tmpAmmoVectorB;
  139843. private _tmpAmmoVectorC;
  139844. private _tmpAmmoVectorD;
  139845. private _tmpContactCallbackResult;
  139846. private _tmpAmmoVectorRCA;
  139847. private _tmpAmmoVectorRCB;
  139848. private _raycastResult;
  139849. private static readonly DISABLE_COLLISION_FLAG;
  139850. private static readonly KINEMATIC_FLAG;
  139851. private static readonly DISABLE_DEACTIVATION_FLAG;
  139852. /**
  139853. * Initializes the ammoJS plugin
  139854. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139855. * @param ammoInjection can be used to inject your own ammo reference
  139856. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139857. */
  139858. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139859. /**
  139860. * Sets the gravity of the physics world (m/(s^2))
  139861. * @param gravity Gravity to set
  139862. */
  139863. setGravity(gravity: Vector3): void;
  139864. /**
  139865. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139866. * @param timeStep timestep to use in seconds
  139867. */
  139868. setTimeStep(timeStep: number): void;
  139869. /**
  139870. * 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)
  139871. * @param fixedTimeStep fixedTimeStep to use in seconds
  139872. */
  139873. setFixedTimeStep(fixedTimeStep: number): void;
  139874. /**
  139875. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139876. * @param maxSteps the maximum number of steps by the physics engine per frame
  139877. */
  139878. setMaxSteps(maxSteps: number): void;
  139879. /**
  139880. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139881. * @returns the current timestep in seconds
  139882. */
  139883. getTimeStep(): number;
  139884. /**
  139885. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139886. */
  139887. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139888. private _isImpostorInContact;
  139889. private _isImpostorPairInContact;
  139890. private _stepSimulation;
  139891. /**
  139892. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139893. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139894. * After the step the babylon meshes are set to the position of the physics imposters
  139895. * @param delta amount of time to step forward
  139896. * @param impostors array of imposters to update before/after the step
  139897. */
  139898. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139899. /**
  139900. * Update babylon mesh to match physics world object
  139901. * @param impostor imposter to match
  139902. */
  139903. private _afterSoftStep;
  139904. /**
  139905. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139906. * @param impostor imposter to match
  139907. */
  139908. private _ropeStep;
  139909. /**
  139910. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139911. * @param impostor imposter to match
  139912. */
  139913. private _softbodyOrClothStep;
  139914. private _tmpMatrix;
  139915. /**
  139916. * Applies an impulse on the imposter
  139917. * @param impostor imposter to apply impulse to
  139918. * @param force amount of force to be applied to the imposter
  139919. * @param contactPoint the location to apply the impulse on the imposter
  139920. */
  139921. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139922. /**
  139923. * Applies a force on the imposter
  139924. * @param impostor imposter to apply force
  139925. * @param force amount of force to be applied to the imposter
  139926. * @param contactPoint the location to apply the force on the imposter
  139927. */
  139928. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139929. /**
  139930. * Creates a physics body using the plugin
  139931. * @param impostor the imposter to create the physics body on
  139932. */
  139933. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139934. /**
  139935. * Removes the physics body from the imposter and disposes of the body's memory
  139936. * @param impostor imposter to remove the physics body from
  139937. */
  139938. removePhysicsBody(impostor: PhysicsImpostor): void;
  139939. /**
  139940. * Generates a joint
  139941. * @param impostorJoint the imposter joint to create the joint with
  139942. */
  139943. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139944. /**
  139945. * Removes a joint
  139946. * @param impostorJoint the imposter joint to remove the joint from
  139947. */
  139948. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139949. private _addMeshVerts;
  139950. /**
  139951. * Initialise the soft body vertices to match its object's (mesh) vertices
  139952. * Softbody vertices (nodes) are in world space and to match this
  139953. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139954. * @param impostor to create the softbody for
  139955. */
  139956. private _softVertexData;
  139957. /**
  139958. * Create an impostor's soft body
  139959. * @param impostor to create the softbody for
  139960. */
  139961. private _createSoftbody;
  139962. /**
  139963. * Create cloth for an impostor
  139964. * @param impostor to create the softbody for
  139965. */
  139966. private _createCloth;
  139967. /**
  139968. * Create rope for an impostor
  139969. * @param impostor to create the softbody for
  139970. */
  139971. private _createRope;
  139972. /**
  139973. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139974. * @param impostor to create the custom physics shape for
  139975. */
  139976. private _createCustom;
  139977. private _addHullVerts;
  139978. private _createShape;
  139979. /**
  139980. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139981. * @param impostor imposter containing the physics body and babylon object
  139982. */
  139983. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139984. /**
  139985. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139986. * @param impostor imposter containing the physics body and babylon object
  139987. * @param newPosition new position
  139988. * @param newRotation new rotation
  139989. */
  139990. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139991. /**
  139992. * If this plugin is supported
  139993. * @returns true if its supported
  139994. */
  139995. isSupported(): boolean;
  139996. /**
  139997. * Sets the linear velocity of the physics body
  139998. * @param impostor imposter to set the velocity on
  139999. * @param velocity velocity to set
  140000. */
  140001. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140002. /**
  140003. * Sets the angular velocity of the physics body
  140004. * @param impostor imposter to set the velocity on
  140005. * @param velocity velocity to set
  140006. */
  140007. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140008. /**
  140009. * gets the linear velocity
  140010. * @param impostor imposter to get linear velocity from
  140011. * @returns linear velocity
  140012. */
  140013. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140014. /**
  140015. * gets the angular velocity
  140016. * @param impostor imposter to get angular velocity from
  140017. * @returns angular velocity
  140018. */
  140019. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140020. /**
  140021. * Sets the mass of physics body
  140022. * @param impostor imposter to set the mass on
  140023. * @param mass mass to set
  140024. */
  140025. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140026. /**
  140027. * Gets the mass of the physics body
  140028. * @param impostor imposter to get the mass from
  140029. * @returns mass
  140030. */
  140031. getBodyMass(impostor: PhysicsImpostor): number;
  140032. /**
  140033. * Gets friction of the impostor
  140034. * @param impostor impostor to get friction from
  140035. * @returns friction value
  140036. */
  140037. getBodyFriction(impostor: PhysicsImpostor): number;
  140038. /**
  140039. * Sets friction of the impostor
  140040. * @param impostor impostor to set friction on
  140041. * @param friction friction value
  140042. */
  140043. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140044. /**
  140045. * Gets restitution of the impostor
  140046. * @param impostor impostor to get restitution from
  140047. * @returns restitution value
  140048. */
  140049. getBodyRestitution(impostor: PhysicsImpostor): number;
  140050. /**
  140051. * Sets resitution of the impostor
  140052. * @param impostor impostor to set resitution on
  140053. * @param restitution resitution value
  140054. */
  140055. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140056. /**
  140057. * Gets pressure inside the impostor
  140058. * @param impostor impostor to get pressure from
  140059. * @returns pressure value
  140060. */
  140061. getBodyPressure(impostor: PhysicsImpostor): number;
  140062. /**
  140063. * Sets pressure inside a soft body impostor
  140064. * Cloth and rope must remain 0 pressure
  140065. * @param impostor impostor to set pressure on
  140066. * @param pressure pressure value
  140067. */
  140068. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  140069. /**
  140070. * Gets stiffness of the impostor
  140071. * @param impostor impostor to get stiffness from
  140072. * @returns pressure value
  140073. */
  140074. getBodyStiffness(impostor: PhysicsImpostor): number;
  140075. /**
  140076. * Sets stiffness of the impostor
  140077. * @param impostor impostor to set stiffness on
  140078. * @param stiffness stiffness value from 0 to 1
  140079. */
  140080. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  140081. /**
  140082. * Gets velocityIterations of the impostor
  140083. * @param impostor impostor to get velocity iterations from
  140084. * @returns velocityIterations value
  140085. */
  140086. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  140087. /**
  140088. * Sets velocityIterations of the impostor
  140089. * @param impostor impostor to set velocity iterations on
  140090. * @param velocityIterations velocityIterations value
  140091. */
  140092. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  140093. /**
  140094. * Gets positionIterations of the impostor
  140095. * @param impostor impostor to get position iterations from
  140096. * @returns positionIterations value
  140097. */
  140098. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  140099. /**
  140100. * Sets positionIterations of the impostor
  140101. * @param impostor impostor to set position on
  140102. * @param positionIterations positionIterations value
  140103. */
  140104. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  140105. /**
  140106. * Append an anchor to a cloth object
  140107. * @param impostor is the cloth impostor to add anchor to
  140108. * @param otherImpostor is the rigid impostor to anchor to
  140109. * @param width ratio across width from 0 to 1
  140110. * @param height ratio up height from 0 to 1
  140111. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  140112. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140113. */
  140114. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140115. /**
  140116. * Append an hook to a rope object
  140117. * @param impostor is the rope impostor to add hook to
  140118. * @param otherImpostor is the rigid impostor to hook to
  140119. * @param length ratio along the rope from 0 to 1
  140120. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  140121. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140122. */
  140123. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140124. /**
  140125. * Sleeps the physics body and stops it from being active
  140126. * @param impostor impostor to sleep
  140127. */
  140128. sleepBody(impostor: PhysicsImpostor): void;
  140129. /**
  140130. * Activates the physics body
  140131. * @param impostor impostor to activate
  140132. */
  140133. wakeUpBody(impostor: PhysicsImpostor): void;
  140134. /**
  140135. * Updates the distance parameters of the joint
  140136. * @param joint joint to update
  140137. * @param maxDistance maximum distance of the joint
  140138. * @param minDistance minimum distance of the joint
  140139. */
  140140. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140141. /**
  140142. * Sets a motor on the joint
  140143. * @param joint joint to set motor on
  140144. * @param speed speed of the motor
  140145. * @param maxForce maximum force of the motor
  140146. * @param motorIndex index of the motor
  140147. */
  140148. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140149. /**
  140150. * Sets the motors limit
  140151. * @param joint joint to set limit on
  140152. * @param upperLimit upper limit
  140153. * @param lowerLimit lower limit
  140154. */
  140155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140156. /**
  140157. * Syncs the position and rotation of a mesh with the impostor
  140158. * @param mesh mesh to sync
  140159. * @param impostor impostor to update the mesh with
  140160. */
  140161. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140162. /**
  140163. * Gets the radius of the impostor
  140164. * @param impostor impostor to get radius from
  140165. * @returns the radius
  140166. */
  140167. getRadius(impostor: PhysicsImpostor): number;
  140168. /**
  140169. * Gets the box size of the impostor
  140170. * @param impostor impostor to get box size from
  140171. * @param result the resulting box size
  140172. */
  140173. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140174. /**
  140175. * Disposes of the impostor
  140176. */
  140177. dispose(): void;
  140178. /**
  140179. * Does a raycast in the physics world
  140180. * @param from when should the ray start?
  140181. * @param to when should the ray end?
  140182. * @returns PhysicsRaycastResult
  140183. */
  140184. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140185. }
  140186. }
  140187. declare module BABYLON {
  140188. interface AbstractScene {
  140189. /**
  140190. * The list of reflection probes added to the scene
  140191. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140192. */
  140193. reflectionProbes: Array<ReflectionProbe>;
  140194. /**
  140195. * Removes the given reflection probe from this scene.
  140196. * @param toRemove The reflection probe to remove
  140197. * @returns The index of the removed reflection probe
  140198. */
  140199. removeReflectionProbe(toRemove: ReflectionProbe): number;
  140200. /**
  140201. * Adds the given reflection probe to this scene.
  140202. * @param newReflectionProbe The reflection probe to add
  140203. */
  140204. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  140205. }
  140206. /**
  140207. * Class used to generate realtime reflection / refraction cube textures
  140208. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140209. */
  140210. export class ReflectionProbe {
  140211. /** defines the name of the probe */
  140212. name: string;
  140213. private _scene;
  140214. private _renderTargetTexture;
  140215. private _projectionMatrix;
  140216. private _viewMatrix;
  140217. private _target;
  140218. private _add;
  140219. private _attachedMesh;
  140220. private _invertYAxis;
  140221. /** Gets or sets probe position (center of the cube map) */
  140222. position: Vector3;
  140223. /**
  140224. * Creates a new reflection probe
  140225. * @param name defines the name of the probe
  140226. * @param size defines the texture resolution (for each face)
  140227. * @param scene defines the hosting scene
  140228. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  140229. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  140230. */
  140231. constructor(
  140232. /** defines the name of the probe */
  140233. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  140234. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  140235. get samples(): number;
  140236. set samples(value: number);
  140237. /** Gets or sets the refresh rate to use (on every frame by default) */
  140238. get refreshRate(): number;
  140239. set refreshRate(value: number);
  140240. /**
  140241. * Gets the hosting scene
  140242. * @returns a Scene
  140243. */
  140244. getScene(): Scene;
  140245. /** Gets the internal CubeTexture used to render to */
  140246. get cubeTexture(): RenderTargetTexture;
  140247. /** Gets the list of meshes to render */
  140248. get renderList(): Nullable<AbstractMesh[]>;
  140249. /**
  140250. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  140251. * @param mesh defines the mesh to attach to
  140252. */
  140253. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  140254. /**
  140255. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  140256. * @param renderingGroupId The rendering group id corresponding to its index
  140257. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  140258. */
  140259. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  140260. /**
  140261. * Clean all associated resources
  140262. */
  140263. dispose(): void;
  140264. /**
  140265. * Converts the reflection probe information to a readable string for debug purpose.
  140266. * @param fullDetails Supports for multiple levels of logging within scene loading
  140267. * @returns the human readable reflection probe info
  140268. */
  140269. toString(fullDetails?: boolean): string;
  140270. /**
  140271. * Get the class name of the relfection probe.
  140272. * @returns "ReflectionProbe"
  140273. */
  140274. getClassName(): string;
  140275. /**
  140276. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  140277. * @returns The JSON representation of the texture
  140278. */
  140279. serialize(): any;
  140280. /**
  140281. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  140282. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  140283. * @param scene Define the scene the parsed reflection probe should be instantiated in
  140284. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  140285. * @returns The parsed reflection probe if successful
  140286. */
  140287. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  140288. }
  140289. }
  140290. declare module BABYLON {
  140291. /** @hidden */
  140292. export var _BabylonLoaderRegistered: boolean;
  140293. /**
  140294. * Helps setting up some configuration for the babylon file loader.
  140295. */
  140296. export class BabylonFileLoaderConfiguration {
  140297. /**
  140298. * The loader does not allow injecting custom physix engine into the plugins.
  140299. * Unfortunately in ES6, we need to manually inject them into the plugin.
  140300. * So you could set this variable to your engine import to make it work.
  140301. */
  140302. static LoaderInjectedPhysicsEngine: any;
  140303. }
  140304. }
  140305. declare module BABYLON {
  140306. /**
  140307. * The Physically based simple base material of BJS.
  140308. *
  140309. * This enables better naming and convention enforcements on top of the pbrMaterial.
  140310. * It is used as the base class for both the specGloss and metalRough conventions.
  140311. */
  140312. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  140313. /**
  140314. * Number of Simultaneous lights allowed on the material.
  140315. */
  140316. maxSimultaneousLights: number;
  140317. /**
  140318. * If sets to true, disables all the lights affecting the material.
  140319. */
  140320. disableLighting: boolean;
  140321. /**
  140322. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  140323. */
  140324. environmentTexture: BaseTexture;
  140325. /**
  140326. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  140327. */
  140328. invertNormalMapX: boolean;
  140329. /**
  140330. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  140331. */
  140332. invertNormalMapY: boolean;
  140333. /**
  140334. * Normal map used in the model.
  140335. */
  140336. normalTexture: BaseTexture;
  140337. /**
  140338. * Emissivie color used to self-illuminate the model.
  140339. */
  140340. emissiveColor: Color3;
  140341. /**
  140342. * Emissivie texture used to self-illuminate the model.
  140343. */
  140344. emissiveTexture: BaseTexture;
  140345. /**
  140346. * Occlusion Channel Strenght.
  140347. */
  140348. occlusionStrength: number;
  140349. /**
  140350. * Occlusion Texture of the material (adding extra occlusion effects).
  140351. */
  140352. occlusionTexture: BaseTexture;
  140353. /**
  140354. * Defines the alpha limits in alpha test mode.
  140355. */
  140356. alphaCutOff: number;
  140357. /**
  140358. * Gets the current double sided mode.
  140359. */
  140360. get doubleSided(): boolean;
  140361. /**
  140362. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  140363. */
  140364. set doubleSided(value: boolean);
  140365. /**
  140366. * Stores the pre-calculated light information of a mesh in a texture.
  140367. */
  140368. lightmapTexture: BaseTexture;
  140369. /**
  140370. * If true, the light map contains occlusion information instead of lighting info.
  140371. */
  140372. useLightmapAsShadowmap: boolean;
  140373. /**
  140374. * Instantiates a new PBRMaterial instance.
  140375. *
  140376. * @param name The material name
  140377. * @param scene The scene the material will be use in.
  140378. */
  140379. constructor(name: string, scene: Scene);
  140380. getClassName(): string;
  140381. }
  140382. }
  140383. declare module BABYLON {
  140384. /**
  140385. * The PBR material of BJS following the metal roughness convention.
  140386. *
  140387. * This fits to the PBR convention in the GLTF definition:
  140388. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  140389. */
  140390. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  140391. /**
  140392. * The base color has two different interpretations depending on the value of metalness.
  140393. * When the material is a metal, the base color is the specific measured reflectance value
  140394. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  140395. * of the material.
  140396. */
  140397. baseColor: Color3;
  140398. /**
  140399. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  140400. * well as opacity information in the alpha channel.
  140401. */
  140402. baseTexture: BaseTexture;
  140403. /**
  140404. * Specifies the metallic scalar value of the material.
  140405. * Can also be used to scale the metalness values of the metallic texture.
  140406. */
  140407. metallic: number;
  140408. /**
  140409. * Specifies the roughness scalar value of the material.
  140410. * Can also be used to scale the roughness values of the metallic texture.
  140411. */
  140412. roughness: number;
  140413. /**
  140414. * Texture containing both the metallic value in the B channel and the
  140415. * roughness value in the G channel to keep better precision.
  140416. */
  140417. metallicRoughnessTexture: BaseTexture;
  140418. /**
  140419. * Instantiates a new PBRMetalRoughnessMaterial instance.
  140420. *
  140421. * @param name The material name
  140422. * @param scene The scene the material will be use in.
  140423. */
  140424. constructor(name: string, scene: Scene);
  140425. /**
  140426. * Return the currrent class name of the material.
  140427. */
  140428. getClassName(): string;
  140429. /**
  140430. * Makes a duplicate of the current material.
  140431. * @param name - name to use for the new material.
  140432. */
  140433. clone(name: string): PBRMetallicRoughnessMaterial;
  140434. /**
  140435. * Serialize the material to a parsable JSON object.
  140436. */
  140437. serialize(): any;
  140438. /**
  140439. * Parses a JSON object correponding to the serialize function.
  140440. */
  140441. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  140442. }
  140443. }
  140444. declare module BABYLON {
  140445. /**
  140446. * The PBR material of BJS following the specular glossiness convention.
  140447. *
  140448. * This fits to the PBR convention in the GLTF definition:
  140449. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  140450. */
  140451. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  140452. /**
  140453. * Specifies the diffuse color of the material.
  140454. */
  140455. diffuseColor: Color3;
  140456. /**
  140457. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  140458. * channel.
  140459. */
  140460. diffuseTexture: BaseTexture;
  140461. /**
  140462. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  140463. */
  140464. specularColor: Color3;
  140465. /**
  140466. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  140467. */
  140468. glossiness: number;
  140469. /**
  140470. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  140471. */
  140472. specularGlossinessTexture: BaseTexture;
  140473. /**
  140474. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  140475. *
  140476. * @param name The material name
  140477. * @param scene The scene the material will be use in.
  140478. */
  140479. constructor(name: string, scene: Scene);
  140480. /**
  140481. * Return the currrent class name of the material.
  140482. */
  140483. getClassName(): string;
  140484. /**
  140485. * Makes a duplicate of the current material.
  140486. * @param name - name to use for the new material.
  140487. */
  140488. clone(name: string): PBRSpecularGlossinessMaterial;
  140489. /**
  140490. * Serialize the material to a parsable JSON object.
  140491. */
  140492. serialize(): any;
  140493. /**
  140494. * Parses a JSON object correponding to the serialize function.
  140495. */
  140496. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  140497. }
  140498. }
  140499. declare module BABYLON {
  140500. /**
  140501. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  140502. * It can help converting any input color in a desired output one. This can then be used to create effects
  140503. * from sepia, black and white to sixties or futuristic rendering...
  140504. *
  140505. * The only supported format is currently 3dl.
  140506. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  140507. */
  140508. export class ColorGradingTexture extends BaseTexture {
  140509. /**
  140510. * The texture URL.
  140511. */
  140512. url: string;
  140513. /**
  140514. * Empty line regex stored for GC.
  140515. */
  140516. private static _noneEmptyLineRegex;
  140517. private _textureMatrix;
  140518. private _onLoad;
  140519. /**
  140520. * Instantiates a ColorGradingTexture from the following parameters.
  140521. *
  140522. * @param url The location of the color gradind data (currently only supporting 3dl)
  140523. * @param sceneOrEngine The scene or engine the texture will be used in
  140524. * @param onLoad defines a callback triggered when the texture has been loaded
  140525. */
  140526. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  140527. /**
  140528. * Fires the onload event from the constructor if requested.
  140529. */
  140530. private _triggerOnLoad;
  140531. /**
  140532. * Returns the texture matrix used in most of the material.
  140533. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  140534. */
  140535. getTextureMatrix(): Matrix;
  140536. /**
  140537. * Occurs when the file being loaded is a .3dl LUT file.
  140538. */
  140539. private load3dlTexture;
  140540. /**
  140541. * Starts the loading process of the texture.
  140542. */
  140543. private loadTexture;
  140544. /**
  140545. * Clones the color gradind texture.
  140546. */
  140547. clone(): ColorGradingTexture;
  140548. /**
  140549. * Called during delayed load for textures.
  140550. */
  140551. delayLoad(): void;
  140552. /**
  140553. * Parses a color grading texture serialized by Babylon.
  140554. * @param parsedTexture The texture information being parsedTexture
  140555. * @param scene The scene to load the texture in
  140556. * @param rootUrl The root url of the data assets to load
  140557. * @return A color gradind texture
  140558. */
  140559. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  140560. /**
  140561. * Serializes the LUT texture to json format.
  140562. */
  140563. serialize(): any;
  140564. }
  140565. }
  140566. declare module BABYLON {
  140567. /**
  140568. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  140569. */
  140570. export class EquiRectangularCubeTexture extends BaseTexture {
  140571. /** The six faces of the cube. */
  140572. private static _FacesMapping;
  140573. private _noMipmap;
  140574. private _onLoad;
  140575. private _onError;
  140576. /** The size of the cubemap. */
  140577. private _size;
  140578. /** The buffer of the image. */
  140579. private _buffer;
  140580. /** The width of the input image. */
  140581. private _width;
  140582. /** The height of the input image. */
  140583. private _height;
  140584. /** The URL to the image. */
  140585. url: string;
  140586. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  140587. coordinatesMode: number;
  140588. /**
  140589. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  140590. * @param url The location of the image
  140591. * @param scene The scene the texture will be used in
  140592. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140593. * @param noMipmap Forces to not generate the mipmap if true
  140594. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140595. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140596. * @param onLoad — defines a callback called when texture is loaded
  140597. * @param onError — defines a callback called if there is an error
  140598. */
  140599. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  140600. /**
  140601. * Load the image data, by putting the image on a canvas and extracting its buffer.
  140602. */
  140603. private loadImage;
  140604. /**
  140605. * Convert the image buffer into a cubemap and create a CubeTexture.
  140606. */
  140607. private loadTexture;
  140608. /**
  140609. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  140610. * @param buffer The ArrayBuffer that should be converted.
  140611. * @returns The buffer as Float32Array.
  140612. */
  140613. private getFloat32ArrayFromArrayBuffer;
  140614. /**
  140615. * Get the current class name of the texture useful for serialization or dynamic coding.
  140616. * @returns "EquiRectangularCubeTexture"
  140617. */
  140618. getClassName(): string;
  140619. /**
  140620. * Create a clone of the current EquiRectangularCubeTexture and return it.
  140621. * @returns A clone of the current EquiRectangularCubeTexture.
  140622. */
  140623. clone(): EquiRectangularCubeTexture;
  140624. }
  140625. }
  140626. declare module BABYLON {
  140627. /**
  140628. * Defines the options related to the creation of an HtmlElementTexture
  140629. */
  140630. export interface IHtmlElementTextureOptions {
  140631. /**
  140632. * Defines wether mip maps should be created or not.
  140633. */
  140634. generateMipMaps?: boolean;
  140635. /**
  140636. * Defines the sampling mode of the texture.
  140637. */
  140638. samplingMode?: number;
  140639. /**
  140640. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  140641. */
  140642. engine: Nullable<ThinEngine>;
  140643. /**
  140644. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  140645. */
  140646. scene: Nullable<Scene>;
  140647. }
  140648. /**
  140649. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  140650. * To be as efficient as possible depending on your constraints nothing aside the first upload
  140651. * is automatically managed.
  140652. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  140653. * in your application.
  140654. *
  140655. * As the update is not automatic, you need to call them manually.
  140656. */
  140657. export class HtmlElementTexture extends BaseTexture {
  140658. /**
  140659. * The texture URL.
  140660. */
  140661. element: HTMLVideoElement | HTMLCanvasElement;
  140662. private static readonly DefaultOptions;
  140663. private _textureMatrix;
  140664. private _isVideo;
  140665. private _generateMipMaps;
  140666. private _samplingMode;
  140667. /**
  140668. * Instantiates a HtmlElementTexture from the following parameters.
  140669. *
  140670. * @param name Defines the name of the texture
  140671. * @param element Defines the video or canvas the texture is filled with
  140672. * @param options Defines the other none mandatory texture creation options
  140673. */
  140674. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  140675. private _createInternalTexture;
  140676. /**
  140677. * Returns the texture matrix used in most of the material.
  140678. */
  140679. getTextureMatrix(): Matrix;
  140680. /**
  140681. * Updates the content of the texture.
  140682. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140683. */
  140684. update(invertY?: Nullable<boolean>): void;
  140685. }
  140686. }
  140687. declare module BABYLON {
  140688. /**
  140689. * Based on jsTGALoader - Javascript loader for TGA file
  140690. * By Vincent Thibault
  140691. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140692. */
  140693. export class TGATools {
  140694. private static _TYPE_INDEXED;
  140695. private static _TYPE_RGB;
  140696. private static _TYPE_GREY;
  140697. private static _TYPE_RLE_INDEXED;
  140698. private static _TYPE_RLE_RGB;
  140699. private static _TYPE_RLE_GREY;
  140700. private static _ORIGIN_MASK;
  140701. private static _ORIGIN_SHIFT;
  140702. private static _ORIGIN_BL;
  140703. private static _ORIGIN_BR;
  140704. private static _ORIGIN_UL;
  140705. private static _ORIGIN_UR;
  140706. /**
  140707. * Gets the header of a TGA file
  140708. * @param data defines the TGA data
  140709. * @returns the header
  140710. */
  140711. static GetTGAHeader(data: Uint8Array): any;
  140712. /**
  140713. * Uploads TGA content to a Babylon Texture
  140714. * @hidden
  140715. */
  140716. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140717. /** @hidden */
  140718. 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;
  140719. /** @hidden */
  140720. 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;
  140721. /** @hidden */
  140722. 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;
  140723. /** @hidden */
  140724. 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;
  140725. /** @hidden */
  140726. 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;
  140727. /** @hidden */
  140728. 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;
  140729. }
  140730. }
  140731. declare module BABYLON {
  140732. /**
  140733. * Implementation of the TGA Texture Loader.
  140734. * @hidden
  140735. */
  140736. export class _TGATextureLoader implements IInternalTextureLoader {
  140737. /**
  140738. * Defines wether the loader supports cascade loading the different faces.
  140739. */
  140740. readonly supportCascades: boolean;
  140741. /**
  140742. * This returns if the loader support the current file information.
  140743. * @param extension defines the file extension of the file being loaded
  140744. * @returns true if the loader can load the specified file
  140745. */
  140746. canLoad(extension: string): boolean;
  140747. /**
  140748. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140749. * @param data contains the texture data
  140750. * @param texture defines the BabylonJS internal texture
  140751. * @param createPolynomials will be true if polynomials have been requested
  140752. * @param onLoad defines the callback to trigger once the texture is ready
  140753. * @param onError defines the callback to trigger in case of error
  140754. */
  140755. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140756. /**
  140757. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140758. * @param data contains the texture data
  140759. * @param texture defines the BabylonJS internal texture
  140760. * @param callback defines the method to call once ready to upload
  140761. */
  140762. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140763. }
  140764. }
  140765. declare module BABYLON {
  140766. /**
  140767. * Info about the .basis files
  140768. */
  140769. class BasisFileInfo {
  140770. /**
  140771. * If the file has alpha
  140772. */
  140773. hasAlpha: boolean;
  140774. /**
  140775. * Info about each image of the basis file
  140776. */
  140777. images: Array<{
  140778. levels: Array<{
  140779. width: number;
  140780. height: number;
  140781. transcodedPixels: ArrayBufferView;
  140782. }>;
  140783. }>;
  140784. }
  140785. /**
  140786. * Result of transcoding a basis file
  140787. */
  140788. class TranscodeResult {
  140789. /**
  140790. * Info about the .basis file
  140791. */
  140792. fileInfo: BasisFileInfo;
  140793. /**
  140794. * Format to use when loading the file
  140795. */
  140796. format: number;
  140797. }
  140798. /**
  140799. * Configuration options for the Basis transcoder
  140800. */
  140801. export class BasisTranscodeConfiguration {
  140802. /**
  140803. * Supported compression formats used to determine the supported output format of the transcoder
  140804. */
  140805. supportedCompressionFormats?: {
  140806. /**
  140807. * etc1 compression format
  140808. */
  140809. etc1?: boolean;
  140810. /**
  140811. * s3tc compression format
  140812. */
  140813. s3tc?: boolean;
  140814. /**
  140815. * pvrtc compression format
  140816. */
  140817. pvrtc?: boolean;
  140818. /**
  140819. * etc2 compression format
  140820. */
  140821. etc2?: boolean;
  140822. };
  140823. /**
  140824. * If mipmap levels should be loaded for transcoded images (Default: true)
  140825. */
  140826. loadMipmapLevels?: boolean;
  140827. /**
  140828. * Index of a single image to load (Default: all images)
  140829. */
  140830. loadSingleImage?: number;
  140831. }
  140832. /**
  140833. * Used to load .Basis files
  140834. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140835. */
  140836. export class BasisTools {
  140837. private static _IgnoreSupportedFormats;
  140838. /**
  140839. * URL to use when loading the basis transcoder
  140840. */
  140841. static JSModuleURL: string;
  140842. /**
  140843. * URL to use when loading the wasm module for the transcoder
  140844. */
  140845. static WasmModuleURL: string;
  140846. /**
  140847. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140848. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140849. * @returns internal format corresponding to the Basis format
  140850. */
  140851. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140852. private static _WorkerPromise;
  140853. private static _Worker;
  140854. private static _actionId;
  140855. private static _CreateWorkerAsync;
  140856. /**
  140857. * Transcodes a loaded image file to compressed pixel data
  140858. * @param data image data to transcode
  140859. * @param config configuration options for the transcoding
  140860. * @returns a promise resulting in the transcoded image
  140861. */
  140862. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140863. /**
  140864. * Loads a texture from the transcode result
  140865. * @param texture texture load to
  140866. * @param transcodeResult the result of transcoding the basis file to load from
  140867. */
  140868. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140869. }
  140870. }
  140871. declare module BABYLON {
  140872. /**
  140873. * Loader for .basis file format
  140874. */
  140875. export class _BasisTextureLoader implements IInternalTextureLoader {
  140876. /**
  140877. * Defines whether the loader supports cascade loading the different faces.
  140878. */
  140879. readonly supportCascades: boolean;
  140880. /**
  140881. * This returns if the loader support the current file information.
  140882. * @param extension defines the file extension of the file being loaded
  140883. * @returns true if the loader can load the specified file
  140884. */
  140885. canLoad(extension: string): boolean;
  140886. /**
  140887. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140888. * @param data contains the texture data
  140889. * @param texture defines the BabylonJS internal texture
  140890. * @param createPolynomials will be true if polynomials have been requested
  140891. * @param onLoad defines the callback to trigger once the texture is ready
  140892. * @param onError defines the callback to trigger in case of error
  140893. */
  140894. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140895. /**
  140896. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140897. * @param data contains the texture data
  140898. * @param texture defines the BabylonJS internal texture
  140899. * @param callback defines the method to call once ready to upload
  140900. */
  140901. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140902. }
  140903. }
  140904. declare module BABYLON {
  140905. /**
  140906. * Defines the basic options interface of a TexturePacker Frame
  140907. */
  140908. export interface ITexturePackerFrame {
  140909. /**
  140910. * The frame ID
  140911. */
  140912. id: number;
  140913. /**
  140914. * The frames Scale
  140915. */
  140916. scale: Vector2;
  140917. /**
  140918. * The Frames offset
  140919. */
  140920. offset: Vector2;
  140921. }
  140922. /**
  140923. * This is a support class for frame Data on texture packer sets.
  140924. */
  140925. export class TexturePackerFrame implements ITexturePackerFrame {
  140926. /**
  140927. * The frame ID
  140928. */
  140929. id: number;
  140930. /**
  140931. * The frames Scale
  140932. */
  140933. scale: Vector2;
  140934. /**
  140935. * The Frames offset
  140936. */
  140937. offset: Vector2;
  140938. /**
  140939. * Initializes a texture package frame.
  140940. * @param id The numerical frame identifier
  140941. * @param scale Scalar Vector2 for UV frame
  140942. * @param offset Vector2 for the frame position in UV units.
  140943. * @returns TexturePackerFrame
  140944. */
  140945. constructor(id: number, scale: Vector2, offset: Vector2);
  140946. }
  140947. }
  140948. declare module BABYLON {
  140949. /**
  140950. * Defines the basic options interface of a TexturePacker
  140951. */
  140952. export interface ITexturePackerOptions {
  140953. /**
  140954. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140955. */
  140956. map?: string[];
  140957. /**
  140958. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140959. */
  140960. uvsIn?: string;
  140961. /**
  140962. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140963. */
  140964. uvsOut?: string;
  140965. /**
  140966. * number representing the layout style. Defaults to LAYOUT_STRIP
  140967. */
  140968. layout?: number;
  140969. /**
  140970. * number of columns if using custom column count layout(2). This defaults to 4.
  140971. */
  140972. colnum?: number;
  140973. /**
  140974. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140975. */
  140976. updateInputMeshes?: boolean;
  140977. /**
  140978. * boolean flag to dispose all the source textures. Defaults to true.
  140979. */
  140980. disposeSources?: boolean;
  140981. /**
  140982. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140983. */
  140984. fillBlanks?: boolean;
  140985. /**
  140986. * string value representing the context fill style color. Defaults to 'black'.
  140987. */
  140988. customFillColor?: string;
  140989. /**
  140990. * Width and Height Value of each Frame in the TexturePacker Sets
  140991. */
  140992. frameSize?: number;
  140993. /**
  140994. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140995. */
  140996. paddingRatio?: number;
  140997. /**
  140998. * Number that declares the fill method for the padding gutter.
  140999. */
  141000. paddingMode?: number;
  141001. /**
  141002. * If in SUBUV_COLOR padding mode what color to use.
  141003. */
  141004. paddingColor?: Color3 | Color4;
  141005. }
  141006. /**
  141007. * Defines the basic interface of a TexturePacker JSON File
  141008. */
  141009. export interface ITexturePackerJSON {
  141010. /**
  141011. * The frame ID
  141012. */
  141013. name: string;
  141014. /**
  141015. * The base64 channel data
  141016. */
  141017. sets: any;
  141018. /**
  141019. * The options of the Packer
  141020. */
  141021. options: ITexturePackerOptions;
  141022. /**
  141023. * The frame data of the Packer
  141024. */
  141025. frames: Array<number>;
  141026. }
  141027. /**
  141028. * This is a support class that generates a series of packed texture sets.
  141029. * @see https://doc.babylonjs.com/babylon101/materials
  141030. */
  141031. export class TexturePacker {
  141032. /** Packer Layout Constant 0 */
  141033. static readonly LAYOUT_STRIP: number;
  141034. /** Packer Layout Constant 1 */
  141035. static readonly LAYOUT_POWER2: number;
  141036. /** Packer Layout Constant 2 */
  141037. static readonly LAYOUT_COLNUM: number;
  141038. /** Packer Layout Constant 0 */
  141039. static readonly SUBUV_WRAP: number;
  141040. /** Packer Layout Constant 1 */
  141041. static readonly SUBUV_EXTEND: number;
  141042. /** Packer Layout Constant 2 */
  141043. static readonly SUBUV_COLOR: number;
  141044. /** The Name of the Texture Package */
  141045. name: string;
  141046. /** The scene scope of the TexturePacker */
  141047. scene: Scene;
  141048. /** The Meshes to target */
  141049. meshes: AbstractMesh[];
  141050. /** Arguments passed with the Constructor */
  141051. options: ITexturePackerOptions;
  141052. /** The promise that is started upon initialization */
  141053. promise: Nullable<Promise<TexturePacker | string>>;
  141054. /** The Container object for the channel sets that are generated */
  141055. sets: object;
  141056. /** The Container array for the frames that are generated */
  141057. frames: TexturePackerFrame[];
  141058. /** The expected number of textures the system is parsing. */
  141059. private _expecting;
  141060. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  141061. private _paddingValue;
  141062. /**
  141063. * Initializes a texture package series from an array of meshes or a single mesh.
  141064. * @param name The name of the package
  141065. * @param meshes The target meshes to compose the package from
  141066. * @param options The arguments that texture packer should follow while building.
  141067. * @param scene The scene which the textures are scoped to.
  141068. * @returns TexturePacker
  141069. */
  141070. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  141071. /**
  141072. * Starts the package process
  141073. * @param resolve The promises resolution function
  141074. * @returns TexturePacker
  141075. */
  141076. private _createFrames;
  141077. /**
  141078. * Calculates the Size of the Channel Sets
  141079. * @returns Vector2
  141080. */
  141081. private _calculateSize;
  141082. /**
  141083. * Calculates the UV data for the frames.
  141084. * @param baseSize the base frameSize
  141085. * @param padding the base frame padding
  141086. * @param dtSize size of the Dynamic Texture for that channel
  141087. * @param dtUnits is 1/dtSize
  141088. * @param update flag to update the input meshes
  141089. */
  141090. private _calculateMeshUVFrames;
  141091. /**
  141092. * Calculates the frames Offset.
  141093. * @param index of the frame
  141094. * @returns Vector2
  141095. */
  141096. private _getFrameOffset;
  141097. /**
  141098. * Updates a Mesh to the frame data
  141099. * @param mesh that is the target
  141100. * @param frameID or the frame index
  141101. */
  141102. private _updateMeshUV;
  141103. /**
  141104. * Updates a Meshes materials to use the texture packer channels
  141105. * @param m is the mesh to target
  141106. * @param force all channels on the packer to be set.
  141107. */
  141108. private _updateTextureReferences;
  141109. /**
  141110. * Public method to set a Mesh to a frame
  141111. * @param m that is the target
  141112. * @param frameID or the frame index
  141113. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  141114. */
  141115. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  141116. /**
  141117. * Starts the async promise to compile the texture packer.
  141118. * @returns Promise<void>
  141119. */
  141120. processAsync(): Promise<void>;
  141121. /**
  141122. * Disposes all textures associated with this packer
  141123. */
  141124. dispose(): void;
  141125. /**
  141126. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  141127. * @param imageType is the image type to use.
  141128. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  141129. */
  141130. download(imageType?: string, quality?: number): void;
  141131. /**
  141132. * Public method to load a texturePacker JSON file.
  141133. * @param data of the JSON file in string format.
  141134. */
  141135. updateFromJSON(data: string): void;
  141136. }
  141137. }
  141138. declare module BABYLON {
  141139. /**
  141140. * 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.
  141141. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141142. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141143. */
  141144. export class CustomProceduralTexture extends ProceduralTexture {
  141145. private _animate;
  141146. private _time;
  141147. private _config;
  141148. private _texturePath;
  141149. /**
  141150. * Instantiates a new Custom Procedural Texture.
  141151. * 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.
  141152. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141153. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141154. * @param name Define the name of the texture
  141155. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  141156. * @param size Define the size of the texture to create
  141157. * @param scene Define the scene the texture belongs to
  141158. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  141159. * @param generateMipMaps Define if the texture should creates mip maps or not
  141160. */
  141161. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141162. private _loadJson;
  141163. /**
  141164. * Is the texture ready to be used ? (rendered at least once)
  141165. * @returns true if ready, otherwise, false.
  141166. */
  141167. isReady(): boolean;
  141168. /**
  141169. * Render the texture to its associated render target.
  141170. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  141171. */
  141172. render(useCameraPostProcess?: boolean): void;
  141173. /**
  141174. * Update the list of dependant textures samplers in the shader.
  141175. */
  141176. updateTextures(): void;
  141177. /**
  141178. * Update the uniform values of the procedural texture in the shader.
  141179. */
  141180. updateShaderUniforms(): void;
  141181. /**
  141182. * Define if the texture animates or not.
  141183. */
  141184. get animate(): boolean;
  141185. set animate(value: boolean);
  141186. }
  141187. }
  141188. declare module BABYLON {
  141189. /** @hidden */
  141190. export var noisePixelShader: {
  141191. name: string;
  141192. shader: string;
  141193. };
  141194. }
  141195. declare module BABYLON {
  141196. /**
  141197. * Class used to generate noise procedural textures
  141198. */
  141199. export class NoiseProceduralTexture extends ProceduralTexture {
  141200. private _time;
  141201. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  141202. brightness: number;
  141203. /** Defines the number of octaves to process */
  141204. octaves: number;
  141205. /** Defines the level of persistence (0.8 by default) */
  141206. persistence: number;
  141207. /** Gets or sets animation speed factor (default is 1) */
  141208. animationSpeedFactor: number;
  141209. /**
  141210. * Creates a new NoiseProceduralTexture
  141211. * @param name defines the name fo the texture
  141212. * @param size defines the size of the texture (default is 256)
  141213. * @param scene defines the hosting scene
  141214. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  141215. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  141216. */
  141217. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141218. private _updateShaderUniforms;
  141219. protected _getDefines(): string;
  141220. /** Generate the current state of the procedural texture */
  141221. render(useCameraPostProcess?: boolean): void;
  141222. /**
  141223. * Serializes this noise procedural texture
  141224. * @returns a serialized noise procedural texture object
  141225. */
  141226. serialize(): any;
  141227. /**
  141228. * Clone the texture.
  141229. * @returns the cloned texture
  141230. */
  141231. clone(): NoiseProceduralTexture;
  141232. /**
  141233. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  141234. * @param parsedTexture defines parsed texture data
  141235. * @param scene defines the current scene
  141236. * @param rootUrl defines the root URL containing noise procedural texture information
  141237. * @returns a parsed NoiseProceduralTexture
  141238. */
  141239. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  141240. }
  141241. }
  141242. declare module BABYLON {
  141243. /**
  141244. * Raw cube texture where the raw buffers are passed in
  141245. */
  141246. export class RawCubeTexture extends CubeTexture {
  141247. /**
  141248. * Creates a cube texture where the raw buffers are passed in.
  141249. * @param scene defines the scene the texture is attached to
  141250. * @param data defines the array of data to use to create each face
  141251. * @param size defines the size of the textures
  141252. * @param format defines the format of the data
  141253. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  141254. * @param generateMipMaps defines if the engine should generate the mip levels
  141255. * @param invertY defines if data must be stored with Y axis inverted
  141256. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  141257. * @param compression defines the compression used (null by default)
  141258. */
  141259. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  141260. /**
  141261. * Updates the raw cube texture.
  141262. * @param data defines the data to store
  141263. * @param format defines the data format
  141264. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141265. * @param invertY defines if data must be stored with Y axis inverted
  141266. * @param compression defines the compression used (null by default)
  141267. * @param level defines which level of the texture to update
  141268. */
  141269. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  141270. /**
  141271. * Updates a raw cube texture with RGBD encoded data.
  141272. * @param data defines the array of data [mipmap][face] to use to create each face
  141273. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  141274. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  141275. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  141276. * @returns a promsie that resolves when the operation is complete
  141277. */
  141278. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  141279. /**
  141280. * Clones the raw cube texture.
  141281. * @return a new cube texture
  141282. */
  141283. clone(): CubeTexture;
  141284. /** @hidden */
  141285. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  141286. }
  141287. }
  141288. declare module BABYLON {
  141289. /**
  141290. * Class used to store 2D array textures containing user data
  141291. */
  141292. export class RawTexture2DArray extends Texture {
  141293. /** Gets or sets the texture format to use */
  141294. format: number;
  141295. /**
  141296. * Create a new RawTexture2DArray
  141297. * @param data defines the data of the texture
  141298. * @param width defines the width of the texture
  141299. * @param height defines the height of the texture
  141300. * @param depth defines the number of layers of the texture
  141301. * @param format defines the texture format to use
  141302. * @param scene defines the hosting scene
  141303. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141304. * @param invertY defines if texture must be stored with Y axis inverted
  141305. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141306. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141307. */
  141308. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141309. /** Gets or sets the texture format to use */
  141310. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141311. /**
  141312. * Update the texture with new data
  141313. * @param data defines the data to store in the texture
  141314. */
  141315. update(data: ArrayBufferView): void;
  141316. }
  141317. }
  141318. declare module BABYLON {
  141319. /**
  141320. * Class used to store 3D textures containing user data
  141321. */
  141322. export class RawTexture3D extends Texture {
  141323. /** Gets or sets the texture format to use */
  141324. format: number;
  141325. /**
  141326. * Create a new RawTexture3D
  141327. * @param data defines the data of the texture
  141328. * @param width defines the width of the texture
  141329. * @param height defines the height of the texture
  141330. * @param depth defines the depth of the texture
  141331. * @param format defines the texture format to use
  141332. * @param scene defines the hosting scene
  141333. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141334. * @param invertY defines if texture must be stored with Y axis inverted
  141335. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141336. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141337. */
  141338. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141339. /** Gets or sets the texture format to use */
  141340. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141341. /**
  141342. * Update the texture with new data
  141343. * @param data defines the data to store in the texture
  141344. */
  141345. update(data: ArrayBufferView): void;
  141346. }
  141347. }
  141348. declare module BABYLON {
  141349. /**
  141350. * Creates a refraction texture used by refraction channel of the standard material.
  141351. * It is like a mirror but to see through a material.
  141352. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141353. */
  141354. export class RefractionTexture extends RenderTargetTexture {
  141355. /**
  141356. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  141357. * 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.
  141358. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141359. */
  141360. refractionPlane: Plane;
  141361. /**
  141362. * Define how deep under the surface we should see.
  141363. */
  141364. depth: number;
  141365. /**
  141366. * Creates a refraction texture used by refraction channel of the standard material.
  141367. * It is like a mirror but to see through a material.
  141368. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141369. * @param name Define the texture name
  141370. * @param size Define the size of the underlying texture
  141371. * @param scene Define the scene the refraction belongs to
  141372. * @param generateMipMaps Define if we need to generate mips level for the refraction
  141373. */
  141374. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  141375. /**
  141376. * Clone the refraction texture.
  141377. * @returns the cloned texture
  141378. */
  141379. clone(): RefractionTexture;
  141380. /**
  141381. * Serialize the texture to a JSON representation you could use in Parse later on
  141382. * @returns the serialized JSON representation
  141383. */
  141384. serialize(): any;
  141385. }
  141386. }
  141387. declare module BABYLON {
  141388. /**
  141389. * Block used to add support for vertex skinning (bones)
  141390. */
  141391. export class BonesBlock extends NodeMaterialBlock {
  141392. /**
  141393. * Creates a new BonesBlock
  141394. * @param name defines the block name
  141395. */
  141396. constructor(name: string);
  141397. /**
  141398. * Initialize the block and prepare the context for build
  141399. * @param state defines the state that will be used for the build
  141400. */
  141401. initialize(state: NodeMaterialBuildState): void;
  141402. /**
  141403. * Gets the current class name
  141404. * @returns the class name
  141405. */
  141406. getClassName(): string;
  141407. /**
  141408. * Gets the matrix indices input component
  141409. */
  141410. get matricesIndices(): NodeMaterialConnectionPoint;
  141411. /**
  141412. * Gets the matrix weights input component
  141413. */
  141414. get matricesWeights(): NodeMaterialConnectionPoint;
  141415. /**
  141416. * Gets the extra matrix indices input component
  141417. */
  141418. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  141419. /**
  141420. * Gets the extra matrix weights input component
  141421. */
  141422. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  141423. /**
  141424. * Gets the world input component
  141425. */
  141426. get world(): NodeMaterialConnectionPoint;
  141427. /**
  141428. * Gets the output component
  141429. */
  141430. get output(): NodeMaterialConnectionPoint;
  141431. autoConfigure(material: NodeMaterial): void;
  141432. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  141433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141435. protected _buildBlock(state: NodeMaterialBuildState): this;
  141436. }
  141437. }
  141438. declare module BABYLON {
  141439. /**
  141440. * Block used to add support for instances
  141441. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  141442. */
  141443. export class InstancesBlock extends NodeMaterialBlock {
  141444. /**
  141445. * Creates a new InstancesBlock
  141446. * @param name defines the block name
  141447. */
  141448. constructor(name: string);
  141449. /**
  141450. * Gets the current class name
  141451. * @returns the class name
  141452. */
  141453. getClassName(): string;
  141454. /**
  141455. * Gets the first world row input component
  141456. */
  141457. get world0(): NodeMaterialConnectionPoint;
  141458. /**
  141459. * Gets the second world row input component
  141460. */
  141461. get world1(): NodeMaterialConnectionPoint;
  141462. /**
  141463. * Gets the third world row input component
  141464. */
  141465. get world2(): NodeMaterialConnectionPoint;
  141466. /**
  141467. * Gets the forth world row input component
  141468. */
  141469. get world3(): NodeMaterialConnectionPoint;
  141470. /**
  141471. * Gets the world input component
  141472. */
  141473. get world(): NodeMaterialConnectionPoint;
  141474. /**
  141475. * Gets the output component
  141476. */
  141477. get output(): NodeMaterialConnectionPoint;
  141478. /**
  141479. * Gets the isntanceID component
  141480. */
  141481. get instanceID(): NodeMaterialConnectionPoint;
  141482. autoConfigure(material: NodeMaterial): void;
  141483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  141484. protected _buildBlock(state: NodeMaterialBuildState): this;
  141485. }
  141486. }
  141487. declare module BABYLON {
  141488. /**
  141489. * Block used to add morph targets support to vertex shader
  141490. */
  141491. export class MorphTargetsBlock extends NodeMaterialBlock {
  141492. private _repeatableContentAnchor;
  141493. /**
  141494. * Create a new MorphTargetsBlock
  141495. * @param name defines the block name
  141496. */
  141497. constructor(name: string);
  141498. /**
  141499. * Gets the current class name
  141500. * @returns the class name
  141501. */
  141502. getClassName(): string;
  141503. /**
  141504. * Gets the position input component
  141505. */
  141506. get position(): NodeMaterialConnectionPoint;
  141507. /**
  141508. * Gets the normal input component
  141509. */
  141510. get normal(): NodeMaterialConnectionPoint;
  141511. /**
  141512. * Gets the tangent input component
  141513. */
  141514. get tangent(): NodeMaterialConnectionPoint;
  141515. /**
  141516. * Gets the tangent input component
  141517. */
  141518. get uv(): NodeMaterialConnectionPoint;
  141519. /**
  141520. * Gets the position output component
  141521. */
  141522. get positionOutput(): NodeMaterialConnectionPoint;
  141523. /**
  141524. * Gets the normal output component
  141525. */
  141526. get normalOutput(): NodeMaterialConnectionPoint;
  141527. /**
  141528. * Gets the tangent output component
  141529. */
  141530. get tangentOutput(): NodeMaterialConnectionPoint;
  141531. /**
  141532. * Gets the tangent output component
  141533. */
  141534. get uvOutput(): NodeMaterialConnectionPoint;
  141535. initialize(state: NodeMaterialBuildState): void;
  141536. autoConfigure(material: NodeMaterial): void;
  141537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141539. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  141540. protected _buildBlock(state: NodeMaterialBuildState): this;
  141541. }
  141542. }
  141543. declare module BABYLON {
  141544. /**
  141545. * Block used to get data information from a light
  141546. */
  141547. export class LightInformationBlock extends NodeMaterialBlock {
  141548. private _lightDataUniformName;
  141549. private _lightColorUniformName;
  141550. private _lightTypeDefineName;
  141551. /**
  141552. * Gets or sets the light associated with this block
  141553. */
  141554. light: Nullable<Light>;
  141555. /**
  141556. * Creates a new LightInformationBlock
  141557. * @param name defines the block name
  141558. */
  141559. constructor(name: string);
  141560. /**
  141561. * Gets the current class name
  141562. * @returns the class name
  141563. */
  141564. getClassName(): string;
  141565. /**
  141566. * Gets the world position input component
  141567. */
  141568. get worldPosition(): NodeMaterialConnectionPoint;
  141569. /**
  141570. * Gets the direction output component
  141571. */
  141572. get direction(): NodeMaterialConnectionPoint;
  141573. /**
  141574. * Gets the direction output component
  141575. */
  141576. get color(): NodeMaterialConnectionPoint;
  141577. /**
  141578. * Gets the direction output component
  141579. */
  141580. get intensity(): NodeMaterialConnectionPoint;
  141581. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141583. protected _buildBlock(state: NodeMaterialBuildState): this;
  141584. serialize(): any;
  141585. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141586. }
  141587. }
  141588. declare module BABYLON {
  141589. /**
  141590. * Block used to add image processing support to fragment shader
  141591. */
  141592. export class ImageProcessingBlock extends NodeMaterialBlock {
  141593. /**
  141594. * Create a new ImageProcessingBlock
  141595. * @param name defines the block name
  141596. */
  141597. constructor(name: string);
  141598. /**
  141599. * Gets the current class name
  141600. * @returns the class name
  141601. */
  141602. getClassName(): string;
  141603. /**
  141604. * Gets the color input component
  141605. */
  141606. get color(): NodeMaterialConnectionPoint;
  141607. /**
  141608. * Gets the output component
  141609. */
  141610. get output(): NodeMaterialConnectionPoint;
  141611. /**
  141612. * Initialize the block and prepare the context for build
  141613. * @param state defines the state that will be used for the build
  141614. */
  141615. initialize(state: NodeMaterialBuildState): void;
  141616. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  141617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141619. protected _buildBlock(state: NodeMaterialBuildState): this;
  141620. }
  141621. }
  141622. declare module BABYLON {
  141623. /**
  141624. * Block used to pertub normals based on a normal map
  141625. */
  141626. export class PerturbNormalBlock extends NodeMaterialBlock {
  141627. private _tangentSpaceParameterName;
  141628. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141629. invertX: boolean;
  141630. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  141631. invertY: boolean;
  141632. /**
  141633. * Create a new PerturbNormalBlock
  141634. * @param name defines the block name
  141635. */
  141636. constructor(name: string);
  141637. /**
  141638. * Gets the current class name
  141639. * @returns the class name
  141640. */
  141641. getClassName(): string;
  141642. /**
  141643. * Gets the world position input component
  141644. */
  141645. get worldPosition(): NodeMaterialConnectionPoint;
  141646. /**
  141647. * Gets the world normal input component
  141648. */
  141649. get worldNormal(): NodeMaterialConnectionPoint;
  141650. /**
  141651. * Gets the world tangent input component
  141652. */
  141653. get worldTangent(): NodeMaterialConnectionPoint;
  141654. /**
  141655. * Gets the uv input component
  141656. */
  141657. get uv(): NodeMaterialConnectionPoint;
  141658. /**
  141659. * Gets the normal map color input component
  141660. */
  141661. get normalMapColor(): NodeMaterialConnectionPoint;
  141662. /**
  141663. * Gets the strength input component
  141664. */
  141665. get strength(): NodeMaterialConnectionPoint;
  141666. /**
  141667. * Gets the output component
  141668. */
  141669. get output(): NodeMaterialConnectionPoint;
  141670. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141672. autoConfigure(material: NodeMaterial): void;
  141673. protected _buildBlock(state: NodeMaterialBuildState): this;
  141674. protected _dumpPropertiesCode(): string;
  141675. serialize(): any;
  141676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141677. }
  141678. }
  141679. declare module BABYLON {
  141680. /**
  141681. * Block used to discard a pixel if a value is smaller than a cutoff
  141682. */
  141683. export class DiscardBlock extends NodeMaterialBlock {
  141684. /**
  141685. * Create a new DiscardBlock
  141686. * @param name defines the block name
  141687. */
  141688. constructor(name: string);
  141689. /**
  141690. * Gets the current class name
  141691. * @returns the class name
  141692. */
  141693. getClassName(): string;
  141694. /**
  141695. * Gets the color input component
  141696. */
  141697. get value(): NodeMaterialConnectionPoint;
  141698. /**
  141699. * Gets the cutoff input component
  141700. */
  141701. get cutoff(): NodeMaterialConnectionPoint;
  141702. protected _buildBlock(state: NodeMaterialBuildState): this;
  141703. }
  141704. }
  141705. declare module BABYLON {
  141706. /**
  141707. * Block used to test if the fragment shader is front facing
  141708. */
  141709. export class FrontFacingBlock extends NodeMaterialBlock {
  141710. /**
  141711. * Creates a new FrontFacingBlock
  141712. * @param name defines the block name
  141713. */
  141714. constructor(name: string);
  141715. /**
  141716. * Gets the current class name
  141717. * @returns the class name
  141718. */
  141719. getClassName(): string;
  141720. /**
  141721. * Gets the output component
  141722. */
  141723. get output(): NodeMaterialConnectionPoint;
  141724. protected _buildBlock(state: NodeMaterialBuildState): this;
  141725. }
  141726. }
  141727. declare module BABYLON {
  141728. /**
  141729. * Block used to get the derivative value on x and y of a given input
  141730. */
  141731. export class DerivativeBlock extends NodeMaterialBlock {
  141732. /**
  141733. * Create a new DerivativeBlock
  141734. * @param name defines the block name
  141735. */
  141736. constructor(name: string);
  141737. /**
  141738. * Gets the current class name
  141739. * @returns the class name
  141740. */
  141741. getClassName(): string;
  141742. /**
  141743. * Gets the input component
  141744. */
  141745. get input(): NodeMaterialConnectionPoint;
  141746. /**
  141747. * Gets the derivative output on x
  141748. */
  141749. get dx(): NodeMaterialConnectionPoint;
  141750. /**
  141751. * Gets the derivative output on y
  141752. */
  141753. get dy(): NodeMaterialConnectionPoint;
  141754. protected _buildBlock(state: NodeMaterialBuildState): this;
  141755. }
  141756. }
  141757. declare module BABYLON {
  141758. /**
  141759. * Block used to make gl_FragCoord available
  141760. */
  141761. export class FragCoordBlock extends NodeMaterialBlock {
  141762. /**
  141763. * Creates a new FragCoordBlock
  141764. * @param name defines the block name
  141765. */
  141766. constructor(name: string);
  141767. /**
  141768. * Gets the current class name
  141769. * @returns the class name
  141770. */
  141771. getClassName(): string;
  141772. /**
  141773. * Gets the xy component
  141774. */
  141775. get xy(): NodeMaterialConnectionPoint;
  141776. /**
  141777. * Gets the xyz component
  141778. */
  141779. get xyz(): NodeMaterialConnectionPoint;
  141780. /**
  141781. * Gets the xyzw component
  141782. */
  141783. get xyzw(): NodeMaterialConnectionPoint;
  141784. /**
  141785. * Gets the x component
  141786. */
  141787. get x(): NodeMaterialConnectionPoint;
  141788. /**
  141789. * Gets the y component
  141790. */
  141791. get y(): NodeMaterialConnectionPoint;
  141792. /**
  141793. * Gets the z component
  141794. */
  141795. get z(): NodeMaterialConnectionPoint;
  141796. /**
  141797. * Gets the w component
  141798. */
  141799. get output(): NodeMaterialConnectionPoint;
  141800. protected writeOutputs(state: NodeMaterialBuildState): string;
  141801. protected _buildBlock(state: NodeMaterialBuildState): this;
  141802. }
  141803. }
  141804. declare module BABYLON {
  141805. /**
  141806. * Block used to get the screen sizes
  141807. */
  141808. export class ScreenSizeBlock extends NodeMaterialBlock {
  141809. private _varName;
  141810. private _scene;
  141811. /**
  141812. * Creates a new ScreenSizeBlock
  141813. * @param name defines the block name
  141814. */
  141815. constructor(name: string);
  141816. /**
  141817. * Gets the current class name
  141818. * @returns the class name
  141819. */
  141820. getClassName(): string;
  141821. /**
  141822. * Gets the xy component
  141823. */
  141824. get xy(): NodeMaterialConnectionPoint;
  141825. /**
  141826. * Gets the x component
  141827. */
  141828. get x(): NodeMaterialConnectionPoint;
  141829. /**
  141830. * Gets the y component
  141831. */
  141832. get y(): NodeMaterialConnectionPoint;
  141833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141834. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141835. protected _buildBlock(state: NodeMaterialBuildState): this;
  141836. }
  141837. }
  141838. declare module BABYLON {
  141839. /**
  141840. * Block used to add support for scene fog
  141841. */
  141842. export class FogBlock extends NodeMaterialBlock {
  141843. private _fogDistanceName;
  141844. private _fogParameters;
  141845. /**
  141846. * Create a new FogBlock
  141847. * @param name defines the block name
  141848. */
  141849. constructor(name: string);
  141850. /**
  141851. * Gets the current class name
  141852. * @returns the class name
  141853. */
  141854. getClassName(): string;
  141855. /**
  141856. * Gets the world position input component
  141857. */
  141858. get worldPosition(): NodeMaterialConnectionPoint;
  141859. /**
  141860. * Gets the view input component
  141861. */
  141862. get view(): NodeMaterialConnectionPoint;
  141863. /**
  141864. * Gets the color input component
  141865. */
  141866. get input(): NodeMaterialConnectionPoint;
  141867. /**
  141868. * Gets the fog color input component
  141869. */
  141870. get fogColor(): NodeMaterialConnectionPoint;
  141871. /**
  141872. * Gets the output component
  141873. */
  141874. get output(): NodeMaterialConnectionPoint;
  141875. autoConfigure(material: NodeMaterial): void;
  141876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141878. protected _buildBlock(state: NodeMaterialBuildState): this;
  141879. }
  141880. }
  141881. declare module BABYLON {
  141882. /**
  141883. * Block used to add light in the fragment shader
  141884. */
  141885. export class LightBlock extends NodeMaterialBlock {
  141886. private _lightId;
  141887. /**
  141888. * Gets or sets the light associated with this block
  141889. */
  141890. light: Nullable<Light>;
  141891. /**
  141892. * Create a new LightBlock
  141893. * @param name defines the block name
  141894. */
  141895. constructor(name: string);
  141896. /**
  141897. * Gets the current class name
  141898. * @returns the class name
  141899. */
  141900. getClassName(): string;
  141901. /**
  141902. * Gets the world position input component
  141903. */
  141904. get worldPosition(): NodeMaterialConnectionPoint;
  141905. /**
  141906. * Gets the world normal input component
  141907. */
  141908. get worldNormal(): NodeMaterialConnectionPoint;
  141909. /**
  141910. * Gets the camera (or eye) position component
  141911. */
  141912. get cameraPosition(): NodeMaterialConnectionPoint;
  141913. /**
  141914. * Gets the glossiness component
  141915. */
  141916. get glossiness(): NodeMaterialConnectionPoint;
  141917. /**
  141918. * Gets the glossinness power component
  141919. */
  141920. get glossPower(): NodeMaterialConnectionPoint;
  141921. /**
  141922. * Gets the diffuse color component
  141923. */
  141924. get diffuseColor(): NodeMaterialConnectionPoint;
  141925. /**
  141926. * Gets the specular color component
  141927. */
  141928. get specularColor(): NodeMaterialConnectionPoint;
  141929. /**
  141930. * Gets the diffuse output component
  141931. */
  141932. get diffuseOutput(): NodeMaterialConnectionPoint;
  141933. /**
  141934. * Gets the specular output component
  141935. */
  141936. get specularOutput(): NodeMaterialConnectionPoint;
  141937. /**
  141938. * Gets the shadow output component
  141939. */
  141940. get shadow(): NodeMaterialConnectionPoint;
  141941. autoConfigure(material: NodeMaterial): void;
  141942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141943. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141944. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141945. private _injectVertexCode;
  141946. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141947. serialize(): any;
  141948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141949. }
  141950. }
  141951. declare module BABYLON {
  141952. /**
  141953. * Block used to read a reflection texture from a sampler
  141954. */
  141955. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141956. /**
  141957. * Create a new ReflectionTextureBlock
  141958. * @param name defines the block name
  141959. */
  141960. constructor(name: string);
  141961. /**
  141962. * Gets the current class name
  141963. * @returns the class name
  141964. */
  141965. getClassName(): string;
  141966. /**
  141967. * Gets the world position input component
  141968. */
  141969. get position(): NodeMaterialConnectionPoint;
  141970. /**
  141971. * Gets the world position input component
  141972. */
  141973. get worldPosition(): NodeMaterialConnectionPoint;
  141974. /**
  141975. * Gets the world normal input component
  141976. */
  141977. get worldNormal(): NodeMaterialConnectionPoint;
  141978. /**
  141979. * Gets the world input component
  141980. */
  141981. get world(): NodeMaterialConnectionPoint;
  141982. /**
  141983. * Gets the camera (or eye) position component
  141984. */
  141985. get cameraPosition(): NodeMaterialConnectionPoint;
  141986. /**
  141987. * Gets the view input component
  141988. */
  141989. get view(): NodeMaterialConnectionPoint;
  141990. /**
  141991. * Gets the rgb output component
  141992. */
  141993. get rgb(): NodeMaterialConnectionPoint;
  141994. /**
  141995. * Gets the rgba output component
  141996. */
  141997. get rgba(): NodeMaterialConnectionPoint;
  141998. /**
  141999. * Gets the r output component
  142000. */
  142001. get r(): NodeMaterialConnectionPoint;
  142002. /**
  142003. * Gets the g output component
  142004. */
  142005. get g(): NodeMaterialConnectionPoint;
  142006. /**
  142007. * Gets the b output component
  142008. */
  142009. get b(): NodeMaterialConnectionPoint;
  142010. /**
  142011. * Gets the a output component
  142012. */
  142013. get a(): NodeMaterialConnectionPoint;
  142014. autoConfigure(material: NodeMaterial): void;
  142015. protected _buildBlock(state: NodeMaterialBuildState): this;
  142016. }
  142017. }
  142018. declare module BABYLON {
  142019. /**
  142020. * Block used to add 2 vectors
  142021. */
  142022. export class AddBlock extends NodeMaterialBlock {
  142023. /**
  142024. * Creates a new AddBlock
  142025. * @param name defines the block name
  142026. */
  142027. constructor(name: string);
  142028. /**
  142029. * Gets the current class name
  142030. * @returns the class name
  142031. */
  142032. getClassName(): string;
  142033. /**
  142034. * Gets the left operand input component
  142035. */
  142036. get left(): NodeMaterialConnectionPoint;
  142037. /**
  142038. * Gets the right operand input component
  142039. */
  142040. get right(): NodeMaterialConnectionPoint;
  142041. /**
  142042. * Gets the output component
  142043. */
  142044. get output(): NodeMaterialConnectionPoint;
  142045. protected _buildBlock(state: NodeMaterialBuildState): this;
  142046. }
  142047. }
  142048. declare module BABYLON {
  142049. /**
  142050. * Block used to scale a vector by a float
  142051. */
  142052. export class ScaleBlock extends NodeMaterialBlock {
  142053. /**
  142054. * Creates a new ScaleBlock
  142055. * @param name defines the block name
  142056. */
  142057. constructor(name: string);
  142058. /**
  142059. * Gets the current class name
  142060. * @returns the class name
  142061. */
  142062. getClassName(): string;
  142063. /**
  142064. * Gets the input component
  142065. */
  142066. get input(): NodeMaterialConnectionPoint;
  142067. /**
  142068. * Gets the factor input component
  142069. */
  142070. get factor(): NodeMaterialConnectionPoint;
  142071. /**
  142072. * Gets the output component
  142073. */
  142074. get output(): NodeMaterialConnectionPoint;
  142075. protected _buildBlock(state: NodeMaterialBuildState): this;
  142076. }
  142077. }
  142078. declare module BABYLON {
  142079. /**
  142080. * Block used to clamp a float
  142081. */
  142082. export class ClampBlock extends NodeMaterialBlock {
  142083. /** Gets or sets the minimum range */
  142084. minimum: number;
  142085. /** Gets or sets the maximum range */
  142086. maximum: number;
  142087. /**
  142088. * Creates a new ClampBlock
  142089. * @param name defines the block name
  142090. */
  142091. constructor(name: string);
  142092. /**
  142093. * Gets the current class name
  142094. * @returns the class name
  142095. */
  142096. getClassName(): string;
  142097. /**
  142098. * Gets the value input component
  142099. */
  142100. get value(): NodeMaterialConnectionPoint;
  142101. /**
  142102. * Gets the output component
  142103. */
  142104. get output(): NodeMaterialConnectionPoint;
  142105. protected _buildBlock(state: NodeMaterialBuildState): this;
  142106. protected _dumpPropertiesCode(): string;
  142107. serialize(): any;
  142108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142109. }
  142110. }
  142111. declare module BABYLON {
  142112. /**
  142113. * Block used to apply a cross product between 2 vectors
  142114. */
  142115. export class CrossBlock extends NodeMaterialBlock {
  142116. /**
  142117. * Creates a new CrossBlock
  142118. * @param name defines the block name
  142119. */
  142120. constructor(name: string);
  142121. /**
  142122. * Gets the current class name
  142123. * @returns the class name
  142124. */
  142125. getClassName(): string;
  142126. /**
  142127. * Gets the left operand input component
  142128. */
  142129. get left(): NodeMaterialConnectionPoint;
  142130. /**
  142131. * Gets the right operand input component
  142132. */
  142133. get right(): NodeMaterialConnectionPoint;
  142134. /**
  142135. * Gets the output component
  142136. */
  142137. get output(): NodeMaterialConnectionPoint;
  142138. protected _buildBlock(state: NodeMaterialBuildState): this;
  142139. }
  142140. }
  142141. declare module BABYLON {
  142142. /**
  142143. * Block used to apply a dot product between 2 vectors
  142144. */
  142145. export class DotBlock extends NodeMaterialBlock {
  142146. /**
  142147. * Creates a new DotBlock
  142148. * @param name defines the block name
  142149. */
  142150. constructor(name: string);
  142151. /**
  142152. * Gets the current class name
  142153. * @returns the class name
  142154. */
  142155. getClassName(): string;
  142156. /**
  142157. * Gets the left operand input component
  142158. */
  142159. get left(): NodeMaterialConnectionPoint;
  142160. /**
  142161. * Gets the right operand input component
  142162. */
  142163. get right(): NodeMaterialConnectionPoint;
  142164. /**
  142165. * Gets the output component
  142166. */
  142167. get output(): NodeMaterialConnectionPoint;
  142168. protected _buildBlock(state: NodeMaterialBuildState): this;
  142169. }
  142170. }
  142171. declare module BABYLON {
  142172. /**
  142173. * Block used to normalize a vector
  142174. */
  142175. export class NormalizeBlock extends NodeMaterialBlock {
  142176. /**
  142177. * Creates a new NormalizeBlock
  142178. * @param name defines the block name
  142179. */
  142180. constructor(name: string);
  142181. /**
  142182. * Gets the current class name
  142183. * @returns the class name
  142184. */
  142185. getClassName(): string;
  142186. /**
  142187. * Gets the input component
  142188. */
  142189. get input(): NodeMaterialConnectionPoint;
  142190. /**
  142191. * Gets the output component
  142192. */
  142193. get output(): NodeMaterialConnectionPoint;
  142194. protected _buildBlock(state: NodeMaterialBuildState): this;
  142195. }
  142196. }
  142197. declare module BABYLON {
  142198. /**
  142199. * Operations supported by the Trigonometry block
  142200. */
  142201. export enum TrigonometryBlockOperations {
  142202. /** Cos */
  142203. Cos = 0,
  142204. /** Sin */
  142205. Sin = 1,
  142206. /** Abs */
  142207. Abs = 2,
  142208. /** Exp */
  142209. Exp = 3,
  142210. /** Exp2 */
  142211. Exp2 = 4,
  142212. /** Round */
  142213. Round = 5,
  142214. /** Floor */
  142215. Floor = 6,
  142216. /** Ceiling */
  142217. Ceiling = 7,
  142218. /** Square root */
  142219. Sqrt = 8,
  142220. /** Log */
  142221. Log = 9,
  142222. /** Tangent */
  142223. Tan = 10,
  142224. /** Arc tangent */
  142225. ArcTan = 11,
  142226. /** Arc cosinus */
  142227. ArcCos = 12,
  142228. /** Arc sinus */
  142229. ArcSin = 13,
  142230. /** Fraction */
  142231. Fract = 14,
  142232. /** Sign */
  142233. Sign = 15,
  142234. /** To radians (from degrees) */
  142235. Radians = 16,
  142236. /** To degrees (from radians) */
  142237. Degrees = 17
  142238. }
  142239. /**
  142240. * Block used to apply trigonometry operation to floats
  142241. */
  142242. export class TrigonometryBlock extends NodeMaterialBlock {
  142243. /**
  142244. * Gets or sets the operation applied by the block
  142245. */
  142246. operation: TrigonometryBlockOperations;
  142247. /**
  142248. * Creates a new TrigonometryBlock
  142249. * @param name defines the block name
  142250. */
  142251. constructor(name: string);
  142252. /**
  142253. * Gets the current class name
  142254. * @returns the class name
  142255. */
  142256. getClassName(): string;
  142257. /**
  142258. * Gets the input component
  142259. */
  142260. get input(): NodeMaterialConnectionPoint;
  142261. /**
  142262. * Gets the output component
  142263. */
  142264. get output(): NodeMaterialConnectionPoint;
  142265. protected _buildBlock(state: NodeMaterialBuildState): this;
  142266. serialize(): any;
  142267. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142268. protected _dumpPropertiesCode(): string;
  142269. }
  142270. }
  142271. declare module BABYLON {
  142272. /**
  142273. * Block used to create a Color3/4 out of individual inputs (one for each component)
  142274. */
  142275. export class ColorMergerBlock extends NodeMaterialBlock {
  142276. /**
  142277. * Create a new ColorMergerBlock
  142278. * @param name defines the block name
  142279. */
  142280. constructor(name: string);
  142281. /**
  142282. * Gets the current class name
  142283. * @returns the class name
  142284. */
  142285. getClassName(): string;
  142286. /**
  142287. * Gets the rgb component (input)
  142288. */
  142289. get rgbIn(): NodeMaterialConnectionPoint;
  142290. /**
  142291. * Gets the r component (input)
  142292. */
  142293. get r(): NodeMaterialConnectionPoint;
  142294. /**
  142295. * Gets the g component (input)
  142296. */
  142297. get g(): NodeMaterialConnectionPoint;
  142298. /**
  142299. * Gets the b component (input)
  142300. */
  142301. get b(): NodeMaterialConnectionPoint;
  142302. /**
  142303. * Gets the a component (input)
  142304. */
  142305. get a(): NodeMaterialConnectionPoint;
  142306. /**
  142307. * Gets the rgba component (output)
  142308. */
  142309. get rgba(): NodeMaterialConnectionPoint;
  142310. /**
  142311. * Gets the rgb component (output)
  142312. */
  142313. get rgbOut(): NodeMaterialConnectionPoint;
  142314. /**
  142315. * Gets the rgb component (output)
  142316. * @deprecated Please use rgbOut instead.
  142317. */
  142318. get rgb(): NodeMaterialConnectionPoint;
  142319. protected _buildBlock(state: NodeMaterialBuildState): this;
  142320. }
  142321. }
  142322. declare module BABYLON {
  142323. /**
  142324. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  142325. */
  142326. export class VectorSplitterBlock extends NodeMaterialBlock {
  142327. /**
  142328. * Create a new VectorSplitterBlock
  142329. * @param name defines the block name
  142330. */
  142331. constructor(name: string);
  142332. /**
  142333. * Gets the current class name
  142334. * @returns the class name
  142335. */
  142336. getClassName(): string;
  142337. /**
  142338. * Gets the xyzw component (input)
  142339. */
  142340. get xyzw(): NodeMaterialConnectionPoint;
  142341. /**
  142342. * Gets the xyz component (input)
  142343. */
  142344. get xyzIn(): NodeMaterialConnectionPoint;
  142345. /**
  142346. * Gets the xy component (input)
  142347. */
  142348. get xyIn(): NodeMaterialConnectionPoint;
  142349. /**
  142350. * Gets the xyz component (output)
  142351. */
  142352. get xyzOut(): NodeMaterialConnectionPoint;
  142353. /**
  142354. * Gets the xy component (output)
  142355. */
  142356. get xyOut(): NodeMaterialConnectionPoint;
  142357. /**
  142358. * Gets the x component (output)
  142359. */
  142360. get x(): NodeMaterialConnectionPoint;
  142361. /**
  142362. * Gets the y component (output)
  142363. */
  142364. get y(): NodeMaterialConnectionPoint;
  142365. /**
  142366. * Gets the z component (output)
  142367. */
  142368. get z(): NodeMaterialConnectionPoint;
  142369. /**
  142370. * Gets the w component (output)
  142371. */
  142372. get w(): NodeMaterialConnectionPoint;
  142373. protected _inputRename(name: string): string;
  142374. protected _outputRename(name: string): string;
  142375. protected _buildBlock(state: NodeMaterialBuildState): this;
  142376. }
  142377. }
  142378. declare module BABYLON {
  142379. /**
  142380. * Block used to lerp between 2 values
  142381. */
  142382. export class LerpBlock extends NodeMaterialBlock {
  142383. /**
  142384. * Creates a new LerpBlock
  142385. * @param name defines the block name
  142386. */
  142387. constructor(name: string);
  142388. /**
  142389. * Gets the current class name
  142390. * @returns the class name
  142391. */
  142392. getClassName(): string;
  142393. /**
  142394. * Gets the left operand input component
  142395. */
  142396. get left(): NodeMaterialConnectionPoint;
  142397. /**
  142398. * Gets the right operand input component
  142399. */
  142400. get right(): NodeMaterialConnectionPoint;
  142401. /**
  142402. * Gets the gradient operand input component
  142403. */
  142404. get gradient(): NodeMaterialConnectionPoint;
  142405. /**
  142406. * Gets the output component
  142407. */
  142408. get output(): NodeMaterialConnectionPoint;
  142409. protected _buildBlock(state: NodeMaterialBuildState): this;
  142410. }
  142411. }
  142412. declare module BABYLON {
  142413. /**
  142414. * Block used to divide 2 vectors
  142415. */
  142416. export class DivideBlock extends NodeMaterialBlock {
  142417. /**
  142418. * Creates a new DivideBlock
  142419. * @param name defines the block name
  142420. */
  142421. constructor(name: string);
  142422. /**
  142423. * Gets the current class name
  142424. * @returns the class name
  142425. */
  142426. getClassName(): string;
  142427. /**
  142428. * Gets the left operand input component
  142429. */
  142430. get left(): NodeMaterialConnectionPoint;
  142431. /**
  142432. * Gets the right operand input component
  142433. */
  142434. get right(): NodeMaterialConnectionPoint;
  142435. /**
  142436. * Gets the output component
  142437. */
  142438. get output(): NodeMaterialConnectionPoint;
  142439. protected _buildBlock(state: NodeMaterialBuildState): this;
  142440. }
  142441. }
  142442. declare module BABYLON {
  142443. /**
  142444. * Block used to subtract 2 vectors
  142445. */
  142446. export class SubtractBlock extends NodeMaterialBlock {
  142447. /**
  142448. * Creates a new SubtractBlock
  142449. * @param name defines the block name
  142450. */
  142451. constructor(name: string);
  142452. /**
  142453. * Gets the current class name
  142454. * @returns the class name
  142455. */
  142456. getClassName(): string;
  142457. /**
  142458. * Gets the left operand input component
  142459. */
  142460. get left(): NodeMaterialConnectionPoint;
  142461. /**
  142462. * Gets the right operand input component
  142463. */
  142464. get right(): NodeMaterialConnectionPoint;
  142465. /**
  142466. * Gets the output component
  142467. */
  142468. get output(): NodeMaterialConnectionPoint;
  142469. protected _buildBlock(state: NodeMaterialBuildState): this;
  142470. }
  142471. }
  142472. declare module BABYLON {
  142473. /**
  142474. * Block used to step a value
  142475. */
  142476. export class StepBlock extends NodeMaterialBlock {
  142477. /**
  142478. * Creates a new StepBlock
  142479. * @param name defines the block name
  142480. */
  142481. constructor(name: string);
  142482. /**
  142483. * Gets the current class name
  142484. * @returns the class name
  142485. */
  142486. getClassName(): string;
  142487. /**
  142488. * Gets the value operand input component
  142489. */
  142490. get value(): NodeMaterialConnectionPoint;
  142491. /**
  142492. * Gets the edge operand input component
  142493. */
  142494. get edge(): NodeMaterialConnectionPoint;
  142495. /**
  142496. * Gets the output component
  142497. */
  142498. get output(): NodeMaterialConnectionPoint;
  142499. protected _buildBlock(state: NodeMaterialBuildState): this;
  142500. }
  142501. }
  142502. declare module BABYLON {
  142503. /**
  142504. * Block used to get the opposite (1 - x) of a value
  142505. */
  142506. export class OneMinusBlock extends NodeMaterialBlock {
  142507. /**
  142508. * Creates a new OneMinusBlock
  142509. * @param name defines the block name
  142510. */
  142511. constructor(name: string);
  142512. /**
  142513. * Gets the current class name
  142514. * @returns the class name
  142515. */
  142516. getClassName(): string;
  142517. /**
  142518. * Gets the input component
  142519. */
  142520. get input(): NodeMaterialConnectionPoint;
  142521. /**
  142522. * Gets the output component
  142523. */
  142524. get output(): NodeMaterialConnectionPoint;
  142525. protected _buildBlock(state: NodeMaterialBuildState): this;
  142526. }
  142527. }
  142528. declare module BABYLON {
  142529. /**
  142530. * Block used to get the view direction
  142531. */
  142532. export class ViewDirectionBlock extends NodeMaterialBlock {
  142533. /**
  142534. * Creates a new ViewDirectionBlock
  142535. * @param name defines the block name
  142536. */
  142537. constructor(name: string);
  142538. /**
  142539. * Gets the current class name
  142540. * @returns the class name
  142541. */
  142542. getClassName(): string;
  142543. /**
  142544. * Gets the world position component
  142545. */
  142546. get worldPosition(): NodeMaterialConnectionPoint;
  142547. /**
  142548. * Gets the camera position component
  142549. */
  142550. get cameraPosition(): NodeMaterialConnectionPoint;
  142551. /**
  142552. * Gets the output component
  142553. */
  142554. get output(): NodeMaterialConnectionPoint;
  142555. autoConfigure(material: NodeMaterial): void;
  142556. protected _buildBlock(state: NodeMaterialBuildState): this;
  142557. }
  142558. }
  142559. declare module BABYLON {
  142560. /**
  142561. * Block used to compute fresnel value
  142562. */
  142563. export class FresnelBlock extends NodeMaterialBlock {
  142564. /**
  142565. * Create a new FresnelBlock
  142566. * @param name defines the block name
  142567. */
  142568. constructor(name: string);
  142569. /**
  142570. * Gets the current class name
  142571. * @returns the class name
  142572. */
  142573. getClassName(): string;
  142574. /**
  142575. * Gets the world normal input component
  142576. */
  142577. get worldNormal(): NodeMaterialConnectionPoint;
  142578. /**
  142579. * Gets the view direction input component
  142580. */
  142581. get viewDirection(): NodeMaterialConnectionPoint;
  142582. /**
  142583. * Gets the bias input component
  142584. */
  142585. get bias(): NodeMaterialConnectionPoint;
  142586. /**
  142587. * Gets the camera (or eye) position component
  142588. */
  142589. get power(): NodeMaterialConnectionPoint;
  142590. /**
  142591. * Gets the fresnel output component
  142592. */
  142593. get fresnel(): NodeMaterialConnectionPoint;
  142594. autoConfigure(material: NodeMaterial): void;
  142595. protected _buildBlock(state: NodeMaterialBuildState): this;
  142596. }
  142597. }
  142598. declare module BABYLON {
  142599. /**
  142600. * Block used to get the max of 2 values
  142601. */
  142602. export class MaxBlock extends NodeMaterialBlock {
  142603. /**
  142604. * Creates a new MaxBlock
  142605. * @param name defines the block name
  142606. */
  142607. constructor(name: string);
  142608. /**
  142609. * Gets the current class name
  142610. * @returns the class name
  142611. */
  142612. getClassName(): string;
  142613. /**
  142614. * Gets the left operand input component
  142615. */
  142616. get left(): NodeMaterialConnectionPoint;
  142617. /**
  142618. * Gets the right operand input component
  142619. */
  142620. get right(): NodeMaterialConnectionPoint;
  142621. /**
  142622. * Gets the output component
  142623. */
  142624. get output(): NodeMaterialConnectionPoint;
  142625. protected _buildBlock(state: NodeMaterialBuildState): this;
  142626. }
  142627. }
  142628. declare module BABYLON {
  142629. /**
  142630. * Block used to get the min of 2 values
  142631. */
  142632. export class MinBlock extends NodeMaterialBlock {
  142633. /**
  142634. * Creates a new MinBlock
  142635. * @param name defines the block name
  142636. */
  142637. constructor(name: string);
  142638. /**
  142639. * Gets the current class name
  142640. * @returns the class name
  142641. */
  142642. getClassName(): string;
  142643. /**
  142644. * Gets the left operand input component
  142645. */
  142646. get left(): NodeMaterialConnectionPoint;
  142647. /**
  142648. * Gets the right operand input component
  142649. */
  142650. get right(): NodeMaterialConnectionPoint;
  142651. /**
  142652. * Gets the output component
  142653. */
  142654. get output(): NodeMaterialConnectionPoint;
  142655. protected _buildBlock(state: NodeMaterialBuildState): this;
  142656. }
  142657. }
  142658. declare module BABYLON {
  142659. /**
  142660. * Block used to get the distance between 2 values
  142661. */
  142662. export class DistanceBlock extends NodeMaterialBlock {
  142663. /**
  142664. * Creates a new DistanceBlock
  142665. * @param name defines the block name
  142666. */
  142667. constructor(name: string);
  142668. /**
  142669. * Gets the current class name
  142670. * @returns the class name
  142671. */
  142672. getClassName(): string;
  142673. /**
  142674. * Gets the left operand input component
  142675. */
  142676. get left(): NodeMaterialConnectionPoint;
  142677. /**
  142678. * Gets the right operand input component
  142679. */
  142680. get right(): NodeMaterialConnectionPoint;
  142681. /**
  142682. * Gets the output component
  142683. */
  142684. get output(): NodeMaterialConnectionPoint;
  142685. protected _buildBlock(state: NodeMaterialBuildState): this;
  142686. }
  142687. }
  142688. declare module BABYLON {
  142689. /**
  142690. * Block used to get the length of a vector
  142691. */
  142692. export class LengthBlock extends NodeMaterialBlock {
  142693. /**
  142694. * Creates a new LengthBlock
  142695. * @param name defines the block name
  142696. */
  142697. constructor(name: string);
  142698. /**
  142699. * Gets the current class name
  142700. * @returns the class name
  142701. */
  142702. getClassName(): string;
  142703. /**
  142704. * Gets the value input component
  142705. */
  142706. get value(): NodeMaterialConnectionPoint;
  142707. /**
  142708. * Gets the output component
  142709. */
  142710. get output(): NodeMaterialConnectionPoint;
  142711. protected _buildBlock(state: NodeMaterialBuildState): this;
  142712. }
  142713. }
  142714. declare module BABYLON {
  142715. /**
  142716. * Block used to get negative version of a value (i.e. x * -1)
  142717. */
  142718. export class NegateBlock extends NodeMaterialBlock {
  142719. /**
  142720. * Creates a new NegateBlock
  142721. * @param name defines the block name
  142722. */
  142723. constructor(name: string);
  142724. /**
  142725. * Gets the current class name
  142726. * @returns the class name
  142727. */
  142728. getClassName(): string;
  142729. /**
  142730. * Gets the value input component
  142731. */
  142732. get value(): NodeMaterialConnectionPoint;
  142733. /**
  142734. * Gets the output component
  142735. */
  142736. get output(): NodeMaterialConnectionPoint;
  142737. protected _buildBlock(state: NodeMaterialBuildState): this;
  142738. }
  142739. }
  142740. declare module BABYLON {
  142741. /**
  142742. * Block used to get the value of the first parameter raised to the power of the second
  142743. */
  142744. export class PowBlock extends NodeMaterialBlock {
  142745. /**
  142746. * Creates a new PowBlock
  142747. * @param name defines the block name
  142748. */
  142749. constructor(name: string);
  142750. /**
  142751. * Gets the current class name
  142752. * @returns the class name
  142753. */
  142754. getClassName(): string;
  142755. /**
  142756. * Gets the value operand input component
  142757. */
  142758. get value(): NodeMaterialConnectionPoint;
  142759. /**
  142760. * Gets the power operand input component
  142761. */
  142762. get power(): NodeMaterialConnectionPoint;
  142763. /**
  142764. * Gets the output component
  142765. */
  142766. get output(): NodeMaterialConnectionPoint;
  142767. protected _buildBlock(state: NodeMaterialBuildState): this;
  142768. }
  142769. }
  142770. declare module BABYLON {
  142771. /**
  142772. * Block used to get a random number
  142773. */
  142774. export class RandomNumberBlock extends NodeMaterialBlock {
  142775. /**
  142776. * Creates a new RandomNumberBlock
  142777. * @param name defines the block name
  142778. */
  142779. constructor(name: string);
  142780. /**
  142781. * Gets the current class name
  142782. * @returns the class name
  142783. */
  142784. getClassName(): string;
  142785. /**
  142786. * Gets the seed input component
  142787. */
  142788. get seed(): NodeMaterialConnectionPoint;
  142789. /**
  142790. * Gets the output component
  142791. */
  142792. get output(): NodeMaterialConnectionPoint;
  142793. protected _buildBlock(state: NodeMaterialBuildState): this;
  142794. }
  142795. }
  142796. declare module BABYLON {
  142797. /**
  142798. * Block used to compute arc tangent of 2 values
  142799. */
  142800. export class ArcTan2Block extends NodeMaterialBlock {
  142801. /**
  142802. * Creates a new ArcTan2Block
  142803. * @param name defines the block name
  142804. */
  142805. constructor(name: string);
  142806. /**
  142807. * Gets the current class name
  142808. * @returns the class name
  142809. */
  142810. getClassName(): string;
  142811. /**
  142812. * Gets the x operand input component
  142813. */
  142814. get x(): NodeMaterialConnectionPoint;
  142815. /**
  142816. * Gets the y operand input component
  142817. */
  142818. get y(): NodeMaterialConnectionPoint;
  142819. /**
  142820. * Gets the output component
  142821. */
  142822. get output(): NodeMaterialConnectionPoint;
  142823. protected _buildBlock(state: NodeMaterialBuildState): this;
  142824. }
  142825. }
  142826. declare module BABYLON {
  142827. /**
  142828. * Block used to smooth step a value
  142829. */
  142830. export class SmoothStepBlock extends NodeMaterialBlock {
  142831. /**
  142832. * Creates a new SmoothStepBlock
  142833. * @param name defines the block name
  142834. */
  142835. constructor(name: string);
  142836. /**
  142837. * Gets the current class name
  142838. * @returns the class name
  142839. */
  142840. getClassName(): string;
  142841. /**
  142842. * Gets the value operand input component
  142843. */
  142844. get value(): NodeMaterialConnectionPoint;
  142845. /**
  142846. * Gets the first edge operand input component
  142847. */
  142848. get edge0(): NodeMaterialConnectionPoint;
  142849. /**
  142850. * Gets the second edge operand input component
  142851. */
  142852. get edge1(): NodeMaterialConnectionPoint;
  142853. /**
  142854. * Gets the output component
  142855. */
  142856. get output(): NodeMaterialConnectionPoint;
  142857. protected _buildBlock(state: NodeMaterialBuildState): this;
  142858. }
  142859. }
  142860. declare module BABYLON {
  142861. /**
  142862. * Block used to get the reciprocal (1 / x) of a value
  142863. */
  142864. export class ReciprocalBlock extends NodeMaterialBlock {
  142865. /**
  142866. * Creates a new ReciprocalBlock
  142867. * @param name defines the block name
  142868. */
  142869. constructor(name: string);
  142870. /**
  142871. * Gets the current class name
  142872. * @returns the class name
  142873. */
  142874. getClassName(): string;
  142875. /**
  142876. * Gets the input component
  142877. */
  142878. get input(): NodeMaterialConnectionPoint;
  142879. /**
  142880. * Gets the output component
  142881. */
  142882. get output(): NodeMaterialConnectionPoint;
  142883. protected _buildBlock(state: NodeMaterialBuildState): this;
  142884. }
  142885. }
  142886. declare module BABYLON {
  142887. /**
  142888. * Block used to replace a color by another one
  142889. */
  142890. export class ReplaceColorBlock extends NodeMaterialBlock {
  142891. /**
  142892. * Creates a new ReplaceColorBlock
  142893. * @param name defines the block name
  142894. */
  142895. constructor(name: string);
  142896. /**
  142897. * Gets the current class name
  142898. * @returns the class name
  142899. */
  142900. getClassName(): string;
  142901. /**
  142902. * Gets the value input component
  142903. */
  142904. get value(): NodeMaterialConnectionPoint;
  142905. /**
  142906. * Gets the reference input component
  142907. */
  142908. get reference(): NodeMaterialConnectionPoint;
  142909. /**
  142910. * Gets the distance input component
  142911. */
  142912. get distance(): NodeMaterialConnectionPoint;
  142913. /**
  142914. * Gets the replacement input component
  142915. */
  142916. get replacement(): NodeMaterialConnectionPoint;
  142917. /**
  142918. * Gets the output component
  142919. */
  142920. get output(): NodeMaterialConnectionPoint;
  142921. protected _buildBlock(state: NodeMaterialBuildState): this;
  142922. }
  142923. }
  142924. declare module BABYLON {
  142925. /**
  142926. * Block used to posterize a value
  142927. * @see https://en.wikipedia.org/wiki/Posterization
  142928. */
  142929. export class PosterizeBlock extends NodeMaterialBlock {
  142930. /**
  142931. * Creates a new PosterizeBlock
  142932. * @param name defines the block name
  142933. */
  142934. constructor(name: string);
  142935. /**
  142936. * Gets the current class name
  142937. * @returns the class name
  142938. */
  142939. getClassName(): string;
  142940. /**
  142941. * Gets the value input component
  142942. */
  142943. get value(): NodeMaterialConnectionPoint;
  142944. /**
  142945. * Gets the steps input component
  142946. */
  142947. get steps(): NodeMaterialConnectionPoint;
  142948. /**
  142949. * Gets the output component
  142950. */
  142951. get output(): NodeMaterialConnectionPoint;
  142952. protected _buildBlock(state: NodeMaterialBuildState): this;
  142953. }
  142954. }
  142955. declare module BABYLON {
  142956. /**
  142957. * Operations supported by the Wave block
  142958. */
  142959. export enum WaveBlockKind {
  142960. /** SawTooth */
  142961. SawTooth = 0,
  142962. /** Square */
  142963. Square = 1,
  142964. /** Triangle */
  142965. Triangle = 2
  142966. }
  142967. /**
  142968. * Block used to apply wave operation to floats
  142969. */
  142970. export class WaveBlock extends NodeMaterialBlock {
  142971. /**
  142972. * Gets or sets the kibnd of wave to be applied by the block
  142973. */
  142974. kind: WaveBlockKind;
  142975. /**
  142976. * Creates a new WaveBlock
  142977. * @param name defines the block name
  142978. */
  142979. constructor(name: string);
  142980. /**
  142981. * Gets the current class name
  142982. * @returns the class name
  142983. */
  142984. getClassName(): string;
  142985. /**
  142986. * Gets the input component
  142987. */
  142988. get input(): NodeMaterialConnectionPoint;
  142989. /**
  142990. * Gets the output component
  142991. */
  142992. get output(): NodeMaterialConnectionPoint;
  142993. protected _buildBlock(state: NodeMaterialBuildState): this;
  142994. serialize(): any;
  142995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142996. }
  142997. }
  142998. declare module BABYLON {
  142999. /**
  143000. * Class used to store a color step for the GradientBlock
  143001. */
  143002. export class GradientBlockColorStep {
  143003. /**
  143004. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143005. */
  143006. step: number;
  143007. /**
  143008. * Gets or sets the color associated with this step
  143009. */
  143010. color: Color3;
  143011. /**
  143012. * Creates a new GradientBlockColorStep
  143013. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143014. * @param color defines the color associated with this step
  143015. */
  143016. constructor(
  143017. /**
  143018. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  143019. */
  143020. step: number,
  143021. /**
  143022. * Gets or sets the color associated with this step
  143023. */
  143024. color: Color3);
  143025. }
  143026. /**
  143027. * Block used to return a color from a gradient based on an input value between 0 and 1
  143028. */
  143029. export class GradientBlock extends NodeMaterialBlock {
  143030. /**
  143031. * Gets or sets the list of color steps
  143032. */
  143033. colorSteps: GradientBlockColorStep[];
  143034. /**
  143035. * Creates a new GradientBlock
  143036. * @param name defines the block name
  143037. */
  143038. constructor(name: string);
  143039. /**
  143040. * Gets the current class name
  143041. * @returns the class name
  143042. */
  143043. getClassName(): string;
  143044. /**
  143045. * Gets the gradient input component
  143046. */
  143047. get gradient(): NodeMaterialConnectionPoint;
  143048. /**
  143049. * Gets the output component
  143050. */
  143051. get output(): NodeMaterialConnectionPoint;
  143052. private _writeColorConstant;
  143053. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143054. serialize(): any;
  143055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143056. protected _dumpPropertiesCode(): string;
  143057. }
  143058. }
  143059. declare module BABYLON {
  143060. /**
  143061. * Block used to normalize lerp between 2 values
  143062. */
  143063. export class NLerpBlock extends NodeMaterialBlock {
  143064. /**
  143065. * Creates a new NLerpBlock
  143066. * @param name defines the block name
  143067. */
  143068. constructor(name: string);
  143069. /**
  143070. * Gets the current class name
  143071. * @returns the class name
  143072. */
  143073. getClassName(): string;
  143074. /**
  143075. * Gets the left operand input component
  143076. */
  143077. get left(): NodeMaterialConnectionPoint;
  143078. /**
  143079. * Gets the right operand input component
  143080. */
  143081. get right(): NodeMaterialConnectionPoint;
  143082. /**
  143083. * Gets the gradient operand input component
  143084. */
  143085. get gradient(): NodeMaterialConnectionPoint;
  143086. /**
  143087. * Gets the output component
  143088. */
  143089. get output(): NodeMaterialConnectionPoint;
  143090. protected _buildBlock(state: NodeMaterialBuildState): this;
  143091. }
  143092. }
  143093. declare module BABYLON {
  143094. /**
  143095. * block used to Generate a Worley Noise 3D Noise Pattern
  143096. */
  143097. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  143098. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143099. manhattanDistance: boolean;
  143100. /**
  143101. * Creates a new WorleyNoise3DBlock
  143102. * @param name defines the block name
  143103. */
  143104. constructor(name: string);
  143105. /**
  143106. * Gets the current class name
  143107. * @returns the class name
  143108. */
  143109. getClassName(): string;
  143110. /**
  143111. * Gets the seed input component
  143112. */
  143113. get seed(): NodeMaterialConnectionPoint;
  143114. /**
  143115. * Gets the jitter input component
  143116. */
  143117. get jitter(): NodeMaterialConnectionPoint;
  143118. /**
  143119. * Gets the output component
  143120. */
  143121. get output(): NodeMaterialConnectionPoint;
  143122. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143123. /**
  143124. * Exposes the properties to the UI?
  143125. */
  143126. protected _dumpPropertiesCode(): string;
  143127. /**
  143128. * Exposes the properties to the Seralize?
  143129. */
  143130. serialize(): any;
  143131. /**
  143132. * Exposes the properties to the deseralize?
  143133. */
  143134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143135. }
  143136. }
  143137. declare module BABYLON {
  143138. /**
  143139. * block used to Generate a Simplex Perlin 3d Noise Pattern
  143140. */
  143141. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  143142. /**
  143143. * Creates a new SimplexPerlin3DBlock
  143144. * @param name defines the block name
  143145. */
  143146. constructor(name: string);
  143147. /**
  143148. * Gets the current class name
  143149. * @returns the class name
  143150. */
  143151. getClassName(): string;
  143152. /**
  143153. * Gets the seed operand input component
  143154. */
  143155. get seed(): NodeMaterialConnectionPoint;
  143156. /**
  143157. * Gets the output component
  143158. */
  143159. get output(): NodeMaterialConnectionPoint;
  143160. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143161. }
  143162. }
  143163. declare module BABYLON {
  143164. /**
  143165. * Block used to blend normals
  143166. */
  143167. export class NormalBlendBlock extends NodeMaterialBlock {
  143168. /**
  143169. * Creates a new NormalBlendBlock
  143170. * @param name defines the block name
  143171. */
  143172. constructor(name: string);
  143173. /**
  143174. * Gets the current class name
  143175. * @returns the class name
  143176. */
  143177. getClassName(): string;
  143178. /**
  143179. * Gets the first input component
  143180. */
  143181. get normalMap0(): NodeMaterialConnectionPoint;
  143182. /**
  143183. * Gets the second input component
  143184. */
  143185. get normalMap1(): NodeMaterialConnectionPoint;
  143186. /**
  143187. * Gets the output component
  143188. */
  143189. get output(): NodeMaterialConnectionPoint;
  143190. protected _buildBlock(state: NodeMaterialBuildState): this;
  143191. }
  143192. }
  143193. declare module BABYLON {
  143194. /**
  143195. * Block used to rotate a 2d vector by a given angle
  143196. */
  143197. export class Rotate2dBlock extends NodeMaterialBlock {
  143198. /**
  143199. * Creates a new Rotate2dBlock
  143200. * @param name defines the block name
  143201. */
  143202. constructor(name: string);
  143203. /**
  143204. * Gets the current class name
  143205. * @returns the class name
  143206. */
  143207. getClassName(): string;
  143208. /**
  143209. * Gets the input vector
  143210. */
  143211. get input(): NodeMaterialConnectionPoint;
  143212. /**
  143213. * Gets the input angle
  143214. */
  143215. get angle(): NodeMaterialConnectionPoint;
  143216. /**
  143217. * Gets the output component
  143218. */
  143219. get output(): NodeMaterialConnectionPoint;
  143220. autoConfigure(material: NodeMaterial): void;
  143221. protected _buildBlock(state: NodeMaterialBuildState): this;
  143222. }
  143223. }
  143224. declare module BABYLON {
  143225. /**
  143226. * Block used to get the reflected vector from a direction and a normal
  143227. */
  143228. export class ReflectBlock extends NodeMaterialBlock {
  143229. /**
  143230. * Creates a new ReflectBlock
  143231. * @param name defines the block name
  143232. */
  143233. constructor(name: string);
  143234. /**
  143235. * Gets the current class name
  143236. * @returns the class name
  143237. */
  143238. getClassName(): string;
  143239. /**
  143240. * Gets the incident component
  143241. */
  143242. get incident(): NodeMaterialConnectionPoint;
  143243. /**
  143244. * Gets the normal component
  143245. */
  143246. get normal(): NodeMaterialConnectionPoint;
  143247. /**
  143248. * Gets the output component
  143249. */
  143250. get output(): NodeMaterialConnectionPoint;
  143251. protected _buildBlock(state: NodeMaterialBuildState): this;
  143252. }
  143253. }
  143254. declare module BABYLON {
  143255. /**
  143256. * Block used to get the refracted vector from a direction and a normal
  143257. */
  143258. export class RefractBlock extends NodeMaterialBlock {
  143259. /**
  143260. * Creates a new RefractBlock
  143261. * @param name defines the block name
  143262. */
  143263. constructor(name: string);
  143264. /**
  143265. * Gets the current class name
  143266. * @returns the class name
  143267. */
  143268. getClassName(): string;
  143269. /**
  143270. * Gets the incident component
  143271. */
  143272. get incident(): NodeMaterialConnectionPoint;
  143273. /**
  143274. * Gets the normal component
  143275. */
  143276. get normal(): NodeMaterialConnectionPoint;
  143277. /**
  143278. * Gets the index of refraction component
  143279. */
  143280. get ior(): NodeMaterialConnectionPoint;
  143281. /**
  143282. * Gets the output component
  143283. */
  143284. get output(): NodeMaterialConnectionPoint;
  143285. protected _buildBlock(state: NodeMaterialBuildState): this;
  143286. }
  143287. }
  143288. declare module BABYLON {
  143289. /**
  143290. * Block used to desaturate a color
  143291. */
  143292. export class DesaturateBlock extends NodeMaterialBlock {
  143293. /**
  143294. * Creates a new DesaturateBlock
  143295. * @param name defines the block name
  143296. */
  143297. constructor(name: string);
  143298. /**
  143299. * Gets the current class name
  143300. * @returns the class name
  143301. */
  143302. getClassName(): string;
  143303. /**
  143304. * Gets the color operand input component
  143305. */
  143306. get color(): NodeMaterialConnectionPoint;
  143307. /**
  143308. * Gets the level operand input component
  143309. */
  143310. get level(): NodeMaterialConnectionPoint;
  143311. /**
  143312. * Gets the output component
  143313. */
  143314. get output(): NodeMaterialConnectionPoint;
  143315. protected _buildBlock(state: NodeMaterialBuildState): this;
  143316. }
  143317. }
  143318. declare module BABYLON {
  143319. /**
  143320. * Block used to implement the ambient occlusion module of the PBR material
  143321. */
  143322. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  143323. /**
  143324. * Create a new AmbientOcclusionBlock
  143325. * @param name defines the block name
  143326. */
  143327. constructor(name: string);
  143328. /**
  143329. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  143330. */
  143331. useAmbientInGrayScale: boolean;
  143332. /**
  143333. * Initialize the block and prepare the context for build
  143334. * @param state defines the state that will be used for the build
  143335. */
  143336. initialize(state: NodeMaterialBuildState): void;
  143337. /**
  143338. * Gets the current class name
  143339. * @returns the class name
  143340. */
  143341. getClassName(): string;
  143342. /**
  143343. * Gets the texture input component
  143344. */
  143345. get texture(): NodeMaterialConnectionPoint;
  143346. /**
  143347. * Gets the texture intensity component
  143348. */
  143349. get intensity(): NodeMaterialConnectionPoint;
  143350. /**
  143351. * Gets the direct light intensity input component
  143352. */
  143353. get directLightIntensity(): NodeMaterialConnectionPoint;
  143354. /**
  143355. * Gets the ambient occlusion object output component
  143356. */
  143357. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143358. /**
  143359. * Gets the main code of the block (fragment side)
  143360. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  143361. * @returns the shader code
  143362. */
  143363. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  143364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143365. protected _buildBlock(state: NodeMaterialBuildState): this;
  143366. protected _dumpPropertiesCode(): string;
  143367. serialize(): any;
  143368. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143369. }
  143370. }
  143371. declare module BABYLON {
  143372. /**
  143373. * Block used to implement the reflection module of the PBR material
  143374. */
  143375. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  143376. /** @hidden */
  143377. _defineLODReflectionAlpha: string;
  143378. /** @hidden */
  143379. _defineLinearSpecularReflection: string;
  143380. private _vEnvironmentIrradianceName;
  143381. /** @hidden */
  143382. _vReflectionMicrosurfaceInfosName: string;
  143383. /** @hidden */
  143384. _vReflectionInfosName: string;
  143385. /** @hidden */
  143386. _vReflectionFilteringInfoName: string;
  143387. private _scene;
  143388. /**
  143389. * The three properties below are set by the main PBR block prior to calling methods of this class.
  143390. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143391. * It's less burden on the user side in the editor part.
  143392. */
  143393. /** @hidden */
  143394. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143395. /** @hidden */
  143396. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143397. /** @hidden */
  143398. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  143399. /**
  143400. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  143401. * diffuse part of the IBL.
  143402. */
  143403. useSphericalHarmonics: boolean;
  143404. /**
  143405. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  143406. */
  143407. forceIrradianceInFragment: boolean;
  143408. /**
  143409. * Create a new ReflectionBlock
  143410. * @param name defines the block name
  143411. */
  143412. constructor(name: string);
  143413. /**
  143414. * Gets the current class name
  143415. * @returns the class name
  143416. */
  143417. getClassName(): string;
  143418. /**
  143419. * Gets the position input component
  143420. */
  143421. get position(): NodeMaterialConnectionPoint;
  143422. /**
  143423. * Gets the world position input component
  143424. */
  143425. get worldPosition(): NodeMaterialConnectionPoint;
  143426. /**
  143427. * Gets the world normal input component
  143428. */
  143429. get worldNormal(): NodeMaterialConnectionPoint;
  143430. /**
  143431. * Gets the world input component
  143432. */
  143433. get world(): NodeMaterialConnectionPoint;
  143434. /**
  143435. * Gets the camera (or eye) position component
  143436. */
  143437. get cameraPosition(): NodeMaterialConnectionPoint;
  143438. /**
  143439. * Gets the view input component
  143440. */
  143441. get view(): NodeMaterialConnectionPoint;
  143442. /**
  143443. * Gets the color input component
  143444. */
  143445. get color(): NodeMaterialConnectionPoint;
  143446. /**
  143447. * Gets the reflection object output component
  143448. */
  143449. get reflection(): NodeMaterialConnectionPoint;
  143450. /**
  143451. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  143452. */
  143453. get hasTexture(): boolean;
  143454. /**
  143455. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  143456. */
  143457. get reflectionColor(): string;
  143458. protected _getTexture(): Nullable<BaseTexture>;
  143459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143461. /**
  143462. * Gets the code to inject in the vertex shader
  143463. * @param state current state of the node material building
  143464. * @returns the shader code
  143465. */
  143466. handleVertexSide(state: NodeMaterialBuildState): string;
  143467. /**
  143468. * Gets the main code of the block (fragment side)
  143469. * @param state current state of the node material building
  143470. * @param normalVarName name of the existing variable corresponding to the normal
  143471. * @returns the shader code
  143472. */
  143473. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  143474. protected _buildBlock(state: NodeMaterialBuildState): this;
  143475. protected _dumpPropertiesCode(): string;
  143476. serialize(): any;
  143477. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143478. }
  143479. }
  143480. declare module BABYLON {
  143481. /**
  143482. * Block used to implement the sheen module of the PBR material
  143483. */
  143484. export class SheenBlock extends NodeMaterialBlock {
  143485. /**
  143486. * Create a new SheenBlock
  143487. * @param name defines the block name
  143488. */
  143489. constructor(name: string);
  143490. /**
  143491. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  143492. * It allows the strength of the sheen effect to not depend on the base color of the material,
  143493. * making it easier to setup and tweak the effect
  143494. */
  143495. albedoScaling: boolean;
  143496. /**
  143497. * Defines if the sheen is linked to the sheen color.
  143498. */
  143499. linkSheenWithAlbedo: boolean;
  143500. /**
  143501. * Initialize the block and prepare the context for build
  143502. * @param state defines the state that will be used for the build
  143503. */
  143504. initialize(state: NodeMaterialBuildState): void;
  143505. /**
  143506. * Gets the current class name
  143507. * @returns the class name
  143508. */
  143509. getClassName(): string;
  143510. /**
  143511. * Gets the intensity input component
  143512. */
  143513. get intensity(): NodeMaterialConnectionPoint;
  143514. /**
  143515. * Gets the color input component
  143516. */
  143517. get color(): NodeMaterialConnectionPoint;
  143518. /**
  143519. * Gets the roughness input component
  143520. */
  143521. get roughness(): NodeMaterialConnectionPoint;
  143522. /**
  143523. * Gets the sheen object output component
  143524. */
  143525. get sheen(): NodeMaterialConnectionPoint;
  143526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143527. /**
  143528. * Gets the main code of the block (fragment side)
  143529. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143530. * @returns the shader code
  143531. */
  143532. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  143533. protected _buildBlock(state: NodeMaterialBuildState): this;
  143534. protected _dumpPropertiesCode(): string;
  143535. serialize(): any;
  143536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143537. }
  143538. }
  143539. declare module BABYLON {
  143540. /**
  143541. * Block used to implement the reflectivity module of the PBR material
  143542. */
  143543. export class ReflectivityBlock extends NodeMaterialBlock {
  143544. private _metallicReflectanceColor;
  143545. private _metallicF0Factor;
  143546. /** @hidden */
  143547. _vMetallicReflectanceFactorsName: string;
  143548. /**
  143549. * The property below is set by the main PBR block prior to calling methods of this class.
  143550. */
  143551. /** @hidden */
  143552. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  143553. /**
  143554. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  143555. */
  143556. useAmbientOcclusionFromMetallicTextureRed: boolean;
  143557. /**
  143558. * Specifies if the metallic texture contains the metallness information in its blue channel.
  143559. */
  143560. useMetallnessFromMetallicTextureBlue: boolean;
  143561. /**
  143562. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  143563. */
  143564. useRoughnessFromMetallicTextureAlpha: boolean;
  143565. /**
  143566. * Specifies if the metallic texture contains the roughness information in its green channel.
  143567. */
  143568. useRoughnessFromMetallicTextureGreen: boolean;
  143569. /**
  143570. * Create a new ReflectivityBlock
  143571. * @param name defines the block name
  143572. */
  143573. constructor(name: string);
  143574. /**
  143575. * Initialize the block and prepare the context for build
  143576. * @param state defines the state that will be used for the build
  143577. */
  143578. initialize(state: NodeMaterialBuildState): void;
  143579. /**
  143580. * Gets the current class name
  143581. * @returns the class name
  143582. */
  143583. getClassName(): string;
  143584. /**
  143585. * Gets the metallic input component
  143586. */
  143587. get metallic(): NodeMaterialConnectionPoint;
  143588. /**
  143589. * Gets the roughness input component
  143590. */
  143591. get roughness(): NodeMaterialConnectionPoint;
  143592. /**
  143593. * Gets the texture input component
  143594. */
  143595. get texture(): NodeMaterialConnectionPoint;
  143596. /**
  143597. * Gets the reflectivity object output component
  143598. */
  143599. get reflectivity(): NodeMaterialConnectionPoint;
  143600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143601. /**
  143602. * Gets the main code of the block (fragment side)
  143603. * @param state current state of the node material building
  143604. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  143605. * @returns the shader code
  143606. */
  143607. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  143608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143609. protected _buildBlock(state: NodeMaterialBuildState): this;
  143610. protected _dumpPropertiesCode(): string;
  143611. serialize(): any;
  143612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143613. }
  143614. }
  143615. declare module BABYLON {
  143616. /**
  143617. * Block used to implement the anisotropy module of the PBR material
  143618. */
  143619. export class AnisotropyBlock extends NodeMaterialBlock {
  143620. /**
  143621. * The two properties below are set by the main PBR block prior to calling methods of this class.
  143622. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143623. * It's less burden on the user side in the editor part.
  143624. */
  143625. /** @hidden */
  143626. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143627. /** @hidden */
  143628. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143629. /**
  143630. * Create a new AnisotropyBlock
  143631. * @param name defines the block name
  143632. */
  143633. constructor(name: string);
  143634. /**
  143635. * Initialize the block and prepare the context for build
  143636. * @param state defines the state that will be used for the build
  143637. */
  143638. initialize(state: NodeMaterialBuildState): void;
  143639. /**
  143640. * Gets the current class name
  143641. * @returns the class name
  143642. */
  143643. getClassName(): string;
  143644. /**
  143645. * Gets the intensity input component
  143646. */
  143647. get intensity(): NodeMaterialConnectionPoint;
  143648. /**
  143649. * Gets the direction input component
  143650. */
  143651. get direction(): NodeMaterialConnectionPoint;
  143652. /**
  143653. * Gets the texture input component
  143654. */
  143655. get texture(): NodeMaterialConnectionPoint;
  143656. /**
  143657. * Gets the uv input component
  143658. */
  143659. get uv(): NodeMaterialConnectionPoint;
  143660. /**
  143661. * Gets the worldTangent input component
  143662. */
  143663. get worldTangent(): NodeMaterialConnectionPoint;
  143664. /**
  143665. * Gets the anisotropy object output component
  143666. */
  143667. get anisotropy(): NodeMaterialConnectionPoint;
  143668. private _generateTBNSpace;
  143669. /**
  143670. * Gets the main code of the block (fragment side)
  143671. * @param state current state of the node material building
  143672. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143673. * @returns the shader code
  143674. */
  143675. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  143676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143677. protected _buildBlock(state: NodeMaterialBuildState): this;
  143678. }
  143679. }
  143680. declare module BABYLON {
  143681. /**
  143682. * Block used to implement the clear coat module of the PBR material
  143683. */
  143684. export class ClearCoatBlock extends NodeMaterialBlock {
  143685. private _scene;
  143686. /**
  143687. * Create a new ClearCoatBlock
  143688. * @param name defines the block name
  143689. */
  143690. constructor(name: string);
  143691. /**
  143692. * Initialize the block and prepare the context for build
  143693. * @param state defines the state that will be used for the build
  143694. */
  143695. initialize(state: NodeMaterialBuildState): void;
  143696. /**
  143697. * Gets the current class name
  143698. * @returns the class name
  143699. */
  143700. getClassName(): string;
  143701. /**
  143702. * Gets the intensity input component
  143703. */
  143704. get intensity(): NodeMaterialConnectionPoint;
  143705. /**
  143706. * Gets the roughness input component
  143707. */
  143708. get roughness(): NodeMaterialConnectionPoint;
  143709. /**
  143710. * Gets the ior input component
  143711. */
  143712. get ior(): NodeMaterialConnectionPoint;
  143713. /**
  143714. * Gets the texture input component
  143715. */
  143716. get texture(): NodeMaterialConnectionPoint;
  143717. /**
  143718. * Gets the bump texture input component
  143719. */
  143720. get bumpTexture(): NodeMaterialConnectionPoint;
  143721. /**
  143722. * Gets the uv input component
  143723. */
  143724. get uv(): NodeMaterialConnectionPoint;
  143725. /**
  143726. * Gets the tint color input component
  143727. */
  143728. get tintColor(): NodeMaterialConnectionPoint;
  143729. /**
  143730. * Gets the tint "at distance" input component
  143731. */
  143732. get tintAtDistance(): NodeMaterialConnectionPoint;
  143733. /**
  143734. * Gets the tint thickness input component
  143735. */
  143736. get tintThickness(): NodeMaterialConnectionPoint;
  143737. /**
  143738. * Gets the world tangent input component
  143739. */
  143740. get worldTangent(): NodeMaterialConnectionPoint;
  143741. /**
  143742. * Gets the clear coat object output component
  143743. */
  143744. get clearcoat(): NodeMaterialConnectionPoint;
  143745. autoConfigure(material: NodeMaterial): void;
  143746. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143748. private _generateTBNSpace;
  143749. /**
  143750. * Gets the main code of the block (fragment side)
  143751. * @param state current state of the node material building
  143752. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143753. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143754. * @param worldPosVarName name of the variable holding the world position
  143755. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143756. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143757. * @param worldNormalVarName name of the variable holding the world normal
  143758. * @returns the shader code
  143759. */
  143760. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143761. protected _buildBlock(state: NodeMaterialBuildState): this;
  143762. }
  143763. }
  143764. declare module BABYLON {
  143765. /**
  143766. * Block used to implement the sub surface module of the PBR material
  143767. */
  143768. export class SubSurfaceBlock extends NodeMaterialBlock {
  143769. /**
  143770. * Create a new SubSurfaceBlock
  143771. * @param name defines the block name
  143772. */
  143773. constructor(name: string);
  143774. /**
  143775. * Stores the intensity of the different subsurface effects in the thickness texture.
  143776. * * the green channel is the translucency intensity.
  143777. * * the blue channel is the scattering intensity.
  143778. * * the alpha channel is the refraction intensity.
  143779. */
  143780. useMaskFromThicknessTexture: boolean;
  143781. /**
  143782. * Initialize the block and prepare the context for build
  143783. * @param state defines the state that will be used for the build
  143784. */
  143785. initialize(state: NodeMaterialBuildState): void;
  143786. /**
  143787. * Gets the current class name
  143788. * @returns the class name
  143789. */
  143790. getClassName(): string;
  143791. /**
  143792. * Gets the min thickness input component
  143793. */
  143794. get minThickness(): NodeMaterialConnectionPoint;
  143795. /**
  143796. * Gets the max thickness input component
  143797. */
  143798. get maxThickness(): NodeMaterialConnectionPoint;
  143799. /**
  143800. * Gets the thickness texture component
  143801. */
  143802. get thicknessTexture(): NodeMaterialConnectionPoint;
  143803. /**
  143804. * Gets the tint color input component
  143805. */
  143806. get tintColor(): NodeMaterialConnectionPoint;
  143807. /**
  143808. * Gets the translucency intensity input component
  143809. */
  143810. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143811. /**
  143812. * Gets the translucency diffusion distance input component
  143813. */
  143814. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143815. /**
  143816. * Gets the refraction object parameters
  143817. */
  143818. get refraction(): NodeMaterialConnectionPoint;
  143819. /**
  143820. * Gets the sub surface object output component
  143821. */
  143822. get subsurface(): NodeMaterialConnectionPoint;
  143823. autoConfigure(material: NodeMaterial): void;
  143824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143825. /**
  143826. * Gets the main code of the block (fragment side)
  143827. * @param state current state of the node material building
  143828. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143829. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143830. * @param worldPosVarName name of the variable holding the world position
  143831. * @returns the shader code
  143832. */
  143833. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143834. protected _buildBlock(state: NodeMaterialBuildState): this;
  143835. }
  143836. }
  143837. declare module BABYLON {
  143838. /**
  143839. * Block used to implement the PBR metallic/roughness model
  143840. */
  143841. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143842. /**
  143843. * Gets or sets the light associated with this block
  143844. */
  143845. light: Nullable<Light>;
  143846. private _lightId;
  143847. private _scene;
  143848. private _environmentBRDFTexture;
  143849. private _environmentBrdfSamplerName;
  143850. private _vNormalWName;
  143851. private _invertNormalName;
  143852. /**
  143853. * Create a new ReflectionBlock
  143854. * @param name defines the block name
  143855. */
  143856. constructor(name: string);
  143857. /**
  143858. * Intensity of the direct lights e.g. the four lights available in your scene.
  143859. * This impacts both the direct diffuse and specular highlights.
  143860. */
  143861. directIntensity: number;
  143862. /**
  143863. * Intensity of the environment e.g. how much the environment will light the object
  143864. * either through harmonics for rough material or through the refelction for shiny ones.
  143865. */
  143866. environmentIntensity: number;
  143867. /**
  143868. * This is a special control allowing the reduction of the specular highlights coming from the
  143869. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143870. */
  143871. specularIntensity: number;
  143872. /**
  143873. * Defines the falloff type used in this material.
  143874. * It by default is Physical.
  143875. */
  143876. lightFalloff: number;
  143877. /**
  143878. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143879. */
  143880. useAlphaFromAlbedoTexture: boolean;
  143881. /**
  143882. * Specifies that alpha test should be used
  143883. */
  143884. useAlphaTest: boolean;
  143885. /**
  143886. * Defines the alpha limits in alpha test mode.
  143887. */
  143888. alphaTestCutoff: number;
  143889. /**
  143890. * Specifies that alpha blending should be used
  143891. */
  143892. useAlphaBlending: boolean;
  143893. /**
  143894. * Defines if the alpha value should be determined via the rgb values.
  143895. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143896. */
  143897. opacityRGB: boolean;
  143898. /**
  143899. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143900. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143901. */
  143902. useRadianceOverAlpha: boolean;
  143903. /**
  143904. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143905. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143906. */
  143907. useSpecularOverAlpha: boolean;
  143908. /**
  143909. * Enables specular anti aliasing in the PBR shader.
  143910. * It will both interacts on the Geometry for analytical and IBL lighting.
  143911. * It also prefilter the roughness map based on the bump values.
  143912. */
  143913. enableSpecularAntiAliasing: boolean;
  143914. /**
  143915. * Enables realtime filtering on the texture.
  143916. */
  143917. realTimeFiltering: boolean;
  143918. /**
  143919. * Quality switch for realtime filtering
  143920. */
  143921. realTimeFilteringQuality: number;
  143922. /**
  143923. * Defines if the material uses energy conservation.
  143924. */
  143925. useEnergyConservation: boolean;
  143926. /**
  143927. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143928. * too much the area relying on ambient texture to define their ambient occlusion.
  143929. */
  143930. useRadianceOcclusion: boolean;
  143931. /**
  143932. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143933. * makes the reflect vector face the model (under horizon).
  143934. */
  143935. useHorizonOcclusion: boolean;
  143936. /**
  143937. * If set to true, no lighting calculations will be applied.
  143938. */
  143939. unlit: boolean;
  143940. /**
  143941. * Force normal to face away from face.
  143942. */
  143943. forceNormalForward: boolean;
  143944. /**
  143945. * Defines the material debug mode.
  143946. * It helps seeing only some components of the material while troubleshooting.
  143947. */
  143948. debugMode: number;
  143949. /**
  143950. * Specify from where on screen the debug mode should start.
  143951. * The value goes from -1 (full screen) to 1 (not visible)
  143952. * It helps with side by side comparison against the final render
  143953. * This defaults to 0
  143954. */
  143955. debugLimit: number;
  143956. /**
  143957. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143958. * You can use the factor to better multiply the final value.
  143959. */
  143960. debugFactor: number;
  143961. /**
  143962. * Initialize the block and prepare the context for build
  143963. * @param state defines the state that will be used for the build
  143964. */
  143965. initialize(state: NodeMaterialBuildState): void;
  143966. /**
  143967. * Gets the current class name
  143968. * @returns the class name
  143969. */
  143970. getClassName(): string;
  143971. /**
  143972. * Gets the world position input component
  143973. */
  143974. get worldPosition(): NodeMaterialConnectionPoint;
  143975. /**
  143976. * Gets the world normal input component
  143977. */
  143978. get worldNormal(): NodeMaterialConnectionPoint;
  143979. /**
  143980. * Gets the perturbed normal input component
  143981. */
  143982. get perturbedNormal(): NodeMaterialConnectionPoint;
  143983. /**
  143984. * Gets the camera position input component
  143985. */
  143986. get cameraPosition(): NodeMaterialConnectionPoint;
  143987. /**
  143988. * Gets the base color input component
  143989. */
  143990. get baseColor(): NodeMaterialConnectionPoint;
  143991. /**
  143992. * Gets the opacity texture input component
  143993. */
  143994. get opacityTexture(): NodeMaterialConnectionPoint;
  143995. /**
  143996. * Gets the ambient color input component
  143997. */
  143998. get ambientColor(): NodeMaterialConnectionPoint;
  143999. /**
  144000. * Gets the reflectivity object parameters
  144001. */
  144002. get reflectivity(): NodeMaterialConnectionPoint;
  144003. /**
  144004. * Gets the ambient occlusion object parameters
  144005. */
  144006. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144007. /**
  144008. * Gets the reflection object parameters
  144009. */
  144010. get reflection(): NodeMaterialConnectionPoint;
  144011. /**
  144012. * Gets the sheen object parameters
  144013. */
  144014. get sheen(): NodeMaterialConnectionPoint;
  144015. /**
  144016. * Gets the clear coat object parameters
  144017. */
  144018. get clearcoat(): NodeMaterialConnectionPoint;
  144019. /**
  144020. * Gets the sub surface object parameters
  144021. */
  144022. get subsurface(): NodeMaterialConnectionPoint;
  144023. /**
  144024. * Gets the anisotropy object parameters
  144025. */
  144026. get anisotropy(): NodeMaterialConnectionPoint;
  144027. /**
  144028. * Gets the ambient output component
  144029. */
  144030. get ambient(): NodeMaterialConnectionPoint;
  144031. /**
  144032. * Gets the diffuse output component
  144033. */
  144034. get diffuse(): NodeMaterialConnectionPoint;
  144035. /**
  144036. * Gets the specular output component
  144037. */
  144038. get specular(): NodeMaterialConnectionPoint;
  144039. /**
  144040. * Gets the sheen output component
  144041. */
  144042. get sheenDir(): NodeMaterialConnectionPoint;
  144043. /**
  144044. * Gets the clear coat output component
  144045. */
  144046. get clearcoatDir(): NodeMaterialConnectionPoint;
  144047. /**
  144048. * Gets the indirect diffuse output component
  144049. */
  144050. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144051. /**
  144052. * Gets the indirect specular output component
  144053. */
  144054. get specularIndirect(): NodeMaterialConnectionPoint;
  144055. /**
  144056. * Gets the indirect sheen output component
  144057. */
  144058. get sheenIndirect(): NodeMaterialConnectionPoint;
  144059. /**
  144060. * Gets the indirect clear coat output component
  144061. */
  144062. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144063. /**
  144064. * Gets the refraction output component
  144065. */
  144066. get refraction(): NodeMaterialConnectionPoint;
  144067. /**
  144068. * Gets the global lighting output component
  144069. */
  144070. get lighting(): NodeMaterialConnectionPoint;
  144071. /**
  144072. * Gets the shadow output component
  144073. */
  144074. get shadow(): NodeMaterialConnectionPoint;
  144075. /**
  144076. * Gets the alpha output component
  144077. */
  144078. get alpha(): NodeMaterialConnectionPoint;
  144079. autoConfigure(material: NodeMaterial): void;
  144080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144081. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144083. private _injectVertexCode;
  144084. /**
  144085. * Gets the code corresponding to the albedo/opacity module
  144086. * @returns the shader code
  144087. */
  144088. getAlbedoOpacityCode(): string;
  144089. protected _buildBlock(state: NodeMaterialBuildState): this;
  144090. protected _dumpPropertiesCode(): string;
  144091. serialize(): any;
  144092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144093. }
  144094. }
  144095. declare module BABYLON {
  144096. /**
  144097. * Block used to compute value of one parameter modulo another
  144098. */
  144099. export class ModBlock extends NodeMaterialBlock {
  144100. /**
  144101. * Creates a new ModBlock
  144102. * @param name defines the block name
  144103. */
  144104. constructor(name: string);
  144105. /**
  144106. * Gets the current class name
  144107. * @returns the class name
  144108. */
  144109. getClassName(): string;
  144110. /**
  144111. * Gets the left operand input component
  144112. */
  144113. get left(): NodeMaterialConnectionPoint;
  144114. /**
  144115. * Gets the right operand input component
  144116. */
  144117. get right(): NodeMaterialConnectionPoint;
  144118. /**
  144119. * Gets the output component
  144120. */
  144121. get output(): NodeMaterialConnectionPoint;
  144122. protected _buildBlock(state: NodeMaterialBuildState): this;
  144123. }
  144124. }
  144125. declare module BABYLON {
  144126. /**
  144127. * Helper class to push actions to a pool of workers.
  144128. */
  144129. export class WorkerPool implements IDisposable {
  144130. private _workerInfos;
  144131. private _pendingActions;
  144132. /**
  144133. * Constructor
  144134. * @param workers Array of workers to use for actions
  144135. */
  144136. constructor(workers: Array<Worker>);
  144137. /**
  144138. * Terminates all workers and clears any pending actions.
  144139. */
  144140. dispose(): void;
  144141. /**
  144142. * Pushes an action to the worker pool. If all the workers are active, the action will be
  144143. * pended until a worker has completed its action.
  144144. * @param action The action to perform. Call onComplete when the action is complete.
  144145. */
  144146. push(action: (worker: Worker, onComplete: () => void) => void): void;
  144147. private _execute;
  144148. }
  144149. }
  144150. declare module BABYLON {
  144151. /**
  144152. * Configuration for Draco compression
  144153. */
  144154. export interface IDracoCompressionConfiguration {
  144155. /**
  144156. * Configuration for the decoder.
  144157. */
  144158. decoder: {
  144159. /**
  144160. * The url to the WebAssembly module.
  144161. */
  144162. wasmUrl?: string;
  144163. /**
  144164. * The url to the WebAssembly binary.
  144165. */
  144166. wasmBinaryUrl?: string;
  144167. /**
  144168. * The url to the fallback JavaScript module.
  144169. */
  144170. fallbackUrl?: string;
  144171. };
  144172. }
  144173. /**
  144174. * Draco compression (https://google.github.io/draco/)
  144175. *
  144176. * This class wraps the Draco module.
  144177. *
  144178. * **Encoder**
  144179. *
  144180. * The encoder is not currently implemented.
  144181. *
  144182. * **Decoder**
  144183. *
  144184. * 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.
  144185. *
  144186. * To update the configuration, use the following code:
  144187. * ```javascript
  144188. * DracoCompression.Configuration = {
  144189. * decoder: {
  144190. * wasmUrl: "<url to the WebAssembly library>",
  144191. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  144192. * fallbackUrl: "<url to the fallback JavaScript library>",
  144193. * }
  144194. * };
  144195. * ```
  144196. *
  144197. * 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.
  144198. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  144199. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  144200. *
  144201. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  144202. * ```javascript
  144203. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  144204. * ```
  144205. *
  144206. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  144207. */
  144208. export class DracoCompression implements IDisposable {
  144209. private _workerPoolPromise?;
  144210. private _decoderModulePromise?;
  144211. /**
  144212. * The configuration. Defaults to the following urls:
  144213. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  144214. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  144215. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  144216. */
  144217. static Configuration: IDracoCompressionConfiguration;
  144218. /**
  144219. * Returns true if the decoder configuration is available.
  144220. */
  144221. static get DecoderAvailable(): boolean;
  144222. /**
  144223. * Default number of workers to create when creating the draco compression object.
  144224. */
  144225. static DefaultNumWorkers: number;
  144226. private static GetDefaultNumWorkers;
  144227. private static _Default;
  144228. /**
  144229. * Default instance for the draco compression object.
  144230. */
  144231. static get Default(): DracoCompression;
  144232. /**
  144233. * Constructor
  144234. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  144235. */
  144236. constructor(numWorkers?: number);
  144237. /**
  144238. * Stop all async operations and release resources.
  144239. */
  144240. dispose(): void;
  144241. /**
  144242. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  144243. * @returns a promise that resolves when ready
  144244. */
  144245. whenReadyAsync(): Promise<void>;
  144246. /**
  144247. * Decode Draco compressed mesh data to vertex data.
  144248. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  144249. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  144250. * @returns A promise that resolves with the decoded vertex data
  144251. */
  144252. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  144253. [kind: string]: number;
  144254. }): Promise<VertexData>;
  144255. }
  144256. }
  144257. declare module BABYLON {
  144258. /**
  144259. * Class for building Constructive Solid Geometry
  144260. */
  144261. export class CSG {
  144262. private polygons;
  144263. /**
  144264. * The world matrix
  144265. */
  144266. matrix: Matrix;
  144267. /**
  144268. * Stores the position
  144269. */
  144270. position: Vector3;
  144271. /**
  144272. * Stores the rotation
  144273. */
  144274. rotation: Vector3;
  144275. /**
  144276. * Stores the rotation quaternion
  144277. */
  144278. rotationQuaternion: Nullable<Quaternion>;
  144279. /**
  144280. * Stores the scaling vector
  144281. */
  144282. scaling: Vector3;
  144283. /**
  144284. * Convert the Mesh to CSG
  144285. * @param mesh The Mesh to convert to CSG
  144286. * @returns A new CSG from the Mesh
  144287. */
  144288. static FromMesh(mesh: Mesh): CSG;
  144289. /**
  144290. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  144291. * @param polygons Polygons used to construct a CSG solid
  144292. */
  144293. private static FromPolygons;
  144294. /**
  144295. * Clones, or makes a deep copy, of the CSG
  144296. * @returns A new CSG
  144297. */
  144298. clone(): CSG;
  144299. /**
  144300. * Unions this CSG with another CSG
  144301. * @param csg The CSG to union against this CSG
  144302. * @returns The unioned CSG
  144303. */
  144304. union(csg: CSG): CSG;
  144305. /**
  144306. * Unions this CSG with another CSG in place
  144307. * @param csg The CSG to union against this CSG
  144308. */
  144309. unionInPlace(csg: CSG): void;
  144310. /**
  144311. * Subtracts this CSG with another CSG
  144312. * @param csg The CSG to subtract against this CSG
  144313. * @returns A new CSG
  144314. */
  144315. subtract(csg: CSG): CSG;
  144316. /**
  144317. * Subtracts this CSG with another CSG in place
  144318. * @param csg The CSG to subtact against this CSG
  144319. */
  144320. subtractInPlace(csg: CSG): void;
  144321. /**
  144322. * Intersect this CSG with another CSG
  144323. * @param csg The CSG to intersect against this CSG
  144324. * @returns A new CSG
  144325. */
  144326. intersect(csg: CSG): CSG;
  144327. /**
  144328. * Intersects this CSG with another CSG in place
  144329. * @param csg The CSG to intersect against this CSG
  144330. */
  144331. intersectInPlace(csg: CSG): void;
  144332. /**
  144333. * Return a new CSG solid with solid and empty space switched. This solid is
  144334. * not modified.
  144335. * @returns A new CSG solid with solid and empty space switched
  144336. */
  144337. inverse(): CSG;
  144338. /**
  144339. * Inverses the CSG in place
  144340. */
  144341. inverseInPlace(): void;
  144342. /**
  144343. * This is used to keep meshes transformations so they can be restored
  144344. * when we build back a Babylon Mesh
  144345. * NB : All CSG operations are performed in world coordinates
  144346. * @param csg The CSG to copy the transform attributes from
  144347. * @returns This CSG
  144348. */
  144349. copyTransformAttributes(csg: CSG): CSG;
  144350. /**
  144351. * Build Raw mesh from CSG
  144352. * Coordinates here are in world space
  144353. * @param name The name of the mesh geometry
  144354. * @param scene The Scene
  144355. * @param keepSubMeshes Specifies if the submeshes should be kept
  144356. * @returns A new Mesh
  144357. */
  144358. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144359. /**
  144360. * Build Mesh from CSG taking material and transforms into account
  144361. * @param name The name of the Mesh
  144362. * @param material The material of the Mesh
  144363. * @param scene The Scene
  144364. * @param keepSubMeshes Specifies if submeshes should be kept
  144365. * @returns The new Mesh
  144366. */
  144367. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144368. }
  144369. }
  144370. declare module BABYLON {
  144371. /**
  144372. * Class used to create a trail following a mesh
  144373. */
  144374. export class TrailMesh extends Mesh {
  144375. private _generator;
  144376. private _autoStart;
  144377. private _running;
  144378. private _diameter;
  144379. private _length;
  144380. private _sectionPolygonPointsCount;
  144381. private _sectionVectors;
  144382. private _sectionNormalVectors;
  144383. private _beforeRenderObserver;
  144384. /**
  144385. * @constructor
  144386. * @param name The value used by scene.getMeshByName() to do a lookup.
  144387. * @param generator The mesh or transform node to generate a trail.
  144388. * @param scene The scene to add this mesh to.
  144389. * @param diameter Diameter of trailing mesh. Default is 1.
  144390. * @param length Length of trailing mesh. Default is 60.
  144391. * @param autoStart Automatically start trailing mesh. Default true.
  144392. */
  144393. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  144394. /**
  144395. * "TrailMesh"
  144396. * @returns "TrailMesh"
  144397. */
  144398. getClassName(): string;
  144399. private _createMesh;
  144400. /**
  144401. * Start trailing mesh.
  144402. */
  144403. start(): void;
  144404. /**
  144405. * Stop trailing mesh.
  144406. */
  144407. stop(): void;
  144408. /**
  144409. * Update trailing mesh geometry.
  144410. */
  144411. update(): void;
  144412. /**
  144413. * Returns a new TrailMesh object.
  144414. * @param name is a string, the name given to the new mesh
  144415. * @param newGenerator use new generator object for cloned trail mesh
  144416. * @returns a new mesh
  144417. */
  144418. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  144419. /**
  144420. * Serializes this trail mesh
  144421. * @param serializationObject object to write serialization to
  144422. */
  144423. serialize(serializationObject: any): void;
  144424. /**
  144425. * Parses a serialized trail mesh
  144426. * @param parsedMesh the serialized mesh
  144427. * @param scene the scene to create the trail mesh in
  144428. * @returns the created trail mesh
  144429. */
  144430. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  144431. }
  144432. }
  144433. declare module BABYLON {
  144434. /**
  144435. * Class containing static functions to help procedurally build meshes
  144436. */
  144437. export class TiledBoxBuilder {
  144438. /**
  144439. * Creates a box mesh
  144440. * 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)
  144441. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144445. * @param name defines the name of the mesh
  144446. * @param options defines the options used to create the mesh
  144447. * @param scene defines the hosting scene
  144448. * @returns the box mesh
  144449. */
  144450. static CreateTiledBox(name: string, options: {
  144451. pattern?: number;
  144452. width?: number;
  144453. height?: number;
  144454. depth?: number;
  144455. tileSize?: number;
  144456. tileWidth?: number;
  144457. tileHeight?: number;
  144458. alignHorizontal?: number;
  144459. alignVertical?: number;
  144460. faceUV?: Vector4[];
  144461. faceColors?: Color4[];
  144462. sideOrientation?: number;
  144463. updatable?: boolean;
  144464. }, scene?: Nullable<Scene>): Mesh;
  144465. }
  144466. }
  144467. declare module BABYLON {
  144468. /**
  144469. * Class containing static functions to help procedurally build meshes
  144470. */
  144471. export class TorusKnotBuilder {
  144472. /**
  144473. * Creates a torus knot mesh
  144474. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144475. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144476. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144477. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144481. * @param name defines the name of the mesh
  144482. * @param options defines the options used to create the mesh
  144483. * @param scene defines the hosting scene
  144484. * @returns the torus knot mesh
  144485. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144486. */
  144487. static CreateTorusKnot(name: string, options: {
  144488. radius?: number;
  144489. tube?: number;
  144490. radialSegments?: number;
  144491. tubularSegments?: number;
  144492. p?: number;
  144493. q?: number;
  144494. updatable?: boolean;
  144495. sideOrientation?: number;
  144496. frontUVs?: Vector4;
  144497. backUVs?: Vector4;
  144498. }, scene: any): Mesh;
  144499. }
  144500. }
  144501. declare module BABYLON {
  144502. /**
  144503. * Polygon
  144504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  144505. */
  144506. export class Polygon {
  144507. /**
  144508. * Creates a rectangle
  144509. * @param xmin bottom X coord
  144510. * @param ymin bottom Y coord
  144511. * @param xmax top X coord
  144512. * @param ymax top Y coord
  144513. * @returns points that make the resulting rectation
  144514. */
  144515. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  144516. /**
  144517. * Creates a circle
  144518. * @param radius radius of circle
  144519. * @param cx scale in x
  144520. * @param cy scale in y
  144521. * @param numberOfSides number of sides that make up the circle
  144522. * @returns points that make the resulting circle
  144523. */
  144524. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  144525. /**
  144526. * Creates a polygon from input string
  144527. * @param input Input polygon data
  144528. * @returns the parsed points
  144529. */
  144530. static Parse(input: string): Vector2[];
  144531. /**
  144532. * Starts building a polygon from x and y coordinates
  144533. * @param x x coordinate
  144534. * @param y y coordinate
  144535. * @returns the started path2
  144536. */
  144537. static StartingAt(x: number, y: number): Path2;
  144538. }
  144539. /**
  144540. * Builds a polygon
  144541. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  144542. */
  144543. export class PolygonMeshBuilder {
  144544. private _points;
  144545. private _outlinepoints;
  144546. private _holes;
  144547. private _name;
  144548. private _scene;
  144549. private _epoints;
  144550. private _eholes;
  144551. private _addToepoint;
  144552. /**
  144553. * Babylon reference to the earcut plugin.
  144554. */
  144555. bjsEarcut: any;
  144556. /**
  144557. * Creates a PolygonMeshBuilder
  144558. * @param name name of the builder
  144559. * @param contours Path of the polygon
  144560. * @param scene scene to add to when creating the mesh
  144561. * @param earcutInjection can be used to inject your own earcut reference
  144562. */
  144563. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  144564. /**
  144565. * Adds a whole within the polygon
  144566. * @param hole Array of points defining the hole
  144567. * @returns this
  144568. */
  144569. addHole(hole: Vector2[]): PolygonMeshBuilder;
  144570. /**
  144571. * Creates the polygon
  144572. * @param updatable If the mesh should be updatable
  144573. * @param depth The depth of the mesh created
  144574. * @returns the created mesh
  144575. */
  144576. build(updatable?: boolean, depth?: number): Mesh;
  144577. /**
  144578. * Creates the polygon
  144579. * @param depth The depth of the mesh created
  144580. * @returns the created VertexData
  144581. */
  144582. buildVertexData(depth?: number): VertexData;
  144583. /**
  144584. * Adds a side to the polygon
  144585. * @param positions points that make the polygon
  144586. * @param normals normals of the polygon
  144587. * @param uvs uvs of the polygon
  144588. * @param indices indices of the polygon
  144589. * @param bounds bounds of the polygon
  144590. * @param points points of the polygon
  144591. * @param depth depth of the polygon
  144592. * @param flip flip of the polygon
  144593. */
  144594. private addSide;
  144595. }
  144596. }
  144597. declare module BABYLON {
  144598. /**
  144599. * Class containing static functions to help procedurally build meshes
  144600. */
  144601. export class PolygonBuilder {
  144602. /**
  144603. * Creates a polygon mesh
  144604. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144605. * * 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
  144606. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144609. * * Remember you can only change the shape positions, not their number when updating a polygon
  144610. * @param name defines the name of the mesh
  144611. * @param options defines the options used to create the mesh
  144612. * @param scene defines the hosting scene
  144613. * @param earcutInjection can be used to inject your own earcut reference
  144614. * @returns the polygon mesh
  144615. */
  144616. static CreatePolygon(name: string, options: {
  144617. shape: Vector3[];
  144618. holes?: Vector3[][];
  144619. depth?: number;
  144620. faceUV?: Vector4[];
  144621. faceColors?: Color4[];
  144622. updatable?: boolean;
  144623. sideOrientation?: number;
  144624. frontUVs?: Vector4;
  144625. backUVs?: Vector4;
  144626. wrap?: boolean;
  144627. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144628. /**
  144629. * Creates an extruded polygon mesh, with depth in the Y direction.
  144630. * * 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)
  144631. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144632. * @param name defines the name of the mesh
  144633. * @param options defines the options used to create the mesh
  144634. * @param scene defines the hosting scene
  144635. * @param earcutInjection can be used to inject your own earcut reference
  144636. * @returns the polygon mesh
  144637. */
  144638. static ExtrudePolygon(name: string, options: {
  144639. shape: Vector3[];
  144640. holes?: Vector3[][];
  144641. depth?: number;
  144642. faceUV?: Vector4[];
  144643. faceColors?: Color4[];
  144644. updatable?: boolean;
  144645. sideOrientation?: number;
  144646. frontUVs?: Vector4;
  144647. backUVs?: Vector4;
  144648. wrap?: boolean;
  144649. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144650. }
  144651. }
  144652. declare module BABYLON {
  144653. /**
  144654. * Class containing static functions to help procedurally build meshes
  144655. */
  144656. export class LatheBuilder {
  144657. /**
  144658. * Creates lathe mesh.
  144659. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144660. * * 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
  144661. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144662. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144663. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144664. * * 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
  144665. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144666. * * 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
  144667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144671. * @param name defines the name of the mesh
  144672. * @param options defines the options used to create the mesh
  144673. * @param scene defines the hosting scene
  144674. * @returns the lathe mesh
  144675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144676. */
  144677. static CreateLathe(name: string, options: {
  144678. shape: Vector3[];
  144679. radius?: number;
  144680. tessellation?: number;
  144681. clip?: number;
  144682. arc?: number;
  144683. closed?: boolean;
  144684. updatable?: boolean;
  144685. sideOrientation?: number;
  144686. frontUVs?: Vector4;
  144687. backUVs?: Vector4;
  144688. cap?: number;
  144689. invertUV?: boolean;
  144690. }, scene?: Nullable<Scene>): Mesh;
  144691. }
  144692. }
  144693. declare module BABYLON {
  144694. /**
  144695. * Class containing static functions to help procedurally build meshes
  144696. */
  144697. export class TiledPlaneBuilder {
  144698. /**
  144699. * Creates a tiled plane mesh
  144700. * * The parameter `pattern` will, depending on value, do nothing or
  144701. * * * flip (reflect about central vertical) alternate tiles across and up
  144702. * * * flip every tile on alternate rows
  144703. * * * rotate (180 degs) alternate tiles across and up
  144704. * * * rotate every tile on alternate rows
  144705. * * * flip and rotate alternate tiles across and up
  144706. * * * flip and rotate every tile on alternate rows
  144707. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144708. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144711. * * 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)
  144712. * * 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)
  144713. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144714. * @param name defines the name of the mesh
  144715. * @param options defines the options used to create the mesh
  144716. * @param scene defines the hosting scene
  144717. * @returns the box mesh
  144718. */
  144719. static CreateTiledPlane(name: string, options: {
  144720. pattern?: number;
  144721. tileSize?: number;
  144722. tileWidth?: number;
  144723. tileHeight?: number;
  144724. size?: number;
  144725. width?: number;
  144726. height?: number;
  144727. alignHorizontal?: number;
  144728. alignVertical?: number;
  144729. sideOrientation?: number;
  144730. frontUVs?: Vector4;
  144731. backUVs?: Vector4;
  144732. updatable?: boolean;
  144733. }, scene?: Nullable<Scene>): Mesh;
  144734. }
  144735. }
  144736. declare module BABYLON {
  144737. /**
  144738. * Class containing static functions to help procedurally build meshes
  144739. */
  144740. export class TubeBuilder {
  144741. /**
  144742. * Creates a tube mesh.
  144743. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144744. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144745. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144746. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144747. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144748. * * 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)
  144749. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144750. * * 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
  144751. * * 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
  144752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144756. * @param name defines the name of the mesh
  144757. * @param options defines the options used to create the mesh
  144758. * @param scene defines the hosting scene
  144759. * @returns the tube mesh
  144760. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144761. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144762. */
  144763. static CreateTube(name: string, options: {
  144764. path: Vector3[];
  144765. radius?: number;
  144766. tessellation?: number;
  144767. radiusFunction?: {
  144768. (i: number, distance: number): number;
  144769. };
  144770. cap?: number;
  144771. arc?: number;
  144772. updatable?: boolean;
  144773. sideOrientation?: number;
  144774. frontUVs?: Vector4;
  144775. backUVs?: Vector4;
  144776. instance?: Mesh;
  144777. invertUV?: boolean;
  144778. }, scene?: Nullable<Scene>): Mesh;
  144779. }
  144780. }
  144781. declare module BABYLON {
  144782. /**
  144783. * Class containing static functions to help procedurally build meshes
  144784. */
  144785. export class IcoSphereBuilder {
  144786. /**
  144787. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144788. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144789. * * 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`)
  144790. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144791. * * 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
  144792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144795. * @param name defines the name of the mesh
  144796. * @param options defines the options used to create the mesh
  144797. * @param scene defines the hosting scene
  144798. * @returns the icosahedron mesh
  144799. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144800. */
  144801. static CreateIcoSphere(name: string, options: {
  144802. radius?: number;
  144803. radiusX?: number;
  144804. radiusY?: number;
  144805. radiusZ?: number;
  144806. flat?: boolean;
  144807. subdivisions?: number;
  144808. sideOrientation?: number;
  144809. frontUVs?: Vector4;
  144810. backUVs?: Vector4;
  144811. updatable?: boolean;
  144812. }, scene?: Nullable<Scene>): Mesh;
  144813. }
  144814. }
  144815. declare module BABYLON {
  144816. /**
  144817. * Class containing static functions to help procedurally build meshes
  144818. */
  144819. export class DecalBuilder {
  144820. /**
  144821. * Creates a decal mesh.
  144822. * 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
  144823. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144824. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144825. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144826. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144827. * @param name defines the name of the mesh
  144828. * @param sourceMesh defines the mesh where the decal must be applied
  144829. * @param options defines the options used to create the mesh
  144830. * @param scene defines the hosting scene
  144831. * @returns the decal mesh
  144832. * @see https://doc.babylonjs.com/how_to/decals
  144833. */
  144834. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144835. position?: Vector3;
  144836. normal?: Vector3;
  144837. size?: Vector3;
  144838. angle?: number;
  144839. }): Mesh;
  144840. }
  144841. }
  144842. declare module BABYLON {
  144843. /**
  144844. * Class containing static functions to help procedurally build meshes
  144845. */
  144846. export class MeshBuilder {
  144847. /**
  144848. * Creates a box mesh
  144849. * * The parameter `size` sets the size (float) of each box side (default 1)
  144850. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144851. * * 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)
  144852. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144856. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144857. * @param name defines the name of the mesh
  144858. * @param options defines the options used to create the mesh
  144859. * @param scene defines the hosting scene
  144860. * @returns the box mesh
  144861. */
  144862. static CreateBox(name: string, options: {
  144863. size?: number;
  144864. width?: number;
  144865. height?: number;
  144866. depth?: number;
  144867. faceUV?: Vector4[];
  144868. faceColors?: Color4[];
  144869. sideOrientation?: number;
  144870. frontUVs?: Vector4;
  144871. backUVs?: Vector4;
  144872. wrap?: boolean;
  144873. topBaseAt?: number;
  144874. bottomBaseAt?: number;
  144875. updatable?: boolean;
  144876. }, scene?: Nullable<Scene>): Mesh;
  144877. /**
  144878. * Creates a tiled box mesh
  144879. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144881. * @param name defines the name of the mesh
  144882. * @param options defines the options used to create the mesh
  144883. * @param scene defines the hosting scene
  144884. * @returns the tiled box mesh
  144885. */
  144886. static CreateTiledBox(name: string, options: {
  144887. pattern?: number;
  144888. size?: number;
  144889. width?: number;
  144890. height?: number;
  144891. depth: number;
  144892. tileSize?: number;
  144893. tileWidth?: number;
  144894. tileHeight?: number;
  144895. faceUV?: Vector4[];
  144896. faceColors?: Color4[];
  144897. alignHorizontal?: number;
  144898. alignVertical?: number;
  144899. sideOrientation?: number;
  144900. updatable?: boolean;
  144901. }, scene?: Nullable<Scene>): Mesh;
  144902. /**
  144903. * Creates a sphere mesh
  144904. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144905. * * 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`)
  144906. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144907. * * 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
  144908. * * 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)
  144909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144912. * @param name defines the name of the mesh
  144913. * @param options defines the options used to create the mesh
  144914. * @param scene defines the hosting scene
  144915. * @returns the sphere mesh
  144916. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144917. */
  144918. static CreateSphere(name: string, options: {
  144919. segments?: number;
  144920. diameter?: number;
  144921. diameterX?: number;
  144922. diameterY?: number;
  144923. diameterZ?: number;
  144924. arc?: number;
  144925. slice?: number;
  144926. sideOrientation?: number;
  144927. frontUVs?: Vector4;
  144928. backUVs?: Vector4;
  144929. updatable?: boolean;
  144930. }, scene?: Nullable<Scene>): Mesh;
  144931. /**
  144932. * Creates a plane polygonal mesh. By default, this is a disc
  144933. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144934. * * 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
  144935. * * 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
  144936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144939. * @param name defines the name of the mesh
  144940. * @param options defines the options used to create the mesh
  144941. * @param scene defines the hosting scene
  144942. * @returns the plane polygonal mesh
  144943. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144944. */
  144945. static CreateDisc(name: string, options: {
  144946. radius?: number;
  144947. tessellation?: number;
  144948. arc?: number;
  144949. updatable?: boolean;
  144950. sideOrientation?: number;
  144951. frontUVs?: Vector4;
  144952. backUVs?: Vector4;
  144953. }, scene?: Nullable<Scene>): Mesh;
  144954. /**
  144955. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144956. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144957. * * 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`)
  144958. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144959. * * 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
  144960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144963. * @param name defines the name of the mesh
  144964. * @param options defines the options used to create the mesh
  144965. * @param scene defines the hosting scene
  144966. * @returns the icosahedron mesh
  144967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144968. */
  144969. static CreateIcoSphere(name: string, options: {
  144970. radius?: number;
  144971. radiusX?: number;
  144972. radiusY?: number;
  144973. radiusZ?: number;
  144974. flat?: boolean;
  144975. subdivisions?: number;
  144976. sideOrientation?: number;
  144977. frontUVs?: Vector4;
  144978. backUVs?: Vector4;
  144979. updatable?: boolean;
  144980. }, scene?: Nullable<Scene>): Mesh;
  144981. /**
  144982. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144983. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144984. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144985. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144986. * * 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
  144987. * * 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
  144988. * * 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
  144989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144992. * * 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
  144993. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144994. * * 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
  144995. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144997. * @param name defines the name of the mesh
  144998. * @param options defines the options used to create the mesh
  144999. * @param scene defines the hosting scene
  145000. * @returns the ribbon mesh
  145001. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145003. */
  145004. static CreateRibbon(name: string, options: {
  145005. pathArray: Vector3[][];
  145006. closeArray?: boolean;
  145007. closePath?: boolean;
  145008. offset?: number;
  145009. updatable?: boolean;
  145010. sideOrientation?: number;
  145011. frontUVs?: Vector4;
  145012. backUVs?: Vector4;
  145013. instance?: Mesh;
  145014. invertUV?: boolean;
  145015. uvs?: Vector2[];
  145016. colors?: Color4[];
  145017. }, scene?: Nullable<Scene>): Mesh;
  145018. /**
  145019. * Creates a cylinder or a cone mesh
  145020. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145021. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145022. * * 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.
  145023. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145024. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145025. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145026. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145027. * * 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).
  145028. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145029. * * 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).
  145030. * * 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
  145031. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145032. * * 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
  145033. * * 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.
  145034. * * If `enclose` is false, a ring surface is one element.
  145035. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145036. * * 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
  145037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145040. * @param name defines the name of the mesh
  145041. * @param options defines the options used to create the mesh
  145042. * @param scene defines the hosting scene
  145043. * @returns the cylinder mesh
  145044. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145045. */
  145046. static CreateCylinder(name: string, options: {
  145047. height?: number;
  145048. diameterTop?: number;
  145049. diameterBottom?: number;
  145050. diameter?: number;
  145051. tessellation?: number;
  145052. subdivisions?: number;
  145053. arc?: number;
  145054. faceColors?: Color4[];
  145055. faceUV?: Vector4[];
  145056. updatable?: boolean;
  145057. hasRings?: boolean;
  145058. enclose?: boolean;
  145059. cap?: number;
  145060. sideOrientation?: number;
  145061. frontUVs?: Vector4;
  145062. backUVs?: Vector4;
  145063. }, scene?: Nullable<Scene>): Mesh;
  145064. /**
  145065. * Creates a torus mesh
  145066. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145067. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145068. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145072. * @param name defines the name of the mesh
  145073. * @param options defines the options used to create the mesh
  145074. * @param scene defines the hosting scene
  145075. * @returns the torus mesh
  145076. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145077. */
  145078. static CreateTorus(name: string, options: {
  145079. diameter?: number;
  145080. thickness?: number;
  145081. tessellation?: number;
  145082. updatable?: boolean;
  145083. sideOrientation?: number;
  145084. frontUVs?: Vector4;
  145085. backUVs?: Vector4;
  145086. }, scene?: Nullable<Scene>): Mesh;
  145087. /**
  145088. * Creates a torus knot mesh
  145089. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145090. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145091. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145092. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145096. * @param name defines the name of the mesh
  145097. * @param options defines the options used to create the mesh
  145098. * @param scene defines the hosting scene
  145099. * @returns the torus knot mesh
  145100. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145101. */
  145102. static CreateTorusKnot(name: string, options: {
  145103. radius?: number;
  145104. tube?: number;
  145105. radialSegments?: number;
  145106. tubularSegments?: number;
  145107. p?: number;
  145108. q?: number;
  145109. updatable?: boolean;
  145110. sideOrientation?: number;
  145111. frontUVs?: Vector4;
  145112. backUVs?: Vector4;
  145113. }, scene?: Nullable<Scene>): Mesh;
  145114. /**
  145115. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145116. * * 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
  145117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145118. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145119. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145120. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  145121. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  145122. * * 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
  145123. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  145124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  145126. * @param name defines the name of the new line system
  145127. * @param options defines the options used to create the line system
  145128. * @param scene defines the hosting scene
  145129. * @returns a new line system mesh
  145130. */
  145131. static CreateLineSystem(name: string, options: {
  145132. lines: Vector3[][];
  145133. updatable?: boolean;
  145134. instance?: Nullable<LinesMesh>;
  145135. colors?: Nullable<Color4[][]>;
  145136. useVertexAlpha?: boolean;
  145137. }, scene: Nullable<Scene>): LinesMesh;
  145138. /**
  145139. * Creates a line mesh
  145140. * 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
  145141. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145142. * * The parameter `points` is an array successive Vector3
  145143. * * 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
  145144. * * The optional parameter `colors` is an array of successive Color4, one per line point
  145145. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  145146. * * When updating an instance, remember that only point positions can change, not the number of points
  145147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  145149. * @param name defines the name of the new line system
  145150. * @param options defines the options used to create the line system
  145151. * @param scene defines the hosting scene
  145152. * @returns a new line mesh
  145153. */
  145154. static CreateLines(name: string, options: {
  145155. points: Vector3[];
  145156. updatable?: boolean;
  145157. instance?: Nullable<LinesMesh>;
  145158. colors?: Color4[];
  145159. useVertexAlpha?: boolean;
  145160. }, scene?: Nullable<Scene>): LinesMesh;
  145161. /**
  145162. * Creates a dashed line mesh
  145163. * * 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
  145164. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145165. * * The parameter `points` is an array successive Vector3
  145166. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  145167. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  145168. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  145169. * * 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
  145170. * * When updating an instance, remember that only point positions can change, not the number of points
  145171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145172. * @param name defines the name of the mesh
  145173. * @param options defines the options used to create the mesh
  145174. * @param scene defines the hosting scene
  145175. * @returns the dashed line mesh
  145176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  145177. */
  145178. static CreateDashedLines(name: string, options: {
  145179. points: Vector3[];
  145180. dashSize?: number;
  145181. gapSize?: number;
  145182. dashNb?: number;
  145183. updatable?: boolean;
  145184. instance?: LinesMesh;
  145185. }, scene?: Nullable<Scene>): LinesMesh;
  145186. /**
  145187. * 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.
  145188. * * 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.
  145189. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145190. * * 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.
  145191. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  145192. * * 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
  145193. * * 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
  145194. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  145195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  145198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145199. * @param name defines the name of the mesh
  145200. * @param options defines the options used to create the mesh
  145201. * @param scene defines the hosting scene
  145202. * @returns the extruded shape mesh
  145203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145205. */
  145206. static ExtrudeShape(name: string, options: {
  145207. shape: Vector3[];
  145208. path: Vector3[];
  145209. scale?: number;
  145210. rotation?: number;
  145211. cap?: number;
  145212. updatable?: boolean;
  145213. sideOrientation?: number;
  145214. frontUVs?: Vector4;
  145215. backUVs?: Vector4;
  145216. instance?: Mesh;
  145217. invertUV?: boolean;
  145218. }, scene?: Nullable<Scene>): Mesh;
  145219. /**
  145220. * Creates an custom extruded shape mesh.
  145221. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  145222. * * 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.
  145223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145224. * * 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
  145225. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  145226. * * 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
  145227. * * It must returns a float value that will be the scale value applied to the shape on each path point
  145228. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  145229. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  145230. * * 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
  145231. * * 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
  145232. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  145233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145237. * @param name defines the name of the mesh
  145238. * @param options defines the options used to create the mesh
  145239. * @param scene defines the hosting scene
  145240. * @returns the custom extruded shape mesh
  145241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  145242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145244. */
  145245. static ExtrudeShapeCustom(name: string, options: {
  145246. shape: Vector3[];
  145247. path: Vector3[];
  145248. scaleFunction?: any;
  145249. rotationFunction?: any;
  145250. ribbonCloseArray?: boolean;
  145251. ribbonClosePath?: boolean;
  145252. cap?: number;
  145253. updatable?: boolean;
  145254. sideOrientation?: number;
  145255. frontUVs?: Vector4;
  145256. backUVs?: Vector4;
  145257. instance?: Mesh;
  145258. invertUV?: boolean;
  145259. }, scene?: Nullable<Scene>): Mesh;
  145260. /**
  145261. * Creates lathe mesh.
  145262. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145263. * * 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
  145264. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145265. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145266. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145267. * * 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
  145268. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145269. * * 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
  145270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145274. * @param name defines the name of the mesh
  145275. * @param options defines the options used to create the mesh
  145276. * @param scene defines the hosting scene
  145277. * @returns the lathe mesh
  145278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145279. */
  145280. static CreateLathe(name: string, options: {
  145281. shape: Vector3[];
  145282. radius?: number;
  145283. tessellation?: number;
  145284. clip?: number;
  145285. arc?: number;
  145286. closed?: boolean;
  145287. updatable?: boolean;
  145288. sideOrientation?: number;
  145289. frontUVs?: Vector4;
  145290. backUVs?: Vector4;
  145291. cap?: number;
  145292. invertUV?: boolean;
  145293. }, scene?: Nullable<Scene>): Mesh;
  145294. /**
  145295. * Creates a tiled plane mesh
  145296. * * You can set a limited pattern arrangement with the tiles
  145297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145300. * @param name defines the name of the mesh
  145301. * @param options defines the options used to create the mesh
  145302. * @param scene defines the hosting scene
  145303. * @returns the plane mesh
  145304. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145305. */
  145306. static CreateTiledPlane(name: string, options: {
  145307. pattern?: number;
  145308. tileSize?: number;
  145309. tileWidth?: number;
  145310. tileHeight?: number;
  145311. size?: number;
  145312. width?: number;
  145313. height?: number;
  145314. alignHorizontal?: number;
  145315. alignVertical?: number;
  145316. sideOrientation?: number;
  145317. frontUVs?: Vector4;
  145318. backUVs?: Vector4;
  145319. updatable?: boolean;
  145320. }, scene?: Nullable<Scene>): Mesh;
  145321. /**
  145322. * Creates a plane mesh
  145323. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  145324. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  145325. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  145326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145329. * @param name defines the name of the mesh
  145330. * @param options defines the options used to create the mesh
  145331. * @param scene defines the hosting scene
  145332. * @returns the plane mesh
  145333. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145334. */
  145335. static CreatePlane(name: string, options: {
  145336. size?: number;
  145337. width?: number;
  145338. height?: number;
  145339. sideOrientation?: number;
  145340. frontUVs?: Vector4;
  145341. backUVs?: Vector4;
  145342. updatable?: boolean;
  145343. sourcePlane?: Plane;
  145344. }, scene?: Nullable<Scene>): Mesh;
  145345. /**
  145346. * Creates a ground mesh
  145347. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  145348. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  145349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145350. * @param name defines the name of the mesh
  145351. * @param options defines the options used to create the mesh
  145352. * @param scene defines the hosting scene
  145353. * @returns the ground mesh
  145354. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  145355. */
  145356. static CreateGround(name: string, options: {
  145357. width?: number;
  145358. height?: number;
  145359. subdivisions?: number;
  145360. subdivisionsX?: number;
  145361. subdivisionsY?: number;
  145362. updatable?: boolean;
  145363. }, scene?: Nullable<Scene>): Mesh;
  145364. /**
  145365. * Creates a tiled ground mesh
  145366. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  145367. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  145368. * * 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
  145369. * * 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
  145370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145371. * @param name defines the name of the mesh
  145372. * @param options defines the options used to create the mesh
  145373. * @param scene defines the hosting scene
  145374. * @returns the tiled ground mesh
  145375. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  145376. */
  145377. static CreateTiledGround(name: string, options: {
  145378. xmin: number;
  145379. zmin: number;
  145380. xmax: number;
  145381. zmax: number;
  145382. subdivisions?: {
  145383. w: number;
  145384. h: number;
  145385. };
  145386. precision?: {
  145387. w: number;
  145388. h: number;
  145389. };
  145390. updatable?: boolean;
  145391. }, scene?: Nullable<Scene>): Mesh;
  145392. /**
  145393. * Creates a ground mesh from a height map
  145394. * * The parameter `url` sets the URL of the height map image resource.
  145395. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  145396. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  145397. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  145398. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  145399. * * 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.
  145400. * * 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).
  145401. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  145402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145403. * @param name defines the name of the mesh
  145404. * @param url defines the url to the height map
  145405. * @param options defines the options used to create the mesh
  145406. * @param scene defines the hosting scene
  145407. * @returns the ground mesh
  145408. * @see https://doc.babylonjs.com/babylon101/height_map
  145409. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  145410. */
  145411. static CreateGroundFromHeightMap(name: string, url: string, options: {
  145412. width?: number;
  145413. height?: number;
  145414. subdivisions?: number;
  145415. minHeight?: number;
  145416. maxHeight?: number;
  145417. colorFilter?: Color3;
  145418. alphaFilter?: number;
  145419. updatable?: boolean;
  145420. onReady?: (mesh: GroundMesh) => void;
  145421. }, scene?: Nullable<Scene>): GroundMesh;
  145422. /**
  145423. * Creates a polygon mesh
  145424. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145425. * * 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
  145426. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145429. * * Remember you can only change the shape positions, not their number when updating a polygon
  145430. * @param name defines the name of the mesh
  145431. * @param options defines the options used to create the mesh
  145432. * @param scene defines the hosting scene
  145433. * @param earcutInjection can be used to inject your own earcut reference
  145434. * @returns the polygon mesh
  145435. */
  145436. static CreatePolygon(name: string, options: {
  145437. shape: Vector3[];
  145438. holes?: Vector3[][];
  145439. depth?: number;
  145440. faceUV?: Vector4[];
  145441. faceColors?: Color4[];
  145442. updatable?: boolean;
  145443. sideOrientation?: number;
  145444. frontUVs?: Vector4;
  145445. backUVs?: Vector4;
  145446. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145447. /**
  145448. * Creates an extruded polygon mesh, with depth in the Y direction.
  145449. * * 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)
  145450. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145451. * @param name defines the name of the mesh
  145452. * @param options defines the options used to create the mesh
  145453. * @param scene defines the hosting scene
  145454. * @param earcutInjection can be used to inject your own earcut reference
  145455. * @returns the polygon mesh
  145456. */
  145457. static ExtrudePolygon(name: string, options: {
  145458. shape: Vector3[];
  145459. holes?: Vector3[][];
  145460. depth?: number;
  145461. faceUV?: Vector4[];
  145462. faceColors?: Color4[];
  145463. updatable?: boolean;
  145464. sideOrientation?: number;
  145465. frontUVs?: Vector4;
  145466. backUVs?: Vector4;
  145467. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145468. /**
  145469. * Creates a tube mesh.
  145470. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145471. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145472. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145473. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145474. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145475. * * 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)
  145476. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145477. * * 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
  145478. * * 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
  145479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145483. * @param name defines the name of the mesh
  145484. * @param options defines the options used to create the mesh
  145485. * @param scene defines the hosting scene
  145486. * @returns the tube mesh
  145487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145488. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145489. */
  145490. static CreateTube(name: string, options: {
  145491. path: Vector3[];
  145492. radius?: number;
  145493. tessellation?: number;
  145494. radiusFunction?: {
  145495. (i: number, distance: number): number;
  145496. };
  145497. cap?: number;
  145498. arc?: number;
  145499. updatable?: boolean;
  145500. sideOrientation?: number;
  145501. frontUVs?: Vector4;
  145502. backUVs?: Vector4;
  145503. instance?: Mesh;
  145504. invertUV?: boolean;
  145505. }, scene?: Nullable<Scene>): Mesh;
  145506. /**
  145507. * Creates a polyhedron mesh
  145508. * * 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
  145509. * * The parameter `size` (positive float, default 1) sets the polygon size
  145510. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  145511. * * 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`
  145512. * * 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
  145513. * * 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)`)
  145514. * * 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
  145515. * * 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
  145516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145519. * @param name defines the name of the mesh
  145520. * @param options defines the options used to create the mesh
  145521. * @param scene defines the hosting scene
  145522. * @returns the polyhedron mesh
  145523. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  145524. */
  145525. static CreatePolyhedron(name: string, options: {
  145526. type?: number;
  145527. size?: number;
  145528. sizeX?: number;
  145529. sizeY?: number;
  145530. sizeZ?: number;
  145531. custom?: any;
  145532. faceUV?: Vector4[];
  145533. faceColors?: Color4[];
  145534. flat?: boolean;
  145535. updatable?: boolean;
  145536. sideOrientation?: number;
  145537. frontUVs?: Vector4;
  145538. backUVs?: Vector4;
  145539. }, scene?: Nullable<Scene>): Mesh;
  145540. /**
  145541. * Creates a decal mesh.
  145542. * 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
  145543. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145544. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145545. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145546. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145547. * @param name defines the name of the mesh
  145548. * @param sourceMesh defines the mesh where the decal must be applied
  145549. * @param options defines the options used to create the mesh
  145550. * @param scene defines the hosting scene
  145551. * @returns the decal mesh
  145552. * @see https://doc.babylonjs.com/how_to/decals
  145553. */
  145554. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145555. position?: Vector3;
  145556. normal?: Vector3;
  145557. size?: Vector3;
  145558. angle?: number;
  145559. }): Mesh;
  145560. }
  145561. }
  145562. declare module BABYLON {
  145563. /**
  145564. * A simplifier interface for future simplification implementations
  145565. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145566. */
  145567. export interface ISimplifier {
  145568. /**
  145569. * Simplification of a given mesh according to the given settings.
  145570. * Since this requires computation, it is assumed that the function runs async.
  145571. * @param settings The settings of the simplification, including quality and distance
  145572. * @param successCallback A callback that will be called after the mesh was simplified.
  145573. * @param errorCallback in case of an error, this callback will be called. optional.
  145574. */
  145575. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  145576. }
  145577. /**
  145578. * Expected simplification settings.
  145579. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  145580. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145581. */
  145582. export interface ISimplificationSettings {
  145583. /**
  145584. * Gets or sets the expected quality
  145585. */
  145586. quality: number;
  145587. /**
  145588. * Gets or sets the distance when this optimized version should be used
  145589. */
  145590. distance: number;
  145591. /**
  145592. * Gets an already optimized mesh
  145593. */
  145594. optimizeMesh?: boolean;
  145595. }
  145596. /**
  145597. * Class used to specify simplification options
  145598. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145599. */
  145600. export class SimplificationSettings implements ISimplificationSettings {
  145601. /** expected quality */
  145602. quality: number;
  145603. /** distance when this optimized version should be used */
  145604. distance: number;
  145605. /** already optimized mesh */
  145606. optimizeMesh?: boolean | undefined;
  145607. /**
  145608. * Creates a SimplificationSettings
  145609. * @param quality expected quality
  145610. * @param distance distance when this optimized version should be used
  145611. * @param optimizeMesh already optimized mesh
  145612. */
  145613. constructor(
  145614. /** expected quality */
  145615. quality: number,
  145616. /** distance when this optimized version should be used */
  145617. distance: number,
  145618. /** already optimized mesh */
  145619. optimizeMesh?: boolean | undefined);
  145620. }
  145621. /**
  145622. * Interface used to define a simplification task
  145623. */
  145624. export interface ISimplificationTask {
  145625. /**
  145626. * Array of settings
  145627. */
  145628. settings: Array<ISimplificationSettings>;
  145629. /**
  145630. * Simplification type
  145631. */
  145632. simplificationType: SimplificationType;
  145633. /**
  145634. * Mesh to simplify
  145635. */
  145636. mesh: Mesh;
  145637. /**
  145638. * Callback called on success
  145639. */
  145640. successCallback?: () => void;
  145641. /**
  145642. * Defines if parallel processing can be used
  145643. */
  145644. parallelProcessing: boolean;
  145645. }
  145646. /**
  145647. * Queue used to order the simplification tasks
  145648. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145649. */
  145650. export class SimplificationQueue {
  145651. private _simplificationArray;
  145652. /**
  145653. * Gets a boolean indicating that the process is still running
  145654. */
  145655. running: boolean;
  145656. /**
  145657. * Creates a new queue
  145658. */
  145659. constructor();
  145660. /**
  145661. * Adds a new simplification task
  145662. * @param task defines a task to add
  145663. */
  145664. addTask(task: ISimplificationTask): void;
  145665. /**
  145666. * Execute next task
  145667. */
  145668. executeNext(): void;
  145669. /**
  145670. * Execute a simplification task
  145671. * @param task defines the task to run
  145672. */
  145673. runSimplification(task: ISimplificationTask): void;
  145674. private getSimplifier;
  145675. }
  145676. /**
  145677. * The implemented types of simplification
  145678. * At the moment only Quadratic Error Decimation is implemented
  145679. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145680. */
  145681. export enum SimplificationType {
  145682. /** Quadratic error decimation */
  145683. QUADRATIC = 0
  145684. }
  145685. /**
  145686. * An implementation of the Quadratic Error simplification algorithm.
  145687. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145688. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145689. * @author RaananW
  145690. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145691. */
  145692. export class QuadraticErrorSimplification implements ISimplifier {
  145693. private _mesh;
  145694. private triangles;
  145695. private vertices;
  145696. private references;
  145697. private _reconstructedMesh;
  145698. /** Gets or sets the number pf sync interations */
  145699. syncIterations: number;
  145700. /** Gets or sets the aggressiveness of the simplifier */
  145701. aggressiveness: number;
  145702. /** Gets or sets the number of allowed iterations for decimation */
  145703. decimationIterations: number;
  145704. /** Gets or sets the espilon to use for bounding box computation */
  145705. boundingBoxEpsilon: number;
  145706. /**
  145707. * Creates a new QuadraticErrorSimplification
  145708. * @param _mesh defines the target mesh
  145709. */
  145710. constructor(_mesh: Mesh);
  145711. /**
  145712. * Simplification of a given mesh according to the given settings.
  145713. * Since this requires computation, it is assumed that the function runs async.
  145714. * @param settings The settings of the simplification, including quality and distance
  145715. * @param successCallback A callback that will be called after the mesh was simplified.
  145716. */
  145717. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145718. private runDecimation;
  145719. private initWithMesh;
  145720. private init;
  145721. private reconstructMesh;
  145722. private initDecimatedMesh;
  145723. private isFlipped;
  145724. private updateTriangles;
  145725. private identifyBorder;
  145726. private updateMesh;
  145727. private vertexError;
  145728. private calculateError;
  145729. }
  145730. }
  145731. declare module BABYLON {
  145732. interface Scene {
  145733. /** @hidden (Backing field) */
  145734. _simplificationQueue: SimplificationQueue;
  145735. /**
  145736. * Gets or sets the simplification queue attached to the scene
  145737. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145738. */
  145739. simplificationQueue: SimplificationQueue;
  145740. }
  145741. interface Mesh {
  145742. /**
  145743. * Simplify the mesh according to the given array of settings.
  145744. * Function will return immediately and will simplify async
  145745. * @param settings a collection of simplification settings
  145746. * @param parallelProcessing should all levels calculate parallel or one after the other
  145747. * @param simplificationType the type of simplification to run
  145748. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145749. * @returns the current mesh
  145750. */
  145751. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145752. }
  145753. /**
  145754. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145755. * created in a scene
  145756. */
  145757. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145758. /**
  145759. * The component name helpfull to identify the component in the list of scene components.
  145760. */
  145761. readonly name: string;
  145762. /**
  145763. * The scene the component belongs to.
  145764. */
  145765. scene: Scene;
  145766. /**
  145767. * Creates a new instance of the component for the given scene
  145768. * @param scene Defines the scene to register the component in
  145769. */
  145770. constructor(scene: Scene);
  145771. /**
  145772. * Registers the component in a given scene
  145773. */
  145774. register(): void;
  145775. /**
  145776. * Rebuilds the elements related to this component in case of
  145777. * context lost for instance.
  145778. */
  145779. rebuild(): void;
  145780. /**
  145781. * Disposes the component and the associated ressources
  145782. */
  145783. dispose(): void;
  145784. private _beforeCameraUpdate;
  145785. }
  145786. }
  145787. declare module BABYLON {
  145788. interface Mesh {
  145789. /**
  145790. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  145791. */
  145792. thinInstanceEnablePicking: boolean;
  145793. /**
  145794. * Creates a new thin instance
  145795. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145796. * @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
  145797. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145798. */
  145799. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145800. /**
  145801. * Adds the transformation (matrix) of the current mesh as a thin instance
  145802. * @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
  145803. * @returns the thin instance index number
  145804. */
  145805. thinInstanceAddSelf(refresh: boolean): number;
  145806. /**
  145807. * Registers a custom attribute to be used with thin instances
  145808. * @param kind name of the attribute
  145809. * @param stride size in floats of the attribute
  145810. */
  145811. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145812. /**
  145813. * Sets the matrix of a thin instance
  145814. * @param index index of the thin instance
  145815. * @param matrix matrix to set
  145816. * @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
  145817. */
  145818. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145819. /**
  145820. * Sets the value of a custom attribute for a thin instance
  145821. * @param kind name of the attribute
  145822. * @param index index of the thin instance
  145823. * @param value value to set
  145824. * @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
  145825. */
  145826. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145827. /**
  145828. * 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.
  145829. */
  145830. thinInstanceCount: number;
  145831. /**
  145832. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145833. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145834. * @param buffer buffer to set
  145835. * @param stride size in floats of each value of the buffer
  145836. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145837. */
  145838. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145839. /**
  145840. * Gets the list of world matrices
  145841. * @return an array containing all the world matrices from the thin instances
  145842. */
  145843. thinInstanceGetWorldMatrices(): Matrix[];
  145844. /**
  145845. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145846. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145847. */
  145848. thinInstanceBufferUpdated(kind: string): void;
  145849. /**
  145850. * Refreshes the bounding info, taking into account all the thin instances defined
  145851. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145852. */
  145853. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145854. /** @hidden */
  145855. _thinInstanceInitializeUserStorage(): void;
  145856. /** @hidden */
  145857. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145858. /** @hidden */
  145859. _userThinInstanceBuffersStorage: {
  145860. data: {
  145861. [key: string]: Float32Array;
  145862. };
  145863. sizes: {
  145864. [key: string]: number;
  145865. };
  145866. vertexBuffers: {
  145867. [key: string]: Nullable<VertexBuffer>;
  145868. };
  145869. strides: {
  145870. [key: string]: number;
  145871. };
  145872. };
  145873. }
  145874. }
  145875. declare module BABYLON {
  145876. /**
  145877. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145878. */
  145879. export interface INavigationEnginePlugin {
  145880. /**
  145881. * plugin name
  145882. */
  145883. name: string;
  145884. /**
  145885. * Creates a navigation mesh
  145886. * @param meshes array of all the geometry used to compute the navigatio mesh
  145887. * @param parameters bunch of parameters used to filter geometry
  145888. */
  145889. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145890. /**
  145891. * Create a navigation mesh debug mesh
  145892. * @param scene is where the mesh will be added
  145893. * @returns debug display mesh
  145894. */
  145895. createDebugNavMesh(scene: Scene): Mesh;
  145896. /**
  145897. * Get a navigation mesh constrained position, closest to the parameter position
  145898. * @param position world position
  145899. * @returns the closest point to position constrained by the navigation mesh
  145900. */
  145901. getClosestPoint(position: Vector3): Vector3;
  145902. /**
  145903. * Get a navigation mesh constrained position, closest to the parameter position
  145904. * @param position world position
  145905. * @param result output the closest point to position constrained by the navigation mesh
  145906. */
  145907. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145908. /**
  145909. * Get a navigation mesh constrained position, within a particular radius
  145910. * @param position world position
  145911. * @param maxRadius the maximum distance to the constrained world position
  145912. * @returns the closest point to position constrained by the navigation mesh
  145913. */
  145914. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145915. /**
  145916. * Get a navigation mesh constrained position, within a particular radius
  145917. * @param position world position
  145918. * @param maxRadius the maximum distance to the constrained world position
  145919. * @param result output the closest point to position constrained by the navigation mesh
  145920. */
  145921. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145922. /**
  145923. * Compute the final position from a segment made of destination-position
  145924. * @param position world position
  145925. * @param destination world position
  145926. * @returns the resulting point along the navmesh
  145927. */
  145928. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145929. /**
  145930. * Compute the final position from a segment made of destination-position
  145931. * @param position world position
  145932. * @param destination world position
  145933. * @param result output the resulting point along the navmesh
  145934. */
  145935. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145936. /**
  145937. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145938. * @param start world position
  145939. * @param end world position
  145940. * @returns array containing world position composing the path
  145941. */
  145942. computePath(start: Vector3, end: Vector3): Vector3[];
  145943. /**
  145944. * If this plugin is supported
  145945. * @returns true if plugin is supported
  145946. */
  145947. isSupported(): boolean;
  145948. /**
  145949. * Create a new Crowd so you can add agents
  145950. * @param maxAgents the maximum agent count in the crowd
  145951. * @param maxAgentRadius the maximum radius an agent can have
  145952. * @param scene to attach the crowd to
  145953. * @returns the crowd you can add agents to
  145954. */
  145955. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145956. /**
  145957. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145958. * The queries will try to find a solution within those bounds
  145959. * default is (1,1,1)
  145960. * @param extent x,y,z value that define the extent around the queries point of reference
  145961. */
  145962. setDefaultQueryExtent(extent: Vector3): void;
  145963. /**
  145964. * Get the Bounding box extent specified by setDefaultQueryExtent
  145965. * @returns the box extent values
  145966. */
  145967. getDefaultQueryExtent(): Vector3;
  145968. /**
  145969. * build the navmesh from a previously saved state using getNavmeshData
  145970. * @param data the Uint8Array returned by getNavmeshData
  145971. */
  145972. buildFromNavmeshData(data: Uint8Array): void;
  145973. /**
  145974. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145975. * @returns data the Uint8Array that can be saved and reused
  145976. */
  145977. getNavmeshData(): Uint8Array;
  145978. /**
  145979. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145980. * @param result output the box extent values
  145981. */
  145982. getDefaultQueryExtentToRef(result: Vector3): void;
  145983. /**
  145984. * Release all resources
  145985. */
  145986. dispose(): void;
  145987. }
  145988. /**
  145989. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145990. */
  145991. export interface ICrowd {
  145992. /**
  145993. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145994. * You can attach anything to that node. The node position is updated in the scene update tick.
  145995. * @param pos world position that will be constrained by the navigation mesh
  145996. * @param parameters agent parameters
  145997. * @param transform hooked to the agent that will be update by the scene
  145998. * @returns agent index
  145999. */
  146000. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146001. /**
  146002. * Returns the agent position in world space
  146003. * @param index agent index returned by addAgent
  146004. * @returns world space position
  146005. */
  146006. getAgentPosition(index: number): Vector3;
  146007. /**
  146008. * Gets the agent position result in world space
  146009. * @param index agent index returned by addAgent
  146010. * @param result output world space position
  146011. */
  146012. getAgentPositionToRef(index: number, result: Vector3): void;
  146013. /**
  146014. * Gets the agent velocity in world space
  146015. * @param index agent index returned by addAgent
  146016. * @returns world space velocity
  146017. */
  146018. getAgentVelocity(index: number): Vector3;
  146019. /**
  146020. * Gets the agent velocity result in world space
  146021. * @param index agent index returned by addAgent
  146022. * @param result output world space velocity
  146023. */
  146024. getAgentVelocityToRef(index: number, result: Vector3): void;
  146025. /**
  146026. * remove a particular agent previously created
  146027. * @param index agent index returned by addAgent
  146028. */
  146029. removeAgent(index: number): void;
  146030. /**
  146031. * get the list of all agents attached to this crowd
  146032. * @returns list of agent indices
  146033. */
  146034. getAgents(): number[];
  146035. /**
  146036. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146037. * @param deltaTime in seconds
  146038. */
  146039. update(deltaTime: number): void;
  146040. /**
  146041. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146042. * @param index agent index returned by addAgent
  146043. * @param destination targeted world position
  146044. */
  146045. agentGoto(index: number, destination: Vector3): void;
  146046. /**
  146047. * Teleport the agent to a new position
  146048. * @param index agent index returned by addAgent
  146049. * @param destination targeted world position
  146050. */
  146051. agentTeleport(index: number, destination: Vector3): void;
  146052. /**
  146053. * Update agent parameters
  146054. * @param index agent index returned by addAgent
  146055. * @param parameters agent parameters
  146056. */
  146057. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146058. /**
  146059. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146060. * The queries will try to find a solution within those bounds
  146061. * default is (1,1,1)
  146062. * @param extent x,y,z value that define the extent around the queries point of reference
  146063. */
  146064. setDefaultQueryExtent(extent: Vector3): void;
  146065. /**
  146066. * Get the Bounding box extent specified by setDefaultQueryExtent
  146067. * @returns the box extent values
  146068. */
  146069. getDefaultQueryExtent(): Vector3;
  146070. /**
  146071. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146072. * @param result output the box extent values
  146073. */
  146074. getDefaultQueryExtentToRef(result: Vector3): void;
  146075. /**
  146076. * Release all resources
  146077. */
  146078. dispose(): void;
  146079. }
  146080. /**
  146081. * Configures an agent
  146082. */
  146083. export interface IAgentParameters {
  146084. /**
  146085. * Agent radius. [Limit: >= 0]
  146086. */
  146087. radius: number;
  146088. /**
  146089. * Agent height. [Limit: > 0]
  146090. */
  146091. height: number;
  146092. /**
  146093. * Maximum allowed acceleration. [Limit: >= 0]
  146094. */
  146095. maxAcceleration: number;
  146096. /**
  146097. * Maximum allowed speed. [Limit: >= 0]
  146098. */
  146099. maxSpeed: number;
  146100. /**
  146101. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146102. */
  146103. collisionQueryRange: number;
  146104. /**
  146105. * The path visibility optimization range. [Limit: > 0]
  146106. */
  146107. pathOptimizationRange: number;
  146108. /**
  146109. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  146110. */
  146111. separationWeight: number;
  146112. }
  146113. /**
  146114. * Configures the navigation mesh creation
  146115. */
  146116. export interface INavMeshParameters {
  146117. /**
  146118. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  146119. */
  146120. cs: number;
  146121. /**
  146122. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  146123. */
  146124. ch: number;
  146125. /**
  146126. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  146127. */
  146128. walkableSlopeAngle: number;
  146129. /**
  146130. * Minimum floor to 'ceiling' height that will still allow the floor area to
  146131. * be considered walkable. [Limit: >= 3] [Units: vx]
  146132. */
  146133. walkableHeight: number;
  146134. /**
  146135. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  146136. */
  146137. walkableClimb: number;
  146138. /**
  146139. * The distance to erode/shrink the walkable area of the heightfield away from
  146140. * obstructions. [Limit: >=0] [Units: vx]
  146141. */
  146142. walkableRadius: number;
  146143. /**
  146144. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  146145. */
  146146. maxEdgeLen: number;
  146147. /**
  146148. * The maximum distance a simplfied contour's border edges should deviate
  146149. * the original raw contour. [Limit: >=0] [Units: vx]
  146150. */
  146151. maxSimplificationError: number;
  146152. /**
  146153. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  146154. */
  146155. minRegionArea: number;
  146156. /**
  146157. * Any regions with a span count smaller than this value will, if possible,
  146158. * be merged with larger regions. [Limit: >=0] [Units: vx]
  146159. */
  146160. mergeRegionArea: number;
  146161. /**
  146162. * The maximum number of vertices allowed for polygons generated during the
  146163. * contour to polygon conversion process. [Limit: >= 3]
  146164. */
  146165. maxVertsPerPoly: number;
  146166. /**
  146167. * Sets the sampling distance to use when generating the detail mesh.
  146168. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  146169. */
  146170. detailSampleDist: number;
  146171. /**
  146172. * The maximum distance the detail mesh surface should deviate from heightfield
  146173. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  146174. */
  146175. detailSampleMaxError: number;
  146176. }
  146177. }
  146178. declare module BABYLON {
  146179. /**
  146180. * RecastJS navigation plugin
  146181. */
  146182. export class RecastJSPlugin implements INavigationEnginePlugin {
  146183. /**
  146184. * Reference to the Recast library
  146185. */
  146186. bjsRECAST: any;
  146187. /**
  146188. * plugin name
  146189. */
  146190. name: string;
  146191. /**
  146192. * the first navmesh created. We might extend this to support multiple navmeshes
  146193. */
  146194. navMesh: any;
  146195. /**
  146196. * Initializes the recastJS plugin
  146197. * @param recastInjection can be used to inject your own recast reference
  146198. */
  146199. constructor(recastInjection?: any);
  146200. /**
  146201. * Creates a navigation mesh
  146202. * @param meshes array of all the geometry used to compute the navigatio mesh
  146203. * @param parameters bunch of parameters used to filter geometry
  146204. */
  146205. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146206. /**
  146207. * Create a navigation mesh debug mesh
  146208. * @param scene is where the mesh will be added
  146209. * @returns debug display mesh
  146210. */
  146211. createDebugNavMesh(scene: Scene): Mesh;
  146212. /**
  146213. * Get a navigation mesh constrained position, closest to the parameter position
  146214. * @param position world position
  146215. * @returns the closest point to position constrained by the navigation mesh
  146216. */
  146217. getClosestPoint(position: Vector3): Vector3;
  146218. /**
  146219. * Get a navigation mesh constrained position, closest to the parameter position
  146220. * @param position world position
  146221. * @param result output the closest point to position constrained by the navigation mesh
  146222. */
  146223. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146224. /**
  146225. * Get a navigation mesh constrained position, within a particular radius
  146226. * @param position world position
  146227. * @param maxRadius the maximum distance to the constrained world position
  146228. * @returns the closest point to position constrained by the navigation mesh
  146229. */
  146230. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146231. /**
  146232. * Get a navigation mesh constrained position, within a particular radius
  146233. * @param position world position
  146234. * @param maxRadius the maximum distance to the constrained world position
  146235. * @param result output the closest point to position constrained by the navigation mesh
  146236. */
  146237. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146238. /**
  146239. * Compute the final position from a segment made of destination-position
  146240. * @param position world position
  146241. * @param destination world position
  146242. * @returns the resulting point along the navmesh
  146243. */
  146244. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146245. /**
  146246. * Compute the final position from a segment made of destination-position
  146247. * @param position world position
  146248. * @param destination world position
  146249. * @param result output the resulting point along the navmesh
  146250. */
  146251. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146252. /**
  146253. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146254. * @param start world position
  146255. * @param end world position
  146256. * @returns array containing world position composing the path
  146257. */
  146258. computePath(start: Vector3, end: Vector3): Vector3[];
  146259. /**
  146260. * Create a new Crowd so you can add agents
  146261. * @param maxAgents the maximum agent count in the crowd
  146262. * @param maxAgentRadius the maximum radius an agent can have
  146263. * @param scene to attach the crowd to
  146264. * @returns the crowd you can add agents to
  146265. */
  146266. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146267. /**
  146268. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146269. * The queries will try to find a solution within those bounds
  146270. * default is (1,1,1)
  146271. * @param extent x,y,z value that define the extent around the queries point of reference
  146272. */
  146273. setDefaultQueryExtent(extent: Vector3): void;
  146274. /**
  146275. * Get the Bounding box extent specified by setDefaultQueryExtent
  146276. * @returns the box extent values
  146277. */
  146278. getDefaultQueryExtent(): Vector3;
  146279. /**
  146280. * build the navmesh from a previously saved state using getNavmeshData
  146281. * @param data the Uint8Array returned by getNavmeshData
  146282. */
  146283. buildFromNavmeshData(data: Uint8Array): void;
  146284. /**
  146285. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146286. * @returns data the Uint8Array that can be saved and reused
  146287. */
  146288. getNavmeshData(): Uint8Array;
  146289. /**
  146290. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146291. * @param result output the box extent values
  146292. */
  146293. getDefaultQueryExtentToRef(result: Vector3): void;
  146294. /**
  146295. * Disposes
  146296. */
  146297. dispose(): void;
  146298. /**
  146299. * If this plugin is supported
  146300. * @returns true if plugin is supported
  146301. */
  146302. isSupported(): boolean;
  146303. }
  146304. /**
  146305. * Recast detour crowd implementation
  146306. */
  146307. export class RecastJSCrowd implements ICrowd {
  146308. /**
  146309. * Recast/detour plugin
  146310. */
  146311. bjsRECASTPlugin: RecastJSPlugin;
  146312. /**
  146313. * Link to the detour crowd
  146314. */
  146315. recastCrowd: any;
  146316. /**
  146317. * One transform per agent
  146318. */
  146319. transforms: TransformNode[];
  146320. /**
  146321. * All agents created
  146322. */
  146323. agents: number[];
  146324. /**
  146325. * Link to the scene is kept to unregister the crowd from the scene
  146326. */
  146327. private _scene;
  146328. /**
  146329. * Observer for crowd updates
  146330. */
  146331. private _onBeforeAnimationsObserver;
  146332. /**
  146333. * Constructor
  146334. * @param plugin recastJS plugin
  146335. * @param maxAgents the maximum agent count in the crowd
  146336. * @param maxAgentRadius the maximum radius an agent can have
  146337. * @param scene to attach the crowd to
  146338. * @returns the crowd you can add agents to
  146339. */
  146340. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  146341. /**
  146342. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146343. * You can attach anything to that node. The node position is updated in the scene update tick.
  146344. * @param pos world position that will be constrained by the navigation mesh
  146345. * @param parameters agent parameters
  146346. * @param transform hooked to the agent that will be update by the scene
  146347. * @returns agent index
  146348. */
  146349. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146350. /**
  146351. * Returns the agent position in world space
  146352. * @param index agent index returned by addAgent
  146353. * @returns world space position
  146354. */
  146355. getAgentPosition(index: number): Vector3;
  146356. /**
  146357. * Returns the agent position result in world space
  146358. * @param index agent index returned by addAgent
  146359. * @param result output world space position
  146360. */
  146361. getAgentPositionToRef(index: number, result: Vector3): void;
  146362. /**
  146363. * Returns the agent velocity in world space
  146364. * @param index agent index returned by addAgent
  146365. * @returns world space velocity
  146366. */
  146367. getAgentVelocity(index: number): Vector3;
  146368. /**
  146369. * Returns the agent velocity result in world space
  146370. * @param index agent index returned by addAgent
  146371. * @param result output world space velocity
  146372. */
  146373. getAgentVelocityToRef(index: number, result: Vector3): void;
  146374. /**
  146375. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146376. * @param index agent index returned by addAgent
  146377. * @param destination targeted world position
  146378. */
  146379. agentGoto(index: number, destination: Vector3): void;
  146380. /**
  146381. * Teleport the agent to a new position
  146382. * @param index agent index returned by addAgent
  146383. * @param destination targeted world position
  146384. */
  146385. agentTeleport(index: number, destination: Vector3): void;
  146386. /**
  146387. * Update agent parameters
  146388. * @param index agent index returned by addAgent
  146389. * @param parameters agent parameters
  146390. */
  146391. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146392. /**
  146393. * remove a particular agent previously created
  146394. * @param index agent index returned by addAgent
  146395. */
  146396. removeAgent(index: number): void;
  146397. /**
  146398. * get the list of all agents attached to this crowd
  146399. * @returns list of agent indices
  146400. */
  146401. getAgents(): number[];
  146402. /**
  146403. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146404. * @param deltaTime in seconds
  146405. */
  146406. update(deltaTime: number): void;
  146407. /**
  146408. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146409. * The queries will try to find a solution within those bounds
  146410. * default is (1,1,1)
  146411. * @param extent x,y,z value that define the extent around the queries point of reference
  146412. */
  146413. setDefaultQueryExtent(extent: Vector3): void;
  146414. /**
  146415. * Get the Bounding box extent specified by setDefaultQueryExtent
  146416. * @returns the box extent values
  146417. */
  146418. getDefaultQueryExtent(): Vector3;
  146419. /**
  146420. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146421. * @param result output the box extent values
  146422. */
  146423. getDefaultQueryExtentToRef(result: Vector3): void;
  146424. /**
  146425. * Release all resources
  146426. */
  146427. dispose(): void;
  146428. }
  146429. }
  146430. declare module BABYLON {
  146431. /**
  146432. * Class used to enable access to IndexedDB
  146433. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  146434. */
  146435. export class Database implements IOfflineProvider {
  146436. private _callbackManifestChecked;
  146437. private _currentSceneUrl;
  146438. private _db;
  146439. private _enableSceneOffline;
  146440. private _enableTexturesOffline;
  146441. private _manifestVersionFound;
  146442. private _mustUpdateRessources;
  146443. private _hasReachedQuota;
  146444. private _isSupported;
  146445. private _idbFactory;
  146446. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  146447. private static IsUASupportingBlobStorage;
  146448. /**
  146449. * Gets a boolean indicating if Database storate is enabled (off by default)
  146450. */
  146451. static IDBStorageEnabled: boolean;
  146452. /**
  146453. * Gets a boolean indicating if scene must be saved in the database
  146454. */
  146455. get enableSceneOffline(): boolean;
  146456. /**
  146457. * Gets a boolean indicating if textures must be saved in the database
  146458. */
  146459. get enableTexturesOffline(): boolean;
  146460. /**
  146461. * Creates a new Database
  146462. * @param urlToScene defines the url to load the scene
  146463. * @param callbackManifestChecked defines the callback to use when manifest is checked
  146464. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  146465. */
  146466. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  146467. private static _ParseURL;
  146468. private static _ReturnFullUrlLocation;
  146469. private _checkManifestFile;
  146470. /**
  146471. * Open the database and make it available
  146472. * @param successCallback defines the callback to call on success
  146473. * @param errorCallback defines the callback to call on error
  146474. */
  146475. open(successCallback: () => void, errorCallback: () => void): void;
  146476. /**
  146477. * Loads an image from the database
  146478. * @param url defines the url to load from
  146479. * @param image defines the target DOM image
  146480. */
  146481. loadImage(url: string, image: HTMLImageElement): void;
  146482. private _loadImageFromDBAsync;
  146483. private _saveImageIntoDBAsync;
  146484. private _checkVersionFromDB;
  146485. private _loadVersionFromDBAsync;
  146486. private _saveVersionIntoDBAsync;
  146487. /**
  146488. * Loads a file from database
  146489. * @param url defines the URL to load from
  146490. * @param sceneLoaded defines a callback to call on success
  146491. * @param progressCallBack defines a callback to call when progress changed
  146492. * @param errorCallback defines a callback to call on error
  146493. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  146494. */
  146495. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  146496. private _loadFileAsync;
  146497. private _saveFileAsync;
  146498. /**
  146499. * Validates if xhr data is correct
  146500. * @param xhr defines the request to validate
  146501. * @param dataType defines the expected data type
  146502. * @returns true if data is correct
  146503. */
  146504. private static _ValidateXHRData;
  146505. }
  146506. }
  146507. declare module BABYLON {
  146508. /** @hidden */
  146509. export var gpuUpdateParticlesPixelShader: {
  146510. name: string;
  146511. shader: string;
  146512. };
  146513. }
  146514. declare module BABYLON {
  146515. /** @hidden */
  146516. export var gpuUpdateParticlesVertexShader: {
  146517. name: string;
  146518. shader: string;
  146519. };
  146520. }
  146521. declare module BABYLON {
  146522. /** @hidden */
  146523. export var clipPlaneFragmentDeclaration2: {
  146524. name: string;
  146525. shader: string;
  146526. };
  146527. }
  146528. declare module BABYLON {
  146529. /** @hidden */
  146530. export var gpuRenderParticlesPixelShader: {
  146531. name: string;
  146532. shader: string;
  146533. };
  146534. }
  146535. declare module BABYLON {
  146536. /** @hidden */
  146537. export var clipPlaneVertexDeclaration2: {
  146538. name: string;
  146539. shader: string;
  146540. };
  146541. }
  146542. declare module BABYLON {
  146543. /** @hidden */
  146544. export var gpuRenderParticlesVertexShader: {
  146545. name: string;
  146546. shader: string;
  146547. };
  146548. }
  146549. declare module BABYLON {
  146550. /**
  146551. * This represents a GPU particle system in Babylon
  146552. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  146553. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  146554. */
  146555. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  146556. /**
  146557. * The layer mask we are rendering the particles through.
  146558. */
  146559. layerMask: number;
  146560. private _capacity;
  146561. private _activeCount;
  146562. private _currentActiveCount;
  146563. private _accumulatedCount;
  146564. private _renderEffect;
  146565. private _updateEffect;
  146566. private _buffer0;
  146567. private _buffer1;
  146568. private _spriteBuffer;
  146569. private _updateVAO;
  146570. private _renderVAO;
  146571. private _targetIndex;
  146572. private _sourceBuffer;
  146573. private _targetBuffer;
  146574. private _currentRenderId;
  146575. private _started;
  146576. private _stopped;
  146577. private _timeDelta;
  146578. private _randomTexture;
  146579. private _randomTexture2;
  146580. private _attributesStrideSize;
  146581. private _updateEffectOptions;
  146582. private _randomTextureSize;
  146583. private _actualFrame;
  146584. private _customEffect;
  146585. private readonly _rawTextureWidth;
  146586. /**
  146587. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  146588. */
  146589. static get IsSupported(): boolean;
  146590. /**
  146591. * An event triggered when the system is disposed.
  146592. */
  146593. onDisposeObservable: Observable<IParticleSystem>;
  146594. /**
  146595. * Gets the maximum number of particles active at the same time.
  146596. * @returns The max number of active particles.
  146597. */
  146598. getCapacity(): number;
  146599. /**
  146600. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  146601. * to override the particles.
  146602. */
  146603. forceDepthWrite: boolean;
  146604. /**
  146605. * Gets or set the number of active particles
  146606. */
  146607. get activeParticleCount(): number;
  146608. set activeParticleCount(value: number);
  146609. private _preWarmDone;
  146610. /**
  146611. * Specifies if the particles are updated in emitter local space or world space.
  146612. */
  146613. isLocal: boolean;
  146614. /** Gets or sets a matrix to use to compute projection */
  146615. defaultProjectionMatrix: Matrix;
  146616. /**
  146617. * Is this system ready to be used/rendered
  146618. * @return true if the system is ready
  146619. */
  146620. isReady(): boolean;
  146621. /**
  146622. * Gets if the system has been started. (Note: this will still be true after stop is called)
  146623. * @returns True if it has been started, otherwise false.
  146624. */
  146625. isStarted(): boolean;
  146626. /**
  146627. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  146628. * @returns True if it has been stopped, otherwise false.
  146629. */
  146630. isStopped(): boolean;
  146631. /**
  146632. * Gets a boolean indicating that the system is stopping
  146633. * @returns true if the system is currently stopping
  146634. */
  146635. isStopping(): boolean;
  146636. /**
  146637. * Gets the number of particles active at the same time.
  146638. * @returns The number of active particles.
  146639. */
  146640. getActiveCount(): number;
  146641. /**
  146642. * Starts the particle system and begins to emit
  146643. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  146644. */
  146645. start(delay?: number): void;
  146646. /**
  146647. * Stops the particle system.
  146648. */
  146649. stop(): void;
  146650. /**
  146651. * Remove all active particles
  146652. */
  146653. reset(): void;
  146654. /**
  146655. * Returns the string "GPUParticleSystem"
  146656. * @returns a string containing the class name
  146657. */
  146658. getClassName(): string;
  146659. /**
  146660. * Gets the custom effect used to render the particles
  146661. * @param blendMode Blend mode for which the effect should be retrieved
  146662. * @returns The effect
  146663. */
  146664. getCustomEffect(blendMode?: number): Nullable<Effect>;
  146665. /**
  146666. * Sets the custom effect used to render the particles
  146667. * @param effect The effect to set
  146668. * @param blendMode Blend mode for which the effect should be set
  146669. */
  146670. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  146671. /** @hidden */
  146672. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  146673. /**
  146674. * Observable that will be called just before the particles are drawn
  146675. */
  146676. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  146677. /**
  146678. * Gets the name of the particle vertex shader
  146679. */
  146680. get vertexShaderName(): string;
  146681. private _colorGradientsTexture;
  146682. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  146683. /**
  146684. * Adds a new color gradient
  146685. * @param gradient defines the gradient to use (between 0 and 1)
  146686. * @param color1 defines the color to affect to the specified gradient
  146687. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146688. * @returns the current particle system
  146689. */
  146690. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146691. private _refreshColorGradient;
  146692. /** Force the system to rebuild all gradients that need to be resync */
  146693. forceRefreshGradients(): void;
  146694. /**
  146695. * Remove a specific color gradient
  146696. * @param gradient defines the gradient to remove
  146697. * @returns the current particle system
  146698. */
  146699. removeColorGradient(gradient: number): GPUParticleSystem;
  146700. private _angularSpeedGradientsTexture;
  146701. private _sizeGradientsTexture;
  146702. private _velocityGradientsTexture;
  146703. private _limitVelocityGradientsTexture;
  146704. private _dragGradientsTexture;
  146705. private _addFactorGradient;
  146706. /**
  146707. * Adds a new size gradient
  146708. * @param gradient defines the gradient to use (between 0 and 1)
  146709. * @param factor defines the size factor to affect to the specified gradient
  146710. * @returns the current particle system
  146711. */
  146712. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146713. /**
  146714. * Remove a specific size gradient
  146715. * @param gradient defines the gradient to remove
  146716. * @returns the current particle system
  146717. */
  146718. removeSizeGradient(gradient: number): GPUParticleSystem;
  146719. private _refreshFactorGradient;
  146720. /**
  146721. * Adds a new angular speed gradient
  146722. * @param gradient defines the gradient to use (between 0 and 1)
  146723. * @param factor defines the angular speed to affect to the specified gradient
  146724. * @returns the current particle system
  146725. */
  146726. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146727. /**
  146728. * Remove a specific angular speed gradient
  146729. * @param gradient defines the gradient to remove
  146730. * @returns the current particle system
  146731. */
  146732. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146733. /**
  146734. * Adds a new velocity gradient
  146735. * @param gradient defines the gradient to use (between 0 and 1)
  146736. * @param factor defines the velocity to affect to the specified gradient
  146737. * @returns the current particle system
  146738. */
  146739. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146740. /**
  146741. * Remove a specific velocity gradient
  146742. * @param gradient defines the gradient to remove
  146743. * @returns the current particle system
  146744. */
  146745. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146746. /**
  146747. * Adds a new limit velocity gradient
  146748. * @param gradient defines the gradient to use (between 0 and 1)
  146749. * @param factor defines the limit velocity value to affect to the specified gradient
  146750. * @returns the current particle system
  146751. */
  146752. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146753. /**
  146754. * Remove a specific limit velocity gradient
  146755. * @param gradient defines the gradient to remove
  146756. * @returns the current particle system
  146757. */
  146758. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146759. /**
  146760. * Adds a new drag gradient
  146761. * @param gradient defines the gradient to use (between 0 and 1)
  146762. * @param factor defines the drag value to affect to the specified gradient
  146763. * @returns the current particle system
  146764. */
  146765. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146766. /**
  146767. * Remove a specific drag gradient
  146768. * @param gradient defines the gradient to remove
  146769. * @returns the current particle system
  146770. */
  146771. removeDragGradient(gradient: number): GPUParticleSystem;
  146772. /**
  146773. * Not supported by GPUParticleSystem
  146774. * @param gradient defines the gradient to use (between 0 and 1)
  146775. * @param factor defines the emit rate value to affect to the specified gradient
  146776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146777. * @returns the current particle system
  146778. */
  146779. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146780. /**
  146781. * Not supported by GPUParticleSystem
  146782. * @param gradient defines the gradient to remove
  146783. * @returns the current particle system
  146784. */
  146785. removeEmitRateGradient(gradient: number): IParticleSystem;
  146786. /**
  146787. * Not supported by GPUParticleSystem
  146788. * @param gradient defines the gradient to use (between 0 and 1)
  146789. * @param factor defines the start size value to affect to the specified gradient
  146790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146791. * @returns the current particle system
  146792. */
  146793. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146794. /**
  146795. * Not supported by GPUParticleSystem
  146796. * @param gradient defines the gradient to remove
  146797. * @returns the current particle system
  146798. */
  146799. removeStartSizeGradient(gradient: number): IParticleSystem;
  146800. /**
  146801. * Not supported by GPUParticleSystem
  146802. * @param gradient defines the gradient to use (between 0 and 1)
  146803. * @param min defines the color remap minimal range
  146804. * @param max defines the color remap maximal range
  146805. * @returns the current particle system
  146806. */
  146807. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146808. /**
  146809. * Not supported by GPUParticleSystem
  146810. * @param gradient defines the gradient to remove
  146811. * @returns the current particle system
  146812. */
  146813. removeColorRemapGradient(): IParticleSystem;
  146814. /**
  146815. * Not supported by GPUParticleSystem
  146816. * @param gradient defines the gradient to use (between 0 and 1)
  146817. * @param min defines the alpha remap minimal range
  146818. * @param max defines the alpha remap maximal range
  146819. * @returns the current particle system
  146820. */
  146821. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146822. /**
  146823. * Not supported by GPUParticleSystem
  146824. * @param gradient defines the gradient to remove
  146825. * @returns the current particle system
  146826. */
  146827. removeAlphaRemapGradient(): IParticleSystem;
  146828. /**
  146829. * Not supported by GPUParticleSystem
  146830. * @param gradient defines the gradient to use (between 0 and 1)
  146831. * @param color defines the color to affect to the specified gradient
  146832. * @returns the current particle system
  146833. */
  146834. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146835. /**
  146836. * Not supported by GPUParticleSystem
  146837. * @param gradient defines the gradient to remove
  146838. * @returns the current particle system
  146839. */
  146840. removeRampGradient(): IParticleSystem;
  146841. /**
  146842. * Not supported by GPUParticleSystem
  146843. * @returns the list of ramp gradients
  146844. */
  146845. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146846. /**
  146847. * Not supported by GPUParticleSystem
  146848. * Gets or sets a boolean indicating that ramp gradients must be used
  146849. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146850. */
  146851. get useRampGradients(): boolean;
  146852. set useRampGradients(value: boolean);
  146853. /**
  146854. * Not supported by GPUParticleSystem
  146855. * @param gradient defines the gradient to use (between 0 and 1)
  146856. * @param factor defines the life time factor to affect to the specified gradient
  146857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146858. * @returns the current particle system
  146859. */
  146860. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146861. /**
  146862. * Not supported by GPUParticleSystem
  146863. * @param gradient defines the gradient to remove
  146864. * @returns the current particle system
  146865. */
  146866. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146867. /**
  146868. * Instantiates a GPU particle system.
  146869. * 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.
  146870. * @param name The name of the particle system
  146871. * @param options The options used to create the system
  146872. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  146873. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146874. * @param customEffect a custom effect used to change the way particles are rendered by default
  146875. */
  146876. constructor(name: string, options: Partial<{
  146877. capacity: number;
  146878. randomTextureSize: number;
  146879. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146880. protected _reset(): void;
  146881. private _createUpdateVAO;
  146882. private _createRenderVAO;
  146883. private _initialize;
  146884. /** @hidden */
  146885. _recreateUpdateEffect(): void;
  146886. private _getEffect;
  146887. /**
  146888. * Fill the defines array according to the current settings of the particle system
  146889. * @param defines Array to be updated
  146890. * @param blendMode blend mode to take into account when updating the array
  146891. */
  146892. fillDefines(defines: Array<string>, blendMode?: number): void;
  146893. /**
  146894. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146895. * @param uniforms Uniforms array to fill
  146896. * @param attributes Attributes array to fill
  146897. * @param samplers Samplers array to fill
  146898. */
  146899. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146900. /** @hidden */
  146901. _recreateRenderEffect(): Effect;
  146902. /**
  146903. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146904. * @param preWarm defines if we are in the pre-warmimg phase
  146905. */
  146906. animate(preWarm?: boolean): void;
  146907. private _createFactorGradientTexture;
  146908. private _createSizeGradientTexture;
  146909. private _createAngularSpeedGradientTexture;
  146910. private _createVelocityGradientTexture;
  146911. private _createLimitVelocityGradientTexture;
  146912. private _createDragGradientTexture;
  146913. private _createColorGradientTexture;
  146914. /**
  146915. * Renders the particle system in its current state
  146916. * @param preWarm defines if the system should only update the particles but not render them
  146917. * @returns the current number of particles
  146918. */
  146919. render(preWarm?: boolean): number;
  146920. /**
  146921. * Rebuilds the particle system
  146922. */
  146923. rebuild(): void;
  146924. private _releaseBuffers;
  146925. private _releaseVAOs;
  146926. /**
  146927. * Disposes the particle system and free the associated resources
  146928. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146929. */
  146930. dispose(disposeTexture?: boolean): void;
  146931. /**
  146932. * Clones the particle system.
  146933. * @param name The name of the cloned object
  146934. * @param newEmitter The new emitter to use
  146935. * @returns the cloned particle system
  146936. */
  146937. clone(name: string, newEmitter: any): GPUParticleSystem;
  146938. /**
  146939. * Serializes the particle system to a JSON object
  146940. * @param serializeTexture defines if the texture must be serialized as well
  146941. * @returns the JSON object
  146942. */
  146943. serialize(serializeTexture?: boolean): any;
  146944. /**
  146945. * Parses a JSON object to create a GPU particle system.
  146946. * @param parsedParticleSystem The JSON object to parse
  146947. * @param sceneOrEngine The scene or the engine to create the particle system in
  146948. * @param rootUrl The root url to use to load external dependencies like texture
  146949. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146950. * @returns the parsed GPU particle system
  146951. */
  146952. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146953. }
  146954. }
  146955. declare module BABYLON {
  146956. /**
  146957. * Represents a set of particle systems working together to create a specific effect
  146958. */
  146959. export class ParticleSystemSet implements IDisposable {
  146960. /**
  146961. * Gets or sets base Assets URL
  146962. */
  146963. static BaseAssetsUrl: string;
  146964. private _emitterCreationOptions;
  146965. private _emitterNode;
  146966. /**
  146967. * Gets the particle system list
  146968. */
  146969. systems: IParticleSystem[];
  146970. /**
  146971. * Gets the emitter node used with this set
  146972. */
  146973. get emitterNode(): Nullable<TransformNode>;
  146974. /**
  146975. * Creates a new emitter mesh as a sphere
  146976. * @param options defines the options used to create the sphere
  146977. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146978. * @param scene defines the hosting scene
  146979. */
  146980. setEmitterAsSphere(options: {
  146981. diameter: number;
  146982. segments: number;
  146983. color: Color3;
  146984. }, renderingGroupId: number, scene: Scene): void;
  146985. /**
  146986. * Starts all particle systems of the set
  146987. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146988. */
  146989. start(emitter?: AbstractMesh): void;
  146990. /**
  146991. * Release all associated resources
  146992. */
  146993. dispose(): void;
  146994. /**
  146995. * Serialize the set into a JSON compatible object
  146996. * @param serializeTexture defines if the texture must be serialized as well
  146997. * @returns a JSON compatible representation of the set
  146998. */
  146999. serialize(serializeTexture?: boolean): any;
  147000. /**
  147001. * Parse a new ParticleSystemSet from a serialized source
  147002. * @param data defines a JSON compatible representation of the set
  147003. * @param scene defines the hosting scene
  147004. * @param gpu defines if we want GPU particles or CPU particles
  147005. * @returns a new ParticleSystemSet
  147006. */
  147007. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147008. }
  147009. }
  147010. declare module BABYLON {
  147011. /**
  147012. * This class is made for on one-liner static method to help creating particle system set.
  147013. */
  147014. export class ParticleHelper {
  147015. /**
  147016. * Gets or sets base Assets URL
  147017. */
  147018. static BaseAssetsUrl: string;
  147019. /** Define the Url to load snippets */
  147020. static SnippetUrl: string;
  147021. /**
  147022. * Create a default particle system that you can tweak
  147023. * @param emitter defines the emitter to use
  147024. * @param capacity defines the system capacity (default is 500 particles)
  147025. * @param scene defines the hosting scene
  147026. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147027. * @returns the new Particle system
  147028. */
  147029. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147030. /**
  147031. * This is the main static method (one-liner) of this helper to create different particle systems
  147032. * @param type This string represents the type to the particle system to create
  147033. * @param scene The scene where the particle system should live
  147034. * @param gpu If the system will use gpu
  147035. * @returns the ParticleSystemSet created
  147036. */
  147037. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147038. /**
  147039. * Static function used to export a particle system to a ParticleSystemSet variable.
  147040. * Please note that the emitter shape is not exported
  147041. * @param systems defines the particle systems to export
  147042. * @returns the created particle system set
  147043. */
  147044. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147045. /**
  147046. * Creates a particle system from a snippet saved in a remote file
  147047. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147048. * @param url defines the url to load from
  147049. * @param scene defines the hosting scene
  147050. * @param gpu If the system will use gpu
  147051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147052. * @returns a promise that will resolve to the new particle system
  147053. */
  147054. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147055. /**
  147056. * Creates a particle system from a snippet saved by the particle system editor
  147057. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147058. * @param scene defines the hosting scene
  147059. * @param gpu If the system will use gpu
  147060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147061. * @returns a promise that will resolve to the new particle system
  147062. */
  147063. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147064. }
  147065. }
  147066. declare module BABYLON {
  147067. interface Engine {
  147068. /**
  147069. * Create an effect to use with particle systems.
  147070. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147071. * the particle system for which you want to create a custom effect in the last parameter
  147072. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147073. * @param uniformsNames defines a list of attribute names
  147074. * @param samplers defines an array of string used to represent textures
  147075. * @param defines defines the string containing the defines to use to compile the shaders
  147076. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147077. * @param onCompiled defines a function to call when the effect creation is successful
  147078. * @param onError defines a function to call when the effect creation has failed
  147079. * @param particleSystem the particle system you want to create the effect for
  147080. * @returns the new Effect
  147081. */
  147082. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147083. }
  147084. interface Mesh {
  147085. /**
  147086. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147087. * @returns an array of IParticleSystem
  147088. */
  147089. getEmittedParticleSystems(): IParticleSystem[];
  147090. /**
  147091. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147092. * @returns an array of IParticleSystem
  147093. */
  147094. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147095. }
  147096. }
  147097. declare module BABYLON {
  147098. /** Defines the 4 color options */
  147099. export enum PointColor {
  147100. /** color value */
  147101. Color = 2,
  147102. /** uv value */
  147103. UV = 1,
  147104. /** random value */
  147105. Random = 0,
  147106. /** stated value */
  147107. Stated = 3
  147108. }
  147109. /**
  147110. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  147111. * 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.
  147112. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  147113. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  147114. *
  147115. * Full documentation here : TO BE ENTERED
  147116. */
  147117. export class PointsCloudSystem implements IDisposable {
  147118. /**
  147119. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  147120. * Example : var p = SPS.particles[i];
  147121. */
  147122. particles: CloudPoint[];
  147123. /**
  147124. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  147125. */
  147126. nbParticles: number;
  147127. /**
  147128. * This a counter for your own usage. It's not set by any SPS functions.
  147129. */
  147130. counter: number;
  147131. /**
  147132. * The PCS name. This name is also given to the underlying mesh.
  147133. */
  147134. name: string;
  147135. /**
  147136. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  147137. */
  147138. mesh: Mesh;
  147139. /**
  147140. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  147141. * Please read :
  147142. */
  147143. vars: any;
  147144. /**
  147145. * @hidden
  147146. */
  147147. _size: number;
  147148. private _scene;
  147149. private _promises;
  147150. private _positions;
  147151. private _indices;
  147152. private _normals;
  147153. private _colors;
  147154. private _uvs;
  147155. private _indices32;
  147156. private _positions32;
  147157. private _colors32;
  147158. private _uvs32;
  147159. private _updatable;
  147160. private _isVisibilityBoxLocked;
  147161. private _alwaysVisible;
  147162. private _groups;
  147163. private _groupCounter;
  147164. private _computeParticleColor;
  147165. private _computeParticleTexture;
  147166. private _computeParticleRotation;
  147167. private _computeBoundingBox;
  147168. private _isReady;
  147169. /**
  147170. * Creates a PCS (Points Cloud System) object
  147171. * @param name (String) is the PCS name, this will be the underlying mesh name
  147172. * @param pointSize (number) is the size for each point
  147173. * @param scene (Scene) is the scene in which the PCS is added
  147174. * @param options defines the options of the PCS e.g.
  147175. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  147176. */
  147177. constructor(name: string, pointSize: number, scene: Scene, options?: {
  147178. updatable?: boolean;
  147179. });
  147180. /**
  147181. * Builds the PCS underlying mesh. Returns a standard Mesh.
  147182. * If no points were added to the PCS, the returned mesh is just a single point.
  147183. * @returns a promise for the created mesh
  147184. */
  147185. buildMeshAsync(): Promise<Mesh>;
  147186. /**
  147187. * @hidden
  147188. */
  147189. private _buildMesh;
  147190. private _addParticle;
  147191. private _randomUnitVector;
  147192. private _getColorIndicesForCoord;
  147193. private _setPointsColorOrUV;
  147194. private _colorFromTexture;
  147195. private _calculateDensity;
  147196. /**
  147197. * Adds points to the PCS in random positions within a unit sphere
  147198. * @param nb (positive integer) the number of particles to be created from this model
  147199. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  147200. * @returns the number of groups in the system
  147201. */
  147202. addPoints(nb: number, pointFunction?: any): number;
  147203. /**
  147204. * Adds points to the PCS from the surface of the model shape
  147205. * @param mesh is any Mesh object that will be used as a surface model for the points
  147206. * @param nb (positive integer) the number of particles to be created from this model
  147207. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147208. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147209. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147210. * @returns the number of groups in the system
  147211. */
  147212. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147213. /**
  147214. * Adds points to the PCS inside the model shape
  147215. * @param mesh is any Mesh object that will be used as a surface model for the points
  147216. * @param nb (positive integer) the number of particles to be created from this model
  147217. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147218. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147219. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147220. * @returns the number of groups in the system
  147221. */
  147222. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147223. /**
  147224. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  147225. * This method calls `updateParticle()` for each particle of the SPS.
  147226. * For an animated SPS, it is usually called within the render loop.
  147227. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  147228. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  147229. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  147230. * @returns the PCS.
  147231. */
  147232. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  147233. /**
  147234. * Disposes the PCS.
  147235. */
  147236. dispose(): void;
  147237. /**
  147238. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  147239. * doc :
  147240. * @returns the PCS.
  147241. */
  147242. refreshVisibleSize(): PointsCloudSystem;
  147243. /**
  147244. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  147245. * @param size the size (float) of the visibility box
  147246. * note : this doesn't lock the PCS mesh bounding box.
  147247. * doc :
  147248. */
  147249. setVisibilityBox(size: number): void;
  147250. /**
  147251. * Gets whether the PCS is always visible or not
  147252. * doc :
  147253. */
  147254. get isAlwaysVisible(): boolean;
  147255. /**
  147256. * Sets the PCS as always visible or not
  147257. * doc :
  147258. */
  147259. set isAlwaysVisible(val: boolean);
  147260. /**
  147261. * Tells to `setParticles()` to compute the particle rotations or not
  147262. * Default value : false. The PCS is faster when it's set to false
  147263. * Note : particle rotations are only applied to parent particles
  147264. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  147265. */
  147266. set computeParticleRotation(val: boolean);
  147267. /**
  147268. * Tells to `setParticles()` to compute the particle colors or not.
  147269. * Default value : true. The PCS is faster when it's set to false.
  147270. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147271. */
  147272. set computeParticleColor(val: boolean);
  147273. set computeParticleTexture(val: boolean);
  147274. /**
  147275. * Gets if `setParticles()` computes the particle colors or not.
  147276. * Default value : false. The PCS is faster when it's set to false.
  147277. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147278. */
  147279. get computeParticleColor(): boolean;
  147280. /**
  147281. * Gets if `setParticles()` computes the particle textures or not.
  147282. * Default value : false. The PCS is faster when it's set to false.
  147283. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  147284. */
  147285. get computeParticleTexture(): boolean;
  147286. /**
  147287. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  147288. */
  147289. set computeBoundingBox(val: boolean);
  147290. /**
  147291. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  147292. */
  147293. get computeBoundingBox(): boolean;
  147294. /**
  147295. * This function does nothing. It may be overwritten to set all the particle first values.
  147296. * The PCS doesn't call this function, you may have to call it by your own.
  147297. * doc :
  147298. */
  147299. initParticles(): void;
  147300. /**
  147301. * This function does nothing. It may be overwritten to recycle a particle
  147302. * The PCS doesn't call this function, you can to call it
  147303. * doc :
  147304. * @param particle The particle to recycle
  147305. * @returns the recycled particle
  147306. */
  147307. recycleParticle(particle: CloudPoint): CloudPoint;
  147308. /**
  147309. * Updates a particle : this function should be overwritten by the user.
  147310. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  147311. * doc :
  147312. * @example : just set a particle position or velocity and recycle conditions
  147313. * @param particle The particle to update
  147314. * @returns the updated particle
  147315. */
  147316. updateParticle(particle: CloudPoint): CloudPoint;
  147317. /**
  147318. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  147319. * This does nothing and may be overwritten by the user.
  147320. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147321. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147322. * @param update the boolean update value actually passed to setParticles()
  147323. */
  147324. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147325. /**
  147326. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  147327. * This will be passed three parameters.
  147328. * This does nothing and may be overwritten by the user.
  147329. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147330. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147331. * @param update the boolean update value actually passed to setParticles()
  147332. */
  147333. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147334. }
  147335. }
  147336. declare module BABYLON {
  147337. /**
  147338. * Represents one particle of a points cloud system.
  147339. */
  147340. export class CloudPoint {
  147341. /**
  147342. * particle global index
  147343. */
  147344. idx: number;
  147345. /**
  147346. * The color of the particle
  147347. */
  147348. color: Nullable<Color4>;
  147349. /**
  147350. * The world space position of the particle.
  147351. */
  147352. position: Vector3;
  147353. /**
  147354. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  147355. */
  147356. rotation: Vector3;
  147357. /**
  147358. * The world space rotation quaternion of the particle.
  147359. */
  147360. rotationQuaternion: Nullable<Quaternion>;
  147361. /**
  147362. * The uv of the particle.
  147363. */
  147364. uv: Nullable<Vector2>;
  147365. /**
  147366. * The current speed of the particle.
  147367. */
  147368. velocity: Vector3;
  147369. /**
  147370. * The pivot point in the particle local space.
  147371. */
  147372. pivot: Vector3;
  147373. /**
  147374. * Must the particle be translated from its pivot point in its local space ?
  147375. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  147376. * Default : false
  147377. */
  147378. translateFromPivot: boolean;
  147379. /**
  147380. * Index of this particle in the global "positions" array (Internal use)
  147381. * @hidden
  147382. */
  147383. _pos: number;
  147384. /**
  147385. * @hidden Index of this particle in the global "indices" array (Internal use)
  147386. */
  147387. _ind: number;
  147388. /**
  147389. * Group this particle belongs to
  147390. */
  147391. _group: PointsGroup;
  147392. /**
  147393. * Group id of this particle
  147394. */
  147395. groupId: number;
  147396. /**
  147397. * Index of the particle in its group id (Internal use)
  147398. */
  147399. idxInGroup: number;
  147400. /**
  147401. * @hidden Particle BoundingInfo object (Internal use)
  147402. */
  147403. _boundingInfo: BoundingInfo;
  147404. /**
  147405. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  147406. */
  147407. _pcs: PointsCloudSystem;
  147408. /**
  147409. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  147410. */
  147411. _stillInvisible: boolean;
  147412. /**
  147413. * @hidden Last computed particle rotation matrix
  147414. */
  147415. _rotationMatrix: number[];
  147416. /**
  147417. * Parent particle Id, if any.
  147418. * Default null.
  147419. */
  147420. parentId: Nullable<number>;
  147421. /**
  147422. * @hidden Internal global position in the PCS.
  147423. */
  147424. _globalPosition: Vector3;
  147425. /**
  147426. * Creates a Point Cloud object.
  147427. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  147428. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  147429. * @param group (PointsGroup) is the group the particle belongs to
  147430. * @param groupId (integer) is the group identifier in the PCS.
  147431. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  147432. * @param pcs defines the PCS it is associated to
  147433. */
  147434. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  147435. /**
  147436. * get point size
  147437. */
  147438. get size(): Vector3;
  147439. /**
  147440. * Set point size
  147441. */
  147442. set size(scale: Vector3);
  147443. /**
  147444. * Legacy support, changed quaternion to rotationQuaternion
  147445. */
  147446. get quaternion(): Nullable<Quaternion>;
  147447. /**
  147448. * Legacy support, changed quaternion to rotationQuaternion
  147449. */
  147450. set quaternion(q: Nullable<Quaternion>);
  147451. /**
  147452. * Returns a boolean. True if the particle intersects a mesh, else false
  147453. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  147454. * @param target is the object (point or mesh) what the intersection is computed against
  147455. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  147456. * @returns true if it intersects
  147457. */
  147458. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  147459. /**
  147460. * get the rotation matrix of the particle
  147461. * @hidden
  147462. */
  147463. getRotationMatrix(m: Matrix): void;
  147464. }
  147465. /**
  147466. * Represents a group of points in a points cloud system
  147467. * * PCS internal tool, don't use it manually.
  147468. */
  147469. export class PointsGroup {
  147470. /**
  147471. * The group id
  147472. * @hidden
  147473. */
  147474. groupID: number;
  147475. /**
  147476. * image data for group (internal use)
  147477. * @hidden
  147478. */
  147479. _groupImageData: Nullable<ArrayBufferView>;
  147480. /**
  147481. * Image Width (internal use)
  147482. * @hidden
  147483. */
  147484. _groupImgWidth: number;
  147485. /**
  147486. * Image Height (internal use)
  147487. * @hidden
  147488. */
  147489. _groupImgHeight: number;
  147490. /**
  147491. * Custom position function (internal use)
  147492. * @hidden
  147493. */
  147494. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  147495. /**
  147496. * density per facet for surface points
  147497. * @hidden
  147498. */
  147499. _groupDensity: number[];
  147500. /**
  147501. * Only when points are colored by texture carries pointer to texture list array
  147502. * @hidden
  147503. */
  147504. _textureNb: number;
  147505. /**
  147506. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  147507. * PCS internal tool, don't use it manually.
  147508. * @hidden
  147509. */
  147510. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  147511. }
  147512. }
  147513. declare module BABYLON {
  147514. interface Scene {
  147515. /** @hidden (Backing field) */
  147516. _physicsEngine: Nullable<IPhysicsEngine>;
  147517. /** @hidden */
  147518. _physicsTimeAccumulator: number;
  147519. /**
  147520. * Gets the current physics engine
  147521. * @returns a IPhysicsEngine or null if none attached
  147522. */
  147523. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  147524. /**
  147525. * Enables physics to the current scene
  147526. * @param gravity defines the scene's gravity for the physics engine
  147527. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  147528. * @return a boolean indicating if the physics engine was initialized
  147529. */
  147530. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  147531. /**
  147532. * Disables and disposes the physics engine associated with the scene
  147533. */
  147534. disablePhysicsEngine(): void;
  147535. /**
  147536. * Gets a boolean indicating if there is an active physics engine
  147537. * @returns a boolean indicating if there is an active physics engine
  147538. */
  147539. isPhysicsEnabled(): boolean;
  147540. /**
  147541. * Deletes a physics compound impostor
  147542. * @param compound defines the compound to delete
  147543. */
  147544. deleteCompoundImpostor(compound: any): void;
  147545. /**
  147546. * An event triggered when physic simulation is about to be run
  147547. */
  147548. onBeforePhysicsObservable: Observable<Scene>;
  147549. /**
  147550. * An event triggered when physic simulation has been done
  147551. */
  147552. onAfterPhysicsObservable: Observable<Scene>;
  147553. }
  147554. interface AbstractMesh {
  147555. /** @hidden */
  147556. _physicsImpostor: Nullable<PhysicsImpostor>;
  147557. /**
  147558. * Gets or sets impostor used for physic simulation
  147559. * @see https://doc.babylonjs.com/features/physics_engine
  147560. */
  147561. physicsImpostor: Nullable<PhysicsImpostor>;
  147562. /**
  147563. * Gets the current physics impostor
  147564. * @see https://doc.babylonjs.com/features/physics_engine
  147565. * @returns a physics impostor or null
  147566. */
  147567. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  147568. /** Apply a physic impulse to the mesh
  147569. * @param force defines the force to apply
  147570. * @param contactPoint defines where to apply the force
  147571. * @returns the current mesh
  147572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  147573. */
  147574. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  147575. /**
  147576. * Creates a physic joint between two meshes
  147577. * @param otherMesh defines the other mesh to use
  147578. * @param pivot1 defines the pivot to use on this mesh
  147579. * @param pivot2 defines the pivot to use on the other mesh
  147580. * @param options defines additional options (can be plugin dependent)
  147581. * @returns the current mesh
  147582. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  147583. */
  147584. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  147585. /** @hidden */
  147586. _disposePhysicsObserver: Nullable<Observer<Node>>;
  147587. }
  147588. /**
  147589. * Defines the physics engine scene component responsible to manage a physics engine
  147590. */
  147591. export class PhysicsEngineSceneComponent implements ISceneComponent {
  147592. /**
  147593. * The component name helpful to identify the component in the list of scene components.
  147594. */
  147595. readonly name: string;
  147596. /**
  147597. * The scene the component belongs to.
  147598. */
  147599. scene: Scene;
  147600. /**
  147601. * Creates a new instance of the component for the given scene
  147602. * @param scene Defines the scene to register the component in
  147603. */
  147604. constructor(scene: Scene);
  147605. /**
  147606. * Registers the component in a given scene
  147607. */
  147608. register(): void;
  147609. /**
  147610. * Rebuilds the elements related to this component in case of
  147611. * context lost for instance.
  147612. */
  147613. rebuild(): void;
  147614. /**
  147615. * Disposes the component and the associated ressources
  147616. */
  147617. dispose(): void;
  147618. }
  147619. }
  147620. declare module BABYLON {
  147621. /**
  147622. * A helper for physics simulations
  147623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147624. */
  147625. export class PhysicsHelper {
  147626. private _scene;
  147627. private _physicsEngine;
  147628. /**
  147629. * Initializes the Physics helper
  147630. * @param scene Babylon.js scene
  147631. */
  147632. constructor(scene: Scene);
  147633. /**
  147634. * Applies a radial explosion impulse
  147635. * @param origin the origin of the explosion
  147636. * @param radiusOrEventOptions the radius or the options of radial explosion
  147637. * @param strength the explosion strength
  147638. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147639. * @returns A physics radial explosion event, or null
  147640. */
  147641. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147642. /**
  147643. * Applies a radial explosion force
  147644. * @param origin the origin of the explosion
  147645. * @param radiusOrEventOptions the radius or the options of radial explosion
  147646. * @param strength the explosion strength
  147647. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147648. * @returns A physics radial explosion event, or null
  147649. */
  147650. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147651. /**
  147652. * Creates a gravitational field
  147653. * @param origin the origin of the explosion
  147654. * @param radiusOrEventOptions the radius or the options of radial explosion
  147655. * @param strength the explosion strength
  147656. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147657. * @returns A physics gravitational field event, or null
  147658. */
  147659. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  147660. /**
  147661. * Creates a physics updraft event
  147662. * @param origin the origin of the updraft
  147663. * @param radiusOrEventOptions the radius or the options of the updraft
  147664. * @param strength the strength of the updraft
  147665. * @param height the height of the updraft
  147666. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  147667. * @returns A physics updraft event, or null
  147668. */
  147669. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  147670. /**
  147671. * Creates a physics vortex event
  147672. * @param origin the of the vortex
  147673. * @param radiusOrEventOptions the radius or the options of the vortex
  147674. * @param strength the strength of the vortex
  147675. * @param height the height of the vortex
  147676. * @returns a Physics vortex event, or null
  147677. * A physics vortex event or null
  147678. */
  147679. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  147680. }
  147681. /**
  147682. * Represents a physics radial explosion event
  147683. */
  147684. class PhysicsRadialExplosionEvent {
  147685. private _scene;
  147686. private _options;
  147687. private _sphere;
  147688. private _dataFetched;
  147689. /**
  147690. * Initializes a radial explosioin event
  147691. * @param _scene BabylonJS scene
  147692. * @param _options The options for the vortex event
  147693. */
  147694. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147695. /**
  147696. * Returns the data related to the radial explosion event (sphere).
  147697. * @returns The radial explosion event data
  147698. */
  147699. getData(): PhysicsRadialExplosionEventData;
  147700. /**
  147701. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147702. * @param impostor A physics imposter
  147703. * @param origin the origin of the explosion
  147704. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147705. */
  147706. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147707. /**
  147708. * Triggers affecterd impostors callbacks
  147709. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147710. */
  147711. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147712. /**
  147713. * Disposes the sphere.
  147714. * @param force Specifies if the sphere should be disposed by force
  147715. */
  147716. dispose(force?: boolean): void;
  147717. /*** Helpers ***/
  147718. private _prepareSphere;
  147719. private _intersectsWithSphere;
  147720. }
  147721. /**
  147722. * Represents a gravitational field event
  147723. */
  147724. class PhysicsGravitationalFieldEvent {
  147725. private _physicsHelper;
  147726. private _scene;
  147727. private _origin;
  147728. private _options;
  147729. private _tickCallback;
  147730. private _sphere;
  147731. private _dataFetched;
  147732. /**
  147733. * Initializes the physics gravitational field event
  147734. * @param _physicsHelper A physics helper
  147735. * @param _scene BabylonJS scene
  147736. * @param _origin The origin position of the gravitational field event
  147737. * @param _options The options for the vortex event
  147738. */
  147739. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147740. /**
  147741. * Returns the data related to the gravitational field event (sphere).
  147742. * @returns A gravitational field event
  147743. */
  147744. getData(): PhysicsGravitationalFieldEventData;
  147745. /**
  147746. * Enables the gravitational field.
  147747. */
  147748. enable(): void;
  147749. /**
  147750. * Disables the gravitational field.
  147751. */
  147752. disable(): void;
  147753. /**
  147754. * Disposes the sphere.
  147755. * @param force The force to dispose from the gravitational field event
  147756. */
  147757. dispose(force?: boolean): void;
  147758. private _tick;
  147759. }
  147760. /**
  147761. * Represents a physics updraft event
  147762. */
  147763. class PhysicsUpdraftEvent {
  147764. private _scene;
  147765. private _origin;
  147766. private _options;
  147767. private _physicsEngine;
  147768. private _originTop;
  147769. private _originDirection;
  147770. private _tickCallback;
  147771. private _cylinder;
  147772. private _cylinderPosition;
  147773. private _dataFetched;
  147774. /**
  147775. * Initializes the physics updraft event
  147776. * @param _scene BabylonJS scene
  147777. * @param _origin The origin position of the updraft
  147778. * @param _options The options for the updraft event
  147779. */
  147780. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147781. /**
  147782. * Returns the data related to the updraft event (cylinder).
  147783. * @returns A physics updraft event
  147784. */
  147785. getData(): PhysicsUpdraftEventData;
  147786. /**
  147787. * Enables the updraft.
  147788. */
  147789. enable(): void;
  147790. /**
  147791. * Disables the updraft.
  147792. */
  147793. disable(): void;
  147794. /**
  147795. * Disposes the cylinder.
  147796. * @param force Specifies if the updraft should be disposed by force
  147797. */
  147798. dispose(force?: boolean): void;
  147799. private getImpostorHitData;
  147800. private _tick;
  147801. /*** Helpers ***/
  147802. private _prepareCylinder;
  147803. private _intersectsWithCylinder;
  147804. }
  147805. /**
  147806. * Represents a physics vortex event
  147807. */
  147808. class PhysicsVortexEvent {
  147809. private _scene;
  147810. private _origin;
  147811. private _options;
  147812. private _physicsEngine;
  147813. private _originTop;
  147814. private _tickCallback;
  147815. private _cylinder;
  147816. private _cylinderPosition;
  147817. private _dataFetched;
  147818. /**
  147819. * Initializes the physics vortex event
  147820. * @param _scene The BabylonJS scene
  147821. * @param _origin The origin position of the vortex
  147822. * @param _options The options for the vortex event
  147823. */
  147824. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147825. /**
  147826. * Returns the data related to the vortex event (cylinder).
  147827. * @returns The physics vortex event data
  147828. */
  147829. getData(): PhysicsVortexEventData;
  147830. /**
  147831. * Enables the vortex.
  147832. */
  147833. enable(): void;
  147834. /**
  147835. * Disables the cortex.
  147836. */
  147837. disable(): void;
  147838. /**
  147839. * Disposes the sphere.
  147840. * @param force
  147841. */
  147842. dispose(force?: boolean): void;
  147843. private getImpostorHitData;
  147844. private _tick;
  147845. /*** Helpers ***/
  147846. private _prepareCylinder;
  147847. private _intersectsWithCylinder;
  147848. }
  147849. /**
  147850. * Options fot the radial explosion event
  147851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147852. */
  147853. export class PhysicsRadialExplosionEventOptions {
  147854. /**
  147855. * The radius of the sphere for the radial explosion.
  147856. */
  147857. radius: number;
  147858. /**
  147859. * The strenth of the explosion.
  147860. */
  147861. strength: number;
  147862. /**
  147863. * The strenght of the force in correspondence to the distance of the affected object
  147864. */
  147865. falloff: PhysicsRadialImpulseFalloff;
  147866. /**
  147867. * Sphere options for the radial explosion.
  147868. */
  147869. sphere: {
  147870. segments: number;
  147871. diameter: number;
  147872. };
  147873. /**
  147874. * Sphere options for the radial explosion.
  147875. */
  147876. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147877. }
  147878. /**
  147879. * Options fot the updraft event
  147880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147881. */
  147882. export class PhysicsUpdraftEventOptions {
  147883. /**
  147884. * The radius of the cylinder for the vortex
  147885. */
  147886. radius: number;
  147887. /**
  147888. * The strenth of the updraft.
  147889. */
  147890. strength: number;
  147891. /**
  147892. * The height of the cylinder for the updraft.
  147893. */
  147894. height: number;
  147895. /**
  147896. * The mode for the the updraft.
  147897. */
  147898. updraftMode: PhysicsUpdraftMode;
  147899. }
  147900. /**
  147901. * Options fot the vortex event
  147902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147903. */
  147904. export class PhysicsVortexEventOptions {
  147905. /**
  147906. * The radius of the cylinder for the vortex
  147907. */
  147908. radius: number;
  147909. /**
  147910. * The strenth of the vortex.
  147911. */
  147912. strength: number;
  147913. /**
  147914. * The height of the cylinder for the vortex.
  147915. */
  147916. height: number;
  147917. /**
  147918. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147919. */
  147920. centripetalForceThreshold: number;
  147921. /**
  147922. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147923. */
  147924. centripetalForceMultiplier: number;
  147925. /**
  147926. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147927. */
  147928. centrifugalForceMultiplier: number;
  147929. /**
  147930. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147931. */
  147932. updraftForceMultiplier: number;
  147933. }
  147934. /**
  147935. * The strenght of the force in correspondence to the distance of the affected object
  147936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147937. */
  147938. export enum PhysicsRadialImpulseFalloff {
  147939. /** Defines that impulse is constant in strength across it's whole radius */
  147940. Constant = 0,
  147941. /** Defines that impulse gets weaker if it's further from the origin */
  147942. Linear = 1
  147943. }
  147944. /**
  147945. * The strength of the force in correspondence to the distance of the affected object
  147946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147947. */
  147948. export enum PhysicsUpdraftMode {
  147949. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147950. Center = 0,
  147951. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147952. Perpendicular = 1
  147953. }
  147954. /**
  147955. * Interface for a physics hit data
  147956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147957. */
  147958. export interface PhysicsHitData {
  147959. /**
  147960. * The force applied at the contact point
  147961. */
  147962. force: Vector3;
  147963. /**
  147964. * The contact point
  147965. */
  147966. contactPoint: Vector3;
  147967. /**
  147968. * The distance from the origin to the contact point
  147969. */
  147970. distanceFromOrigin: number;
  147971. }
  147972. /**
  147973. * Interface for radial explosion event data
  147974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147975. */
  147976. export interface PhysicsRadialExplosionEventData {
  147977. /**
  147978. * A sphere used for the radial explosion event
  147979. */
  147980. sphere: Mesh;
  147981. }
  147982. /**
  147983. * Interface for gravitational field event data
  147984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147985. */
  147986. export interface PhysicsGravitationalFieldEventData {
  147987. /**
  147988. * A sphere mesh used for the gravitational field event
  147989. */
  147990. sphere: Mesh;
  147991. }
  147992. /**
  147993. * Interface for updraft event data
  147994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147995. */
  147996. export interface PhysicsUpdraftEventData {
  147997. /**
  147998. * A cylinder used for the updraft event
  147999. */
  148000. cylinder: Mesh;
  148001. }
  148002. /**
  148003. * Interface for vortex event data
  148004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148005. */
  148006. export interface PhysicsVortexEventData {
  148007. /**
  148008. * A cylinder used for the vortex event
  148009. */
  148010. cylinder: Mesh;
  148011. }
  148012. /**
  148013. * Interface for an affected physics impostor
  148014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148015. */
  148016. export interface PhysicsAffectedImpostorWithData {
  148017. /**
  148018. * The impostor affected by the effect
  148019. */
  148020. impostor: PhysicsImpostor;
  148021. /**
  148022. * The data about the hit/horce from the explosion
  148023. */
  148024. hitData: PhysicsHitData;
  148025. }
  148026. }
  148027. declare module BABYLON {
  148028. /** @hidden */
  148029. export var blackAndWhitePixelShader: {
  148030. name: string;
  148031. shader: string;
  148032. };
  148033. }
  148034. declare module BABYLON {
  148035. /**
  148036. * Post process used to render in black and white
  148037. */
  148038. export class BlackAndWhitePostProcess extends PostProcess {
  148039. /**
  148040. * Linear about to convert he result to black and white (default: 1)
  148041. */
  148042. degree: number;
  148043. /**
  148044. * Gets a string identifying the name of the class
  148045. * @returns "BlackAndWhitePostProcess" string
  148046. */
  148047. getClassName(): string;
  148048. /**
  148049. * Creates a black and white post process
  148050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148051. * @param name The name of the effect.
  148052. * @param options The required width/height ratio to downsize to before computing the render pass.
  148053. * @param camera The camera to apply the render pass to.
  148054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148055. * @param engine The engine which the post process will be applied. (default: current engine)
  148056. * @param reusable If the post process can be reused on the same frame. (default: false)
  148057. */
  148058. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148059. /** @hidden */
  148060. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148061. }
  148062. }
  148063. declare module BABYLON {
  148064. /**
  148065. * This represents a set of one or more post processes in Babylon.
  148066. * A post process can be used to apply a shader to a texture after it is rendered.
  148067. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148068. */
  148069. export class PostProcessRenderEffect {
  148070. private _postProcesses;
  148071. private _getPostProcesses;
  148072. private _singleInstance;
  148073. private _cameras;
  148074. private _indicesForCamera;
  148075. /**
  148076. * Name of the effect
  148077. * @hidden
  148078. */
  148079. _name: string;
  148080. /**
  148081. * Instantiates a post process render effect.
  148082. * A post process can be used to apply a shader to a texture after it is rendered.
  148083. * @param engine The engine the effect is tied to
  148084. * @param name The name of the effect
  148085. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148086. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148087. */
  148088. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148089. /**
  148090. * Checks if all the post processes in the effect are supported.
  148091. */
  148092. get isSupported(): boolean;
  148093. /**
  148094. * Updates the current state of the effect
  148095. * @hidden
  148096. */
  148097. _update(): void;
  148098. /**
  148099. * Attaches the effect on cameras
  148100. * @param cameras The camera to attach to.
  148101. * @hidden
  148102. */
  148103. _attachCameras(cameras: Camera): void;
  148104. /**
  148105. * Attaches the effect on cameras
  148106. * @param cameras The camera to attach to.
  148107. * @hidden
  148108. */
  148109. _attachCameras(cameras: Camera[]): void;
  148110. /**
  148111. * Detaches the effect on cameras
  148112. * @param cameras The camera to detatch from.
  148113. * @hidden
  148114. */
  148115. _detachCameras(cameras: Camera): void;
  148116. /**
  148117. * Detatches the effect on cameras
  148118. * @param cameras The camera to detatch from.
  148119. * @hidden
  148120. */
  148121. _detachCameras(cameras: Camera[]): void;
  148122. /**
  148123. * Enables the effect on given cameras
  148124. * @param cameras The camera to enable.
  148125. * @hidden
  148126. */
  148127. _enable(cameras: Camera): void;
  148128. /**
  148129. * Enables the effect on given cameras
  148130. * @param cameras The camera to enable.
  148131. * @hidden
  148132. */
  148133. _enable(cameras: Nullable<Camera[]>): void;
  148134. /**
  148135. * Disables the effect on the given cameras
  148136. * @param cameras The camera to disable.
  148137. * @hidden
  148138. */
  148139. _disable(cameras: Camera): void;
  148140. /**
  148141. * Disables the effect on the given cameras
  148142. * @param cameras The camera to disable.
  148143. * @hidden
  148144. */
  148145. _disable(cameras: Nullable<Camera[]>): void;
  148146. /**
  148147. * Gets a list of the post processes contained in the effect.
  148148. * @param camera The camera to get the post processes on.
  148149. * @returns The list of the post processes in the effect.
  148150. */
  148151. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  148152. }
  148153. }
  148154. declare module BABYLON {
  148155. /** @hidden */
  148156. export var extractHighlightsPixelShader: {
  148157. name: string;
  148158. shader: string;
  148159. };
  148160. }
  148161. declare module BABYLON {
  148162. /**
  148163. * 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.
  148164. */
  148165. export class ExtractHighlightsPostProcess extends PostProcess {
  148166. /**
  148167. * The luminance threshold, pixels below this value will be set to black.
  148168. */
  148169. threshold: number;
  148170. /** @hidden */
  148171. _exposure: number;
  148172. /**
  148173. * Post process which has the input texture to be used when performing highlight extraction
  148174. * @hidden
  148175. */
  148176. _inputPostProcess: Nullable<PostProcess>;
  148177. /**
  148178. * Gets a string identifying the name of the class
  148179. * @returns "ExtractHighlightsPostProcess" string
  148180. */
  148181. getClassName(): string;
  148182. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148183. }
  148184. }
  148185. declare module BABYLON {
  148186. /** @hidden */
  148187. export var bloomMergePixelShader: {
  148188. name: string;
  148189. shader: string;
  148190. };
  148191. }
  148192. declare module BABYLON {
  148193. /**
  148194. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148195. */
  148196. export class BloomMergePostProcess extends PostProcess {
  148197. /** Weight of the bloom to be added to the original input. */
  148198. weight: number;
  148199. /**
  148200. * Gets a string identifying the name of the class
  148201. * @returns "BloomMergePostProcess" string
  148202. */
  148203. getClassName(): string;
  148204. /**
  148205. * Creates a new instance of @see BloomMergePostProcess
  148206. * @param name The name of the effect.
  148207. * @param originalFromInput Post process which's input will be used for the merge.
  148208. * @param blurred Blurred highlights post process which's output will be used.
  148209. * @param weight Weight of the bloom to be added to the original input.
  148210. * @param options The required width/height ratio to downsize to before computing the render pass.
  148211. * @param camera The camera to apply the render pass to.
  148212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148213. * @param engine The engine which the post process will be applied. (default: current engine)
  148214. * @param reusable If the post process can be reused on the same frame. (default: false)
  148215. * @param textureType Type of textures used when performing the post process. (default: 0)
  148216. * @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)
  148217. */
  148218. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  148219. /** Weight of the bloom to be added to the original input. */
  148220. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148221. }
  148222. }
  148223. declare module BABYLON {
  148224. /**
  148225. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  148226. */
  148227. export class BloomEffect extends PostProcessRenderEffect {
  148228. private bloomScale;
  148229. /**
  148230. * @hidden Internal
  148231. */
  148232. _effects: Array<PostProcess>;
  148233. /**
  148234. * @hidden Internal
  148235. */
  148236. _downscale: ExtractHighlightsPostProcess;
  148237. private _blurX;
  148238. private _blurY;
  148239. private _merge;
  148240. /**
  148241. * The luminance threshold to find bright areas of the image to bloom.
  148242. */
  148243. get threshold(): number;
  148244. set threshold(value: number);
  148245. /**
  148246. * The strength of the bloom.
  148247. */
  148248. get weight(): number;
  148249. set weight(value: number);
  148250. /**
  148251. * Specifies the size of the bloom blur kernel, relative to the final output size
  148252. */
  148253. get kernel(): number;
  148254. set kernel(value: number);
  148255. /**
  148256. * Creates a new instance of @see BloomEffect
  148257. * @param scene The scene the effect belongs to.
  148258. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  148259. * @param bloomKernel The size of the kernel to be used when applying the blur.
  148260. * @param bloomWeight The the strength of bloom.
  148261. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148262. * @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)
  148263. */
  148264. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  148265. /**
  148266. * Disposes each of the internal effects for a given camera.
  148267. * @param camera The camera to dispose the effect on.
  148268. */
  148269. disposeEffects(camera: Camera): void;
  148270. /**
  148271. * @hidden Internal
  148272. */
  148273. _updateEffects(): void;
  148274. /**
  148275. * Internal
  148276. * @returns if all the contained post processes are ready.
  148277. * @hidden
  148278. */
  148279. _isReady(): boolean;
  148280. }
  148281. }
  148282. declare module BABYLON {
  148283. /** @hidden */
  148284. export var chromaticAberrationPixelShader: {
  148285. name: string;
  148286. shader: string;
  148287. };
  148288. }
  148289. declare module BABYLON {
  148290. /**
  148291. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  148292. */
  148293. export class ChromaticAberrationPostProcess extends PostProcess {
  148294. /**
  148295. * The amount of seperation of rgb channels (default: 30)
  148296. */
  148297. aberrationAmount: number;
  148298. /**
  148299. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  148300. */
  148301. radialIntensity: number;
  148302. /**
  148303. * 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))
  148304. */
  148305. direction: Vector2;
  148306. /**
  148307. * 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))
  148308. */
  148309. centerPosition: Vector2;
  148310. /** The width of the screen to apply the effect on */
  148311. screenWidth: number;
  148312. /** The height of the screen to apply the effect on */
  148313. screenHeight: number;
  148314. /**
  148315. * Gets a string identifying the name of the class
  148316. * @returns "ChromaticAberrationPostProcess" string
  148317. */
  148318. getClassName(): string;
  148319. /**
  148320. * Creates a new instance ChromaticAberrationPostProcess
  148321. * @param name The name of the effect.
  148322. * @param screenWidth The width of the screen to apply the effect on.
  148323. * @param screenHeight The height of the screen to apply the effect on.
  148324. * @param options The required width/height ratio to downsize to before computing the render pass.
  148325. * @param camera The camera to apply the render pass to.
  148326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148327. * @param engine The engine which the post process will be applied. (default: current engine)
  148328. * @param reusable If the post process can be reused on the same frame. (default: false)
  148329. * @param textureType Type of textures used when performing the post process. (default: 0)
  148330. * @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)
  148331. */
  148332. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148333. /** @hidden */
  148334. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  148335. }
  148336. }
  148337. declare module BABYLON {
  148338. /** @hidden */
  148339. export var circleOfConfusionPixelShader: {
  148340. name: string;
  148341. shader: string;
  148342. };
  148343. }
  148344. declare module BABYLON {
  148345. /**
  148346. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  148347. */
  148348. export class CircleOfConfusionPostProcess extends PostProcess {
  148349. /**
  148350. * 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.
  148351. */
  148352. lensSize: number;
  148353. /**
  148354. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148355. */
  148356. fStop: number;
  148357. /**
  148358. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148359. */
  148360. focusDistance: number;
  148361. /**
  148362. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  148363. */
  148364. focalLength: number;
  148365. /**
  148366. * Gets a string identifying the name of the class
  148367. * @returns "CircleOfConfusionPostProcess" string
  148368. */
  148369. getClassName(): string;
  148370. private _depthTexture;
  148371. /**
  148372. * Creates a new instance CircleOfConfusionPostProcess
  148373. * @param name The name of the effect.
  148374. * @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.
  148375. * @param options The required width/height ratio to downsize to before computing the render pass.
  148376. * @param camera The camera to apply the render pass to.
  148377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148378. * @param engine The engine which the post process will be applied. (default: current engine)
  148379. * @param reusable If the post process can be reused on the same frame. (default: false)
  148380. * @param textureType Type of textures used when performing the post process. (default: 0)
  148381. * @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)
  148382. */
  148383. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148384. /**
  148385. * 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.
  148386. */
  148387. set depthTexture(value: RenderTargetTexture);
  148388. }
  148389. }
  148390. declare module BABYLON {
  148391. /** @hidden */
  148392. export var colorCorrectionPixelShader: {
  148393. name: string;
  148394. shader: string;
  148395. };
  148396. }
  148397. declare module BABYLON {
  148398. /**
  148399. *
  148400. * This post-process allows the modification of rendered colors by using
  148401. * a 'look-up table' (LUT). This effect is also called Color Grading.
  148402. *
  148403. * The object needs to be provided an url to a texture containing the color
  148404. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  148405. * Use an image editing software to tweak the LUT to match your needs.
  148406. *
  148407. * For an example of a color LUT, see here:
  148408. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  148409. * For explanations on color grading, see here:
  148410. * @see http://udn.epicgames.com/Three/ColorGrading.html
  148411. *
  148412. */
  148413. export class ColorCorrectionPostProcess extends PostProcess {
  148414. private _colorTableTexture;
  148415. /**
  148416. * Gets the color table url used to create the LUT texture
  148417. */
  148418. colorTableUrl: string;
  148419. /**
  148420. * Gets a string identifying the name of the class
  148421. * @returns "ColorCorrectionPostProcess" string
  148422. */
  148423. getClassName(): string;
  148424. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148425. /** @hidden */
  148426. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  148427. }
  148428. }
  148429. declare module BABYLON {
  148430. /** @hidden */
  148431. export var convolutionPixelShader: {
  148432. name: string;
  148433. shader: string;
  148434. };
  148435. }
  148436. declare module BABYLON {
  148437. /**
  148438. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  148439. * input texture to perform effects such as edge detection or sharpening
  148440. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148441. */
  148442. export class ConvolutionPostProcess extends PostProcess {
  148443. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  148444. kernel: number[];
  148445. /**
  148446. * Gets a string identifying the name of the class
  148447. * @returns "ConvolutionPostProcess" string
  148448. */
  148449. getClassName(): string;
  148450. /**
  148451. * Creates a new instance ConvolutionPostProcess
  148452. * @param name The name of the effect.
  148453. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  148454. * @param options The required width/height ratio to downsize to before computing the render pass.
  148455. * @param camera The camera to apply the render pass to.
  148456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148457. * @param engine The engine which the post process will be applied. (default: current engine)
  148458. * @param reusable If the post process can be reused on the same frame. (default: false)
  148459. * @param textureType Type of textures used when performing the post process. (default: 0)
  148460. */
  148461. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148462. /** @hidden */
  148463. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  148464. /**
  148465. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148466. */
  148467. static EdgeDetect0Kernel: number[];
  148468. /**
  148469. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148470. */
  148471. static EdgeDetect1Kernel: number[];
  148472. /**
  148473. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148474. */
  148475. static EdgeDetect2Kernel: number[];
  148476. /**
  148477. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148478. */
  148479. static SharpenKernel: number[];
  148480. /**
  148481. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148482. */
  148483. static EmbossKernel: number[];
  148484. /**
  148485. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148486. */
  148487. static GaussianKernel: number[];
  148488. }
  148489. }
  148490. declare module BABYLON {
  148491. /**
  148492. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  148493. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  148494. * based on samples that have a large difference in distance than the center pixel.
  148495. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  148496. */
  148497. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  148498. /**
  148499. * The direction the blur should be applied
  148500. */
  148501. direction: Vector2;
  148502. /**
  148503. * Gets a string identifying the name of the class
  148504. * @returns "DepthOfFieldBlurPostProcess" string
  148505. */
  148506. getClassName(): string;
  148507. /**
  148508. * Creates a new instance CircleOfConfusionPostProcess
  148509. * @param name The name of the effect.
  148510. * @param scene The scene the effect belongs to.
  148511. * @param direction The direction the blur should be applied.
  148512. * @param kernel The size of the kernel used to blur.
  148513. * @param options The required width/height ratio to downsize to before computing the render pass.
  148514. * @param camera The camera to apply the render pass to.
  148515. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  148516. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  148517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148518. * @param engine The engine which the post process will be applied. (default: current engine)
  148519. * @param reusable If the post process can be reused on the same frame. (default: false)
  148520. * @param textureType Type of textures used when performing the post process. (default: 0)
  148521. * @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)
  148522. */
  148523. 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);
  148524. }
  148525. }
  148526. declare module BABYLON {
  148527. /** @hidden */
  148528. export var depthOfFieldMergePixelShader: {
  148529. name: string;
  148530. shader: string;
  148531. };
  148532. }
  148533. declare module BABYLON {
  148534. /**
  148535. * Options to be set when merging outputs from the default pipeline.
  148536. */
  148537. export class DepthOfFieldMergePostProcessOptions {
  148538. /**
  148539. * The original image to merge on top of
  148540. */
  148541. originalFromInput: PostProcess;
  148542. /**
  148543. * Parameters to perform the merge of the depth of field effect
  148544. */
  148545. depthOfField?: {
  148546. circleOfConfusion: PostProcess;
  148547. blurSteps: Array<PostProcess>;
  148548. };
  148549. /**
  148550. * Parameters to perform the merge of bloom effect
  148551. */
  148552. bloom?: {
  148553. blurred: PostProcess;
  148554. weight: number;
  148555. };
  148556. }
  148557. /**
  148558. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148559. */
  148560. export class DepthOfFieldMergePostProcess extends PostProcess {
  148561. private blurSteps;
  148562. /**
  148563. * Gets a string identifying the name of the class
  148564. * @returns "DepthOfFieldMergePostProcess" string
  148565. */
  148566. getClassName(): string;
  148567. /**
  148568. * Creates a new instance of DepthOfFieldMergePostProcess
  148569. * @param name The name of the effect.
  148570. * @param originalFromInput Post process which's input will be used for the merge.
  148571. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  148572. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  148573. * @param options The required width/height ratio to downsize to before computing the render pass.
  148574. * @param camera The camera to apply the render pass to.
  148575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148576. * @param engine The engine which the post process will be applied. (default: current engine)
  148577. * @param reusable If the post process can be reused on the same frame. (default: false)
  148578. * @param textureType Type of textures used when performing the post process. (default: 0)
  148579. * @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)
  148580. */
  148581. 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);
  148582. /**
  148583. * Updates the effect with the current post process compile time values and recompiles the shader.
  148584. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  148585. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  148586. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  148587. * @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
  148588. * @param onCompiled Called when the shader has been compiled.
  148589. * @param onError Called if there is an error when compiling a shader.
  148590. */
  148591. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  148592. }
  148593. }
  148594. declare module BABYLON {
  148595. /**
  148596. * Specifies the level of max blur that should be applied when using the depth of field effect
  148597. */
  148598. export enum DepthOfFieldEffectBlurLevel {
  148599. /**
  148600. * Subtle blur
  148601. */
  148602. Low = 0,
  148603. /**
  148604. * Medium blur
  148605. */
  148606. Medium = 1,
  148607. /**
  148608. * Large blur
  148609. */
  148610. High = 2
  148611. }
  148612. /**
  148613. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  148614. */
  148615. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  148616. private _circleOfConfusion;
  148617. /**
  148618. * @hidden Internal, blurs from high to low
  148619. */
  148620. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  148621. private _depthOfFieldBlurY;
  148622. private _dofMerge;
  148623. /**
  148624. * @hidden Internal post processes in depth of field effect
  148625. */
  148626. _effects: Array<PostProcess>;
  148627. /**
  148628. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  148629. */
  148630. set focalLength(value: number);
  148631. get focalLength(): number;
  148632. /**
  148633. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148634. */
  148635. set fStop(value: number);
  148636. get fStop(): number;
  148637. /**
  148638. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148639. */
  148640. set focusDistance(value: number);
  148641. get focusDistance(): number;
  148642. /**
  148643. * 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.
  148644. */
  148645. set lensSize(value: number);
  148646. get lensSize(): number;
  148647. /**
  148648. * Creates a new instance DepthOfFieldEffect
  148649. * @param scene The scene the effect belongs to.
  148650. * @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.
  148651. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148652. * @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)
  148653. */
  148654. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  148655. /**
  148656. * Get the current class name of the current effet
  148657. * @returns "DepthOfFieldEffect"
  148658. */
  148659. getClassName(): string;
  148660. /**
  148661. * 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.
  148662. */
  148663. set depthTexture(value: RenderTargetTexture);
  148664. /**
  148665. * Disposes each of the internal effects for a given camera.
  148666. * @param camera The camera to dispose the effect on.
  148667. */
  148668. disposeEffects(camera: Camera): void;
  148669. /**
  148670. * @hidden Internal
  148671. */
  148672. _updateEffects(): void;
  148673. /**
  148674. * Internal
  148675. * @returns if all the contained post processes are ready.
  148676. * @hidden
  148677. */
  148678. _isReady(): boolean;
  148679. }
  148680. }
  148681. declare module BABYLON {
  148682. /** @hidden */
  148683. export var displayPassPixelShader: {
  148684. name: string;
  148685. shader: string;
  148686. };
  148687. }
  148688. declare module BABYLON {
  148689. /**
  148690. * DisplayPassPostProcess which produces an output the same as it's input
  148691. */
  148692. export class DisplayPassPostProcess extends PostProcess {
  148693. /**
  148694. * Gets a string identifying the name of the class
  148695. * @returns "DisplayPassPostProcess" string
  148696. */
  148697. getClassName(): string;
  148698. /**
  148699. * Creates the DisplayPassPostProcess
  148700. * @param name The name of the effect.
  148701. * @param options The required width/height ratio to downsize to before computing the render pass.
  148702. * @param camera The camera to apply the render pass to.
  148703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148704. * @param engine The engine which the post process will be applied. (default: current engine)
  148705. * @param reusable If the post process can be reused on the same frame. (default: false)
  148706. */
  148707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148708. /** @hidden */
  148709. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  148710. }
  148711. }
  148712. declare module BABYLON {
  148713. /** @hidden */
  148714. export var filterPixelShader: {
  148715. name: string;
  148716. shader: string;
  148717. };
  148718. }
  148719. declare module BABYLON {
  148720. /**
  148721. * Applies a kernel filter to the image
  148722. */
  148723. export class FilterPostProcess extends PostProcess {
  148724. /** The matrix to be applied to the image */
  148725. kernelMatrix: Matrix;
  148726. /**
  148727. * Gets a string identifying the name of the class
  148728. * @returns "FilterPostProcess" string
  148729. */
  148730. getClassName(): string;
  148731. /**
  148732. *
  148733. * @param name The name of the effect.
  148734. * @param kernelMatrix The matrix to be applied to the image
  148735. * @param options The required width/height ratio to downsize to before computing the render pass.
  148736. * @param camera The camera to apply the render pass to.
  148737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148738. * @param engine The engine which the post process will be applied. (default: current engine)
  148739. * @param reusable If the post process can be reused on the same frame. (default: false)
  148740. */
  148741. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148742. /** @hidden */
  148743. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  148744. }
  148745. }
  148746. declare module BABYLON {
  148747. /** @hidden */
  148748. export var fxaaPixelShader: {
  148749. name: string;
  148750. shader: string;
  148751. };
  148752. }
  148753. declare module BABYLON {
  148754. /** @hidden */
  148755. export var fxaaVertexShader: {
  148756. name: string;
  148757. shader: string;
  148758. };
  148759. }
  148760. declare module BABYLON {
  148761. /**
  148762. * Fxaa post process
  148763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148764. */
  148765. export class FxaaPostProcess extends PostProcess {
  148766. /**
  148767. * Gets a string identifying the name of the class
  148768. * @returns "FxaaPostProcess" string
  148769. */
  148770. getClassName(): string;
  148771. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148772. private _getDefines;
  148773. /** @hidden */
  148774. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  148775. }
  148776. }
  148777. declare module BABYLON {
  148778. /** @hidden */
  148779. export var grainPixelShader: {
  148780. name: string;
  148781. shader: string;
  148782. };
  148783. }
  148784. declare module BABYLON {
  148785. /**
  148786. * The GrainPostProcess adds noise to the image at mid luminance levels
  148787. */
  148788. export class GrainPostProcess extends PostProcess {
  148789. /**
  148790. * The intensity of the grain added (default: 30)
  148791. */
  148792. intensity: number;
  148793. /**
  148794. * If the grain should be randomized on every frame
  148795. */
  148796. animated: boolean;
  148797. /**
  148798. * Gets a string identifying the name of the class
  148799. * @returns "GrainPostProcess" string
  148800. */
  148801. getClassName(): string;
  148802. /**
  148803. * Creates a new instance of @see GrainPostProcess
  148804. * @param name The name of the effect.
  148805. * @param options The required width/height ratio to downsize to before computing the render pass.
  148806. * @param camera The camera to apply the render pass to.
  148807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148808. * @param engine The engine which the post process will be applied. (default: current engine)
  148809. * @param reusable If the post process can be reused on the same frame. (default: false)
  148810. * @param textureType Type of textures used when performing the post process. (default: 0)
  148811. * @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)
  148812. */
  148813. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148814. /** @hidden */
  148815. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  148816. }
  148817. }
  148818. declare module BABYLON {
  148819. /** @hidden */
  148820. export var highlightsPixelShader: {
  148821. name: string;
  148822. shader: string;
  148823. };
  148824. }
  148825. declare module BABYLON {
  148826. /**
  148827. * Extracts highlights from the image
  148828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148829. */
  148830. export class HighlightsPostProcess extends PostProcess {
  148831. /**
  148832. * Gets a string identifying the name of the class
  148833. * @returns "HighlightsPostProcess" string
  148834. */
  148835. getClassName(): string;
  148836. /**
  148837. * Extracts highlights from the image
  148838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148839. * @param name The name of the effect.
  148840. * @param options The required width/height ratio to downsize to before computing the render pass.
  148841. * @param camera The camera to apply the render pass to.
  148842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148843. * @param engine The engine which the post process will be applied. (default: current engine)
  148844. * @param reusable If the post process can be reused on the same frame. (default: false)
  148845. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148846. */
  148847. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148848. }
  148849. }
  148850. declare module BABYLON {
  148851. /** @hidden */
  148852. export var mrtFragmentDeclaration: {
  148853. name: string;
  148854. shader: string;
  148855. };
  148856. }
  148857. declare module BABYLON {
  148858. /** @hidden */
  148859. export var geometryPixelShader: {
  148860. name: string;
  148861. shader: string;
  148862. };
  148863. }
  148864. declare module BABYLON {
  148865. /** @hidden */
  148866. export var geometryVertexShader: {
  148867. name: string;
  148868. shader: string;
  148869. };
  148870. }
  148871. declare module BABYLON {
  148872. /** @hidden */
  148873. interface ISavedTransformationMatrix {
  148874. world: Matrix;
  148875. viewProjection: Matrix;
  148876. }
  148877. /**
  148878. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148879. */
  148880. export class GeometryBufferRenderer {
  148881. /**
  148882. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148883. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148884. */
  148885. static readonly POSITION_TEXTURE_TYPE: number;
  148886. /**
  148887. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148888. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148889. */
  148890. static readonly VELOCITY_TEXTURE_TYPE: number;
  148891. /**
  148892. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148893. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148894. */
  148895. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148896. /**
  148897. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148898. * in order to compute objects velocities when enableVelocity is set to "true"
  148899. * @hidden
  148900. */
  148901. _previousTransformationMatrices: {
  148902. [index: number]: ISavedTransformationMatrix;
  148903. };
  148904. /**
  148905. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148906. * in order to compute objects velocities when enableVelocity is set to "true"
  148907. * @hidden
  148908. */
  148909. _previousBonesTransformationMatrices: {
  148910. [index: number]: Float32Array;
  148911. };
  148912. /**
  148913. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148914. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148915. */
  148916. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148917. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148918. renderTransparentMeshes: boolean;
  148919. private _scene;
  148920. private _resizeObserver;
  148921. private _multiRenderTarget;
  148922. private _ratio;
  148923. private _enablePosition;
  148924. private _enableVelocity;
  148925. private _enableReflectivity;
  148926. private _positionIndex;
  148927. private _velocityIndex;
  148928. private _reflectivityIndex;
  148929. protected _effect: Effect;
  148930. protected _cachedDefines: string;
  148931. /**
  148932. * Set the render list (meshes to be rendered) used in the G buffer.
  148933. */
  148934. set renderList(meshes: Mesh[]);
  148935. /**
  148936. * Gets wether or not G buffer are supported by the running hardware.
  148937. * This requires draw buffer supports
  148938. */
  148939. get isSupported(): boolean;
  148940. /**
  148941. * Returns the index of the given texture type in the G-Buffer textures array
  148942. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148943. * @returns the index of the given texture type in the G-Buffer textures array
  148944. */
  148945. getTextureIndex(textureType: number): number;
  148946. /**
  148947. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148948. */
  148949. get enablePosition(): boolean;
  148950. /**
  148951. * Sets whether or not objects positions are enabled for the G buffer.
  148952. */
  148953. set enablePosition(enable: boolean);
  148954. /**
  148955. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148956. */
  148957. get enableVelocity(): boolean;
  148958. /**
  148959. * Sets wether or not objects velocities are enabled for the G buffer.
  148960. */
  148961. set enableVelocity(enable: boolean);
  148962. /**
  148963. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148964. */
  148965. get enableReflectivity(): boolean;
  148966. /**
  148967. * Sets wether or not objects roughness are enabled for the G buffer.
  148968. */
  148969. set enableReflectivity(enable: boolean);
  148970. /**
  148971. * Gets the scene associated with the buffer.
  148972. */
  148973. get scene(): Scene;
  148974. /**
  148975. * Gets the ratio used by the buffer during its creation.
  148976. * How big is the buffer related to the main canvas.
  148977. */
  148978. get ratio(): number;
  148979. /** @hidden */
  148980. static _SceneComponentInitialization: (scene: Scene) => void;
  148981. /**
  148982. * Creates a new G Buffer for the scene
  148983. * @param scene The scene the buffer belongs to
  148984. * @param ratio How big is the buffer related to the main canvas.
  148985. */
  148986. constructor(scene: Scene, ratio?: number);
  148987. /**
  148988. * Checks wether everything is ready to render a submesh to the G buffer.
  148989. * @param subMesh the submesh to check readiness for
  148990. * @param useInstances is the mesh drawn using instance or not
  148991. * @returns true if ready otherwise false
  148992. */
  148993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148994. /**
  148995. * Gets the current underlying G Buffer.
  148996. * @returns the buffer
  148997. */
  148998. getGBuffer(): MultiRenderTarget;
  148999. /**
  149000. * Gets the number of samples used to render the buffer (anti aliasing).
  149001. */
  149002. get samples(): number;
  149003. /**
  149004. * Sets the number of samples used to render the buffer (anti aliasing).
  149005. */
  149006. set samples(value: number);
  149007. /**
  149008. * Disposes the renderer and frees up associated resources.
  149009. */
  149010. dispose(): void;
  149011. protected _createRenderTargets(): void;
  149012. private _copyBonesTransformationMatrices;
  149013. }
  149014. }
  149015. declare module BABYLON {
  149016. interface Scene {
  149017. /** @hidden (Backing field) */
  149018. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149019. /**
  149020. * Gets or Sets the current geometry buffer associated to the scene.
  149021. */
  149022. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149023. /**
  149024. * Enables a GeometryBufferRender and associates it with the scene
  149025. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149026. * @returns the GeometryBufferRenderer
  149027. */
  149028. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149029. /**
  149030. * Disables the GeometryBufferRender associated with the scene
  149031. */
  149032. disableGeometryBufferRenderer(): void;
  149033. }
  149034. /**
  149035. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149036. * in several rendering techniques.
  149037. */
  149038. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149039. /**
  149040. * The component name helpful to identify the component in the list of scene components.
  149041. */
  149042. readonly name: string;
  149043. /**
  149044. * The scene the component belongs to.
  149045. */
  149046. scene: Scene;
  149047. /**
  149048. * Creates a new instance of the component for the given scene
  149049. * @param scene Defines the scene to register the component in
  149050. */
  149051. constructor(scene: Scene);
  149052. /**
  149053. * Registers the component in a given scene
  149054. */
  149055. register(): void;
  149056. /**
  149057. * Rebuilds the elements related to this component in case of
  149058. * context lost for instance.
  149059. */
  149060. rebuild(): void;
  149061. /**
  149062. * Disposes the component and the associated ressources
  149063. */
  149064. dispose(): void;
  149065. private _gatherRenderTargets;
  149066. }
  149067. }
  149068. declare module BABYLON {
  149069. /** @hidden */
  149070. export var motionBlurPixelShader: {
  149071. name: string;
  149072. shader: string;
  149073. };
  149074. }
  149075. declare module BABYLON {
  149076. /**
  149077. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149078. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149079. * As an example, all you have to do is to create the post-process:
  149080. * var mb = new BABYLON.MotionBlurPostProcess(
  149081. * 'mb', // The name of the effect.
  149082. * scene, // The scene containing the objects to blur according to their velocity.
  149083. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149084. * camera // The camera to apply the render pass to.
  149085. * );
  149086. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149087. */
  149088. export class MotionBlurPostProcess extends PostProcess {
  149089. /**
  149090. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149091. */
  149092. motionStrength: number;
  149093. /**
  149094. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149095. */
  149096. get motionBlurSamples(): number;
  149097. /**
  149098. * Sets the number of iterations to be used for motion blur quality
  149099. */
  149100. set motionBlurSamples(samples: number);
  149101. private _motionBlurSamples;
  149102. private _geometryBufferRenderer;
  149103. /**
  149104. * Gets a string identifying the name of the class
  149105. * @returns "MotionBlurPostProcess" string
  149106. */
  149107. getClassName(): string;
  149108. /**
  149109. * Creates a new instance MotionBlurPostProcess
  149110. * @param name The name of the effect.
  149111. * @param scene The scene containing the objects to blur according to their velocity.
  149112. * @param options The required width/height ratio to downsize to before computing the render pass.
  149113. * @param camera The camera to apply the render pass to.
  149114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149115. * @param engine The engine which the post process will be applied. (default: current engine)
  149116. * @param reusable If the post process can be reused on the same frame. (default: false)
  149117. * @param textureType Type of textures used when performing the post process. (default: 0)
  149118. * @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)
  149119. */
  149120. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149121. /**
  149122. * Excludes the given skinned mesh from computing bones velocities.
  149123. * 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.
  149124. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  149125. */
  149126. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149127. /**
  149128. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  149129. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  149130. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  149131. */
  149132. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149133. /**
  149134. * Disposes the post process.
  149135. * @param camera The camera to dispose the post process on.
  149136. */
  149137. dispose(camera?: Camera): void;
  149138. /** @hidden */
  149139. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  149140. }
  149141. }
  149142. declare module BABYLON {
  149143. /** @hidden */
  149144. export var refractionPixelShader: {
  149145. name: string;
  149146. shader: string;
  149147. };
  149148. }
  149149. declare module BABYLON {
  149150. /**
  149151. * Post process which applies a refractin texture
  149152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149153. */
  149154. export class RefractionPostProcess extends PostProcess {
  149155. private _refTexture;
  149156. private _ownRefractionTexture;
  149157. /** the base color of the refraction (used to taint the rendering) */
  149158. color: Color3;
  149159. /** simulated refraction depth */
  149160. depth: number;
  149161. /** the coefficient of the base color (0 to remove base color tainting) */
  149162. colorLevel: number;
  149163. /** Gets the url used to load the refraction texture */
  149164. refractionTextureUrl: string;
  149165. /**
  149166. * Gets or sets the refraction texture
  149167. * Please note that you are responsible for disposing the texture if you set it manually
  149168. */
  149169. get refractionTexture(): Texture;
  149170. set refractionTexture(value: Texture);
  149171. /**
  149172. * Gets a string identifying the name of the class
  149173. * @returns "RefractionPostProcess" string
  149174. */
  149175. getClassName(): string;
  149176. /**
  149177. * Initializes the RefractionPostProcess
  149178. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149179. * @param name The name of the effect.
  149180. * @param refractionTextureUrl Url of the refraction texture to use
  149181. * @param color the base color of the refraction (used to taint the rendering)
  149182. * @param depth simulated refraction depth
  149183. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  149184. * @param camera The camera to apply the render pass to.
  149185. * @param options The required width/height ratio to downsize to before computing the render pass.
  149186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149187. * @param engine The engine which the post process will be applied. (default: current engine)
  149188. * @param reusable If the post process can be reused on the same frame. (default: false)
  149189. */
  149190. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149191. /**
  149192. * Disposes of the post process
  149193. * @param camera Camera to dispose post process on
  149194. */
  149195. dispose(camera: Camera): void;
  149196. /** @hidden */
  149197. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  149198. }
  149199. }
  149200. declare module BABYLON {
  149201. /** @hidden */
  149202. export var sharpenPixelShader: {
  149203. name: string;
  149204. shader: string;
  149205. };
  149206. }
  149207. declare module BABYLON {
  149208. /**
  149209. * The SharpenPostProcess applies a sharpen kernel to every pixel
  149210. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149211. */
  149212. export class SharpenPostProcess extends PostProcess {
  149213. /**
  149214. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  149215. */
  149216. colorAmount: number;
  149217. /**
  149218. * How much sharpness should be applied (default: 0.3)
  149219. */
  149220. edgeAmount: number;
  149221. /**
  149222. * Gets a string identifying the name of the class
  149223. * @returns "SharpenPostProcess" string
  149224. */
  149225. getClassName(): string;
  149226. /**
  149227. * Creates a new instance ConvolutionPostProcess
  149228. * @param name The name of the effect.
  149229. * @param options The required width/height ratio to downsize to before computing the render pass.
  149230. * @param camera The camera to apply the render pass to.
  149231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149232. * @param engine The engine which the post process will be applied. (default: current engine)
  149233. * @param reusable If the post process can be reused on the same frame. (default: false)
  149234. * @param textureType Type of textures used when performing the post process. (default: 0)
  149235. * @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)
  149236. */
  149237. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149238. /** @hidden */
  149239. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  149240. }
  149241. }
  149242. declare module BABYLON {
  149243. /**
  149244. * PostProcessRenderPipeline
  149245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149246. */
  149247. export class PostProcessRenderPipeline {
  149248. private engine;
  149249. private _renderEffects;
  149250. private _renderEffectsForIsolatedPass;
  149251. /**
  149252. * List of inspectable custom properties (used by the Inspector)
  149253. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  149254. */
  149255. inspectableCustomProperties: IInspectable[];
  149256. /**
  149257. * @hidden
  149258. */
  149259. protected _cameras: Camera[];
  149260. /** @hidden */
  149261. _name: string;
  149262. /**
  149263. * Gets pipeline name
  149264. */
  149265. get name(): string;
  149266. /** Gets the list of attached cameras */
  149267. get cameras(): Camera[];
  149268. /**
  149269. * Initializes a PostProcessRenderPipeline
  149270. * @param engine engine to add the pipeline to
  149271. * @param name name of the pipeline
  149272. */
  149273. constructor(engine: Engine, name: string);
  149274. /**
  149275. * Gets the class name
  149276. * @returns "PostProcessRenderPipeline"
  149277. */
  149278. getClassName(): string;
  149279. /**
  149280. * If all the render effects in the pipeline are supported
  149281. */
  149282. get isSupported(): boolean;
  149283. /**
  149284. * Adds an effect to the pipeline
  149285. * @param renderEffect the effect to add
  149286. */
  149287. addEffect(renderEffect: PostProcessRenderEffect): void;
  149288. /** @hidden */
  149289. _rebuild(): void;
  149290. /** @hidden */
  149291. _enableEffect(renderEffectName: string, cameras: Camera): void;
  149292. /** @hidden */
  149293. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  149294. /** @hidden */
  149295. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149296. /** @hidden */
  149297. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  149298. /** @hidden */
  149299. _attachCameras(cameras: Camera, unique: boolean): void;
  149300. /** @hidden */
  149301. _attachCameras(cameras: Camera[], unique: boolean): void;
  149302. /** @hidden */
  149303. _detachCameras(cameras: Camera): void;
  149304. /** @hidden */
  149305. _detachCameras(cameras: Nullable<Camera[]>): void;
  149306. /** @hidden */
  149307. _update(): void;
  149308. /** @hidden */
  149309. _reset(): void;
  149310. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  149311. /**
  149312. * Sets the required values to the prepass renderer.
  149313. * @param prePassRenderer defines the prepass renderer to setup.
  149314. * @returns true if the pre pass is needed.
  149315. */
  149316. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149317. /**
  149318. * Disposes of the pipeline
  149319. */
  149320. dispose(): void;
  149321. }
  149322. }
  149323. declare module BABYLON {
  149324. /**
  149325. * PostProcessRenderPipelineManager class
  149326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149327. */
  149328. export class PostProcessRenderPipelineManager {
  149329. private _renderPipelines;
  149330. /**
  149331. * Initializes a PostProcessRenderPipelineManager
  149332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149333. */
  149334. constructor();
  149335. /**
  149336. * Gets the list of supported render pipelines
  149337. */
  149338. get supportedPipelines(): PostProcessRenderPipeline[];
  149339. /**
  149340. * Adds a pipeline to the manager
  149341. * @param renderPipeline The pipeline to add
  149342. */
  149343. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  149344. /**
  149345. * Attaches a camera to the pipeline
  149346. * @param renderPipelineName The name of the pipeline to attach to
  149347. * @param cameras the camera to attach
  149348. * @param unique if the camera can be attached multiple times to the pipeline
  149349. */
  149350. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  149351. /**
  149352. * Detaches a camera from the pipeline
  149353. * @param renderPipelineName The name of the pipeline to detach from
  149354. * @param cameras the camera to detach
  149355. */
  149356. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  149357. /**
  149358. * Enables an effect by name on a pipeline
  149359. * @param renderPipelineName the name of the pipeline to enable the effect in
  149360. * @param renderEffectName the name of the effect to enable
  149361. * @param cameras the cameras that the effect should be enabled on
  149362. */
  149363. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149364. /**
  149365. * Disables an effect by name on a pipeline
  149366. * @param renderPipelineName the name of the pipeline to disable the effect in
  149367. * @param renderEffectName the name of the effect to disable
  149368. * @param cameras the cameras that the effect should be disabled on
  149369. */
  149370. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  149371. /**
  149372. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  149373. */
  149374. update(): void;
  149375. /** @hidden */
  149376. _rebuild(): void;
  149377. /**
  149378. * Disposes of the manager and pipelines
  149379. */
  149380. dispose(): void;
  149381. }
  149382. }
  149383. declare module BABYLON {
  149384. interface Scene {
  149385. /** @hidden (Backing field) */
  149386. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149387. /**
  149388. * Gets the postprocess render pipeline manager
  149389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149390. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149391. */
  149392. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  149393. }
  149394. /**
  149395. * Defines the Render Pipeline scene component responsible to rendering pipelines
  149396. */
  149397. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  149398. /**
  149399. * The component name helpfull to identify the component in the list of scene components.
  149400. */
  149401. readonly name: string;
  149402. /**
  149403. * The scene the component belongs to.
  149404. */
  149405. scene: Scene;
  149406. /**
  149407. * Creates a new instance of the component for the given scene
  149408. * @param scene Defines the scene to register the component in
  149409. */
  149410. constructor(scene: Scene);
  149411. /**
  149412. * Registers the component in a given scene
  149413. */
  149414. register(): void;
  149415. /**
  149416. * Rebuilds the elements related to this component in case of
  149417. * context lost for instance.
  149418. */
  149419. rebuild(): void;
  149420. /**
  149421. * Disposes the component and the associated ressources
  149422. */
  149423. dispose(): void;
  149424. private _gatherRenderTargets;
  149425. }
  149426. }
  149427. declare module BABYLON {
  149428. /**
  149429. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  149430. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149431. */
  149432. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149433. private _scene;
  149434. private _camerasToBeAttached;
  149435. /**
  149436. * ID of the sharpen post process,
  149437. */
  149438. private readonly SharpenPostProcessId;
  149439. /**
  149440. * @ignore
  149441. * ID of the image processing post process;
  149442. */
  149443. readonly ImageProcessingPostProcessId: string;
  149444. /**
  149445. * @ignore
  149446. * ID of the Fast Approximate Anti-Aliasing post process;
  149447. */
  149448. readonly FxaaPostProcessId: string;
  149449. /**
  149450. * ID of the chromatic aberration post process,
  149451. */
  149452. private readonly ChromaticAberrationPostProcessId;
  149453. /**
  149454. * ID of the grain post process
  149455. */
  149456. private readonly GrainPostProcessId;
  149457. /**
  149458. * Sharpen post process which will apply a sharpen convolution to enhance edges
  149459. */
  149460. sharpen: SharpenPostProcess;
  149461. private _sharpenEffect;
  149462. private bloom;
  149463. /**
  149464. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  149465. */
  149466. depthOfField: DepthOfFieldEffect;
  149467. /**
  149468. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149469. */
  149470. fxaa: FxaaPostProcess;
  149471. /**
  149472. * Image post processing pass used to perform operations such as tone mapping or color grading.
  149473. */
  149474. imageProcessing: ImageProcessingPostProcess;
  149475. /**
  149476. * Chromatic aberration post process which will shift rgb colors in the image
  149477. */
  149478. chromaticAberration: ChromaticAberrationPostProcess;
  149479. private _chromaticAberrationEffect;
  149480. /**
  149481. * Grain post process which add noise to the image
  149482. */
  149483. grain: GrainPostProcess;
  149484. private _grainEffect;
  149485. /**
  149486. * Glow post process which adds a glow to emissive areas of the image
  149487. */
  149488. private _glowLayer;
  149489. /**
  149490. * Animations which can be used to tweak settings over a period of time
  149491. */
  149492. animations: Animation[];
  149493. private _imageProcessingConfigurationObserver;
  149494. private _sharpenEnabled;
  149495. private _bloomEnabled;
  149496. private _depthOfFieldEnabled;
  149497. private _depthOfFieldBlurLevel;
  149498. private _fxaaEnabled;
  149499. private _imageProcessingEnabled;
  149500. private _defaultPipelineTextureType;
  149501. private _bloomScale;
  149502. private _chromaticAberrationEnabled;
  149503. private _grainEnabled;
  149504. private _buildAllowed;
  149505. /**
  149506. * Gets active scene
  149507. */
  149508. get scene(): Scene;
  149509. /**
  149510. * Enable or disable the sharpen process from the pipeline
  149511. */
  149512. set sharpenEnabled(enabled: boolean);
  149513. get sharpenEnabled(): boolean;
  149514. private _resizeObserver;
  149515. private _hardwareScaleLevel;
  149516. private _bloomKernel;
  149517. /**
  149518. * Specifies the size of the bloom blur kernel, relative to the final output size
  149519. */
  149520. get bloomKernel(): number;
  149521. set bloomKernel(value: number);
  149522. /**
  149523. * Specifies the weight of the bloom in the final rendering
  149524. */
  149525. private _bloomWeight;
  149526. /**
  149527. * Specifies the luma threshold for the area that will be blurred by the bloom
  149528. */
  149529. private _bloomThreshold;
  149530. private _hdr;
  149531. /**
  149532. * The strength of the bloom.
  149533. */
  149534. set bloomWeight(value: number);
  149535. get bloomWeight(): number;
  149536. /**
  149537. * The strength of the bloom.
  149538. */
  149539. set bloomThreshold(value: number);
  149540. get bloomThreshold(): number;
  149541. /**
  149542. * The scale of the bloom, lower value will provide better performance.
  149543. */
  149544. set bloomScale(value: number);
  149545. get bloomScale(): number;
  149546. /**
  149547. * Enable or disable the bloom from the pipeline
  149548. */
  149549. set bloomEnabled(enabled: boolean);
  149550. get bloomEnabled(): boolean;
  149551. private _rebuildBloom;
  149552. /**
  149553. * If the depth of field is enabled.
  149554. */
  149555. get depthOfFieldEnabled(): boolean;
  149556. set depthOfFieldEnabled(enabled: boolean);
  149557. /**
  149558. * Blur level of the depth of field effect. (Higher blur will effect performance)
  149559. */
  149560. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  149561. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  149562. /**
  149563. * If the anti aliasing is enabled.
  149564. */
  149565. set fxaaEnabled(enabled: boolean);
  149566. get fxaaEnabled(): boolean;
  149567. private _samples;
  149568. /**
  149569. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149570. */
  149571. set samples(sampleCount: number);
  149572. get samples(): number;
  149573. /**
  149574. * If image processing is enabled.
  149575. */
  149576. set imageProcessingEnabled(enabled: boolean);
  149577. get imageProcessingEnabled(): boolean;
  149578. /**
  149579. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  149580. */
  149581. set glowLayerEnabled(enabled: boolean);
  149582. get glowLayerEnabled(): boolean;
  149583. /**
  149584. * Gets the glow layer (or null if not defined)
  149585. */
  149586. get glowLayer(): Nullable<GlowLayer>;
  149587. /**
  149588. * Enable or disable the chromaticAberration process from the pipeline
  149589. */
  149590. set chromaticAberrationEnabled(enabled: boolean);
  149591. get chromaticAberrationEnabled(): boolean;
  149592. /**
  149593. * Enable or disable the grain process from the pipeline
  149594. */
  149595. set grainEnabled(enabled: boolean);
  149596. get grainEnabled(): boolean;
  149597. /**
  149598. * @constructor
  149599. * @param name - The rendering pipeline name (default: "")
  149600. * @param hdr - If high dynamic range textures should be used (default: true)
  149601. * @param scene - The scene linked to this pipeline (default: the last created scene)
  149602. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  149603. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  149604. */
  149605. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  149606. /**
  149607. * Get the class name
  149608. * @returns "DefaultRenderingPipeline"
  149609. */
  149610. getClassName(): string;
  149611. /**
  149612. * Force the compilation of the entire pipeline.
  149613. */
  149614. prepare(): void;
  149615. private _hasCleared;
  149616. private _prevPostProcess;
  149617. private _prevPrevPostProcess;
  149618. private _setAutoClearAndTextureSharing;
  149619. private _depthOfFieldSceneObserver;
  149620. private _buildPipeline;
  149621. private _disposePostProcesses;
  149622. /**
  149623. * Adds a camera to the pipeline
  149624. * @param camera the camera to be added
  149625. */
  149626. addCamera(camera: Camera): void;
  149627. /**
  149628. * Removes a camera from the pipeline
  149629. * @param camera the camera to remove
  149630. */
  149631. removeCamera(camera: Camera): void;
  149632. /**
  149633. * Dispose of the pipeline and stop all post processes
  149634. */
  149635. dispose(): void;
  149636. /**
  149637. * Serialize the rendering pipeline (Used when exporting)
  149638. * @returns the serialized object
  149639. */
  149640. serialize(): any;
  149641. /**
  149642. * Parse the serialized pipeline
  149643. * @param source Source pipeline.
  149644. * @param scene The scene to load the pipeline to.
  149645. * @param rootUrl The URL of the serialized pipeline.
  149646. * @returns An instantiated pipeline from the serialized object.
  149647. */
  149648. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  149649. }
  149650. }
  149651. declare module BABYLON {
  149652. /** @hidden */
  149653. export var lensHighlightsPixelShader: {
  149654. name: string;
  149655. shader: string;
  149656. };
  149657. }
  149658. declare module BABYLON {
  149659. /** @hidden */
  149660. export var depthOfFieldPixelShader: {
  149661. name: string;
  149662. shader: string;
  149663. };
  149664. }
  149665. declare module BABYLON {
  149666. /**
  149667. * BABYLON.JS Chromatic Aberration GLSL Shader
  149668. * Author: Olivier Guyot
  149669. * Separates very slightly R, G and B colors on the edges of the screen
  149670. * Inspired by Francois Tarlier & Martins Upitis
  149671. */
  149672. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  149673. /**
  149674. * @ignore
  149675. * The chromatic aberration PostProcess id in the pipeline
  149676. */
  149677. LensChromaticAberrationEffect: string;
  149678. /**
  149679. * @ignore
  149680. * The highlights enhancing PostProcess id in the pipeline
  149681. */
  149682. HighlightsEnhancingEffect: string;
  149683. /**
  149684. * @ignore
  149685. * The depth-of-field PostProcess id in the pipeline
  149686. */
  149687. LensDepthOfFieldEffect: string;
  149688. private _scene;
  149689. private _depthTexture;
  149690. private _grainTexture;
  149691. private _chromaticAberrationPostProcess;
  149692. private _highlightsPostProcess;
  149693. private _depthOfFieldPostProcess;
  149694. private _edgeBlur;
  149695. private _grainAmount;
  149696. private _chromaticAberration;
  149697. private _distortion;
  149698. private _highlightsGain;
  149699. private _highlightsThreshold;
  149700. private _dofDistance;
  149701. private _dofAperture;
  149702. private _dofDarken;
  149703. private _dofPentagon;
  149704. private _blurNoise;
  149705. /**
  149706. * @constructor
  149707. *
  149708. * Effect parameters are as follow:
  149709. * {
  149710. * chromatic_aberration: number; // from 0 to x (1 for realism)
  149711. * edge_blur: number; // from 0 to x (1 for realism)
  149712. * distortion: number; // from 0 to x (1 for realism)
  149713. * grain_amount: number; // from 0 to 1
  149714. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  149715. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  149716. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  149717. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  149718. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  149719. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  149720. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  149721. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  149722. * }
  149723. * Note: if an effect parameter is unset, effect is disabled
  149724. *
  149725. * @param name The rendering pipeline name
  149726. * @param parameters - An object containing all parameters (see above)
  149727. * @param scene The scene linked to this pipeline
  149728. * @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)
  149729. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149730. */
  149731. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  149732. /**
  149733. * Get the class name
  149734. * @returns "LensRenderingPipeline"
  149735. */
  149736. getClassName(): string;
  149737. /**
  149738. * Gets associated scene
  149739. */
  149740. get scene(): Scene;
  149741. /**
  149742. * Gets or sets the edge blur
  149743. */
  149744. get edgeBlur(): number;
  149745. set edgeBlur(value: number);
  149746. /**
  149747. * Gets or sets the grain amount
  149748. */
  149749. get grainAmount(): number;
  149750. set grainAmount(value: number);
  149751. /**
  149752. * Gets or sets the chromatic aberration amount
  149753. */
  149754. get chromaticAberration(): number;
  149755. set chromaticAberration(value: number);
  149756. /**
  149757. * Gets or sets the depth of field aperture
  149758. */
  149759. get dofAperture(): number;
  149760. set dofAperture(value: number);
  149761. /**
  149762. * Gets or sets the edge distortion
  149763. */
  149764. get edgeDistortion(): number;
  149765. set edgeDistortion(value: number);
  149766. /**
  149767. * Gets or sets the depth of field distortion
  149768. */
  149769. get dofDistortion(): number;
  149770. set dofDistortion(value: number);
  149771. /**
  149772. * Gets or sets the darken out of focus amount
  149773. */
  149774. get darkenOutOfFocus(): number;
  149775. set darkenOutOfFocus(value: number);
  149776. /**
  149777. * Gets or sets a boolean indicating if blur noise is enabled
  149778. */
  149779. get blurNoise(): boolean;
  149780. set blurNoise(value: boolean);
  149781. /**
  149782. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  149783. */
  149784. get pentagonBokeh(): boolean;
  149785. set pentagonBokeh(value: boolean);
  149786. /**
  149787. * Gets or sets the highlight grain amount
  149788. */
  149789. get highlightsGain(): number;
  149790. set highlightsGain(value: number);
  149791. /**
  149792. * Gets or sets the highlight threshold
  149793. */
  149794. get highlightsThreshold(): number;
  149795. set highlightsThreshold(value: number);
  149796. /**
  149797. * Sets the amount of blur at the edges
  149798. * @param amount blur amount
  149799. */
  149800. setEdgeBlur(amount: number): void;
  149801. /**
  149802. * Sets edge blur to 0
  149803. */
  149804. disableEdgeBlur(): void;
  149805. /**
  149806. * Sets the amout of grain
  149807. * @param amount Amount of grain
  149808. */
  149809. setGrainAmount(amount: number): void;
  149810. /**
  149811. * Set grain amount to 0
  149812. */
  149813. disableGrain(): void;
  149814. /**
  149815. * Sets the chromatic aberration amount
  149816. * @param amount amount of chromatic aberration
  149817. */
  149818. setChromaticAberration(amount: number): void;
  149819. /**
  149820. * Sets chromatic aberration amount to 0
  149821. */
  149822. disableChromaticAberration(): void;
  149823. /**
  149824. * Sets the EdgeDistortion amount
  149825. * @param amount amount of EdgeDistortion
  149826. */
  149827. setEdgeDistortion(amount: number): void;
  149828. /**
  149829. * Sets edge distortion to 0
  149830. */
  149831. disableEdgeDistortion(): void;
  149832. /**
  149833. * Sets the FocusDistance amount
  149834. * @param amount amount of FocusDistance
  149835. */
  149836. setFocusDistance(amount: number): void;
  149837. /**
  149838. * Disables depth of field
  149839. */
  149840. disableDepthOfField(): void;
  149841. /**
  149842. * Sets the Aperture amount
  149843. * @param amount amount of Aperture
  149844. */
  149845. setAperture(amount: number): void;
  149846. /**
  149847. * Sets the DarkenOutOfFocus amount
  149848. * @param amount amount of DarkenOutOfFocus
  149849. */
  149850. setDarkenOutOfFocus(amount: number): void;
  149851. private _pentagonBokehIsEnabled;
  149852. /**
  149853. * Creates a pentagon bokeh effect
  149854. */
  149855. enablePentagonBokeh(): void;
  149856. /**
  149857. * Disables the pentagon bokeh effect
  149858. */
  149859. disablePentagonBokeh(): void;
  149860. /**
  149861. * Enables noise blur
  149862. */
  149863. enableNoiseBlur(): void;
  149864. /**
  149865. * Disables noise blur
  149866. */
  149867. disableNoiseBlur(): void;
  149868. /**
  149869. * Sets the HighlightsGain amount
  149870. * @param amount amount of HighlightsGain
  149871. */
  149872. setHighlightsGain(amount: number): void;
  149873. /**
  149874. * Sets the HighlightsThreshold amount
  149875. * @param amount amount of HighlightsThreshold
  149876. */
  149877. setHighlightsThreshold(amount: number): void;
  149878. /**
  149879. * Disables highlights
  149880. */
  149881. disableHighlights(): void;
  149882. /**
  149883. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149884. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149885. */
  149886. dispose(disableDepthRender?: boolean): void;
  149887. private _createChromaticAberrationPostProcess;
  149888. private _createHighlightsPostProcess;
  149889. private _createDepthOfFieldPostProcess;
  149890. private _createGrainTexture;
  149891. }
  149892. }
  149893. declare module BABYLON {
  149894. /** @hidden */
  149895. export var ssao2PixelShader: {
  149896. name: string;
  149897. shader: string;
  149898. };
  149899. }
  149900. declare module BABYLON {
  149901. /** @hidden */
  149902. export var ssaoCombinePixelShader: {
  149903. name: string;
  149904. shader: string;
  149905. };
  149906. }
  149907. declare module BABYLON {
  149908. /**
  149909. * Render pipeline to produce ssao effect
  149910. */
  149911. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149912. /**
  149913. * @ignore
  149914. * The PassPostProcess id in the pipeline that contains the original scene color
  149915. */
  149916. SSAOOriginalSceneColorEffect: string;
  149917. /**
  149918. * @ignore
  149919. * The SSAO PostProcess id in the pipeline
  149920. */
  149921. SSAORenderEffect: string;
  149922. /**
  149923. * @ignore
  149924. * The horizontal blur PostProcess id in the pipeline
  149925. */
  149926. SSAOBlurHRenderEffect: string;
  149927. /**
  149928. * @ignore
  149929. * The vertical blur PostProcess id in the pipeline
  149930. */
  149931. SSAOBlurVRenderEffect: string;
  149932. /**
  149933. * @ignore
  149934. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149935. */
  149936. SSAOCombineRenderEffect: string;
  149937. /**
  149938. * The output strength of the SSAO post-process. Default value is 1.0.
  149939. */
  149940. totalStrength: number;
  149941. /**
  149942. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149943. */
  149944. maxZ: number;
  149945. /**
  149946. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149947. */
  149948. minZAspect: number;
  149949. private _samples;
  149950. /**
  149951. * Number of samples used for the SSAO calculations. Default value is 8
  149952. */
  149953. set samples(n: number);
  149954. get samples(): number;
  149955. private _textureSamples;
  149956. /**
  149957. * Number of samples to use for antialiasing
  149958. */
  149959. set textureSamples(n: number);
  149960. get textureSamples(): number;
  149961. /**
  149962. * Force rendering the geometry through geometry buffer
  149963. */
  149964. private _forceGeometryBuffer;
  149965. /**
  149966. * Ratio object used for SSAO ratio and blur ratio
  149967. */
  149968. private _ratio;
  149969. /**
  149970. * Dynamically generated sphere sampler.
  149971. */
  149972. private _sampleSphere;
  149973. /**
  149974. * Blur filter offsets
  149975. */
  149976. private _samplerOffsets;
  149977. private _expensiveBlur;
  149978. /**
  149979. * If bilateral blur should be used
  149980. */
  149981. set expensiveBlur(b: boolean);
  149982. get expensiveBlur(): boolean;
  149983. /**
  149984. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149985. */
  149986. radius: number;
  149987. /**
  149988. * The base color of the SSAO post-process
  149989. * The final result is "base + ssao" between [0, 1]
  149990. */
  149991. base: number;
  149992. /**
  149993. * Support test.
  149994. */
  149995. static get IsSupported(): boolean;
  149996. private _scene;
  149997. private _randomTexture;
  149998. private _originalColorPostProcess;
  149999. private _ssaoPostProcess;
  150000. private _blurHPostProcess;
  150001. private _blurVPostProcess;
  150002. private _ssaoCombinePostProcess;
  150003. private _prePassRenderer;
  150004. /**
  150005. * Gets active scene
  150006. */
  150007. get scene(): Scene;
  150008. /**
  150009. * @constructor
  150010. * @param name The rendering pipeline name
  150011. * @param scene The scene linked to this pipeline
  150012. * @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 }
  150013. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150014. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150015. */
  150016. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150017. /**
  150018. * Get the class name
  150019. * @returns "SSAO2RenderingPipeline"
  150020. */
  150021. getClassName(): string;
  150022. /**
  150023. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150024. */
  150025. dispose(disableGeometryBufferRenderer?: boolean): void;
  150026. private _createBlurPostProcess;
  150027. /** @hidden */
  150028. _rebuild(): void;
  150029. private _bits;
  150030. private _radicalInverse_VdC;
  150031. private _hammersley;
  150032. private _hemisphereSample_uniform;
  150033. private _generateHemisphere;
  150034. private _getDefinesForSSAO;
  150035. private _createSSAOPostProcess;
  150036. private _createSSAOCombinePostProcess;
  150037. private _createRandomTexture;
  150038. /**
  150039. * Serialize the rendering pipeline (Used when exporting)
  150040. * @returns the serialized object
  150041. */
  150042. serialize(): any;
  150043. /**
  150044. * Parse the serialized pipeline
  150045. * @param source Source pipeline.
  150046. * @param scene The scene to load the pipeline to.
  150047. * @param rootUrl The URL of the serialized pipeline.
  150048. * @returns An instantiated pipeline from the serialized object.
  150049. */
  150050. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150051. /**
  150052. * Sets the required values to the prepass renderer.
  150053. * @param prePassRenderer defines the prepass renderer to setup
  150054. * @returns true if the pre pass is needed.
  150055. */
  150056. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150057. }
  150058. }
  150059. declare module BABYLON {
  150060. /** @hidden */
  150061. export var ssaoPixelShader: {
  150062. name: string;
  150063. shader: string;
  150064. };
  150065. }
  150066. declare module BABYLON {
  150067. /**
  150068. * Render pipeline to produce ssao effect
  150069. */
  150070. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150071. /**
  150072. * @ignore
  150073. * The PassPostProcess id in the pipeline that contains the original scene color
  150074. */
  150075. SSAOOriginalSceneColorEffect: string;
  150076. /**
  150077. * @ignore
  150078. * The SSAO PostProcess id in the pipeline
  150079. */
  150080. SSAORenderEffect: string;
  150081. /**
  150082. * @ignore
  150083. * The horizontal blur PostProcess id in the pipeline
  150084. */
  150085. SSAOBlurHRenderEffect: string;
  150086. /**
  150087. * @ignore
  150088. * The vertical blur PostProcess id in the pipeline
  150089. */
  150090. SSAOBlurVRenderEffect: string;
  150091. /**
  150092. * @ignore
  150093. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150094. */
  150095. SSAOCombineRenderEffect: string;
  150096. /**
  150097. * The output strength of the SSAO post-process. Default value is 1.0.
  150098. */
  150099. totalStrength: number;
  150100. /**
  150101. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150102. */
  150103. radius: number;
  150104. /**
  150105. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  150106. * Must not be equal to fallOff and superior to fallOff.
  150107. * Default value is 0.0075
  150108. */
  150109. area: number;
  150110. /**
  150111. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  150112. * Must not be equal to area and inferior to area.
  150113. * Default value is 0.000001
  150114. */
  150115. fallOff: number;
  150116. /**
  150117. * The base color of the SSAO post-process
  150118. * The final result is "base + ssao" between [0, 1]
  150119. */
  150120. base: number;
  150121. private _scene;
  150122. private _depthTexture;
  150123. private _randomTexture;
  150124. private _originalColorPostProcess;
  150125. private _ssaoPostProcess;
  150126. private _blurHPostProcess;
  150127. private _blurVPostProcess;
  150128. private _ssaoCombinePostProcess;
  150129. private _firstUpdate;
  150130. /**
  150131. * Gets active scene
  150132. */
  150133. get scene(): Scene;
  150134. /**
  150135. * @constructor
  150136. * @param name - The rendering pipeline name
  150137. * @param scene - The scene linked to this pipeline
  150138. * @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 }
  150139. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  150140. */
  150141. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  150142. /**
  150143. * Get the class name
  150144. * @returns "SSAORenderingPipeline"
  150145. */
  150146. getClassName(): string;
  150147. /**
  150148. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150149. */
  150150. dispose(disableDepthRender?: boolean): void;
  150151. private _createBlurPostProcess;
  150152. /** @hidden */
  150153. _rebuild(): void;
  150154. private _createSSAOPostProcess;
  150155. private _createSSAOCombinePostProcess;
  150156. private _createRandomTexture;
  150157. }
  150158. }
  150159. declare module BABYLON {
  150160. /** @hidden */
  150161. export var screenSpaceReflectionPixelShader: {
  150162. name: string;
  150163. shader: string;
  150164. };
  150165. }
  150166. declare module BABYLON {
  150167. /**
  150168. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  150169. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  150170. */
  150171. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  150172. /**
  150173. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  150174. */
  150175. threshold: number;
  150176. /**
  150177. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  150178. */
  150179. strength: number;
  150180. /**
  150181. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  150182. */
  150183. reflectionSpecularFalloffExponent: number;
  150184. /**
  150185. * 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]
  150186. */
  150187. step: number;
  150188. /**
  150189. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  150190. */
  150191. roughnessFactor: number;
  150192. private _geometryBufferRenderer;
  150193. private _enableSmoothReflections;
  150194. private _reflectionSamples;
  150195. private _smoothSteps;
  150196. /**
  150197. * Gets a string identifying the name of the class
  150198. * @returns "ScreenSpaceReflectionPostProcess" string
  150199. */
  150200. getClassName(): string;
  150201. /**
  150202. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  150203. * @param name The name of the effect.
  150204. * @param scene The scene containing the objects to calculate reflections.
  150205. * @param options The required width/height ratio to downsize to before computing the render pass.
  150206. * @param camera The camera to apply the render pass to.
  150207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150208. * @param engine The engine which the post process will be applied. (default: current engine)
  150209. * @param reusable If the post process can be reused on the same frame. (default: false)
  150210. * @param textureType Type of textures used when performing the post process. (default: 0)
  150211. * @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)
  150212. */
  150213. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150214. /**
  150215. * Gets wether or not smoothing reflections is enabled.
  150216. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150217. */
  150218. get enableSmoothReflections(): boolean;
  150219. /**
  150220. * Sets wether or not smoothing reflections is enabled.
  150221. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150222. */
  150223. set enableSmoothReflections(enabled: boolean);
  150224. /**
  150225. * Gets the number of samples taken while computing reflections. More samples count is high,
  150226. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150227. */
  150228. get reflectionSamples(): number;
  150229. /**
  150230. * Sets the number of samples taken while computing reflections. More samples count is high,
  150231. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150232. */
  150233. set reflectionSamples(samples: number);
  150234. /**
  150235. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  150236. * more the post-process will require GPU power and can generate a drop in FPS.
  150237. * Default value (5.0) work pretty well in all cases but can be adjusted.
  150238. */
  150239. get smoothSteps(): number;
  150240. set smoothSteps(steps: number);
  150241. private _updateEffectDefines;
  150242. /** @hidden */
  150243. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  150244. }
  150245. }
  150246. declare module BABYLON {
  150247. /** @hidden */
  150248. export var standardPixelShader: {
  150249. name: string;
  150250. shader: string;
  150251. };
  150252. }
  150253. declare module BABYLON {
  150254. /**
  150255. * Standard rendering pipeline
  150256. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150257. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  150258. */
  150259. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150260. /**
  150261. * Public members
  150262. */
  150263. /**
  150264. * Post-process which contains the original scene color before the pipeline applies all the effects
  150265. */
  150266. originalPostProcess: Nullable<PostProcess>;
  150267. /**
  150268. * Post-process used to down scale an image x4
  150269. */
  150270. downSampleX4PostProcess: Nullable<PostProcess>;
  150271. /**
  150272. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  150273. */
  150274. brightPassPostProcess: Nullable<PostProcess>;
  150275. /**
  150276. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  150277. */
  150278. blurHPostProcesses: PostProcess[];
  150279. /**
  150280. * Post-process array storing all the vertical blur post-processes used by the pipeline
  150281. */
  150282. blurVPostProcesses: PostProcess[];
  150283. /**
  150284. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  150285. */
  150286. textureAdderPostProcess: Nullable<PostProcess>;
  150287. /**
  150288. * Post-process used to create volumetric lighting effect
  150289. */
  150290. volumetricLightPostProcess: Nullable<PostProcess>;
  150291. /**
  150292. * Post-process used to smooth the previous volumetric light post-process on the X axis
  150293. */
  150294. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  150295. /**
  150296. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  150297. */
  150298. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  150299. /**
  150300. * Post-process used to merge the volumetric light effect and the real scene color
  150301. */
  150302. volumetricLightMergePostProces: Nullable<PostProcess>;
  150303. /**
  150304. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  150305. */
  150306. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  150307. /**
  150308. * Base post-process used to calculate the average luminance of the final image for HDR
  150309. */
  150310. luminancePostProcess: Nullable<PostProcess>;
  150311. /**
  150312. * Post-processes used to create down sample post-processes in order to get
  150313. * the average luminance of the final image for HDR
  150314. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  150315. */
  150316. luminanceDownSamplePostProcesses: PostProcess[];
  150317. /**
  150318. * Post-process used to create a HDR effect (light adaptation)
  150319. */
  150320. hdrPostProcess: Nullable<PostProcess>;
  150321. /**
  150322. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  150323. */
  150324. textureAdderFinalPostProcess: Nullable<PostProcess>;
  150325. /**
  150326. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  150327. */
  150328. lensFlareFinalPostProcess: Nullable<PostProcess>;
  150329. /**
  150330. * Post-process used to merge the final HDR post-process and the real scene color
  150331. */
  150332. hdrFinalPostProcess: Nullable<PostProcess>;
  150333. /**
  150334. * Post-process used to create a lens flare effect
  150335. */
  150336. lensFlarePostProcess: Nullable<PostProcess>;
  150337. /**
  150338. * Post-process that merges the result of the lens flare post-process and the real scene color
  150339. */
  150340. lensFlareComposePostProcess: Nullable<PostProcess>;
  150341. /**
  150342. * Post-process used to create a motion blur effect
  150343. */
  150344. motionBlurPostProcess: Nullable<PostProcess>;
  150345. /**
  150346. * Post-process used to create a depth of field effect
  150347. */
  150348. depthOfFieldPostProcess: Nullable<PostProcess>;
  150349. /**
  150350. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150351. */
  150352. fxaaPostProcess: Nullable<FxaaPostProcess>;
  150353. /**
  150354. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  150355. */
  150356. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  150357. /**
  150358. * Represents the brightness threshold in order to configure the illuminated surfaces
  150359. */
  150360. brightThreshold: number;
  150361. /**
  150362. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  150363. */
  150364. blurWidth: number;
  150365. /**
  150366. * Sets if the blur for highlighted surfaces must be only horizontal
  150367. */
  150368. horizontalBlur: boolean;
  150369. /**
  150370. * Gets the overall exposure used by the pipeline
  150371. */
  150372. get exposure(): number;
  150373. /**
  150374. * Sets the overall exposure used by the pipeline
  150375. */
  150376. set exposure(value: number);
  150377. /**
  150378. * Texture used typically to simulate "dirty" on camera lens
  150379. */
  150380. lensTexture: Nullable<Texture>;
  150381. /**
  150382. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  150383. */
  150384. volumetricLightCoefficient: number;
  150385. /**
  150386. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  150387. */
  150388. volumetricLightPower: number;
  150389. /**
  150390. * Used the set the blur intensity to smooth the volumetric lights
  150391. */
  150392. volumetricLightBlurScale: number;
  150393. /**
  150394. * Light (spot or directional) used to generate the volumetric lights rays
  150395. * The source light must have a shadow generate so the pipeline can get its
  150396. * depth map
  150397. */
  150398. sourceLight: Nullable<SpotLight | DirectionalLight>;
  150399. /**
  150400. * For eye adaptation, represents the minimum luminance the eye can see
  150401. */
  150402. hdrMinimumLuminance: number;
  150403. /**
  150404. * For eye adaptation, represents the decrease luminance speed
  150405. */
  150406. hdrDecreaseRate: number;
  150407. /**
  150408. * For eye adaptation, represents the increase luminance speed
  150409. */
  150410. hdrIncreaseRate: number;
  150411. /**
  150412. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150413. */
  150414. get hdrAutoExposure(): boolean;
  150415. /**
  150416. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  150417. */
  150418. set hdrAutoExposure(value: boolean);
  150419. /**
  150420. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  150421. */
  150422. lensColorTexture: Nullable<Texture>;
  150423. /**
  150424. * The overall strengh for the lens flare effect
  150425. */
  150426. lensFlareStrength: number;
  150427. /**
  150428. * Dispersion coefficient for lens flare ghosts
  150429. */
  150430. lensFlareGhostDispersal: number;
  150431. /**
  150432. * Main lens flare halo width
  150433. */
  150434. lensFlareHaloWidth: number;
  150435. /**
  150436. * Based on the lens distortion effect, defines how much the lens flare result
  150437. * is distorted
  150438. */
  150439. lensFlareDistortionStrength: number;
  150440. /**
  150441. * Configures the blur intensity used for for lens flare (halo)
  150442. */
  150443. lensFlareBlurWidth: number;
  150444. /**
  150445. * Lens star texture must be used to simulate rays on the flares and is available
  150446. * in the documentation
  150447. */
  150448. lensStarTexture: Nullable<Texture>;
  150449. /**
  150450. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  150451. * flare effect by taking account of the dirt texture
  150452. */
  150453. lensFlareDirtTexture: Nullable<Texture>;
  150454. /**
  150455. * Represents the focal length for the depth of field effect
  150456. */
  150457. depthOfFieldDistance: number;
  150458. /**
  150459. * Represents the blur intensity for the blurred part of the depth of field effect
  150460. */
  150461. depthOfFieldBlurWidth: number;
  150462. /**
  150463. * Gets how much the image is blurred by the movement while using the motion blur post-process
  150464. */
  150465. get motionStrength(): number;
  150466. /**
  150467. * Sets how much the image is blurred by the movement while using the motion blur post-process
  150468. */
  150469. set motionStrength(strength: number);
  150470. /**
  150471. * Gets wether or not the motion blur post-process is object based or screen based.
  150472. */
  150473. get objectBasedMotionBlur(): boolean;
  150474. /**
  150475. * Sets wether or not the motion blur post-process should be object based or screen based
  150476. */
  150477. set objectBasedMotionBlur(value: boolean);
  150478. /**
  150479. * List of animations for the pipeline (IAnimatable implementation)
  150480. */
  150481. animations: Animation[];
  150482. /**
  150483. * Private members
  150484. */
  150485. private _scene;
  150486. private _currentDepthOfFieldSource;
  150487. private _basePostProcess;
  150488. private _fixedExposure;
  150489. private _currentExposure;
  150490. private _hdrAutoExposure;
  150491. private _hdrCurrentLuminance;
  150492. private _motionStrength;
  150493. private _isObjectBasedMotionBlur;
  150494. private _floatTextureType;
  150495. private _camerasToBeAttached;
  150496. private _ratio;
  150497. private _bloomEnabled;
  150498. private _depthOfFieldEnabled;
  150499. private _vlsEnabled;
  150500. private _lensFlareEnabled;
  150501. private _hdrEnabled;
  150502. private _motionBlurEnabled;
  150503. private _fxaaEnabled;
  150504. private _screenSpaceReflectionsEnabled;
  150505. private _motionBlurSamples;
  150506. private _volumetricLightStepsCount;
  150507. private _samples;
  150508. /**
  150509. * @ignore
  150510. * Specifies if the bloom pipeline is enabled
  150511. */
  150512. get BloomEnabled(): boolean;
  150513. set BloomEnabled(enabled: boolean);
  150514. /**
  150515. * @ignore
  150516. * Specifies if the depth of field pipeline is enabed
  150517. */
  150518. get DepthOfFieldEnabled(): boolean;
  150519. set DepthOfFieldEnabled(enabled: boolean);
  150520. /**
  150521. * @ignore
  150522. * Specifies if the lens flare pipeline is enabed
  150523. */
  150524. get LensFlareEnabled(): boolean;
  150525. set LensFlareEnabled(enabled: boolean);
  150526. /**
  150527. * @ignore
  150528. * Specifies if the HDR pipeline is enabled
  150529. */
  150530. get HDREnabled(): boolean;
  150531. set HDREnabled(enabled: boolean);
  150532. /**
  150533. * @ignore
  150534. * Specifies if the volumetric lights scattering effect is enabled
  150535. */
  150536. get VLSEnabled(): boolean;
  150537. set VLSEnabled(enabled: boolean);
  150538. /**
  150539. * @ignore
  150540. * Specifies if the motion blur effect is enabled
  150541. */
  150542. get MotionBlurEnabled(): boolean;
  150543. set MotionBlurEnabled(enabled: boolean);
  150544. /**
  150545. * Specifies if anti-aliasing is enabled
  150546. */
  150547. get fxaaEnabled(): boolean;
  150548. set fxaaEnabled(enabled: boolean);
  150549. /**
  150550. * Specifies if screen space reflections are enabled.
  150551. */
  150552. get screenSpaceReflectionsEnabled(): boolean;
  150553. set screenSpaceReflectionsEnabled(enabled: boolean);
  150554. /**
  150555. * Specifies the number of steps used to calculate the volumetric lights
  150556. * Typically in interval [50, 200]
  150557. */
  150558. get volumetricLightStepsCount(): number;
  150559. set volumetricLightStepsCount(count: number);
  150560. /**
  150561. * Specifies the number of samples used for the motion blur effect
  150562. * Typically in interval [16, 64]
  150563. */
  150564. get motionBlurSamples(): number;
  150565. set motionBlurSamples(samples: number);
  150566. /**
  150567. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150568. */
  150569. get samples(): number;
  150570. set samples(sampleCount: number);
  150571. /**
  150572. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150573. * @constructor
  150574. * @param name The rendering pipeline name
  150575. * @param scene The scene linked to this pipeline
  150576. * @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)
  150577. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  150578. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150579. */
  150580. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  150581. private _buildPipeline;
  150582. private _createDownSampleX4PostProcess;
  150583. private _createBrightPassPostProcess;
  150584. private _createBlurPostProcesses;
  150585. private _createTextureAdderPostProcess;
  150586. private _createVolumetricLightPostProcess;
  150587. private _createLuminancePostProcesses;
  150588. private _createHdrPostProcess;
  150589. private _createLensFlarePostProcess;
  150590. private _createDepthOfFieldPostProcess;
  150591. private _createMotionBlurPostProcess;
  150592. private _getDepthTexture;
  150593. private _disposePostProcesses;
  150594. /**
  150595. * Dispose of the pipeline and stop all post processes
  150596. */
  150597. dispose(): void;
  150598. /**
  150599. * Serialize the rendering pipeline (Used when exporting)
  150600. * @returns the serialized object
  150601. */
  150602. serialize(): any;
  150603. /**
  150604. * Parse the serialized pipeline
  150605. * @param source Source pipeline.
  150606. * @param scene The scene to load the pipeline to.
  150607. * @param rootUrl The URL of the serialized pipeline.
  150608. * @returns An instantiated pipeline from the serialized object.
  150609. */
  150610. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  150611. /**
  150612. * Luminance steps
  150613. */
  150614. static LuminanceSteps: number;
  150615. }
  150616. }
  150617. declare module BABYLON {
  150618. /** @hidden */
  150619. export var stereoscopicInterlacePixelShader: {
  150620. name: string;
  150621. shader: string;
  150622. };
  150623. }
  150624. declare module BABYLON {
  150625. /**
  150626. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  150627. */
  150628. export class StereoscopicInterlacePostProcessI extends PostProcess {
  150629. private _stepSize;
  150630. private _passedProcess;
  150631. /**
  150632. * Gets a string identifying the name of the class
  150633. * @returns "StereoscopicInterlacePostProcessI" string
  150634. */
  150635. getClassName(): string;
  150636. /**
  150637. * Initializes a StereoscopicInterlacePostProcessI
  150638. * @param name The name of the effect.
  150639. * @param rigCameras The rig cameras to be appled to the post process
  150640. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  150641. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  150642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150643. * @param engine The engine which the post process will be applied. (default: current engine)
  150644. * @param reusable If the post process can be reused on the same frame. (default: false)
  150645. */
  150646. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150647. }
  150648. /**
  150649. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  150650. */
  150651. export class StereoscopicInterlacePostProcess extends PostProcess {
  150652. private _stepSize;
  150653. private _passedProcess;
  150654. /**
  150655. * Gets a string identifying the name of the class
  150656. * @returns "StereoscopicInterlacePostProcess" string
  150657. */
  150658. getClassName(): string;
  150659. /**
  150660. * Initializes a StereoscopicInterlacePostProcess
  150661. * @param name The name of the effect.
  150662. * @param rigCameras The rig cameras to be appled to the post process
  150663. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  150664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150665. * @param engine The engine which the post process will be applied. (default: current engine)
  150666. * @param reusable If the post process can be reused on the same frame. (default: false)
  150667. */
  150668. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150669. }
  150670. }
  150671. declare module BABYLON {
  150672. /** @hidden */
  150673. export var tonemapPixelShader: {
  150674. name: string;
  150675. shader: string;
  150676. };
  150677. }
  150678. declare module BABYLON {
  150679. /** Defines operator used for tonemapping */
  150680. export enum TonemappingOperator {
  150681. /** Hable */
  150682. Hable = 0,
  150683. /** Reinhard */
  150684. Reinhard = 1,
  150685. /** HejiDawson */
  150686. HejiDawson = 2,
  150687. /** Photographic */
  150688. Photographic = 3
  150689. }
  150690. /**
  150691. * Defines a post process to apply tone mapping
  150692. */
  150693. export class TonemapPostProcess extends PostProcess {
  150694. private _operator;
  150695. /** Defines the required exposure adjustement */
  150696. exposureAdjustment: number;
  150697. /**
  150698. * Gets a string identifying the name of the class
  150699. * @returns "TonemapPostProcess" string
  150700. */
  150701. getClassName(): string;
  150702. /**
  150703. * Creates a new TonemapPostProcess
  150704. * @param name defines the name of the postprocess
  150705. * @param _operator defines the operator to use
  150706. * @param exposureAdjustment defines the required exposure adjustement
  150707. * @param camera defines the camera to use (can be null)
  150708. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  150709. * @param engine defines the hosting engine (can be ignore if camera is set)
  150710. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  150711. */
  150712. constructor(name: string, _operator: TonemappingOperator,
  150713. /** Defines the required exposure adjustement */
  150714. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  150715. }
  150716. }
  150717. declare module BABYLON {
  150718. /** @hidden */
  150719. export var volumetricLightScatteringPixelShader: {
  150720. name: string;
  150721. shader: string;
  150722. };
  150723. }
  150724. declare module BABYLON {
  150725. /** @hidden */
  150726. export var volumetricLightScatteringPassVertexShader: {
  150727. name: string;
  150728. shader: string;
  150729. };
  150730. }
  150731. declare module BABYLON {
  150732. /** @hidden */
  150733. export var volumetricLightScatteringPassPixelShader: {
  150734. name: string;
  150735. shader: string;
  150736. };
  150737. }
  150738. declare module BABYLON {
  150739. /**
  150740. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  150741. */
  150742. export class VolumetricLightScatteringPostProcess extends PostProcess {
  150743. private _volumetricLightScatteringPass;
  150744. private _volumetricLightScatteringRTT;
  150745. private _viewPort;
  150746. private _screenCoordinates;
  150747. private _cachedDefines;
  150748. /**
  150749. * If not undefined, the mesh position is computed from the attached node position
  150750. */
  150751. attachedNode: {
  150752. position: Vector3;
  150753. };
  150754. /**
  150755. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  150756. */
  150757. customMeshPosition: Vector3;
  150758. /**
  150759. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  150760. */
  150761. useCustomMeshPosition: boolean;
  150762. /**
  150763. * If the post-process should inverse the light scattering direction
  150764. */
  150765. invert: boolean;
  150766. /**
  150767. * The internal mesh used by the post-process
  150768. */
  150769. mesh: Mesh;
  150770. /**
  150771. * @hidden
  150772. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  150773. */
  150774. get useDiffuseColor(): boolean;
  150775. set useDiffuseColor(useDiffuseColor: boolean);
  150776. /**
  150777. * Array containing the excluded meshes not rendered in the internal pass
  150778. */
  150779. excludedMeshes: AbstractMesh[];
  150780. /**
  150781. * Controls the overall intensity of the post-process
  150782. */
  150783. exposure: number;
  150784. /**
  150785. * Dissipates each sample's contribution in range [0, 1]
  150786. */
  150787. decay: number;
  150788. /**
  150789. * Controls the overall intensity of each sample
  150790. */
  150791. weight: number;
  150792. /**
  150793. * Controls the density of each sample
  150794. */
  150795. density: number;
  150796. /**
  150797. * @constructor
  150798. * @param name The post-process name
  150799. * @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)
  150800. * @param camera The camera that the post-process will be attached to
  150801. * @param mesh The mesh used to create the light scattering
  150802. * @param samples The post-process quality, default 100
  150803. * @param samplingModeThe post-process filtering mode
  150804. * @param engine The babylon engine
  150805. * @param reusable If the post-process is reusable
  150806. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  150807. */
  150808. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  150809. /**
  150810. * Returns the string "VolumetricLightScatteringPostProcess"
  150811. * @returns "VolumetricLightScatteringPostProcess"
  150812. */
  150813. getClassName(): string;
  150814. private _isReady;
  150815. /**
  150816. * Sets the new light position for light scattering effect
  150817. * @param position The new custom light position
  150818. */
  150819. setCustomMeshPosition(position: Vector3): void;
  150820. /**
  150821. * Returns the light position for light scattering effect
  150822. * @return Vector3 The custom light position
  150823. */
  150824. getCustomMeshPosition(): Vector3;
  150825. /**
  150826. * Disposes the internal assets and detaches the post-process from the camera
  150827. */
  150828. dispose(camera: Camera): void;
  150829. /**
  150830. * Returns the render target texture used by the post-process
  150831. * @return the render target texture used by the post-process
  150832. */
  150833. getPass(): RenderTargetTexture;
  150834. private _meshExcluded;
  150835. private _createPass;
  150836. private _updateMeshScreenCoordinates;
  150837. /**
  150838. * Creates a default mesh for the Volumeric Light Scattering post-process
  150839. * @param name The mesh name
  150840. * @param scene The scene where to create the mesh
  150841. * @return the default mesh
  150842. */
  150843. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150844. }
  150845. }
  150846. declare module BABYLON {
  150847. /** @hidden */
  150848. export var screenSpaceCurvaturePixelShader: {
  150849. name: string;
  150850. shader: string;
  150851. };
  150852. }
  150853. declare module BABYLON {
  150854. /**
  150855. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150856. */
  150857. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150858. /**
  150859. * Defines how much ridge the curvature effect displays.
  150860. */
  150861. ridge: number;
  150862. /**
  150863. * Defines how much valley the curvature effect displays.
  150864. */
  150865. valley: number;
  150866. private _geometryBufferRenderer;
  150867. /**
  150868. * Gets a string identifying the name of the class
  150869. * @returns "ScreenSpaceCurvaturePostProcess" string
  150870. */
  150871. getClassName(): string;
  150872. /**
  150873. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150874. * @param name The name of the effect.
  150875. * @param scene The scene containing the objects to blur according to their velocity.
  150876. * @param options The required width/height ratio to downsize to before computing the render pass.
  150877. * @param camera The camera to apply the render pass to.
  150878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150879. * @param engine The engine which the post process will be applied. (default: current engine)
  150880. * @param reusable If the post process can be reused on the same frame. (default: false)
  150881. * @param textureType Type of textures used when performing the post process. (default: 0)
  150882. * @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)
  150883. */
  150884. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150885. /**
  150886. * Support test.
  150887. */
  150888. static get IsSupported(): boolean;
  150889. /** @hidden */
  150890. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  150891. }
  150892. }
  150893. declare module BABYLON {
  150894. interface Scene {
  150895. /** @hidden (Backing field) */
  150896. _boundingBoxRenderer: BoundingBoxRenderer;
  150897. /** @hidden (Backing field) */
  150898. _forceShowBoundingBoxes: boolean;
  150899. /**
  150900. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150901. */
  150902. forceShowBoundingBoxes: boolean;
  150903. /**
  150904. * Gets the bounding box renderer associated with the scene
  150905. * @returns a BoundingBoxRenderer
  150906. */
  150907. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150908. }
  150909. interface AbstractMesh {
  150910. /** @hidden (Backing field) */
  150911. _showBoundingBox: boolean;
  150912. /**
  150913. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150914. */
  150915. showBoundingBox: boolean;
  150916. }
  150917. /**
  150918. * Component responsible of rendering the bounding box of the meshes in a scene.
  150919. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150920. */
  150921. export class BoundingBoxRenderer implements ISceneComponent {
  150922. /**
  150923. * The component name helpfull to identify the component in the list of scene components.
  150924. */
  150925. readonly name: string;
  150926. /**
  150927. * The scene the component belongs to.
  150928. */
  150929. scene: Scene;
  150930. /**
  150931. * Color of the bounding box lines placed in front of an object
  150932. */
  150933. frontColor: Color3;
  150934. /**
  150935. * Color of the bounding box lines placed behind an object
  150936. */
  150937. backColor: Color3;
  150938. /**
  150939. * Defines if the renderer should show the back lines or not
  150940. */
  150941. showBackLines: boolean;
  150942. /**
  150943. * Observable raised before rendering a bounding box
  150944. */
  150945. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150946. /**
  150947. * Observable raised after rendering a bounding box
  150948. */
  150949. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150950. /**
  150951. * @hidden
  150952. */
  150953. renderList: SmartArray<BoundingBox>;
  150954. private _colorShader;
  150955. private _vertexBuffers;
  150956. private _indexBuffer;
  150957. private _fillIndexBuffer;
  150958. private _fillIndexData;
  150959. /**
  150960. * Instantiates a new bounding box renderer in a scene.
  150961. * @param scene the scene the renderer renders in
  150962. */
  150963. constructor(scene: Scene);
  150964. /**
  150965. * Registers the component in a given scene
  150966. */
  150967. register(): void;
  150968. private _evaluateSubMesh;
  150969. private _activeMesh;
  150970. private _prepareRessources;
  150971. private _createIndexBuffer;
  150972. /**
  150973. * Rebuilds the elements related to this component in case of
  150974. * context lost for instance.
  150975. */
  150976. rebuild(): void;
  150977. /**
  150978. * @hidden
  150979. */
  150980. reset(): void;
  150981. /**
  150982. * Render the bounding boxes of a specific rendering group
  150983. * @param renderingGroupId defines the rendering group to render
  150984. */
  150985. render(renderingGroupId: number): void;
  150986. /**
  150987. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150988. * @param mesh Define the mesh to render the occlusion bounding box for
  150989. */
  150990. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150991. /**
  150992. * Dispose and release the resources attached to this renderer.
  150993. */
  150994. dispose(): void;
  150995. }
  150996. }
  150997. declare module BABYLON {
  150998. interface Scene {
  150999. /** @hidden (Backing field) */
  151000. _depthRenderer: {
  151001. [id: string]: DepthRenderer;
  151002. };
  151003. /**
  151004. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151005. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151006. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151007. * @returns the created depth renderer
  151008. */
  151009. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151010. /**
  151011. * Disables a depth renderer for a given camera
  151012. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151013. */
  151014. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151015. }
  151016. /**
  151017. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151018. * in several rendering techniques.
  151019. */
  151020. export class DepthRendererSceneComponent implements ISceneComponent {
  151021. /**
  151022. * The component name helpfull to identify the component in the list of scene components.
  151023. */
  151024. readonly name: string;
  151025. /**
  151026. * The scene the component belongs to.
  151027. */
  151028. scene: Scene;
  151029. /**
  151030. * Creates a new instance of the component for the given scene
  151031. * @param scene Defines the scene to register the component in
  151032. */
  151033. constructor(scene: Scene);
  151034. /**
  151035. * Registers the component in a given scene
  151036. */
  151037. register(): void;
  151038. /**
  151039. * Rebuilds the elements related to this component in case of
  151040. * context lost for instance.
  151041. */
  151042. rebuild(): void;
  151043. /**
  151044. * Disposes the component and the associated ressources
  151045. */
  151046. dispose(): void;
  151047. private _gatherRenderTargets;
  151048. private _gatherActiveCameraRenderTargets;
  151049. }
  151050. }
  151051. declare module BABYLON {
  151052. interface AbstractScene {
  151053. /** @hidden (Backing field) */
  151054. _prePassRenderer: Nullable<PrePassRenderer>;
  151055. /**
  151056. * Gets or Sets the current prepass renderer associated to the scene.
  151057. */
  151058. prePassRenderer: Nullable<PrePassRenderer>;
  151059. /**
  151060. * Enables the prepass and associates it with the scene
  151061. * @returns the PrePassRenderer
  151062. */
  151063. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151064. /**
  151065. * Disables the prepass associated with the scene
  151066. */
  151067. disablePrePassRenderer(): void;
  151068. }
  151069. /**
  151070. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151071. * in several rendering techniques.
  151072. */
  151073. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151074. /**
  151075. * The component name helpful to identify the component in the list of scene components.
  151076. */
  151077. readonly name: string;
  151078. /**
  151079. * The scene the component belongs to.
  151080. */
  151081. scene: Scene;
  151082. /**
  151083. * Creates a new instance of the component for the given scene
  151084. * @param scene Defines the scene to register the component in
  151085. */
  151086. constructor(scene: Scene);
  151087. /**
  151088. * Registers the component in a given scene
  151089. */
  151090. register(): void;
  151091. private _beforeCameraDraw;
  151092. private _afterCameraDraw;
  151093. private _beforeClearStage;
  151094. /**
  151095. * Serializes the component data to the specified json object
  151096. * @param serializationObject The object to serialize to
  151097. */
  151098. serialize(serializationObject: any): void;
  151099. /**
  151100. * Adds all the elements from the container to the scene
  151101. * @param container the container holding the elements
  151102. */
  151103. addFromContainer(container: AbstractScene): void;
  151104. /**
  151105. * Removes all the elements in the container from the scene
  151106. * @param container contains the elements to remove
  151107. * @param dispose if the removed element should be disposed (default: false)
  151108. */
  151109. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  151110. /**
  151111. * Rebuilds the elements related to this component in case of
  151112. * context lost for instance.
  151113. */
  151114. rebuild(): void;
  151115. /**
  151116. * Disposes the component and the associated ressources
  151117. */
  151118. dispose(): void;
  151119. }
  151120. }
  151121. declare module BABYLON {
  151122. /** @hidden */
  151123. export var outlinePixelShader: {
  151124. name: string;
  151125. shader: string;
  151126. };
  151127. }
  151128. declare module BABYLON {
  151129. /** @hidden */
  151130. export var outlineVertexShader: {
  151131. name: string;
  151132. shader: string;
  151133. };
  151134. }
  151135. declare module BABYLON {
  151136. interface Scene {
  151137. /** @hidden */
  151138. _outlineRenderer: OutlineRenderer;
  151139. /**
  151140. * Gets the outline renderer associated with the scene
  151141. * @returns a OutlineRenderer
  151142. */
  151143. getOutlineRenderer(): OutlineRenderer;
  151144. }
  151145. interface AbstractMesh {
  151146. /** @hidden (Backing field) */
  151147. _renderOutline: boolean;
  151148. /**
  151149. * Gets or sets a boolean indicating if the outline must be rendered as well
  151150. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  151151. */
  151152. renderOutline: boolean;
  151153. /** @hidden (Backing field) */
  151154. _renderOverlay: boolean;
  151155. /**
  151156. * Gets or sets a boolean indicating if the overlay must be rendered as well
  151157. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  151158. */
  151159. renderOverlay: boolean;
  151160. }
  151161. /**
  151162. * This class is responsible to draw bothe outline/overlay of meshes.
  151163. * It should not be used directly but through the available method on mesh.
  151164. */
  151165. export class OutlineRenderer implements ISceneComponent {
  151166. /**
  151167. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  151168. */
  151169. private static _StencilReference;
  151170. /**
  151171. * The name of the component. Each component must have a unique name.
  151172. */
  151173. name: string;
  151174. /**
  151175. * The scene the component belongs to.
  151176. */
  151177. scene: Scene;
  151178. /**
  151179. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  151180. */
  151181. zOffset: number;
  151182. private _engine;
  151183. private _effect;
  151184. private _cachedDefines;
  151185. private _savedDepthWrite;
  151186. /**
  151187. * Instantiates a new outline renderer. (There could be only one per scene).
  151188. * @param scene Defines the scene it belongs to
  151189. */
  151190. constructor(scene: Scene);
  151191. /**
  151192. * Register the component to one instance of a scene.
  151193. */
  151194. register(): void;
  151195. /**
  151196. * Rebuilds the elements related to this component in case of
  151197. * context lost for instance.
  151198. */
  151199. rebuild(): void;
  151200. /**
  151201. * Disposes the component and the associated ressources.
  151202. */
  151203. dispose(): void;
  151204. /**
  151205. * Renders the outline in the canvas.
  151206. * @param subMesh Defines the sumesh to render
  151207. * @param batch Defines the batch of meshes in case of instances
  151208. * @param useOverlay Defines if the rendering is for the overlay or the outline
  151209. */
  151210. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  151211. /**
  151212. * Returns whether or not the outline renderer is ready for a given submesh.
  151213. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  151214. * @param subMesh Defines the submesh to check readyness for
  151215. * @param useInstances Defines wheter wee are trying to render instances or not
  151216. * @returns true if ready otherwise false
  151217. */
  151218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  151219. private _beforeRenderingMesh;
  151220. private _afterRenderingMesh;
  151221. }
  151222. }
  151223. declare module BABYLON {
  151224. /**
  151225. * Defines the basic options interface of a Sprite Frame Source Size.
  151226. */
  151227. export interface ISpriteJSONSpriteSourceSize {
  151228. /**
  151229. * number of the original width of the Frame
  151230. */
  151231. w: number;
  151232. /**
  151233. * number of the original height of the Frame
  151234. */
  151235. h: number;
  151236. }
  151237. /**
  151238. * Defines the basic options interface of a Sprite Frame Data.
  151239. */
  151240. export interface ISpriteJSONSpriteFrameData {
  151241. /**
  151242. * number of the x offset of the Frame
  151243. */
  151244. x: number;
  151245. /**
  151246. * number of the y offset of the Frame
  151247. */
  151248. y: number;
  151249. /**
  151250. * number of the width of the Frame
  151251. */
  151252. w: number;
  151253. /**
  151254. * number of the height of the Frame
  151255. */
  151256. h: number;
  151257. }
  151258. /**
  151259. * Defines the basic options interface of a JSON Sprite.
  151260. */
  151261. export interface ISpriteJSONSprite {
  151262. /**
  151263. * string name of the Frame
  151264. */
  151265. filename: string;
  151266. /**
  151267. * ISpriteJSONSpriteFrame basic object of the frame data
  151268. */
  151269. frame: ISpriteJSONSpriteFrameData;
  151270. /**
  151271. * boolean to flag is the frame was rotated.
  151272. */
  151273. rotated: boolean;
  151274. /**
  151275. * boolean to flag is the frame was trimmed.
  151276. */
  151277. trimmed: boolean;
  151278. /**
  151279. * ISpriteJSONSpriteFrame basic object of the source data
  151280. */
  151281. spriteSourceSize: ISpriteJSONSpriteFrameData;
  151282. /**
  151283. * ISpriteJSONSpriteFrame basic object of the source data
  151284. */
  151285. sourceSize: ISpriteJSONSpriteSourceSize;
  151286. }
  151287. /**
  151288. * Defines the basic options interface of a JSON atlas.
  151289. */
  151290. export interface ISpriteJSONAtlas {
  151291. /**
  151292. * Array of objects that contain the frame data.
  151293. */
  151294. frames: Array<ISpriteJSONSprite>;
  151295. /**
  151296. * object basic object containing the sprite meta data.
  151297. */
  151298. meta?: object;
  151299. }
  151300. }
  151301. declare module BABYLON {
  151302. /** @hidden */
  151303. export var spriteMapPixelShader: {
  151304. name: string;
  151305. shader: string;
  151306. };
  151307. }
  151308. declare module BABYLON {
  151309. /** @hidden */
  151310. export var spriteMapVertexShader: {
  151311. name: string;
  151312. shader: string;
  151313. };
  151314. }
  151315. declare module BABYLON {
  151316. /**
  151317. * Defines the basic options interface of a SpriteMap
  151318. */
  151319. export interface ISpriteMapOptions {
  151320. /**
  151321. * Vector2 of the number of cells in the grid.
  151322. */
  151323. stageSize?: Vector2;
  151324. /**
  151325. * Vector2 of the size of the output plane in World Units.
  151326. */
  151327. outputSize?: Vector2;
  151328. /**
  151329. * Vector3 of the position of the output plane in World Units.
  151330. */
  151331. outputPosition?: Vector3;
  151332. /**
  151333. * Vector3 of the rotation of the output plane.
  151334. */
  151335. outputRotation?: Vector3;
  151336. /**
  151337. * number of layers that the system will reserve in resources.
  151338. */
  151339. layerCount?: number;
  151340. /**
  151341. * number of max animation frames a single cell will reserve in resources.
  151342. */
  151343. maxAnimationFrames?: number;
  151344. /**
  151345. * number cell index of the base tile when the system compiles.
  151346. */
  151347. baseTile?: number;
  151348. /**
  151349. * boolean flip the sprite after its been repositioned by the framing data.
  151350. */
  151351. flipU?: boolean;
  151352. /**
  151353. * Vector3 scalar of the global RGB values of the SpriteMap.
  151354. */
  151355. colorMultiply?: Vector3;
  151356. }
  151357. /**
  151358. * Defines the IDisposable interface in order to be cleanable from resources.
  151359. */
  151360. export interface ISpriteMap extends IDisposable {
  151361. /**
  151362. * String name of the SpriteMap.
  151363. */
  151364. name: string;
  151365. /**
  151366. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  151367. */
  151368. atlasJSON: ISpriteJSONAtlas;
  151369. /**
  151370. * Texture of the SpriteMap.
  151371. */
  151372. spriteSheet: Texture;
  151373. /**
  151374. * The parameters to initialize the SpriteMap with.
  151375. */
  151376. options: ISpriteMapOptions;
  151377. }
  151378. /**
  151379. * Class used to manage a grid restricted sprite deployment on an Output plane.
  151380. */
  151381. export class SpriteMap implements ISpriteMap {
  151382. /** The Name of the spriteMap */
  151383. name: string;
  151384. /** The JSON file with the frame and meta data */
  151385. atlasJSON: ISpriteJSONAtlas;
  151386. /** The systems Sprite Sheet Texture */
  151387. spriteSheet: Texture;
  151388. /** Arguments passed with the Constructor */
  151389. options: ISpriteMapOptions;
  151390. /** Public Sprite Storage array, parsed from atlasJSON */
  151391. sprites: Array<ISpriteJSONSprite>;
  151392. /** Returns the Number of Sprites in the System */
  151393. get spriteCount(): number;
  151394. /** Returns the Position of Output Plane*/
  151395. get position(): Vector3;
  151396. /** Returns the Position of Output Plane*/
  151397. set position(v: Vector3);
  151398. /** Returns the Rotation of Output Plane*/
  151399. get rotation(): Vector3;
  151400. /** Returns the Rotation of Output Plane*/
  151401. set rotation(v: Vector3);
  151402. /** Sets the AnimationMap*/
  151403. get animationMap(): RawTexture;
  151404. /** Sets the AnimationMap*/
  151405. set animationMap(v: RawTexture);
  151406. /** Scene that the SpriteMap was created in */
  151407. private _scene;
  151408. /** Texture Buffer of Float32 that holds tile frame data*/
  151409. private _frameMap;
  151410. /** Texture Buffers of Float32 that holds tileMap data*/
  151411. private _tileMaps;
  151412. /** Texture Buffer of Float32 that holds Animation Data*/
  151413. private _animationMap;
  151414. /** Custom ShaderMaterial Central to the System*/
  151415. private _material;
  151416. /** Custom ShaderMaterial Central to the System*/
  151417. private _output;
  151418. /** Systems Time Ticker*/
  151419. private _time;
  151420. /**
  151421. * Creates a new SpriteMap
  151422. * @param name defines the SpriteMaps Name
  151423. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  151424. * @param spriteSheet is the Texture that the Sprites are on.
  151425. * @param options a basic deployment configuration
  151426. * @param scene The Scene that the map is deployed on
  151427. */
  151428. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  151429. /**
  151430. * Returns tileID location
  151431. * @returns Vector2 the cell position ID
  151432. */
  151433. getTileID(): Vector2;
  151434. /**
  151435. * Gets the UV location of the mouse over the SpriteMap.
  151436. * @returns Vector2 the UV position of the mouse interaction
  151437. */
  151438. getMousePosition(): Vector2;
  151439. /**
  151440. * Creates the "frame" texture Buffer
  151441. * -------------------------------------
  151442. * Structure of frames
  151443. * "filename": "Falling-Water-2.png",
  151444. * "frame": {"x":69,"y":103,"w":24,"h":32},
  151445. * "rotated": true,
  151446. * "trimmed": true,
  151447. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  151448. * "sourceSize": {"w":32,"h":32}
  151449. * @returns RawTexture of the frameMap
  151450. */
  151451. private _createFrameBuffer;
  151452. /**
  151453. * Creates the tileMap texture Buffer
  151454. * @param buffer normally and array of numbers, or a false to generate from scratch
  151455. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  151456. * @returns RawTexture of the tileMap
  151457. */
  151458. private _createTileBuffer;
  151459. /**
  151460. * Modifies the data of the tileMaps
  151461. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  151462. * @param pos is the iVector2 Coordinates of the Tile
  151463. * @param tile The SpriteIndex of the new Tile
  151464. */
  151465. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  151466. /**
  151467. * Creates the animationMap texture Buffer
  151468. * @param buffer normally and array of numbers, or a false to generate from scratch
  151469. * @returns RawTexture of the animationMap
  151470. */
  151471. private _createTileAnimationBuffer;
  151472. /**
  151473. * Modifies the data of the animationMap
  151474. * @param cellID is the Index of the Sprite
  151475. * @param _frame is the target Animation frame
  151476. * @param toCell is the Target Index of the next frame of the animation
  151477. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  151478. * @param speed is a global scalar of the time variable on the map.
  151479. */
  151480. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  151481. /**
  151482. * Exports the .tilemaps file
  151483. */
  151484. saveTileMaps(): void;
  151485. /**
  151486. * Imports the .tilemaps file
  151487. * @param url of the .tilemaps file
  151488. */
  151489. loadTileMaps(url: string): void;
  151490. /**
  151491. * Release associated resources
  151492. */
  151493. dispose(): void;
  151494. }
  151495. }
  151496. declare module BABYLON {
  151497. /**
  151498. * Class used to manage multiple sprites of different sizes on the same spritesheet
  151499. * @see https://doc.babylonjs.com/babylon101/sprites
  151500. */
  151501. export class SpritePackedManager extends SpriteManager {
  151502. /** defines the packed manager's name */
  151503. name: string;
  151504. /**
  151505. * Creates a new sprite manager from a packed sprite sheet
  151506. * @param name defines the manager's name
  151507. * @param imgUrl defines the sprite sheet url
  151508. * @param capacity defines the maximum allowed number of sprites
  151509. * @param scene defines the hosting scene
  151510. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  151511. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  151512. * @param samplingMode defines the smapling mode to use with spritesheet
  151513. * @param fromPacked set to true; do not alter
  151514. */
  151515. constructor(
  151516. /** defines the packed manager's name */
  151517. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  151518. }
  151519. }
  151520. declare module BABYLON {
  151521. /**
  151522. * Defines the list of states available for a task inside a AssetsManager
  151523. */
  151524. export enum AssetTaskState {
  151525. /**
  151526. * Initialization
  151527. */
  151528. INIT = 0,
  151529. /**
  151530. * Running
  151531. */
  151532. RUNNING = 1,
  151533. /**
  151534. * Done
  151535. */
  151536. DONE = 2,
  151537. /**
  151538. * Error
  151539. */
  151540. ERROR = 3
  151541. }
  151542. /**
  151543. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  151544. */
  151545. export abstract class AbstractAssetTask {
  151546. /**
  151547. * Task name
  151548. */ name: string;
  151549. /**
  151550. * Callback called when the task is successful
  151551. */
  151552. onSuccess: (task: any) => void;
  151553. /**
  151554. * Callback called when the task is not successful
  151555. */
  151556. onError: (task: any, message?: string, exception?: any) => void;
  151557. /**
  151558. * Creates a new AssetsManager
  151559. * @param name defines the name of the task
  151560. */
  151561. constructor(
  151562. /**
  151563. * Task name
  151564. */ name: string);
  151565. private _isCompleted;
  151566. private _taskState;
  151567. private _errorObject;
  151568. /**
  151569. * Get if the task is completed
  151570. */
  151571. get isCompleted(): boolean;
  151572. /**
  151573. * Gets the current state of the task
  151574. */
  151575. get taskState(): AssetTaskState;
  151576. /**
  151577. * Gets the current error object (if task is in error)
  151578. */
  151579. get errorObject(): {
  151580. message?: string;
  151581. exception?: any;
  151582. };
  151583. /**
  151584. * Internal only
  151585. * @hidden
  151586. */
  151587. _setErrorObject(message?: string, exception?: any): void;
  151588. /**
  151589. * Execute the current task
  151590. * @param scene defines the scene where you want your assets to be loaded
  151591. * @param onSuccess is a callback called when the task is successfully executed
  151592. * @param onError is a callback called if an error occurs
  151593. */
  151594. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151595. /**
  151596. * Execute the current task
  151597. * @param scene defines the scene where you want your assets to be loaded
  151598. * @param onSuccess is a callback called when the task is successfully executed
  151599. * @param onError is a callback called if an error occurs
  151600. */
  151601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151602. /**
  151603. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  151604. * This can be used with failed tasks that have the reason for failure fixed.
  151605. */
  151606. reset(): void;
  151607. private onErrorCallback;
  151608. private onDoneCallback;
  151609. }
  151610. /**
  151611. * Define the interface used by progress events raised during assets loading
  151612. */
  151613. export interface IAssetsProgressEvent {
  151614. /**
  151615. * Defines the number of remaining tasks to process
  151616. */
  151617. remainingCount: number;
  151618. /**
  151619. * Defines the total number of tasks
  151620. */
  151621. totalCount: number;
  151622. /**
  151623. * Defines the task that was just processed
  151624. */
  151625. task: AbstractAssetTask;
  151626. }
  151627. /**
  151628. * Class used to share progress information about assets loading
  151629. */
  151630. export class AssetsProgressEvent implements IAssetsProgressEvent {
  151631. /**
  151632. * Defines the number of remaining tasks to process
  151633. */
  151634. remainingCount: number;
  151635. /**
  151636. * Defines the total number of tasks
  151637. */
  151638. totalCount: number;
  151639. /**
  151640. * Defines the task that was just processed
  151641. */
  151642. task: AbstractAssetTask;
  151643. /**
  151644. * Creates a AssetsProgressEvent
  151645. * @param remainingCount defines the number of remaining tasks to process
  151646. * @param totalCount defines the total number of tasks
  151647. * @param task defines the task that was just processed
  151648. */
  151649. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  151650. }
  151651. /**
  151652. * Define a task used by AssetsManager to load assets into a container
  151653. */
  151654. export class ContainerAssetTask extends AbstractAssetTask {
  151655. /**
  151656. * Defines the name of the task
  151657. */
  151658. name: string;
  151659. /**
  151660. * Defines the list of mesh's names you want to load
  151661. */
  151662. meshesNames: any;
  151663. /**
  151664. * Defines the root url to use as a base to load your meshes and associated resources
  151665. */
  151666. rootUrl: string;
  151667. /**
  151668. * Defines the filename or File of the scene to load from
  151669. */
  151670. sceneFilename: string | File;
  151671. /**
  151672. * Get the loaded asset container
  151673. */
  151674. loadedContainer: AssetContainer;
  151675. /**
  151676. * Gets the list of loaded meshes
  151677. */
  151678. loadedMeshes: Array<AbstractMesh>;
  151679. /**
  151680. * Gets the list of loaded particle systems
  151681. */
  151682. loadedParticleSystems: Array<IParticleSystem>;
  151683. /**
  151684. * Gets the list of loaded skeletons
  151685. */
  151686. loadedSkeletons: Array<Skeleton>;
  151687. /**
  151688. * Gets the list of loaded animation groups
  151689. */
  151690. loadedAnimationGroups: Array<AnimationGroup>;
  151691. /**
  151692. * Callback called when the task is successful
  151693. */
  151694. onSuccess: (task: ContainerAssetTask) => void;
  151695. /**
  151696. * Callback called when the task is successful
  151697. */
  151698. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  151699. /**
  151700. * Creates a new ContainerAssetTask
  151701. * @param name defines the name of the task
  151702. * @param meshesNames defines the list of mesh's names you want to load
  151703. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151704. * @param sceneFilename defines the filename or File of the scene to load from
  151705. */
  151706. constructor(
  151707. /**
  151708. * Defines the name of the task
  151709. */
  151710. name: string,
  151711. /**
  151712. * Defines the list of mesh's names you want to load
  151713. */
  151714. meshesNames: any,
  151715. /**
  151716. * Defines the root url to use as a base to load your meshes and associated resources
  151717. */
  151718. rootUrl: string,
  151719. /**
  151720. * Defines the filename or File of the scene to load from
  151721. */
  151722. sceneFilename: string | File);
  151723. /**
  151724. * Execute the current task
  151725. * @param scene defines the scene where you want your assets to be loaded
  151726. * @param onSuccess is a callback called when the task is successfully executed
  151727. * @param onError is a callback called if an error occurs
  151728. */
  151729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151730. }
  151731. /**
  151732. * Define a task used by AssetsManager to load meshes
  151733. */
  151734. export class MeshAssetTask extends AbstractAssetTask {
  151735. /**
  151736. * Defines the name of the task
  151737. */
  151738. name: string;
  151739. /**
  151740. * Defines the list of mesh's names you want to load
  151741. */
  151742. meshesNames: any;
  151743. /**
  151744. * Defines the root url to use as a base to load your meshes and associated resources
  151745. */
  151746. rootUrl: string;
  151747. /**
  151748. * Defines the filename or File of the scene to load from
  151749. */
  151750. sceneFilename: string | File;
  151751. /**
  151752. * Gets the list of loaded meshes
  151753. */
  151754. loadedMeshes: Array<AbstractMesh>;
  151755. /**
  151756. * Gets the list of loaded particle systems
  151757. */
  151758. loadedParticleSystems: Array<IParticleSystem>;
  151759. /**
  151760. * Gets the list of loaded skeletons
  151761. */
  151762. loadedSkeletons: Array<Skeleton>;
  151763. /**
  151764. * Gets the list of loaded animation groups
  151765. */
  151766. loadedAnimationGroups: Array<AnimationGroup>;
  151767. /**
  151768. * Callback called when the task is successful
  151769. */
  151770. onSuccess: (task: MeshAssetTask) => void;
  151771. /**
  151772. * Callback called when the task is successful
  151773. */
  151774. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  151775. /**
  151776. * Creates a new MeshAssetTask
  151777. * @param name defines the name of the task
  151778. * @param meshesNames defines the list of mesh's names you want to load
  151779. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151780. * @param sceneFilename defines the filename or File of the scene to load from
  151781. */
  151782. constructor(
  151783. /**
  151784. * Defines the name of the task
  151785. */
  151786. name: string,
  151787. /**
  151788. * Defines the list of mesh's names you want to load
  151789. */
  151790. meshesNames: any,
  151791. /**
  151792. * Defines the root url to use as a base to load your meshes and associated resources
  151793. */
  151794. rootUrl: string,
  151795. /**
  151796. * Defines the filename or File of the scene to load from
  151797. */
  151798. sceneFilename: string | File);
  151799. /**
  151800. * Execute the current task
  151801. * @param scene defines the scene where you want your assets to be loaded
  151802. * @param onSuccess is a callback called when the task is successfully executed
  151803. * @param onError is a callback called if an error occurs
  151804. */
  151805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151806. }
  151807. /**
  151808. * Define a task used by AssetsManager to load text content
  151809. */
  151810. export class TextFileAssetTask extends AbstractAssetTask {
  151811. /**
  151812. * Defines the name of the task
  151813. */
  151814. name: string;
  151815. /**
  151816. * Defines the location of the file to load
  151817. */
  151818. url: string;
  151819. /**
  151820. * Gets the loaded text string
  151821. */
  151822. text: string;
  151823. /**
  151824. * Callback called when the task is successful
  151825. */
  151826. onSuccess: (task: TextFileAssetTask) => void;
  151827. /**
  151828. * Callback called when the task is successful
  151829. */
  151830. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151831. /**
  151832. * Creates a new TextFileAssetTask object
  151833. * @param name defines the name of the task
  151834. * @param url defines the location of the file to load
  151835. */
  151836. constructor(
  151837. /**
  151838. * Defines the name of the task
  151839. */
  151840. name: string,
  151841. /**
  151842. * Defines the location of the file to load
  151843. */
  151844. url: string);
  151845. /**
  151846. * Execute the current task
  151847. * @param scene defines the scene where you want your assets to be loaded
  151848. * @param onSuccess is a callback called when the task is successfully executed
  151849. * @param onError is a callback called if an error occurs
  151850. */
  151851. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151852. }
  151853. /**
  151854. * Define a task used by AssetsManager to load binary data
  151855. */
  151856. export class BinaryFileAssetTask extends AbstractAssetTask {
  151857. /**
  151858. * Defines the name of the task
  151859. */
  151860. name: string;
  151861. /**
  151862. * Defines the location of the file to load
  151863. */
  151864. url: string;
  151865. /**
  151866. * Gets the lodaded data (as an array buffer)
  151867. */
  151868. data: ArrayBuffer;
  151869. /**
  151870. * Callback called when the task is successful
  151871. */
  151872. onSuccess: (task: BinaryFileAssetTask) => void;
  151873. /**
  151874. * Callback called when the task is successful
  151875. */
  151876. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151877. /**
  151878. * Creates a new BinaryFileAssetTask object
  151879. * @param name defines the name of the new task
  151880. * @param url defines the location of the file to load
  151881. */
  151882. constructor(
  151883. /**
  151884. * Defines the name of the task
  151885. */
  151886. name: string,
  151887. /**
  151888. * Defines the location of the file to load
  151889. */
  151890. url: string);
  151891. /**
  151892. * Execute the current task
  151893. * @param scene defines the scene where you want your assets to be loaded
  151894. * @param onSuccess is a callback called when the task is successfully executed
  151895. * @param onError is a callback called if an error occurs
  151896. */
  151897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151898. }
  151899. /**
  151900. * Define a task used by AssetsManager to load images
  151901. */
  151902. export class ImageAssetTask extends AbstractAssetTask {
  151903. /**
  151904. * Defines the name of the task
  151905. */
  151906. name: string;
  151907. /**
  151908. * Defines the location of the image to load
  151909. */
  151910. url: string;
  151911. /**
  151912. * Gets the loaded images
  151913. */
  151914. image: HTMLImageElement;
  151915. /**
  151916. * Callback called when the task is successful
  151917. */
  151918. onSuccess: (task: ImageAssetTask) => void;
  151919. /**
  151920. * Callback called when the task is successful
  151921. */
  151922. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151923. /**
  151924. * Creates a new ImageAssetTask
  151925. * @param name defines the name of the task
  151926. * @param url defines the location of the image to load
  151927. */
  151928. constructor(
  151929. /**
  151930. * Defines the name of the task
  151931. */
  151932. name: string,
  151933. /**
  151934. * Defines the location of the image to load
  151935. */
  151936. url: string);
  151937. /**
  151938. * Execute the current task
  151939. * @param scene defines the scene where you want your assets to be loaded
  151940. * @param onSuccess is a callback called when the task is successfully executed
  151941. * @param onError is a callback called if an error occurs
  151942. */
  151943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151944. }
  151945. /**
  151946. * Defines the interface used by texture loading tasks
  151947. */
  151948. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151949. /**
  151950. * Gets the loaded texture
  151951. */
  151952. texture: TEX;
  151953. }
  151954. /**
  151955. * Define a task used by AssetsManager to load 2D textures
  151956. */
  151957. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151958. /**
  151959. * Defines the name of the task
  151960. */
  151961. name: string;
  151962. /**
  151963. * Defines the location of the file to load
  151964. */
  151965. url: string;
  151966. /**
  151967. * Defines if mipmap should not be generated (default is false)
  151968. */
  151969. noMipmap?: boolean | undefined;
  151970. /**
  151971. * Defines if texture must be inverted on Y axis (default is true)
  151972. */
  151973. invertY: boolean;
  151974. /**
  151975. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151976. */
  151977. samplingMode: number;
  151978. /**
  151979. * Gets the loaded texture
  151980. */
  151981. texture: Texture;
  151982. /**
  151983. * Callback called when the task is successful
  151984. */
  151985. onSuccess: (task: TextureAssetTask) => void;
  151986. /**
  151987. * Callback called when the task is successful
  151988. */
  151989. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151990. /**
  151991. * Creates a new TextureAssetTask object
  151992. * @param name defines the name of the task
  151993. * @param url defines the location of the file to load
  151994. * @param noMipmap defines if mipmap should not be generated (default is false)
  151995. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151996. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151997. */
  151998. constructor(
  151999. /**
  152000. * Defines the name of the task
  152001. */
  152002. name: string,
  152003. /**
  152004. * Defines the location of the file to load
  152005. */
  152006. url: string,
  152007. /**
  152008. * Defines if mipmap should not be generated (default is false)
  152009. */
  152010. noMipmap?: boolean | undefined,
  152011. /**
  152012. * Defines if texture must be inverted on Y axis (default is true)
  152013. */
  152014. invertY?: boolean,
  152015. /**
  152016. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152017. */
  152018. samplingMode?: number);
  152019. /**
  152020. * Execute the current task
  152021. * @param scene defines the scene where you want your assets to be loaded
  152022. * @param onSuccess is a callback called when the task is successfully executed
  152023. * @param onError is a callback called if an error occurs
  152024. */
  152025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152026. }
  152027. /**
  152028. * Define a task used by AssetsManager to load cube textures
  152029. */
  152030. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152031. /**
  152032. * Defines the name of the task
  152033. */
  152034. name: string;
  152035. /**
  152036. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152037. */
  152038. url: string;
  152039. /**
  152040. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152041. */
  152042. extensions?: string[] | undefined;
  152043. /**
  152044. * Defines if mipmaps should not be generated (default is false)
  152045. */
  152046. noMipmap?: boolean | undefined;
  152047. /**
  152048. * Defines the explicit list of files (undefined by default)
  152049. */
  152050. files?: string[] | undefined;
  152051. /**
  152052. * Gets the loaded texture
  152053. */
  152054. texture: CubeTexture;
  152055. /**
  152056. * Callback called when the task is successful
  152057. */
  152058. onSuccess: (task: CubeTextureAssetTask) => void;
  152059. /**
  152060. * Callback called when the task is successful
  152061. */
  152062. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152063. /**
  152064. * Creates a new CubeTextureAssetTask
  152065. * @param name defines the name of the task
  152066. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152067. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152068. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152069. * @param files defines the explicit list of files (undefined by default)
  152070. */
  152071. constructor(
  152072. /**
  152073. * Defines the name of the task
  152074. */
  152075. name: string,
  152076. /**
  152077. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152078. */
  152079. url: string,
  152080. /**
  152081. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152082. */
  152083. extensions?: string[] | undefined,
  152084. /**
  152085. * Defines if mipmaps should not be generated (default is false)
  152086. */
  152087. noMipmap?: boolean | undefined,
  152088. /**
  152089. * Defines the explicit list of files (undefined by default)
  152090. */
  152091. files?: string[] | undefined);
  152092. /**
  152093. * Execute the current task
  152094. * @param scene defines the scene where you want your assets to be loaded
  152095. * @param onSuccess is a callback called when the task is successfully executed
  152096. * @param onError is a callback called if an error occurs
  152097. */
  152098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152099. }
  152100. /**
  152101. * Define a task used by AssetsManager to load HDR cube textures
  152102. */
  152103. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  152104. /**
  152105. * Defines the name of the task
  152106. */
  152107. name: string;
  152108. /**
  152109. * Defines the location of the file to load
  152110. */
  152111. url: string;
  152112. /**
  152113. * Defines the desired size (the more it increases the longer the generation will be)
  152114. */
  152115. size: number;
  152116. /**
  152117. * Defines if mipmaps should not be generated (default is false)
  152118. */
  152119. noMipmap: boolean;
  152120. /**
  152121. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152122. */
  152123. generateHarmonics: boolean;
  152124. /**
  152125. * 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)
  152126. */
  152127. gammaSpace: boolean;
  152128. /**
  152129. * Internal Use Only
  152130. */
  152131. reserved: boolean;
  152132. /**
  152133. * Gets the loaded texture
  152134. */
  152135. texture: HDRCubeTexture;
  152136. /**
  152137. * Callback called when the task is successful
  152138. */
  152139. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  152140. /**
  152141. * Callback called when the task is successful
  152142. */
  152143. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  152144. /**
  152145. * Creates a new HDRCubeTextureAssetTask object
  152146. * @param name defines the name of the task
  152147. * @param url defines the location of the file to load
  152148. * @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.
  152149. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152150. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152151. * @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)
  152152. * @param reserved Internal use only
  152153. */
  152154. constructor(
  152155. /**
  152156. * Defines the name of the task
  152157. */
  152158. name: string,
  152159. /**
  152160. * Defines the location of the file to load
  152161. */
  152162. url: string,
  152163. /**
  152164. * Defines the desired size (the more it increases the longer the generation will be)
  152165. */
  152166. size: number,
  152167. /**
  152168. * Defines if mipmaps should not be generated (default is false)
  152169. */
  152170. noMipmap?: boolean,
  152171. /**
  152172. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152173. */
  152174. generateHarmonics?: boolean,
  152175. /**
  152176. * 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)
  152177. */
  152178. gammaSpace?: boolean,
  152179. /**
  152180. * Internal Use Only
  152181. */
  152182. reserved?: boolean);
  152183. /**
  152184. * Execute the current task
  152185. * @param scene defines the scene where you want your assets to be loaded
  152186. * @param onSuccess is a callback called when the task is successfully executed
  152187. * @param onError is a callback called if an error occurs
  152188. */
  152189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152190. }
  152191. /**
  152192. * Define a task used by AssetsManager to load Equirectangular cube textures
  152193. */
  152194. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  152195. /**
  152196. * Defines the name of the task
  152197. */
  152198. name: string;
  152199. /**
  152200. * Defines the location of the file to load
  152201. */
  152202. url: string;
  152203. /**
  152204. * Defines the desired size (the more it increases the longer the generation will be)
  152205. */
  152206. size: number;
  152207. /**
  152208. * Defines if mipmaps should not be generated (default is false)
  152209. */
  152210. noMipmap: boolean;
  152211. /**
  152212. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152213. * but the standard material would require them in Gamma space) (default is true)
  152214. */
  152215. gammaSpace: boolean;
  152216. /**
  152217. * Gets the loaded texture
  152218. */
  152219. texture: EquiRectangularCubeTexture;
  152220. /**
  152221. * Callback called when the task is successful
  152222. */
  152223. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  152224. /**
  152225. * Callback called when the task is successful
  152226. */
  152227. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  152228. /**
  152229. * Creates a new EquiRectangularCubeTextureAssetTask object
  152230. * @param name defines the name of the task
  152231. * @param url defines the location of the file to load
  152232. * @param size defines the desired size (the more it increases the longer the generation will be)
  152233. * If the size is omitted this implies you are using a preprocessed cubemap.
  152234. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152235. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  152236. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  152237. * (default is true)
  152238. */
  152239. constructor(
  152240. /**
  152241. * Defines the name of the task
  152242. */
  152243. name: string,
  152244. /**
  152245. * Defines the location of the file to load
  152246. */
  152247. url: string,
  152248. /**
  152249. * Defines the desired size (the more it increases the longer the generation will be)
  152250. */
  152251. size: number,
  152252. /**
  152253. * Defines if mipmaps should not be generated (default is false)
  152254. */
  152255. noMipmap?: boolean,
  152256. /**
  152257. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152258. * but the standard material would require them in Gamma space) (default is true)
  152259. */
  152260. gammaSpace?: boolean);
  152261. /**
  152262. * Execute the current task
  152263. * @param scene defines the scene where you want your assets to be loaded
  152264. * @param onSuccess is a callback called when the task is successfully executed
  152265. * @param onError is a callback called if an error occurs
  152266. */
  152267. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152268. }
  152269. /**
  152270. * This class can be used to easily import assets into a scene
  152271. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  152272. */
  152273. export class AssetsManager {
  152274. private _scene;
  152275. private _isLoading;
  152276. protected _tasks: AbstractAssetTask[];
  152277. protected _waitingTasksCount: number;
  152278. protected _totalTasksCount: number;
  152279. /**
  152280. * Callback called when all tasks are processed
  152281. */
  152282. onFinish: (tasks: AbstractAssetTask[]) => void;
  152283. /**
  152284. * Callback called when a task is successful
  152285. */
  152286. onTaskSuccess: (task: AbstractAssetTask) => void;
  152287. /**
  152288. * Callback called when a task had an error
  152289. */
  152290. onTaskError: (task: AbstractAssetTask) => void;
  152291. /**
  152292. * Callback called when a task is done (whatever the result is)
  152293. */
  152294. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  152295. /**
  152296. * Observable called when all tasks are processed
  152297. */
  152298. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  152299. /**
  152300. * Observable called when a task had an error
  152301. */
  152302. onTaskErrorObservable: Observable<AbstractAssetTask>;
  152303. /**
  152304. * Observable called when all tasks were executed
  152305. */
  152306. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  152307. /**
  152308. * Observable called when a task is done (whatever the result is)
  152309. */
  152310. onProgressObservable: Observable<IAssetsProgressEvent>;
  152311. /**
  152312. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  152313. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  152314. */
  152315. useDefaultLoadingScreen: boolean;
  152316. /**
  152317. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  152318. * when all assets have been downloaded.
  152319. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  152320. */
  152321. autoHideLoadingUI: boolean;
  152322. /**
  152323. * Creates a new AssetsManager
  152324. * @param scene defines the scene to work on
  152325. */
  152326. constructor(scene: Scene);
  152327. /**
  152328. * Add a ContainerAssetTask to the list of active tasks
  152329. * @param taskName defines the name of the new task
  152330. * @param meshesNames defines the name of meshes to load
  152331. * @param rootUrl defines the root url to use to locate files
  152332. * @param sceneFilename defines the filename of the scene file
  152333. * @returns a new ContainerAssetTask object
  152334. */
  152335. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  152336. /**
  152337. * Add a MeshAssetTask to the list of active tasks
  152338. * @param taskName defines the name of the new task
  152339. * @param meshesNames defines the name of meshes to load
  152340. * @param rootUrl defines the root url to use to locate files
  152341. * @param sceneFilename defines the filename of the scene file
  152342. * @returns a new MeshAssetTask object
  152343. */
  152344. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  152345. /**
  152346. * Add a TextFileAssetTask to the list of active tasks
  152347. * @param taskName defines the name of the new task
  152348. * @param url defines the url of the file to load
  152349. * @returns a new TextFileAssetTask object
  152350. */
  152351. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  152352. /**
  152353. * Add a BinaryFileAssetTask to the list of active tasks
  152354. * @param taskName defines the name of the new task
  152355. * @param url defines the url of the file to load
  152356. * @returns a new BinaryFileAssetTask object
  152357. */
  152358. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  152359. /**
  152360. * Add a ImageAssetTask to the list of active tasks
  152361. * @param taskName defines the name of the new task
  152362. * @param url defines the url of the file to load
  152363. * @returns a new ImageAssetTask object
  152364. */
  152365. addImageTask(taskName: string, url: string): ImageAssetTask;
  152366. /**
  152367. * Add a TextureAssetTask to the list of active tasks
  152368. * @param taskName defines the name of the new task
  152369. * @param url defines the url of the file to load
  152370. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152371. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  152372. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  152373. * @returns a new TextureAssetTask object
  152374. */
  152375. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  152376. /**
  152377. * Add a CubeTextureAssetTask to the list of active tasks
  152378. * @param taskName defines the name of the new task
  152379. * @param url defines the url of the file to load
  152380. * @param extensions defines the extension to use to load the cube map (can be null)
  152381. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152382. * @param files defines the list of files to load (can be null)
  152383. * @returns a new CubeTextureAssetTask object
  152384. */
  152385. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  152386. /**
  152387. *
  152388. * Add a HDRCubeTextureAssetTask to the list of active tasks
  152389. * @param taskName defines the name of the new task
  152390. * @param url defines the url of the file to load
  152391. * @param size defines the size you want for the cubemap (can be null)
  152392. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152393. * @param generateHarmonics defines if you want to automatically generate (true by default)
  152394. * @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)
  152395. * @param reserved Internal use only
  152396. * @returns a new HDRCubeTextureAssetTask object
  152397. */
  152398. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  152399. /**
  152400. *
  152401. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  152402. * @param taskName defines the name of the new task
  152403. * @param url defines the url of the file to load
  152404. * @param size defines the size you want for the cubemap (can be null)
  152405. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  152406. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  152407. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  152408. * @returns a new EquiRectangularCubeTextureAssetTask object
  152409. */
  152410. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  152411. /**
  152412. * Remove a task from the assets manager.
  152413. * @param task the task to remove
  152414. */
  152415. removeTask(task: AbstractAssetTask): void;
  152416. private _decreaseWaitingTasksCount;
  152417. private _runTask;
  152418. /**
  152419. * Reset the AssetsManager and remove all tasks
  152420. * @return the current instance of the AssetsManager
  152421. */
  152422. reset(): AssetsManager;
  152423. /**
  152424. * Start the loading process
  152425. * @return the current instance of the AssetsManager
  152426. */
  152427. load(): AssetsManager;
  152428. /**
  152429. * Start the loading process as an async operation
  152430. * @return a promise returning the list of failed tasks
  152431. */
  152432. loadAsync(): Promise<void>;
  152433. }
  152434. }
  152435. declare module BABYLON {
  152436. /**
  152437. * Wrapper class for promise with external resolve and reject.
  152438. */
  152439. export class Deferred<T> {
  152440. /**
  152441. * The promise associated with this deferred object.
  152442. */
  152443. readonly promise: Promise<T>;
  152444. private _resolve;
  152445. private _reject;
  152446. /**
  152447. * The resolve method of the promise associated with this deferred object.
  152448. */
  152449. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  152450. /**
  152451. * The reject method of the promise associated with this deferred object.
  152452. */
  152453. get reject(): (reason?: any) => void;
  152454. /**
  152455. * Constructor for this deferred object.
  152456. */
  152457. constructor();
  152458. }
  152459. }
  152460. declare module BABYLON {
  152461. /**
  152462. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  152463. */
  152464. export class MeshExploder {
  152465. private _centerMesh;
  152466. private _meshes;
  152467. private _meshesOrigins;
  152468. private _toCenterVectors;
  152469. private _scaledDirection;
  152470. private _newPosition;
  152471. private _centerPosition;
  152472. /**
  152473. * Explodes meshes from a center mesh.
  152474. * @param meshes The meshes to explode.
  152475. * @param centerMesh The mesh to be center of explosion.
  152476. */
  152477. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  152478. private _setCenterMesh;
  152479. /**
  152480. * Get class name
  152481. * @returns "MeshExploder"
  152482. */
  152483. getClassName(): string;
  152484. /**
  152485. * "Exploded meshes"
  152486. * @returns Array of meshes with the centerMesh at index 0.
  152487. */
  152488. getMeshes(): Array<Mesh>;
  152489. /**
  152490. * Explodes meshes giving a specific direction
  152491. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  152492. */
  152493. explode(direction?: number): void;
  152494. }
  152495. }
  152496. declare module BABYLON {
  152497. /**
  152498. * Class used to help managing file picking and drag'n'drop
  152499. */
  152500. export class FilesInput {
  152501. /**
  152502. * List of files ready to be loaded
  152503. */
  152504. static get FilesToLoad(): {
  152505. [key: string]: File;
  152506. };
  152507. /**
  152508. * Callback called when a file is processed
  152509. */
  152510. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  152511. private _engine;
  152512. private _currentScene;
  152513. private _sceneLoadedCallback;
  152514. private _progressCallback;
  152515. private _additionalRenderLoopLogicCallback;
  152516. private _textureLoadingCallback;
  152517. private _startingProcessingFilesCallback;
  152518. private _onReloadCallback;
  152519. private _errorCallback;
  152520. private _elementToMonitor;
  152521. private _sceneFileToLoad;
  152522. private _filesToLoad;
  152523. /**
  152524. * Creates a new FilesInput
  152525. * @param engine defines the rendering engine
  152526. * @param scene defines the hosting scene
  152527. * @param sceneLoadedCallback callback called when scene is loaded
  152528. * @param progressCallback callback called to track progress
  152529. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  152530. * @param textureLoadingCallback callback called when a texture is loading
  152531. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  152532. * @param onReloadCallback callback called when a reload is requested
  152533. * @param errorCallback callback call if an error occurs
  152534. */
  152535. 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>);
  152536. private _dragEnterHandler;
  152537. private _dragOverHandler;
  152538. private _dropHandler;
  152539. /**
  152540. * Calls this function to listen to drag'n'drop events on a specific DOM element
  152541. * @param elementToMonitor defines the DOM element to track
  152542. */
  152543. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  152544. /** Gets the current list of files to load */
  152545. get filesToLoad(): File[];
  152546. /**
  152547. * Release all associated resources
  152548. */
  152549. dispose(): void;
  152550. private renderFunction;
  152551. private drag;
  152552. private drop;
  152553. private _traverseFolder;
  152554. private _processFiles;
  152555. /**
  152556. * Load files from a drop event
  152557. * @param event defines the drop event to use as source
  152558. */
  152559. loadFiles(event: any): void;
  152560. private _processReload;
  152561. /**
  152562. * Reload the current scene from the loaded files
  152563. */
  152564. reload(): void;
  152565. }
  152566. }
  152567. declare module BABYLON {
  152568. /**
  152569. * Defines the root class used to create scene optimization to use with SceneOptimizer
  152570. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152571. */
  152572. export class SceneOptimization {
  152573. /**
  152574. * Defines the priority of this optimization (0 by default which means first in the list)
  152575. */
  152576. priority: number;
  152577. /**
  152578. * Gets a string describing the action executed by the current optimization
  152579. * @returns description string
  152580. */
  152581. getDescription(): string;
  152582. /**
  152583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152584. * @param scene defines the current scene where to apply this optimization
  152585. * @param optimizer defines the current optimizer
  152586. * @returns true if everything that can be done was applied
  152587. */
  152588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152589. /**
  152590. * Creates the SceneOptimization object
  152591. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152592. * @param desc defines the description associated with the optimization
  152593. */
  152594. constructor(
  152595. /**
  152596. * Defines the priority of this optimization (0 by default which means first in the list)
  152597. */
  152598. priority?: number);
  152599. }
  152600. /**
  152601. * Defines an optimization used to reduce the size of render target textures
  152602. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152603. */
  152604. export class TextureOptimization extends SceneOptimization {
  152605. /**
  152606. * Defines the priority of this optimization (0 by default which means first in the list)
  152607. */
  152608. priority: number;
  152609. /**
  152610. * 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
  152611. */
  152612. maximumSize: number;
  152613. /**
  152614. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152615. */
  152616. step: number;
  152617. /**
  152618. * Gets a string describing the action executed by the current optimization
  152619. * @returns description string
  152620. */
  152621. getDescription(): string;
  152622. /**
  152623. * Creates the TextureOptimization object
  152624. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152625. * @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
  152626. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152627. */
  152628. constructor(
  152629. /**
  152630. * Defines the priority of this optimization (0 by default which means first in the list)
  152631. */
  152632. priority?: number,
  152633. /**
  152634. * 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
  152635. */
  152636. maximumSize?: number,
  152637. /**
  152638. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152639. */
  152640. step?: number);
  152641. /**
  152642. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152643. * @param scene defines the current scene where to apply this optimization
  152644. * @param optimizer defines the current optimizer
  152645. * @returns true if everything that can be done was applied
  152646. */
  152647. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152648. }
  152649. /**
  152650. * Defines an optimization used to increase or decrease the rendering resolution
  152651. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152652. */
  152653. export class HardwareScalingOptimization extends SceneOptimization {
  152654. /**
  152655. * Defines the priority of this optimization (0 by default which means first in the list)
  152656. */
  152657. priority: number;
  152658. /**
  152659. * Defines the maximum scale to use (2 by default)
  152660. */
  152661. maximumScale: number;
  152662. /**
  152663. * Defines the step to use between two passes (0.5 by default)
  152664. */
  152665. step: number;
  152666. private _currentScale;
  152667. private _directionOffset;
  152668. /**
  152669. * Gets a string describing the action executed by the current optimization
  152670. * @return description string
  152671. */
  152672. getDescription(): string;
  152673. /**
  152674. * Creates the HardwareScalingOptimization object
  152675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152676. * @param maximumScale defines the maximum scale to use (2 by default)
  152677. * @param step defines the step to use between two passes (0.5 by default)
  152678. */
  152679. constructor(
  152680. /**
  152681. * Defines the priority of this optimization (0 by default which means first in the list)
  152682. */
  152683. priority?: number,
  152684. /**
  152685. * Defines the maximum scale to use (2 by default)
  152686. */
  152687. maximumScale?: number,
  152688. /**
  152689. * Defines the step to use between two passes (0.5 by default)
  152690. */
  152691. step?: number);
  152692. /**
  152693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152694. * @param scene defines the current scene where to apply this optimization
  152695. * @param optimizer defines the current optimizer
  152696. * @returns true if everything that can be done was applied
  152697. */
  152698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152699. }
  152700. /**
  152701. * Defines an optimization used to remove shadows
  152702. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152703. */
  152704. export class ShadowsOptimization extends SceneOptimization {
  152705. /**
  152706. * Gets a string describing the action executed by the current optimization
  152707. * @return description string
  152708. */
  152709. getDescription(): string;
  152710. /**
  152711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152712. * @param scene defines the current scene where to apply this optimization
  152713. * @param optimizer defines the current optimizer
  152714. * @returns true if everything that can be done was applied
  152715. */
  152716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152717. }
  152718. /**
  152719. * Defines an optimization used to turn post-processes off
  152720. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152721. */
  152722. export class PostProcessesOptimization extends SceneOptimization {
  152723. /**
  152724. * Gets a string describing the action executed by the current optimization
  152725. * @return description string
  152726. */
  152727. getDescription(): string;
  152728. /**
  152729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152730. * @param scene defines the current scene where to apply this optimization
  152731. * @param optimizer defines the current optimizer
  152732. * @returns true if everything that can be done was applied
  152733. */
  152734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152735. }
  152736. /**
  152737. * Defines an optimization used to turn lens flares off
  152738. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152739. */
  152740. export class LensFlaresOptimization extends SceneOptimization {
  152741. /**
  152742. * Gets a string describing the action executed by the current optimization
  152743. * @return description string
  152744. */
  152745. getDescription(): string;
  152746. /**
  152747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152748. * @param scene defines the current scene where to apply this optimization
  152749. * @param optimizer defines the current optimizer
  152750. * @returns true if everything that can be done was applied
  152751. */
  152752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152753. }
  152754. /**
  152755. * Defines an optimization based on user defined callback.
  152756. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152757. */
  152758. export class CustomOptimization extends SceneOptimization {
  152759. /**
  152760. * Callback called to apply the custom optimization.
  152761. */
  152762. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  152763. /**
  152764. * Callback called to get custom description
  152765. */
  152766. onGetDescription: () => string;
  152767. /**
  152768. * Gets a string describing the action executed by the current optimization
  152769. * @returns description string
  152770. */
  152771. getDescription(): string;
  152772. /**
  152773. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152774. * @param scene defines the current scene where to apply this optimization
  152775. * @param optimizer defines the current optimizer
  152776. * @returns true if everything that can be done was applied
  152777. */
  152778. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152779. }
  152780. /**
  152781. * Defines an optimization used to turn particles off
  152782. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152783. */
  152784. export class ParticlesOptimization extends SceneOptimization {
  152785. /**
  152786. * Gets a string describing the action executed by the current optimization
  152787. * @return description string
  152788. */
  152789. getDescription(): string;
  152790. /**
  152791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152792. * @param scene defines the current scene where to apply this optimization
  152793. * @param optimizer defines the current optimizer
  152794. * @returns true if everything that can be done was applied
  152795. */
  152796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152797. }
  152798. /**
  152799. * Defines an optimization used to turn render targets off
  152800. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152801. */
  152802. export class RenderTargetsOptimization extends SceneOptimization {
  152803. /**
  152804. * Gets a string describing the action executed by the current optimization
  152805. * @return description string
  152806. */
  152807. getDescription(): string;
  152808. /**
  152809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152810. * @param scene defines the current scene where to apply this optimization
  152811. * @param optimizer defines the current optimizer
  152812. * @returns true if everything that can be done was applied
  152813. */
  152814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152815. }
  152816. /**
  152817. * Defines an optimization used to merge meshes with compatible materials
  152818. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152819. */
  152820. export class MergeMeshesOptimization extends SceneOptimization {
  152821. private static _UpdateSelectionTree;
  152822. /**
  152823. * Gets or sets a boolean which defines if optimization octree has to be updated
  152824. */
  152825. static get UpdateSelectionTree(): boolean;
  152826. /**
  152827. * Gets or sets a boolean which defines if optimization octree has to be updated
  152828. */
  152829. static set UpdateSelectionTree(value: boolean);
  152830. /**
  152831. * Gets a string describing the action executed by the current optimization
  152832. * @return description string
  152833. */
  152834. getDescription(): string;
  152835. private _canBeMerged;
  152836. /**
  152837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152838. * @param scene defines the current scene where to apply this optimization
  152839. * @param optimizer defines the current optimizer
  152840. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152841. * @returns true if everything that can be done was applied
  152842. */
  152843. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152844. }
  152845. /**
  152846. * Defines a list of options used by SceneOptimizer
  152847. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152848. */
  152849. export class SceneOptimizerOptions {
  152850. /**
  152851. * Defines the target frame rate to reach (60 by default)
  152852. */
  152853. targetFrameRate: number;
  152854. /**
  152855. * Defines the interval between two checkes (2000ms by default)
  152856. */
  152857. trackerDuration: number;
  152858. /**
  152859. * Gets the list of optimizations to apply
  152860. */
  152861. optimizations: SceneOptimization[];
  152862. /**
  152863. * Creates a new list of options used by SceneOptimizer
  152864. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152865. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152866. */
  152867. constructor(
  152868. /**
  152869. * Defines the target frame rate to reach (60 by default)
  152870. */
  152871. targetFrameRate?: number,
  152872. /**
  152873. * Defines the interval between two checkes (2000ms by default)
  152874. */
  152875. trackerDuration?: number);
  152876. /**
  152877. * Add a new optimization
  152878. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152879. * @returns the current SceneOptimizerOptions
  152880. */
  152881. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152882. /**
  152883. * Add a new custom optimization
  152884. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152885. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152886. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152887. * @returns the current SceneOptimizerOptions
  152888. */
  152889. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152890. /**
  152891. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152892. * @param targetFrameRate defines the target frame rate (60 by default)
  152893. * @returns a SceneOptimizerOptions object
  152894. */
  152895. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152896. /**
  152897. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152898. * @param targetFrameRate defines the target frame rate (60 by default)
  152899. * @returns a SceneOptimizerOptions object
  152900. */
  152901. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152902. /**
  152903. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152904. * @param targetFrameRate defines the target frame rate (60 by default)
  152905. * @returns a SceneOptimizerOptions object
  152906. */
  152907. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152908. }
  152909. /**
  152910. * Class used to run optimizations in order to reach a target frame rate
  152911. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152912. */
  152913. export class SceneOptimizer implements IDisposable {
  152914. private _isRunning;
  152915. private _options;
  152916. private _scene;
  152917. private _currentPriorityLevel;
  152918. private _targetFrameRate;
  152919. private _trackerDuration;
  152920. private _currentFrameRate;
  152921. private _sceneDisposeObserver;
  152922. private _improvementMode;
  152923. /**
  152924. * Defines an observable called when the optimizer reaches the target frame rate
  152925. */
  152926. onSuccessObservable: Observable<SceneOptimizer>;
  152927. /**
  152928. * Defines an observable called when the optimizer enables an optimization
  152929. */
  152930. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152931. /**
  152932. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152933. */
  152934. onFailureObservable: Observable<SceneOptimizer>;
  152935. /**
  152936. * Gets a boolean indicating if the optimizer is in improvement mode
  152937. */
  152938. get isInImprovementMode(): boolean;
  152939. /**
  152940. * Gets the current priority level (0 at start)
  152941. */
  152942. get currentPriorityLevel(): number;
  152943. /**
  152944. * Gets the current frame rate checked by the SceneOptimizer
  152945. */
  152946. get currentFrameRate(): number;
  152947. /**
  152948. * Gets or sets the current target frame rate (60 by default)
  152949. */
  152950. get targetFrameRate(): number;
  152951. /**
  152952. * Gets or sets the current target frame rate (60 by default)
  152953. */
  152954. set targetFrameRate(value: number);
  152955. /**
  152956. * Gets or sets the current interval between two checks (every 2000ms by default)
  152957. */
  152958. get trackerDuration(): number;
  152959. /**
  152960. * Gets or sets the current interval between two checks (every 2000ms by default)
  152961. */
  152962. set trackerDuration(value: number);
  152963. /**
  152964. * Gets the list of active optimizations
  152965. */
  152966. get optimizations(): SceneOptimization[];
  152967. /**
  152968. * Creates a new SceneOptimizer
  152969. * @param scene defines the scene to work on
  152970. * @param options defines the options to use with the SceneOptimizer
  152971. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152972. * @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)
  152973. */
  152974. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152975. /**
  152976. * Stops the current optimizer
  152977. */
  152978. stop(): void;
  152979. /**
  152980. * Reset the optimizer to initial step (current priority level = 0)
  152981. */
  152982. reset(): void;
  152983. /**
  152984. * Start the optimizer. By default it will try to reach a specific framerate
  152985. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152986. */
  152987. start(): void;
  152988. private _checkCurrentState;
  152989. /**
  152990. * Release all resources
  152991. */
  152992. dispose(): void;
  152993. /**
  152994. * Helper function to create a SceneOptimizer with one single line of code
  152995. * @param scene defines the scene to work on
  152996. * @param options defines the options to use with the SceneOptimizer
  152997. * @param onSuccess defines a callback to call on success
  152998. * @param onFailure defines a callback to call on failure
  152999. * @returns the new SceneOptimizer object
  153000. */
  153001. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153002. }
  153003. }
  153004. declare module BABYLON {
  153005. /**
  153006. * Class used to serialize a scene into a string
  153007. */
  153008. export class SceneSerializer {
  153009. /**
  153010. * Clear cache used by a previous serialization
  153011. */
  153012. static ClearCache(): void;
  153013. /**
  153014. * Serialize a scene into a JSON compatible object
  153015. * @param scene defines the scene to serialize
  153016. * @returns a JSON compatible object
  153017. */
  153018. static Serialize(scene: Scene): any;
  153019. /**
  153020. * Serialize a mesh into a JSON compatible object
  153021. * @param toSerialize defines the mesh to serialize
  153022. * @param withParents defines if parents must be serialized as well
  153023. * @param withChildren defines if children must be serialized as well
  153024. * @returns a JSON compatible object
  153025. */
  153026. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153027. }
  153028. }
  153029. declare module BABYLON {
  153030. /**
  153031. * Class used to host texture specific utilities
  153032. */
  153033. export class TextureTools {
  153034. /**
  153035. * Uses the GPU to create a copy texture rescaled at a given size
  153036. * @param texture Texture to copy from
  153037. * @param width defines the desired width
  153038. * @param height defines the desired height
  153039. * @param useBilinearMode defines if bilinear mode has to be used
  153040. * @return the generated texture
  153041. */
  153042. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153043. }
  153044. }
  153045. declare module BABYLON {
  153046. /**
  153047. * This represents the different options available for the video capture.
  153048. */
  153049. export interface VideoRecorderOptions {
  153050. /** Defines the mime type of the video. */
  153051. mimeType: string;
  153052. /** Defines the FPS the video should be recorded at. */
  153053. fps: number;
  153054. /** Defines the chunk size for the recording data. */
  153055. recordChunckSize: number;
  153056. /** The audio tracks to attach to the recording. */
  153057. audioTracks?: MediaStreamTrack[];
  153058. }
  153059. /**
  153060. * This can help with recording videos from BabylonJS.
  153061. * This is based on the available WebRTC functionalities of the browser.
  153062. *
  153063. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153064. */
  153065. export class VideoRecorder {
  153066. private static readonly _defaultOptions;
  153067. /**
  153068. * Returns whether or not the VideoRecorder is available in your browser.
  153069. * @param engine Defines the Babylon Engine.
  153070. * @returns true if supported otherwise false.
  153071. */
  153072. static IsSupported(engine: Engine): boolean;
  153073. private readonly _options;
  153074. private _canvas;
  153075. private _mediaRecorder;
  153076. private _recordedChunks;
  153077. private _fileName;
  153078. private _resolve;
  153079. private _reject;
  153080. /**
  153081. * True when a recording is already in progress.
  153082. */
  153083. get isRecording(): boolean;
  153084. /**
  153085. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153086. * @param engine Defines the BabylonJS Engine you wish to record.
  153087. * @param options Defines options that can be used to customize the capture.
  153088. */
  153089. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153090. /**
  153091. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153092. */
  153093. stopRecording(): void;
  153094. /**
  153095. * Starts recording the canvas for a max duration specified in parameters.
  153096. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153097. * If null no automatic download will start and you can rely on the promise to get the data back.
  153098. * @param maxDuration Defines the maximum recording time in seconds.
  153099. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153100. * @return A promise callback at the end of the recording with the video data in Blob.
  153101. */
  153102. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153103. /**
  153104. * Releases internal resources used during the recording.
  153105. */
  153106. dispose(): void;
  153107. private _handleDataAvailable;
  153108. private _handleError;
  153109. private _handleStop;
  153110. }
  153111. }
  153112. declare module BABYLON {
  153113. /**
  153114. * Class containing a set of static utilities functions for screenshots
  153115. */
  153116. export class ScreenshotTools {
  153117. /**
  153118. * Captures a screenshot of the current rendering
  153119. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153120. * @param engine defines the rendering engine
  153121. * @param camera defines the source camera
  153122. * @param size This parameter can be set to a single number or to an object with the
  153123. * following (optional) properties: precision, width, height. If a single number is passed,
  153124. * it will be used for both width and height. If an object is passed, the screenshot size
  153125. * will be derived from the parameters. The precision property is a multiplier allowing
  153126. * rendering at a higher or lower resolution
  153127. * @param successCallback defines the callback receives a single parameter which contains the
  153128. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153129. * src parameter of an <img> to display it
  153130. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153131. * Check your browser for supported MIME types
  153132. */
  153133. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  153134. /**
  153135. * Captures a screenshot of the current rendering
  153136. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153137. * @param engine defines the rendering engine
  153138. * @param camera defines the source camera
  153139. * @param size This parameter can be set to a single number or to an object with the
  153140. * following (optional) properties: precision, width, height. If a single number is passed,
  153141. * it will be used for both width and height. If an object is passed, the screenshot size
  153142. * will be derived from the parameters. The precision property is a multiplier allowing
  153143. * rendering at a higher or lower resolution
  153144. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153145. * Check your browser for supported MIME types
  153146. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153147. * to the src parameter of an <img> to display it
  153148. */
  153149. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  153150. /**
  153151. * Generates an image screenshot from the specified camera.
  153152. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153153. * @param engine The engine to use for rendering
  153154. * @param camera The camera to use for rendering
  153155. * @param size This parameter can be set to a single number or to an object with the
  153156. * following (optional) properties: precision, width, height. If a single number is passed,
  153157. * it will be used for both width and height. If an object is passed, the screenshot size
  153158. * will be derived from the parameters. The precision property is a multiplier allowing
  153159. * rendering at a higher or lower resolution
  153160. * @param successCallback The callback receives a single parameter which contains the
  153161. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153162. * src parameter of an <img> to display it
  153163. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153164. * Check your browser for supported MIME types
  153165. * @param samples Texture samples (default: 1)
  153166. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153167. * @param fileName A name for for the downloaded file.
  153168. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153169. */
  153170. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  153171. /**
  153172. * Generates an image screenshot from the specified camera.
  153173. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153174. * @param engine The engine to use for rendering
  153175. * @param camera The camera to use for rendering
  153176. * @param size This parameter can be set to a single number or to an object with the
  153177. * following (optional) properties: precision, width, height. If a single number is passed,
  153178. * it will be used for both width and height. If an object is passed, the screenshot size
  153179. * will be derived from the parameters. The precision property is a multiplier allowing
  153180. * rendering at a higher or lower resolution
  153181. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153182. * Check your browser for supported MIME types
  153183. * @param samples Texture samples (default: 1)
  153184. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153185. * @param fileName A name for for the downloaded file.
  153186. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153187. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153188. * to the src parameter of an <img> to display it
  153189. */
  153190. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  153191. /**
  153192. * Gets height and width for screenshot size
  153193. * @private
  153194. */
  153195. private static _getScreenshotSize;
  153196. }
  153197. }
  153198. declare module BABYLON {
  153199. /**
  153200. * Interface for a data buffer
  153201. */
  153202. export interface IDataBuffer {
  153203. /**
  153204. * Reads bytes from the data buffer.
  153205. * @param byteOffset The byte offset to read
  153206. * @param byteLength The byte length to read
  153207. * @returns A promise that resolves when the bytes are read
  153208. */
  153209. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  153210. /**
  153211. * The byte length of the buffer.
  153212. */
  153213. readonly byteLength: number;
  153214. }
  153215. /**
  153216. * Utility class for reading from a data buffer
  153217. */
  153218. export class DataReader {
  153219. /**
  153220. * The data buffer associated with this data reader.
  153221. */
  153222. readonly buffer: IDataBuffer;
  153223. /**
  153224. * The current byte offset from the beginning of the data buffer.
  153225. */
  153226. byteOffset: number;
  153227. private _dataView;
  153228. private _dataByteOffset;
  153229. /**
  153230. * Constructor
  153231. * @param buffer The buffer to read
  153232. */
  153233. constructor(buffer: IDataBuffer);
  153234. /**
  153235. * Loads the given byte length.
  153236. * @param byteLength The byte length to load
  153237. * @returns A promise that resolves when the load is complete
  153238. */
  153239. loadAsync(byteLength: number): Promise<void>;
  153240. /**
  153241. * Read a unsigned 32-bit integer from the currently loaded data range.
  153242. * @returns The 32-bit integer read
  153243. */
  153244. readUint32(): number;
  153245. /**
  153246. * Read a byte array from the currently loaded data range.
  153247. * @param byteLength The byte length to read
  153248. * @returns The byte array read
  153249. */
  153250. readUint8Array(byteLength: number): Uint8Array;
  153251. /**
  153252. * Read a string from the currently loaded data range.
  153253. * @param byteLength The byte length to read
  153254. * @returns The string read
  153255. */
  153256. readString(byteLength: number): string;
  153257. /**
  153258. * Skips the given byte length the currently loaded data range.
  153259. * @param byteLength The byte length to skip
  153260. */
  153261. skipBytes(byteLength: number): void;
  153262. }
  153263. }
  153264. declare module BABYLON {
  153265. /**
  153266. * Class for storing data to local storage if available or in-memory storage otherwise
  153267. */
  153268. export class DataStorage {
  153269. private static _Storage;
  153270. private static _GetStorage;
  153271. /**
  153272. * Reads a string from the data storage
  153273. * @param key The key to read
  153274. * @param defaultValue The value if the key doesn't exist
  153275. * @returns The string value
  153276. */
  153277. static ReadString(key: string, defaultValue: string): string;
  153278. /**
  153279. * Writes a string to the data storage
  153280. * @param key The key to write
  153281. * @param value The value to write
  153282. */
  153283. static WriteString(key: string, value: string): void;
  153284. /**
  153285. * Reads a boolean from the data storage
  153286. * @param key The key to read
  153287. * @param defaultValue The value if the key doesn't exist
  153288. * @returns The boolean value
  153289. */
  153290. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  153291. /**
  153292. * Writes a boolean to the data storage
  153293. * @param key The key to write
  153294. * @param value The value to write
  153295. */
  153296. static WriteBoolean(key: string, value: boolean): void;
  153297. /**
  153298. * Reads a number from the data storage
  153299. * @param key The key to read
  153300. * @param defaultValue The value if the key doesn't exist
  153301. * @returns The number value
  153302. */
  153303. static ReadNumber(key: string, defaultValue: number): number;
  153304. /**
  153305. * Writes a number to the data storage
  153306. * @param key The key to write
  153307. * @param value The value to write
  153308. */
  153309. static WriteNumber(key: string, value: number): void;
  153310. }
  153311. }
  153312. declare module BABYLON {
  153313. /**
  153314. * Class used to record delta files between 2 scene states
  153315. */
  153316. export class SceneRecorder {
  153317. private _trackedScene;
  153318. private _savedJSON;
  153319. /**
  153320. * Track a given scene. This means the current scene state will be considered the original state
  153321. * @param scene defines the scene to track
  153322. */
  153323. track(scene: Scene): void;
  153324. /**
  153325. * Get the delta between current state and original state
  153326. * @returns a string containing the delta
  153327. */
  153328. getDelta(): any;
  153329. private _compareArray;
  153330. private _compareObjects;
  153331. private _compareCollections;
  153332. private static GetShadowGeneratorById;
  153333. /**
  153334. * Apply a given delta to a given scene
  153335. * @param deltaJSON defines the JSON containing the delta
  153336. * @param scene defines the scene to apply the delta to
  153337. */
  153338. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  153339. private static _ApplyPropertiesToEntity;
  153340. private static _ApplyDeltaForEntity;
  153341. }
  153342. }
  153343. declare module BABYLON {
  153344. /**
  153345. * An interface for all Hit test features
  153346. */
  153347. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  153348. /**
  153349. * Triggered when new babylon (transformed) hit test results are available
  153350. */
  153351. onHitTestResultObservable: Observable<T[]>;
  153352. }
  153353. /**
  153354. * Options used for hit testing
  153355. */
  153356. export interface IWebXRLegacyHitTestOptions {
  153357. /**
  153358. * Only test when user interacted with the scene. Default - hit test every frame
  153359. */
  153360. testOnPointerDownOnly?: boolean;
  153361. /**
  153362. * The node to use to transform the local results to world coordinates
  153363. */
  153364. worldParentNode?: TransformNode;
  153365. }
  153366. /**
  153367. * Interface defining the babylon result of raycasting/hit-test
  153368. */
  153369. export interface IWebXRLegacyHitResult {
  153370. /**
  153371. * Transformation matrix that can be applied to a node that will put it in the hit point location
  153372. */
  153373. transformationMatrix: Matrix;
  153374. /**
  153375. * The native hit test result
  153376. */
  153377. xrHitResult: XRHitResult | XRHitTestResult;
  153378. }
  153379. /**
  153380. * The currently-working hit-test module.
  153381. * Hit test (or Ray-casting) is used to interact with the real world.
  153382. * For further information read here - https://github.com/immersive-web/hit-test
  153383. */
  153384. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  153385. /**
  153386. * options to use when constructing this feature
  153387. */
  153388. readonly options: IWebXRLegacyHitTestOptions;
  153389. private _direction;
  153390. private _mat;
  153391. private _onSelectEnabled;
  153392. private _origin;
  153393. /**
  153394. * The module's name
  153395. */
  153396. static readonly Name: string;
  153397. /**
  153398. * The (Babylon) version of this module.
  153399. * This is an integer representing the implementation version.
  153400. * This number does not correspond to the WebXR specs version
  153401. */
  153402. static readonly Version: number;
  153403. /**
  153404. * Populated with the last native XR Hit Results
  153405. */
  153406. lastNativeXRHitResults: XRHitResult[];
  153407. /**
  153408. * Triggered when new babylon (transformed) hit test results are available
  153409. */
  153410. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  153411. /**
  153412. * Creates a new instance of the (legacy version) hit test feature
  153413. * @param _xrSessionManager an instance of WebXRSessionManager
  153414. * @param options options to use when constructing this feature
  153415. */
  153416. constructor(_xrSessionManager: WebXRSessionManager,
  153417. /**
  153418. * options to use when constructing this feature
  153419. */
  153420. options?: IWebXRLegacyHitTestOptions);
  153421. /**
  153422. * execute a hit test with an XR Ray
  153423. *
  153424. * @param xrSession a native xrSession that will execute this hit test
  153425. * @param xrRay the ray (position and direction) to use for ray-casting
  153426. * @param referenceSpace native XR reference space to use for the hit-test
  153427. * @param filter filter function that will filter the results
  153428. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153429. */
  153430. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  153431. /**
  153432. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  153433. * @param event the (select) event to use to select with
  153434. * @param referenceSpace the reference space to use for this hit test
  153435. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  153436. */
  153437. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153438. /**
  153439. * attach this feature
  153440. * Will usually be called by the features manager
  153441. *
  153442. * @returns true if successful.
  153443. */
  153444. attach(): boolean;
  153445. /**
  153446. * detach this feature.
  153447. * Will usually be called by the features manager
  153448. *
  153449. * @returns true if successful.
  153450. */
  153451. detach(): boolean;
  153452. /**
  153453. * Dispose this feature and all of the resources attached
  153454. */
  153455. dispose(): void;
  153456. protected _onXRFrame(frame: XRFrame): void;
  153457. private _onHitTestResults;
  153458. private _onSelect;
  153459. }
  153460. }
  153461. declare module BABYLON {
  153462. /**
  153463. * Options used for hit testing (version 2)
  153464. */
  153465. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  153466. /**
  153467. * Do not create a permanent hit test. Will usually be used when only
  153468. * transient inputs are needed.
  153469. */
  153470. disablePermanentHitTest?: boolean;
  153471. /**
  153472. * Enable transient (for example touch-based) hit test inspections
  153473. */
  153474. enableTransientHitTest?: boolean;
  153475. /**
  153476. * Offset ray for the permanent hit test
  153477. */
  153478. offsetRay?: Vector3;
  153479. /**
  153480. * Offset ray for the transient hit test
  153481. */
  153482. transientOffsetRay?: Vector3;
  153483. /**
  153484. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  153485. */
  153486. useReferenceSpace?: boolean;
  153487. /**
  153488. * Override the default entity type(s) of the hit-test result
  153489. */
  153490. entityTypes?: XRHitTestTrackableType[];
  153491. }
  153492. /**
  153493. * Interface defining the babylon result of hit-test
  153494. */
  153495. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  153496. /**
  153497. * The input source that generated this hit test (if transient)
  153498. */
  153499. inputSource?: XRInputSource;
  153500. /**
  153501. * Is this a transient hit test
  153502. */
  153503. isTransient?: boolean;
  153504. /**
  153505. * Position of the hit test result
  153506. */
  153507. position: Vector3;
  153508. /**
  153509. * Rotation of the hit test result
  153510. */
  153511. rotationQuaternion: Quaternion;
  153512. /**
  153513. * The native hit test result
  153514. */
  153515. xrHitResult: XRHitTestResult;
  153516. }
  153517. /**
  153518. * The currently-working hit-test module.
  153519. * Hit test (or Ray-casting) is used to interact with the real world.
  153520. * For further information read here - https://github.com/immersive-web/hit-test
  153521. *
  153522. * Tested on chrome (mobile) 80.
  153523. */
  153524. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  153525. /**
  153526. * options to use when constructing this feature
  153527. */
  153528. readonly options: IWebXRHitTestOptions;
  153529. private _tmpMat;
  153530. private _tmpPos;
  153531. private _tmpQuat;
  153532. private _transientXrHitTestSource;
  153533. private _xrHitTestSource;
  153534. private initHitTestSource;
  153535. /**
  153536. * The module's name
  153537. */
  153538. static readonly Name: string;
  153539. /**
  153540. * The (Babylon) version of this module.
  153541. * This is an integer representing the implementation version.
  153542. * This number does not correspond to the WebXR specs version
  153543. */
  153544. static readonly Version: number;
  153545. /**
  153546. * When set to true, each hit test will have its own position/rotation objects
  153547. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  153548. * the developers will clone them or copy them as they see fit.
  153549. */
  153550. autoCloneTransformation: boolean;
  153551. /**
  153552. * Triggered when new babylon (transformed) hit test results are available
  153553. */
  153554. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  153555. /**
  153556. * Use this to temporarily pause hit test checks.
  153557. */
  153558. paused: boolean;
  153559. /**
  153560. * Creates a new instance of the hit test feature
  153561. * @param _xrSessionManager an instance of WebXRSessionManager
  153562. * @param options options to use when constructing this feature
  153563. */
  153564. constructor(_xrSessionManager: WebXRSessionManager,
  153565. /**
  153566. * options to use when constructing this feature
  153567. */
  153568. options?: IWebXRHitTestOptions);
  153569. /**
  153570. * attach this feature
  153571. * Will usually be called by the features manager
  153572. *
  153573. * @returns true if successful.
  153574. */
  153575. attach(): boolean;
  153576. /**
  153577. * detach this feature.
  153578. * Will usually be called by the features manager
  153579. *
  153580. * @returns true if successful.
  153581. */
  153582. detach(): boolean;
  153583. /**
  153584. * Dispose this feature and all of the resources attached
  153585. */
  153586. dispose(): void;
  153587. protected _onXRFrame(frame: XRFrame): void;
  153588. private _processWebXRHitTestResult;
  153589. }
  153590. }
  153591. declare module BABYLON {
  153592. /**
  153593. * Configuration options of the anchor system
  153594. */
  153595. export interface IWebXRAnchorSystemOptions {
  153596. /**
  153597. * a node that will be used to convert local to world coordinates
  153598. */
  153599. worldParentNode?: TransformNode;
  153600. /**
  153601. * If set to true a reference of the created anchors will be kept until the next session starts
  153602. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  153603. */
  153604. doNotRemoveAnchorsOnSessionEnded?: boolean;
  153605. }
  153606. /**
  153607. * A babylon container for an XR Anchor
  153608. */
  153609. export interface IWebXRAnchor {
  153610. /**
  153611. * A babylon-assigned ID for this anchor
  153612. */
  153613. id: number;
  153614. /**
  153615. * Transformation matrix to apply to an object attached to this anchor
  153616. */
  153617. transformationMatrix: Matrix;
  153618. /**
  153619. * The native anchor object
  153620. */
  153621. xrAnchor: XRAnchor;
  153622. /**
  153623. * if defined, this object will be constantly updated by the anchor's position and rotation
  153624. */
  153625. attachedNode?: TransformNode;
  153626. }
  153627. /**
  153628. * An implementation of the anchor system for WebXR.
  153629. * For further information see https://github.com/immersive-web/anchors/
  153630. */
  153631. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  153632. private _options;
  153633. private _lastFrameDetected;
  153634. private _trackedAnchors;
  153635. private _referenceSpaceForFrameAnchors;
  153636. private _futureAnchors;
  153637. /**
  153638. * The module's name
  153639. */
  153640. static readonly Name: string;
  153641. /**
  153642. * The (Babylon) version of this module.
  153643. * This is an integer representing the implementation version.
  153644. * This number does not correspond to the WebXR specs version
  153645. */
  153646. static readonly Version: number;
  153647. /**
  153648. * Observers registered here will be executed when a new anchor was added to the session
  153649. */
  153650. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  153651. /**
  153652. * Observers registered here will be executed when an anchor was removed from the session
  153653. */
  153654. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  153655. /**
  153656. * Observers registered here will be executed when an existing anchor updates
  153657. * This can execute N times every frame
  153658. */
  153659. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  153660. /**
  153661. * Set the reference space to use for anchor creation, when not using a hit test.
  153662. * Will default to the session's reference space if not defined
  153663. */
  153664. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  153665. /**
  153666. * constructs a new anchor system
  153667. * @param _xrSessionManager an instance of WebXRSessionManager
  153668. * @param _options configuration object for this feature
  153669. */
  153670. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  153671. private _tmpVector;
  153672. private _tmpQuaternion;
  153673. private _populateTmpTransformation;
  153674. /**
  153675. * Create a new anchor point using a hit test result at a specific point in the scene
  153676. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153677. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153678. *
  153679. * @param hitTestResult The hit test result to use for this anchor creation
  153680. * @param position an optional position offset for this anchor
  153681. * @param rotationQuaternion an optional rotation offset for this anchor
  153682. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153683. */
  153684. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  153685. /**
  153686. * Add a new anchor at a specific position and rotation
  153687. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  153688. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  153689. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153690. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153691. *
  153692. * @param position the position in which to add an anchor
  153693. * @param rotationQuaternion an optional rotation for the anchor transformation
  153694. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  153695. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153696. */
  153697. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  153698. /**
  153699. * detach this feature.
  153700. * Will usually be called by the features manager
  153701. *
  153702. * @returns true if successful.
  153703. */
  153704. detach(): boolean;
  153705. /**
  153706. * Dispose this feature and all of the resources attached
  153707. */
  153708. dispose(): void;
  153709. protected _onXRFrame(frame: XRFrame): void;
  153710. /**
  153711. * avoiding using Array.find for global support.
  153712. * @param xrAnchor the plane to find in the array
  153713. */
  153714. private _findIndexInAnchorArray;
  153715. private _updateAnchorWithXRFrame;
  153716. private _createAnchorAtTransformation;
  153717. }
  153718. }
  153719. declare module BABYLON {
  153720. /**
  153721. * Options used in the plane detector module
  153722. */
  153723. export interface IWebXRPlaneDetectorOptions {
  153724. /**
  153725. * The node to use to transform the local results to world coordinates
  153726. */
  153727. worldParentNode?: TransformNode;
  153728. /**
  153729. * If set to true a reference of the created planes will be kept until the next session starts
  153730. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  153731. */
  153732. doNotRemovePlanesOnSessionEnded?: boolean;
  153733. }
  153734. /**
  153735. * A babylon interface for a WebXR plane.
  153736. * A Plane is actually a polygon, built from N points in space
  153737. *
  153738. * Supported in chrome 79, not supported in canary 81 ATM
  153739. */
  153740. export interface IWebXRPlane {
  153741. /**
  153742. * a babylon-assigned ID for this polygon
  153743. */
  153744. id: number;
  153745. /**
  153746. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  153747. */
  153748. polygonDefinition: Array<Vector3>;
  153749. /**
  153750. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  153751. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  153752. */
  153753. transformationMatrix: Matrix;
  153754. /**
  153755. * the native xr-plane object
  153756. */
  153757. xrPlane: XRPlane;
  153758. }
  153759. /**
  153760. * The plane detector is used to detect planes in the real world when in AR
  153761. * For more information see https://github.com/immersive-web/real-world-geometry/
  153762. */
  153763. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  153764. private _options;
  153765. private _detectedPlanes;
  153766. private _enabled;
  153767. private _lastFrameDetected;
  153768. /**
  153769. * The module's name
  153770. */
  153771. static readonly Name: string;
  153772. /**
  153773. * The (Babylon) version of this module.
  153774. * This is an integer representing the implementation version.
  153775. * This number does not correspond to the WebXR specs version
  153776. */
  153777. static readonly Version: number;
  153778. /**
  153779. * Observers registered here will be executed when a new plane was added to the session
  153780. */
  153781. onPlaneAddedObservable: Observable<IWebXRPlane>;
  153782. /**
  153783. * Observers registered here will be executed when a plane is no longer detected in the session
  153784. */
  153785. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  153786. /**
  153787. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  153788. * This can execute N times every frame
  153789. */
  153790. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  153791. /**
  153792. * construct a new Plane Detector
  153793. * @param _xrSessionManager an instance of xr Session manager
  153794. * @param _options configuration to use when constructing this feature
  153795. */
  153796. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  153797. /**
  153798. * detach this feature.
  153799. * Will usually be called by the features manager
  153800. *
  153801. * @returns true if successful.
  153802. */
  153803. detach(): boolean;
  153804. /**
  153805. * Dispose this feature and all of the resources attached
  153806. */
  153807. dispose(): void;
  153808. protected _onXRFrame(frame: XRFrame): void;
  153809. private _init;
  153810. private _updatePlaneWithXRPlane;
  153811. /**
  153812. * avoiding using Array.find for global support.
  153813. * @param xrPlane the plane to find in the array
  153814. */
  153815. private findIndexInPlaneArray;
  153816. }
  153817. }
  153818. declare module BABYLON {
  153819. /**
  153820. * Options interface for the background remover plugin
  153821. */
  153822. export interface IWebXRBackgroundRemoverOptions {
  153823. /**
  153824. * Further background meshes to disable when entering AR
  153825. */
  153826. backgroundMeshes?: AbstractMesh[];
  153827. /**
  153828. * flags to configure the removal of the environment helper.
  153829. * If not set, the entire background will be removed. If set, flags should be set as well.
  153830. */
  153831. environmentHelperRemovalFlags?: {
  153832. /**
  153833. * Should the skybox be removed (default false)
  153834. */
  153835. skyBox?: boolean;
  153836. /**
  153837. * Should the ground be removed (default false)
  153838. */
  153839. ground?: boolean;
  153840. };
  153841. /**
  153842. * don't disable the environment helper
  153843. */
  153844. ignoreEnvironmentHelper?: boolean;
  153845. }
  153846. /**
  153847. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153848. */
  153849. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153850. /**
  153851. * read-only options to be used in this module
  153852. */
  153853. readonly options: IWebXRBackgroundRemoverOptions;
  153854. /**
  153855. * The module's name
  153856. */
  153857. static readonly Name: string;
  153858. /**
  153859. * The (Babylon) version of this module.
  153860. * This is an integer representing the implementation version.
  153861. * This number does not correspond to the WebXR specs version
  153862. */
  153863. static readonly Version: number;
  153864. /**
  153865. * registered observers will be triggered when the background state changes
  153866. */
  153867. onBackgroundStateChangedObservable: Observable<boolean>;
  153868. /**
  153869. * constructs a new background remover module
  153870. * @param _xrSessionManager the session manager for this module
  153871. * @param options read-only options to be used in this module
  153872. */
  153873. constructor(_xrSessionManager: WebXRSessionManager,
  153874. /**
  153875. * read-only options to be used in this module
  153876. */
  153877. options?: IWebXRBackgroundRemoverOptions);
  153878. /**
  153879. * attach this feature
  153880. * Will usually be called by the features manager
  153881. *
  153882. * @returns true if successful.
  153883. */
  153884. attach(): boolean;
  153885. /**
  153886. * detach this feature.
  153887. * Will usually be called by the features manager
  153888. *
  153889. * @returns true if successful.
  153890. */
  153891. detach(): boolean;
  153892. /**
  153893. * Dispose this feature and all of the resources attached
  153894. */
  153895. dispose(): void;
  153896. protected _onXRFrame(_xrFrame: XRFrame): void;
  153897. private _setBackgroundState;
  153898. }
  153899. }
  153900. declare module BABYLON {
  153901. /**
  153902. * Options for the controller physics feature
  153903. */
  153904. export class IWebXRControllerPhysicsOptions {
  153905. /**
  153906. * Should the headset get its own impostor
  153907. */
  153908. enableHeadsetImpostor?: boolean;
  153909. /**
  153910. * Optional parameters for the headset impostor
  153911. */
  153912. headsetImpostorParams?: {
  153913. /**
  153914. * The type of impostor to create. Default is sphere
  153915. */
  153916. impostorType: number;
  153917. /**
  153918. * the size of the impostor. Defaults to 10cm
  153919. */
  153920. impostorSize?: number | {
  153921. width: number;
  153922. height: number;
  153923. depth: number;
  153924. };
  153925. /**
  153926. * Friction definitions
  153927. */
  153928. friction?: number;
  153929. /**
  153930. * Restitution
  153931. */
  153932. restitution?: number;
  153933. };
  153934. /**
  153935. * The physics properties of the future impostors
  153936. */
  153937. physicsProperties?: {
  153938. /**
  153939. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153940. * Note that this requires a physics engine that supports mesh impostors!
  153941. */
  153942. useControllerMesh?: boolean;
  153943. /**
  153944. * The type of impostor to create. Default is sphere
  153945. */
  153946. impostorType?: number;
  153947. /**
  153948. * the size of the impostor. Defaults to 10cm
  153949. */
  153950. impostorSize?: number | {
  153951. width: number;
  153952. height: number;
  153953. depth: number;
  153954. };
  153955. /**
  153956. * Friction definitions
  153957. */
  153958. friction?: number;
  153959. /**
  153960. * Restitution
  153961. */
  153962. restitution?: number;
  153963. };
  153964. /**
  153965. * the xr input to use with this pointer selection
  153966. */
  153967. xrInput: WebXRInput;
  153968. }
  153969. /**
  153970. * Add physics impostor to your webxr controllers,
  153971. * including naive calculation of their linear and angular velocity
  153972. */
  153973. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153974. private readonly _options;
  153975. private _attachController;
  153976. private _controllers;
  153977. private _debugMode;
  153978. private _delta;
  153979. private _headsetImpostor?;
  153980. private _headsetMesh?;
  153981. private _lastTimestamp;
  153982. private _tmpQuaternion;
  153983. private _tmpVector;
  153984. /**
  153985. * The module's name
  153986. */
  153987. static readonly Name: string;
  153988. /**
  153989. * The (Babylon) version of this module.
  153990. * This is an integer representing the implementation version.
  153991. * This number does not correspond to the webxr specs version
  153992. */
  153993. static readonly Version: number;
  153994. /**
  153995. * Construct a new Controller Physics Feature
  153996. * @param _xrSessionManager the corresponding xr session manager
  153997. * @param _options options to create this feature with
  153998. */
  153999. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154000. /**
  154001. * @hidden
  154002. * enable debugging - will show console outputs and the impostor mesh
  154003. */
  154004. _enablePhysicsDebug(): void;
  154005. /**
  154006. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154007. * @param xrController the controller to add
  154008. */
  154009. addController(xrController: WebXRInputSource): void;
  154010. /**
  154011. * attach this feature
  154012. * Will usually be called by the features manager
  154013. *
  154014. * @returns true if successful.
  154015. */
  154016. attach(): boolean;
  154017. /**
  154018. * detach this feature.
  154019. * Will usually be called by the features manager
  154020. *
  154021. * @returns true if successful.
  154022. */
  154023. detach(): boolean;
  154024. /**
  154025. * Get the headset impostor, if enabled
  154026. * @returns the impostor
  154027. */
  154028. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154029. /**
  154030. * Get the physics impostor of a specific controller.
  154031. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154032. * @param controller the controller or the controller id of which to get the impostor
  154033. * @returns the impostor or null
  154034. */
  154035. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154036. /**
  154037. * Update the physics properties provided in the constructor
  154038. * @param newProperties the new properties object
  154039. */
  154040. setPhysicsProperties(newProperties: {
  154041. impostorType?: number;
  154042. impostorSize?: number | {
  154043. width: number;
  154044. height: number;
  154045. depth: number;
  154046. };
  154047. friction?: number;
  154048. restitution?: number;
  154049. }): void;
  154050. protected _onXRFrame(_xrFrame: any): void;
  154051. private _detachController;
  154052. }
  154053. }
  154054. declare module BABYLON {
  154055. /**
  154056. * The motion controller class for all microsoft mixed reality controllers
  154057. */
  154058. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  154059. protected readonly _mapping: {
  154060. defaultButton: {
  154061. valueNodeName: string;
  154062. unpressedNodeName: string;
  154063. pressedNodeName: string;
  154064. };
  154065. defaultAxis: {
  154066. valueNodeName: string;
  154067. minNodeName: string;
  154068. maxNodeName: string;
  154069. };
  154070. buttons: {
  154071. "xr-standard-trigger": {
  154072. rootNodeName: string;
  154073. componentProperty: string;
  154074. states: string[];
  154075. };
  154076. "xr-standard-squeeze": {
  154077. rootNodeName: string;
  154078. componentProperty: string;
  154079. states: string[];
  154080. };
  154081. "xr-standard-touchpad": {
  154082. rootNodeName: string;
  154083. labelAnchorNodeName: string;
  154084. touchPointNodeName: string;
  154085. };
  154086. "xr-standard-thumbstick": {
  154087. rootNodeName: string;
  154088. componentProperty: string;
  154089. states: string[];
  154090. };
  154091. };
  154092. axes: {
  154093. "xr-standard-touchpad": {
  154094. "x-axis": {
  154095. rootNodeName: string;
  154096. };
  154097. "y-axis": {
  154098. rootNodeName: string;
  154099. };
  154100. };
  154101. "xr-standard-thumbstick": {
  154102. "x-axis": {
  154103. rootNodeName: string;
  154104. };
  154105. "y-axis": {
  154106. rootNodeName: string;
  154107. };
  154108. };
  154109. };
  154110. };
  154111. /**
  154112. * The base url used to load the left and right controller models
  154113. */
  154114. static MODEL_BASE_URL: string;
  154115. /**
  154116. * The name of the left controller model file
  154117. */
  154118. static MODEL_LEFT_FILENAME: string;
  154119. /**
  154120. * The name of the right controller model file
  154121. */
  154122. static MODEL_RIGHT_FILENAME: string;
  154123. profileId: string;
  154124. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154125. protected _getFilenameAndPath(): {
  154126. filename: string;
  154127. path: string;
  154128. };
  154129. protected _getModelLoadingConstraints(): boolean;
  154130. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154131. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154132. protected _updateModel(): void;
  154133. }
  154134. }
  154135. declare module BABYLON {
  154136. /**
  154137. * The motion controller class for oculus touch (quest, rift).
  154138. * This class supports legacy mapping as well the standard xr mapping
  154139. */
  154140. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  154141. private _forceLegacyControllers;
  154142. private _modelRootNode;
  154143. /**
  154144. * The base url used to load the left and right controller models
  154145. */
  154146. static MODEL_BASE_URL: string;
  154147. /**
  154148. * The name of the left controller model file
  154149. */
  154150. static MODEL_LEFT_FILENAME: string;
  154151. /**
  154152. * The name of the right controller model file
  154153. */
  154154. static MODEL_RIGHT_FILENAME: string;
  154155. /**
  154156. * Base Url for the Quest controller model.
  154157. */
  154158. static QUEST_MODEL_BASE_URL: string;
  154159. profileId: string;
  154160. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  154161. protected _getFilenameAndPath(): {
  154162. filename: string;
  154163. path: string;
  154164. };
  154165. protected _getModelLoadingConstraints(): boolean;
  154166. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154167. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154168. protected _updateModel(): void;
  154169. /**
  154170. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  154171. * between the touch and touch 2.
  154172. */
  154173. private _isQuest;
  154174. }
  154175. }
  154176. declare module BABYLON {
  154177. /**
  154178. * The motion controller class for the standard HTC-Vive controllers
  154179. */
  154180. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  154181. private _modelRootNode;
  154182. /**
  154183. * The base url used to load the left and right controller models
  154184. */
  154185. static MODEL_BASE_URL: string;
  154186. /**
  154187. * File name for the controller model.
  154188. */
  154189. static MODEL_FILENAME: string;
  154190. profileId: string;
  154191. /**
  154192. * Create a new Vive motion controller object
  154193. * @param scene the scene to use to create this controller
  154194. * @param gamepadObject the corresponding gamepad object
  154195. * @param handedness the handedness of the controller
  154196. */
  154197. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  154198. protected _getFilenameAndPath(): {
  154199. filename: string;
  154200. path: string;
  154201. };
  154202. protected _getModelLoadingConstraints(): boolean;
  154203. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  154204. protected _setRootMesh(meshes: AbstractMesh[]): void;
  154205. protected _updateModel(): void;
  154206. }
  154207. }
  154208. declare module BABYLON {
  154209. /**
  154210. * A cursor which tracks a point on a path
  154211. */
  154212. export class PathCursor {
  154213. private path;
  154214. /**
  154215. * Stores path cursor callbacks for when an onchange event is triggered
  154216. */
  154217. private _onchange;
  154218. /**
  154219. * The value of the path cursor
  154220. */
  154221. value: number;
  154222. /**
  154223. * The animation array of the path cursor
  154224. */
  154225. animations: Animation[];
  154226. /**
  154227. * Initializes the path cursor
  154228. * @param path The path to track
  154229. */
  154230. constructor(path: Path2);
  154231. /**
  154232. * Gets the cursor point on the path
  154233. * @returns A point on the path cursor at the cursor location
  154234. */
  154235. getPoint(): Vector3;
  154236. /**
  154237. * Moves the cursor ahead by the step amount
  154238. * @param step The amount to move the cursor forward
  154239. * @returns This path cursor
  154240. */
  154241. moveAhead(step?: number): PathCursor;
  154242. /**
  154243. * Moves the cursor behind by the step amount
  154244. * @param step The amount to move the cursor back
  154245. * @returns This path cursor
  154246. */
  154247. moveBack(step?: number): PathCursor;
  154248. /**
  154249. * Moves the cursor by the step amount
  154250. * If the step amount is greater than one, an exception is thrown
  154251. * @param step The amount to move the cursor
  154252. * @returns This path cursor
  154253. */
  154254. move(step: number): PathCursor;
  154255. /**
  154256. * Ensures that the value is limited between zero and one
  154257. * @returns This path cursor
  154258. */
  154259. private ensureLimits;
  154260. /**
  154261. * Runs onchange callbacks on change (used by the animation engine)
  154262. * @returns This path cursor
  154263. */
  154264. private raiseOnChange;
  154265. /**
  154266. * Executes a function on change
  154267. * @param f A path cursor onchange callback
  154268. * @returns This path cursor
  154269. */
  154270. onchange(f: (cursor: PathCursor) => void): PathCursor;
  154271. }
  154272. }
  154273. declare module BABYLON {
  154274. /** @hidden */
  154275. export var blurPixelShader: {
  154276. name: string;
  154277. shader: string;
  154278. };
  154279. }
  154280. declare module BABYLON {
  154281. /** @hidden */
  154282. export var pointCloudVertexDeclaration: {
  154283. name: string;
  154284. shader: string;
  154285. };
  154286. }
  154287. // Mixins
  154288. interface Window {
  154289. mozIndexedDB: IDBFactory;
  154290. webkitIndexedDB: IDBFactory;
  154291. msIndexedDB: IDBFactory;
  154292. webkitURL: typeof URL;
  154293. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  154294. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  154295. WebGLRenderingContext: WebGLRenderingContext;
  154296. MSGesture: MSGesture;
  154297. CANNON: any;
  154298. AudioContext: AudioContext;
  154299. webkitAudioContext: AudioContext;
  154300. PointerEvent: any;
  154301. Math: Math;
  154302. Uint8Array: Uint8ArrayConstructor;
  154303. Float32Array: Float32ArrayConstructor;
  154304. mozURL: typeof URL;
  154305. msURL: typeof URL;
  154306. VRFrameData: any; // WebVR, from specs 1.1
  154307. DracoDecoderModule: any;
  154308. setImmediate(handler: (...args: any[]) => void): number;
  154309. }
  154310. interface HTMLCanvasElement {
  154311. requestPointerLock(): void;
  154312. msRequestPointerLock?(): void;
  154313. mozRequestPointerLock?(): void;
  154314. webkitRequestPointerLock?(): void;
  154315. /** Track wether a record is in progress */
  154316. isRecording: boolean;
  154317. /** Capture Stream method defined by some browsers */
  154318. captureStream(fps?: number): MediaStream;
  154319. }
  154320. interface CanvasRenderingContext2D {
  154321. msImageSmoothingEnabled: boolean;
  154322. }
  154323. interface MouseEvent {
  154324. mozMovementX: number;
  154325. mozMovementY: number;
  154326. webkitMovementX: number;
  154327. webkitMovementY: number;
  154328. msMovementX: number;
  154329. msMovementY: number;
  154330. }
  154331. interface Navigator {
  154332. mozGetVRDevices: (any: any) => any;
  154333. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154334. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154335. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  154336. webkitGetGamepads(): Gamepad[];
  154337. msGetGamepads(): Gamepad[];
  154338. webkitGamepads(): Gamepad[];
  154339. }
  154340. interface HTMLVideoElement {
  154341. mozSrcObject: any;
  154342. }
  154343. interface Math {
  154344. fround(x: number): number;
  154345. imul(a: number, b: number): number;
  154346. }
  154347. interface WebGLRenderingContext {
  154348. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  154349. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  154350. vertexAttribDivisor(index: number, divisor: number): void;
  154351. createVertexArray(): any;
  154352. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  154353. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  154354. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  154355. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  154356. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  154357. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  154358. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  154359. // Queries
  154360. createQuery(): WebGLQuery;
  154361. deleteQuery(query: WebGLQuery): void;
  154362. beginQuery(target: number, query: WebGLQuery): void;
  154363. endQuery(target: number): void;
  154364. getQueryParameter(query: WebGLQuery, pname: number): any;
  154365. getQuery(target: number, pname: number): any;
  154366. MAX_SAMPLES: number;
  154367. RGBA8: number;
  154368. READ_FRAMEBUFFER: number;
  154369. DRAW_FRAMEBUFFER: number;
  154370. UNIFORM_BUFFER: number;
  154371. HALF_FLOAT_OES: number;
  154372. RGBA16F: number;
  154373. RGBA32F: number;
  154374. R32F: number;
  154375. RG32F: number;
  154376. RGB32F: number;
  154377. R16F: number;
  154378. RG16F: number;
  154379. RGB16F: number;
  154380. RED: number;
  154381. RG: number;
  154382. R8: number;
  154383. RG8: number;
  154384. UNSIGNED_INT_24_8: number;
  154385. DEPTH24_STENCIL8: number;
  154386. MIN: number;
  154387. MAX: number;
  154388. /* Multiple Render Targets */
  154389. drawBuffers(buffers: number[]): void;
  154390. readBuffer(src: number): void;
  154391. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  154392. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  154393. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  154394. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  154395. // Occlusion Query
  154396. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  154397. ANY_SAMPLES_PASSED: number;
  154398. QUERY_RESULT_AVAILABLE: number;
  154399. QUERY_RESULT: number;
  154400. }
  154401. interface WebGLProgram {
  154402. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  154403. }
  154404. interface EXT_disjoint_timer_query {
  154405. QUERY_COUNTER_BITS_EXT: number;
  154406. TIME_ELAPSED_EXT: number;
  154407. TIMESTAMP_EXT: number;
  154408. GPU_DISJOINT_EXT: number;
  154409. QUERY_RESULT_EXT: number;
  154410. QUERY_RESULT_AVAILABLE_EXT: number;
  154411. queryCounterEXT(query: WebGLQuery, target: number): void;
  154412. createQueryEXT(): WebGLQuery;
  154413. beginQueryEXT(target: number, query: WebGLQuery): void;
  154414. endQueryEXT(target: number): void;
  154415. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  154416. deleteQueryEXT(query: WebGLQuery): void;
  154417. }
  154418. interface WebGLUniformLocation {
  154419. _currentState: any;
  154420. }
  154421. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  154422. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  154423. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  154424. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  154425. interface WebGLRenderingContext {
  154426. readonly RASTERIZER_DISCARD: number;
  154427. readonly DEPTH_COMPONENT24: number;
  154428. readonly TEXTURE_3D: number;
  154429. readonly TEXTURE_2D_ARRAY: number;
  154430. readonly TEXTURE_COMPARE_FUNC: number;
  154431. readonly TEXTURE_COMPARE_MODE: number;
  154432. readonly COMPARE_REF_TO_TEXTURE: number;
  154433. readonly TEXTURE_WRAP_R: number;
  154434. readonly HALF_FLOAT: number;
  154435. readonly RGB8: number;
  154436. readonly RED_INTEGER: number;
  154437. readonly RG_INTEGER: number;
  154438. readonly RGB_INTEGER: number;
  154439. readonly RGBA_INTEGER: number;
  154440. readonly R8_SNORM: number;
  154441. readonly RG8_SNORM: number;
  154442. readonly RGB8_SNORM: number;
  154443. readonly RGBA8_SNORM: number;
  154444. readonly R8I: number;
  154445. readonly RG8I: number;
  154446. readonly RGB8I: number;
  154447. readonly RGBA8I: number;
  154448. readonly R8UI: number;
  154449. readonly RG8UI: number;
  154450. readonly RGB8UI: number;
  154451. readonly RGBA8UI: number;
  154452. readonly R16I: number;
  154453. readonly RG16I: number;
  154454. readonly RGB16I: number;
  154455. readonly RGBA16I: number;
  154456. readonly R16UI: number;
  154457. readonly RG16UI: number;
  154458. readonly RGB16UI: number;
  154459. readonly RGBA16UI: number;
  154460. readonly R32I: number;
  154461. readonly RG32I: number;
  154462. readonly RGB32I: number;
  154463. readonly RGBA32I: number;
  154464. readonly R32UI: number;
  154465. readonly RG32UI: number;
  154466. readonly RGB32UI: number;
  154467. readonly RGBA32UI: number;
  154468. readonly RGB10_A2UI: number;
  154469. readonly R11F_G11F_B10F: number;
  154470. readonly RGB9_E5: number;
  154471. readonly RGB10_A2: number;
  154472. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  154473. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  154474. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  154475. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  154476. readonly DEPTH_COMPONENT32F: number;
  154477. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  154478. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  154479. 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;
  154480. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  154481. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  154482. readonly TRANSFORM_FEEDBACK: number;
  154483. readonly INTERLEAVED_ATTRIBS: number;
  154484. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  154485. createTransformFeedback(): WebGLTransformFeedback;
  154486. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  154487. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  154488. beginTransformFeedback(primitiveMode: number): void;
  154489. endTransformFeedback(): void;
  154490. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  154491. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154492. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154493. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154494. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  154495. }
  154496. interface ImageBitmap {
  154497. readonly width: number;
  154498. readonly height: number;
  154499. close(): void;
  154500. }
  154501. interface WebGLQuery extends WebGLObject {
  154502. }
  154503. declare var WebGLQuery: {
  154504. prototype: WebGLQuery;
  154505. new(): WebGLQuery;
  154506. };
  154507. interface WebGLSampler extends WebGLObject {
  154508. }
  154509. declare var WebGLSampler: {
  154510. prototype: WebGLSampler;
  154511. new(): WebGLSampler;
  154512. };
  154513. interface WebGLSync extends WebGLObject {
  154514. }
  154515. declare var WebGLSync: {
  154516. prototype: WebGLSync;
  154517. new(): WebGLSync;
  154518. };
  154519. interface WebGLTransformFeedback extends WebGLObject {
  154520. }
  154521. declare var WebGLTransformFeedback: {
  154522. prototype: WebGLTransformFeedback;
  154523. new(): WebGLTransformFeedback;
  154524. };
  154525. interface WebGLVertexArrayObject extends WebGLObject {
  154526. }
  154527. declare var WebGLVertexArrayObject: {
  154528. prototype: WebGLVertexArrayObject;
  154529. new(): WebGLVertexArrayObject;
  154530. };
  154531. // Type definitions for WebVR API
  154532. // Project: https://w3c.github.io/webvr/
  154533. // Definitions by: six a <https://github.com/lostfictions>
  154534. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  154535. interface VRDisplay extends EventTarget {
  154536. /**
  154537. * Dictionary of capabilities describing the VRDisplay.
  154538. */
  154539. readonly capabilities: VRDisplayCapabilities;
  154540. /**
  154541. * z-depth defining the far plane of the eye view frustum
  154542. * enables mapping of values in the render target depth
  154543. * attachment to scene coordinates. Initially set to 10000.0.
  154544. */
  154545. depthFar: number;
  154546. /**
  154547. * z-depth defining the near plane of the eye view frustum
  154548. * enables mapping of values in the render target depth
  154549. * attachment to scene coordinates. Initially set to 0.01.
  154550. */
  154551. depthNear: number;
  154552. /**
  154553. * An identifier for this distinct VRDisplay. Used as an
  154554. * association point in the Gamepad API.
  154555. */
  154556. readonly displayId: number;
  154557. /**
  154558. * A display name, a user-readable name identifying it.
  154559. */
  154560. readonly displayName: string;
  154561. readonly isConnected: boolean;
  154562. readonly isPresenting: boolean;
  154563. /**
  154564. * If this VRDisplay supports room-scale experiences, the optional
  154565. * stage attribute contains details on the room-scale parameters.
  154566. */
  154567. readonly stageParameters: VRStageParameters | null;
  154568. /**
  154569. * Passing the value returned by `requestAnimationFrame` to
  154570. * `cancelAnimationFrame` will unregister the callback.
  154571. * @param handle Define the hanle of the request to cancel
  154572. */
  154573. cancelAnimationFrame(handle: number): void;
  154574. /**
  154575. * Stops presenting to the VRDisplay.
  154576. * @returns a promise to know when it stopped
  154577. */
  154578. exitPresent(): Promise<void>;
  154579. /**
  154580. * Return the current VREyeParameters for the given eye.
  154581. * @param whichEye Define the eye we want the parameter for
  154582. * @returns the eye parameters
  154583. */
  154584. getEyeParameters(whichEye: string): VREyeParameters;
  154585. /**
  154586. * Populates the passed VRFrameData with the information required to render
  154587. * the current frame.
  154588. * @param frameData Define the data structure to populate
  154589. * @returns true if ok otherwise false
  154590. */
  154591. getFrameData(frameData: VRFrameData): boolean;
  154592. /**
  154593. * Get the layers currently being presented.
  154594. * @returns the list of VR layers
  154595. */
  154596. getLayers(): VRLayer[];
  154597. /**
  154598. * Return a VRPose containing the future predicted pose of the VRDisplay
  154599. * when the current frame will be presented. The value returned will not
  154600. * change until JavaScript has returned control to the browser.
  154601. *
  154602. * The VRPose will contain the position, orientation, velocity,
  154603. * and acceleration of each of these properties.
  154604. * @returns the pose object
  154605. */
  154606. getPose(): VRPose;
  154607. /**
  154608. * Return the current instantaneous pose of the VRDisplay, with no
  154609. * prediction applied.
  154610. * @returns the current instantaneous pose
  154611. */
  154612. getImmediatePose(): VRPose;
  154613. /**
  154614. * The callback passed to `requestAnimationFrame` will be called
  154615. * any time a new frame should be rendered. When the VRDisplay is
  154616. * presenting the callback will be called at the native refresh
  154617. * rate of the HMD. When not presenting this function acts
  154618. * identically to how window.requestAnimationFrame acts. Content should
  154619. * make no assumptions of frame rate or vsync behavior as the HMD runs
  154620. * asynchronously from other displays and at differing refresh rates.
  154621. * @param callback Define the eaction to run next frame
  154622. * @returns the request handle it
  154623. */
  154624. requestAnimationFrame(callback: FrameRequestCallback): number;
  154625. /**
  154626. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  154627. * Repeat calls while already presenting will update the VRLayers being displayed.
  154628. * @param layers Define the list of layer to present
  154629. * @returns a promise to know when the request has been fulfilled
  154630. */
  154631. requestPresent(layers: VRLayer[]): Promise<void>;
  154632. /**
  154633. * Reset the pose for this display, treating its current position and
  154634. * orientation as the "origin/zero" values. VRPose.position,
  154635. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  154636. * updated when calling resetPose(). This should be called in only
  154637. * sitting-space experiences.
  154638. */
  154639. resetPose(): void;
  154640. /**
  154641. * The VRLayer provided to the VRDisplay will be captured and presented
  154642. * in the HMD. Calling this function has the same effect on the source
  154643. * canvas as any other operation that uses its source image, and canvases
  154644. * created without preserveDrawingBuffer set to true will be cleared.
  154645. * @param pose Define the pose to submit
  154646. */
  154647. submitFrame(pose?: VRPose): void;
  154648. }
  154649. declare var VRDisplay: {
  154650. prototype: VRDisplay;
  154651. new(): VRDisplay;
  154652. };
  154653. interface VRLayer {
  154654. leftBounds?: number[] | Float32Array | null;
  154655. rightBounds?: number[] | Float32Array | null;
  154656. source?: HTMLCanvasElement | null;
  154657. }
  154658. interface VRDisplayCapabilities {
  154659. readonly canPresent: boolean;
  154660. readonly hasExternalDisplay: boolean;
  154661. readonly hasOrientation: boolean;
  154662. readonly hasPosition: boolean;
  154663. readonly maxLayers: number;
  154664. }
  154665. interface VREyeParameters {
  154666. /** @deprecated */
  154667. readonly fieldOfView: VRFieldOfView;
  154668. readonly offset: Float32Array;
  154669. readonly renderHeight: number;
  154670. readonly renderWidth: number;
  154671. }
  154672. interface VRFieldOfView {
  154673. readonly downDegrees: number;
  154674. readonly leftDegrees: number;
  154675. readonly rightDegrees: number;
  154676. readonly upDegrees: number;
  154677. }
  154678. interface VRFrameData {
  154679. readonly leftProjectionMatrix: Float32Array;
  154680. readonly leftViewMatrix: Float32Array;
  154681. readonly pose: VRPose;
  154682. readonly rightProjectionMatrix: Float32Array;
  154683. readonly rightViewMatrix: Float32Array;
  154684. readonly timestamp: number;
  154685. }
  154686. interface VRPose {
  154687. readonly angularAcceleration: Float32Array | null;
  154688. readonly angularVelocity: Float32Array | null;
  154689. readonly linearAcceleration: Float32Array | null;
  154690. readonly linearVelocity: Float32Array | null;
  154691. readonly orientation: Float32Array | null;
  154692. readonly position: Float32Array | null;
  154693. readonly timestamp: number;
  154694. }
  154695. interface VRStageParameters {
  154696. sittingToStandingTransform?: Float32Array;
  154697. sizeX?: number;
  154698. sizeY?: number;
  154699. }
  154700. interface Navigator {
  154701. getVRDisplays(): Promise<VRDisplay[]>;
  154702. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  154703. }
  154704. interface Window {
  154705. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  154706. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  154707. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  154708. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154709. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154710. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  154711. }
  154712. interface Gamepad {
  154713. readonly displayId: number;
  154714. }
  154715. type XRSessionMode =
  154716. | "inline"
  154717. | "immersive-vr"
  154718. | "immersive-ar";
  154719. type XRReferenceSpaceType =
  154720. | "viewer"
  154721. | "local"
  154722. | "local-floor"
  154723. | "bounded-floor"
  154724. | "unbounded";
  154725. type XREnvironmentBlendMode =
  154726. | "opaque"
  154727. | "additive"
  154728. | "alpha-blend";
  154729. type XRVisibilityState =
  154730. | "visible"
  154731. | "visible-blurred"
  154732. | "hidden";
  154733. type XRHandedness =
  154734. | "none"
  154735. | "left"
  154736. | "right";
  154737. type XRTargetRayMode =
  154738. | "gaze"
  154739. | "tracked-pointer"
  154740. | "screen";
  154741. type XREye =
  154742. | "none"
  154743. | "left"
  154744. | "right";
  154745. type XREventType =
  154746. | "devicechange"
  154747. | "visibilitychange"
  154748. | "end"
  154749. | "inputsourceschange"
  154750. | "select"
  154751. | "selectstart"
  154752. | "selectend"
  154753. | "squeeze"
  154754. | "squeezestart"
  154755. | "squeezeend"
  154756. | "reset";
  154757. interface XRSpace extends EventTarget {
  154758. }
  154759. interface XRRenderState {
  154760. depthNear?: number;
  154761. depthFar?: number;
  154762. inlineVerticalFieldOfView?: number;
  154763. baseLayer?: XRWebGLLayer;
  154764. }
  154765. interface XRInputSource {
  154766. handedness: XRHandedness;
  154767. targetRayMode: XRTargetRayMode;
  154768. targetRaySpace: XRSpace;
  154769. gripSpace: XRSpace | undefined;
  154770. gamepad: Gamepad | undefined;
  154771. profiles: Array<string>;
  154772. }
  154773. interface XRSessionInit {
  154774. optionalFeatures?: string[];
  154775. requiredFeatures?: string[];
  154776. }
  154777. interface XRSession {
  154778. addEventListener: Function;
  154779. removeEventListener: Function;
  154780. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  154781. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  154782. requestAnimationFrame: Function;
  154783. end(): Promise<void>;
  154784. renderState: XRRenderState;
  154785. inputSources: Array<XRInputSource>;
  154786. // hit test
  154787. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  154788. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  154789. // legacy AR hit test
  154790. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154791. // legacy plane detection
  154792. updateWorldTrackingState(options: {
  154793. planeDetectionState?: { enabled: boolean; }
  154794. }): void;
  154795. }
  154796. interface XRReferenceSpace extends XRSpace {
  154797. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  154798. onreset: any;
  154799. }
  154800. type XRPlaneSet = Set<XRPlane>;
  154801. type XRAnchorSet = Set<XRAnchor>;
  154802. interface XRFrame {
  154803. session: XRSession;
  154804. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  154805. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  154806. // AR
  154807. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  154808. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  154809. // Anchors
  154810. trackedAnchors?: XRAnchorSet;
  154811. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  154812. // Planes
  154813. worldInformation: {
  154814. detectedPlanes?: XRPlaneSet;
  154815. };
  154816. }
  154817. interface XRViewerPose extends XRPose {
  154818. views: Array<XRView>;
  154819. }
  154820. interface XRPose {
  154821. transform: XRRigidTransform;
  154822. emulatedPosition: boolean;
  154823. }
  154824. interface XRWebGLLayerOptions {
  154825. antialias?: boolean;
  154826. depth?: boolean;
  154827. stencil?: boolean;
  154828. alpha?: boolean;
  154829. multiview?: boolean;
  154830. framebufferScaleFactor?: number;
  154831. }
  154832. declare var XRWebGLLayer: {
  154833. prototype: XRWebGLLayer;
  154834. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154835. };
  154836. interface XRWebGLLayer {
  154837. framebuffer: WebGLFramebuffer;
  154838. framebufferWidth: number;
  154839. framebufferHeight: number;
  154840. getViewport: Function;
  154841. }
  154842. declare class XRRigidTransform {
  154843. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154844. position: DOMPointReadOnly;
  154845. orientation: DOMPointReadOnly;
  154846. matrix: Float32Array;
  154847. inverse: XRRigidTransform;
  154848. }
  154849. interface XRView {
  154850. eye: XREye;
  154851. projectionMatrix: Float32Array;
  154852. transform: XRRigidTransform;
  154853. }
  154854. interface XRInputSourceChangeEvent {
  154855. session: XRSession;
  154856. removed: Array<XRInputSource>;
  154857. added: Array<XRInputSource>;
  154858. }
  154859. interface XRInputSourceEvent extends Event {
  154860. readonly frame: XRFrame;
  154861. readonly inputSource: XRInputSource;
  154862. }
  154863. // Experimental(er) features
  154864. declare class XRRay {
  154865. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154866. origin: DOMPointReadOnly;
  154867. direction: DOMPointReadOnly;
  154868. matrix: Float32Array;
  154869. }
  154870. declare enum XRHitTestTrackableType {
  154871. "point",
  154872. "plane",
  154873. "mesh"
  154874. }
  154875. interface XRHitResult {
  154876. hitMatrix: Float32Array;
  154877. }
  154878. interface XRTransientInputHitTestResult {
  154879. readonly inputSource: XRInputSource;
  154880. readonly results: Array<XRHitTestResult>;
  154881. }
  154882. interface XRHitTestResult {
  154883. getPose(baseSpace: XRSpace): XRPose | undefined;
  154884. // When anchor system is enabled
  154885. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154886. }
  154887. interface XRHitTestSource {
  154888. cancel(): void;
  154889. }
  154890. interface XRTransientInputHitTestSource {
  154891. cancel(): void;
  154892. }
  154893. interface XRHitTestOptionsInit {
  154894. space: XRSpace;
  154895. entityTypes?: Array<XRHitTestTrackableType>;
  154896. offsetRay?: XRRay;
  154897. }
  154898. interface XRTransientInputHitTestOptionsInit {
  154899. profile: string;
  154900. entityTypes?: Array<XRHitTestTrackableType>;
  154901. offsetRay?: XRRay;
  154902. }
  154903. interface XRAnchor {
  154904. anchorSpace: XRSpace;
  154905. delete(): void;
  154906. }
  154907. interface XRPlane {
  154908. orientation: "Horizontal" | "Vertical";
  154909. planeSpace: XRSpace;
  154910. polygon: Array<DOMPointReadOnly>;
  154911. lastChangedTime: number;
  154912. }